babylon.d.ts 3.1 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276
  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. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** 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 */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** 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 */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** 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 */
  689. static readonly GEQUAL: number;
  690. /** 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 */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * 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.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * 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.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. }
  1053. }
  1054. declare module BABYLON {
  1055. /**
  1056. * This represents the required contract to create a new type of texture loader.
  1057. */
  1058. export interface IInternalTextureLoader {
  1059. /**
  1060. * Defines wether the loader supports cascade loading the different faces.
  1061. */
  1062. supportCascades: boolean;
  1063. /**
  1064. * This returns if the loader support the current file information.
  1065. * @param extension defines the file extension of the file being loaded
  1066. * @returns true if the loader can load the specified file
  1067. */
  1068. canLoad(extension: string): boolean;
  1069. /**
  1070. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1071. * @param data contains the texture data
  1072. * @param texture defines the BabylonJS internal texture
  1073. * @param createPolynomials will be true if polynomials have been requested
  1074. * @param onLoad defines the callback to trigger once the texture is ready
  1075. * @param onError defines the callback to trigger in case of error
  1076. */
  1077. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1078. /**
  1079. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param callback defines the method to call once ready to upload
  1083. */
  1084. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1085. }
  1086. }
  1087. declare module BABYLON {
  1088. /**
  1089. * Class used to store and describe the pipeline context associated with an effect
  1090. */
  1091. export interface IPipelineContext {
  1092. /**
  1093. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1094. */
  1095. isAsync: boolean;
  1096. /**
  1097. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1098. */
  1099. isReady: boolean;
  1100. /** @hidden */
  1101. _getVertexShaderCode(): string | null;
  1102. /** @hidden */
  1103. _getFragmentShaderCode(): string | null;
  1104. /** @hidden */
  1105. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1106. }
  1107. }
  1108. declare module BABYLON {
  1109. /**
  1110. * Class used to store gfx data (like WebGLBuffer)
  1111. */
  1112. export class DataBuffer {
  1113. /**
  1114. * Gets or sets the number of objects referencing this buffer
  1115. */
  1116. references: number;
  1117. /** Gets or sets the size of the underlying buffer */
  1118. capacity: number;
  1119. /**
  1120. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1121. */
  1122. is32Bits: boolean;
  1123. /**
  1124. * Gets the underlying buffer
  1125. */
  1126. get underlyingResource(): any;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface IShaderProcessor {
  1132. attributeProcessor?: (attribute: string) => string;
  1133. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1134. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1135. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1136. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1137. lineProcessor?: (line: string, isFragment: boolean) => string;
  1138. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1139. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1140. }
  1141. }
  1142. declare module BABYLON {
  1143. /** @hidden */
  1144. export interface ProcessingOptions {
  1145. defines: string[];
  1146. indexParameters: any;
  1147. isFragment: boolean;
  1148. shouldUseHighPrecisionShader: boolean;
  1149. supportsUniformBuffers: boolean;
  1150. shadersRepository: string;
  1151. includesShadersStore: {
  1152. [key: string]: string;
  1153. };
  1154. processor?: IShaderProcessor;
  1155. version: string;
  1156. platformName: string;
  1157. lookForClosingBracketForUniformBuffer?: boolean;
  1158. }
  1159. }
  1160. declare module BABYLON {
  1161. /** @hidden */
  1162. export class ShaderCodeNode {
  1163. line: string;
  1164. children: ShaderCodeNode[];
  1165. additionalDefineKey?: string;
  1166. additionalDefineValue?: string;
  1167. isValid(preprocessors: {
  1168. [key: string]: string;
  1169. }): boolean;
  1170. process(preprocessors: {
  1171. [key: string]: string;
  1172. }, options: ProcessingOptions): string;
  1173. }
  1174. }
  1175. declare module BABYLON {
  1176. /** @hidden */
  1177. export class ShaderCodeCursor {
  1178. private _lines;
  1179. lineIndex: number;
  1180. get currentLine(): string;
  1181. get canRead(): boolean;
  1182. set lines(value: string[]);
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1188. process(preprocessors: {
  1189. [key: string]: string;
  1190. }, options: ProcessingOptions): string;
  1191. }
  1192. }
  1193. declare module BABYLON {
  1194. /** @hidden */
  1195. export class ShaderDefineExpression {
  1196. isTrue(preprocessors: {
  1197. [key: string]: string;
  1198. }): boolean;
  1199. private static _OperatorPriority;
  1200. private static _Stack;
  1201. static postfixToInfix(postfix: string[]): string;
  1202. static infixToPostfix(infix: string): string[];
  1203. }
  1204. }
  1205. declare module BABYLON {
  1206. /** @hidden */
  1207. export class ShaderCodeTestNode extends ShaderCodeNode {
  1208. testExpression: ShaderDefineExpression;
  1209. isValid(preprocessors: {
  1210. [key: string]: string;
  1211. }): boolean;
  1212. }
  1213. }
  1214. declare module BABYLON {
  1215. /** @hidden */
  1216. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1217. define: string;
  1218. not: boolean;
  1219. constructor(define: string, not?: boolean);
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module BABYLON {
  1226. /** @hidden */
  1227. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1228. leftOperand: ShaderDefineExpression;
  1229. rightOperand: ShaderDefineExpression;
  1230. isTrue(preprocessors: {
  1231. [key: string]: string;
  1232. }): boolean;
  1233. }
  1234. }
  1235. declare module BABYLON {
  1236. /** @hidden */
  1237. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1238. leftOperand: ShaderDefineExpression;
  1239. rightOperand: ShaderDefineExpression;
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module BABYLON {
  1246. /** @hidden */
  1247. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1248. define: string;
  1249. operand: string;
  1250. testValue: string;
  1251. constructor(define: string, operand: string, testValue: string);
  1252. isTrue(preprocessors: {
  1253. [key: string]: string;
  1254. }): boolean;
  1255. }
  1256. }
  1257. declare module BABYLON {
  1258. /**
  1259. * Class used to enable access to offline support
  1260. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1261. */
  1262. export interface IOfflineProvider {
  1263. /**
  1264. * Gets a boolean indicating if scene must be saved in the database
  1265. */
  1266. enableSceneOffline: boolean;
  1267. /**
  1268. * Gets a boolean indicating if textures must be saved in the database
  1269. */
  1270. enableTexturesOffline: boolean;
  1271. /**
  1272. * Open the offline support and make it available
  1273. * @param successCallback defines the callback to call on success
  1274. * @param errorCallback defines the callback to call on error
  1275. */
  1276. open(successCallback: () => void, errorCallback: () => void): void;
  1277. /**
  1278. * Loads an image from the offline support
  1279. * @param url defines the url to load from
  1280. * @param image defines the target DOM image
  1281. */
  1282. loadImage(url: string, image: HTMLImageElement): void;
  1283. /**
  1284. * Loads a file from offline support
  1285. * @param url defines the URL to load from
  1286. * @param sceneLoaded defines a callback to call on success
  1287. * @param progressCallBack defines a callback to call when progress changed
  1288. * @param errorCallback defines a callback to call on error
  1289. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1290. */
  1291. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class used to help managing file picking and drag'n'drop
  1297. * File Storage
  1298. */
  1299. export class FilesInputStore {
  1300. /**
  1301. * List of files ready to be loaded
  1302. */
  1303. static FilesToLoad: {
  1304. [key: string]: File;
  1305. };
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * Class used to define a retry strategy when error happens while loading assets
  1311. */
  1312. export class RetryStrategy {
  1313. /**
  1314. * Function used to defines an exponential back off strategy
  1315. * @param maxRetries defines the maximum number of retries (3 by default)
  1316. * @param baseInterval defines the interval between retries
  1317. * @returns the strategy function to use
  1318. */
  1319. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1320. }
  1321. }
  1322. declare module BABYLON {
  1323. /**
  1324. * @ignore
  1325. * Application error to support additional information when loading a file
  1326. */
  1327. export abstract class BaseError extends Error {
  1328. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1329. }
  1330. }
  1331. declare module BABYLON {
  1332. /** @ignore */
  1333. export class LoadFileError extends BaseError {
  1334. request?: WebRequest;
  1335. file?: File;
  1336. /**
  1337. * Creates a new LoadFileError
  1338. * @param message defines the message of the error
  1339. * @param request defines the optional web request
  1340. * @param file defines the optional file
  1341. */
  1342. constructor(message: string, object?: WebRequest | File);
  1343. }
  1344. /** @ignore */
  1345. export class RequestFileError extends BaseError {
  1346. request: WebRequest;
  1347. /**
  1348. * Creates a new LoadFileError
  1349. * @param message defines the message of the error
  1350. * @param request defines the optional web request
  1351. */
  1352. constructor(message: string, request: WebRequest);
  1353. }
  1354. /** @ignore */
  1355. export class ReadFileError extends BaseError {
  1356. file: File;
  1357. /**
  1358. * Creates a new ReadFileError
  1359. * @param message defines the message of the error
  1360. * @param file defines the optional file
  1361. */
  1362. constructor(message: string, file: File);
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export class FileTools {
  1368. /**
  1369. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1370. */
  1371. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1372. /**
  1373. * Gets or sets the base URL to use to load assets
  1374. */
  1375. static BaseUrl: string;
  1376. /**
  1377. * Default behaviour for cors in the application.
  1378. * It can be a string if the expected behavior is identical in the entire app.
  1379. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1380. */
  1381. static CorsBehavior: string | ((url: string | string[]) => string);
  1382. /**
  1383. * Gets or sets a function used to pre-process url before using them to load assets
  1384. */
  1385. static PreprocessUrl: (url: string) => string;
  1386. /**
  1387. * Removes unwanted characters from an url
  1388. * @param url defines the url to clean
  1389. * @returns the cleaned url
  1390. */
  1391. private static _CleanUrl;
  1392. /**
  1393. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1394. * @param url define the url we are trying
  1395. * @param element define the dom element where to configure the cors policy
  1396. */
  1397. static SetCorsBehavior(url: string | string[], element: {
  1398. crossOrigin: string | null;
  1399. }): void;
  1400. /**
  1401. * Loads an image as an HTMLImageElement.
  1402. * @param input url string, ArrayBuffer, or Blob to load
  1403. * @param onLoad callback called when the image successfully loads
  1404. * @param onError callback called when the image fails to load
  1405. * @param offlineProvider offline provider for caching
  1406. * @param mimeType optional mime type
  1407. * @returns the HTMLImageElement of the loaded image
  1408. */
  1409. 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>;
  1410. /**
  1411. * Reads a file from a File object
  1412. * @param file defines the file to load
  1413. * @param onSuccess defines the callback to call when data is loaded
  1414. * @param onProgress defines the callback to call during loading process
  1415. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1416. * @param onError defines the callback to call when an error occurs
  1417. * @returns a file request object
  1418. */
  1419. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1420. /**
  1421. * Loads a file from a url
  1422. * @param url url to load
  1423. * @param onSuccess callback called when the file successfully loads
  1424. * @param onProgress callback called while file is loading (if the server supports this mode)
  1425. * @param offlineProvider defines the offline provider for caching
  1426. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1427. * @param onError callback called when the file fails to load
  1428. * @returns a file request object
  1429. */
  1430. 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;
  1431. /**
  1432. * Loads a file
  1433. * @param url url to load
  1434. * @param onSuccess callback called when the file successfully loads
  1435. * @param onProgress callback called while file is loading (if the server supports this mode)
  1436. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1437. * @param onError callback called when the file fails to load
  1438. * @param onOpened callback called when the web request is opened
  1439. * @returns a file request object
  1440. */
  1441. 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;
  1442. /**
  1443. * Checks if the loaded document was accessed via `file:`-Protocol.
  1444. * @returns boolean
  1445. */
  1446. static IsFileURL(): boolean;
  1447. }
  1448. }
  1449. declare module BABYLON {
  1450. /** @hidden */
  1451. export class ShaderProcessor {
  1452. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1453. private static _ProcessPrecision;
  1454. private static _ExtractOperation;
  1455. private static _BuildSubExpression;
  1456. private static _BuildExpression;
  1457. private static _MoveCursorWithinIf;
  1458. private static _MoveCursor;
  1459. private static _EvaluatePreProcessors;
  1460. private static _PreparePreProcessors;
  1461. private static _ProcessShaderConversion;
  1462. private static _ProcessIncludes;
  1463. /**
  1464. * Loads a file from a url
  1465. * @param url url to load
  1466. * @param onSuccess callback called when the file successfully loads
  1467. * @param onProgress callback called while file is loading (if the server supports this mode)
  1468. * @param offlineProvider defines the offline provider for caching
  1469. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1470. * @param onError callback called when the file fails to load
  1471. * @returns a file request object
  1472. * @hidden
  1473. */
  1474. 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;
  1475. }
  1476. }
  1477. declare module BABYLON {
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IColor4Like {
  1482. r: float;
  1483. g: float;
  1484. b: float;
  1485. a: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IColor3Like {
  1491. r: float;
  1492. g: float;
  1493. b: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector4Like {
  1499. x: float;
  1500. y: float;
  1501. z: float;
  1502. w: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector3Like {
  1508. x: float;
  1509. y: float;
  1510. z: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector2Like {
  1516. x: float;
  1517. y: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IMatrixLike {
  1523. toArray(): DeepImmutable<Float32Array>;
  1524. updateFlag: int;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IViewportLike {
  1530. x: float;
  1531. y: float;
  1532. width: float;
  1533. height: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IPlaneLike {
  1539. normal: IVector3Like;
  1540. d: float;
  1541. normalize(): void;
  1542. }
  1543. }
  1544. declare module BABYLON {
  1545. /**
  1546. * Interface used to define common properties for effect fallbacks
  1547. */
  1548. export interface IEffectFallbacks {
  1549. /**
  1550. * Removes the defines that should be removed when falling back.
  1551. * @param currentDefines defines the current define statements for the shader.
  1552. * @param effect defines the current effect we try to compile
  1553. * @returns The resulting defines with defines of the current rank removed.
  1554. */
  1555. reduce(currentDefines: string, effect: Effect): string;
  1556. /**
  1557. * Removes the fallback from the bound mesh.
  1558. */
  1559. unBindMesh(): void;
  1560. /**
  1561. * Checks to see if more fallbacks are still availible.
  1562. */
  1563. hasMoreFallbacks: boolean;
  1564. }
  1565. }
  1566. declare module BABYLON {
  1567. /**
  1568. * Class used to evalaute queries containing `and` and `or` operators
  1569. */
  1570. export class AndOrNotEvaluator {
  1571. /**
  1572. * Evaluate a query
  1573. * @param query defines the query to evaluate
  1574. * @param evaluateCallback defines the callback used to filter result
  1575. * @returns true if the query matches
  1576. */
  1577. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1578. private static _HandleParenthesisContent;
  1579. private static _SimplifyNegation;
  1580. }
  1581. }
  1582. declare module BABYLON {
  1583. /**
  1584. * Class used to store custom tags
  1585. */
  1586. export class Tags {
  1587. /**
  1588. * Adds support for tags on the given object
  1589. * @param obj defines the object to use
  1590. */
  1591. static EnableFor(obj: any): void;
  1592. /**
  1593. * Removes tags support
  1594. * @param obj defines the object to use
  1595. */
  1596. static DisableFor(obj: any): void;
  1597. /**
  1598. * Gets a boolean indicating if the given object has tags
  1599. * @param obj defines the object to use
  1600. * @returns a boolean
  1601. */
  1602. static HasTags(obj: any): boolean;
  1603. /**
  1604. * Gets the tags available on a given object
  1605. * @param obj defines the object to use
  1606. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1607. * @returns the tags
  1608. */
  1609. static GetTags(obj: any, asString?: boolean): any;
  1610. /**
  1611. * Adds tags to an object
  1612. * @param obj defines the object to use
  1613. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1614. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1615. */
  1616. static AddTagsTo(obj: any, tagsString: string): void;
  1617. /**
  1618. * @hidden
  1619. */
  1620. static _AddTagTo(obj: any, tag: string): void;
  1621. /**
  1622. * Removes specific tags from a specific object
  1623. * @param obj defines the object to use
  1624. * @param tagsString defines the tags to remove
  1625. */
  1626. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1627. /**
  1628. * @hidden
  1629. */
  1630. static _RemoveTagFrom(obj: any, tag: string): void;
  1631. /**
  1632. * Defines if tags hosted on an object match a given query
  1633. * @param obj defines the object to use
  1634. * @param tagsQuery defines the tag query
  1635. * @returns a boolean
  1636. */
  1637. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1638. }
  1639. }
  1640. declare module BABYLON {
  1641. /**
  1642. * Scalar computation library
  1643. */
  1644. export class Scalar {
  1645. /**
  1646. * Two pi constants convenient for computation.
  1647. */
  1648. static TwoPi: number;
  1649. /**
  1650. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1651. * @param a number
  1652. * @param b number
  1653. * @param epsilon (default = 1.401298E-45)
  1654. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1655. */
  1656. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1657. /**
  1658. * Returns a string : the upper case translation of the number i to hexadecimal.
  1659. * @param i number
  1660. * @returns the upper case translation of the number i to hexadecimal.
  1661. */
  1662. static ToHex(i: number): string;
  1663. /**
  1664. * Returns -1 if value is negative and +1 is value is positive.
  1665. * @param value the value
  1666. * @returns the value itself if it's equal to zero.
  1667. */
  1668. static Sign(value: number): number;
  1669. /**
  1670. * Returns the value itself if it's between min and max.
  1671. * Returns min if the value is lower than min.
  1672. * Returns max if the value is greater than max.
  1673. * @param value the value to clmap
  1674. * @param min the min value to clamp to (default: 0)
  1675. * @param max the max value to clamp to (default: 1)
  1676. * @returns the clamped value
  1677. */
  1678. static Clamp(value: number, min?: number, max?: number): number;
  1679. /**
  1680. * the log2 of value.
  1681. * @param value the value to compute log2 of
  1682. * @returns the log2 of value.
  1683. */
  1684. static Log2(value: number): number;
  1685. /**
  1686. * Loops the value, so that it is never larger than length and never smaller than 0.
  1687. *
  1688. * This is similar to the modulo operator but it works with floating point numbers.
  1689. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1690. * With t = 5 and length = 2.5, the result would be 0.0.
  1691. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1692. * @param value the value
  1693. * @param length the length
  1694. * @returns the looped value
  1695. */
  1696. static Repeat(value: number, length: number): number;
  1697. /**
  1698. * Normalize the value between 0.0 and 1.0 using min and max values
  1699. * @param value value to normalize
  1700. * @param min max to normalize between
  1701. * @param max min to normalize between
  1702. * @returns the normalized value
  1703. */
  1704. static Normalize(value: number, min: number, max: number): number;
  1705. /**
  1706. * Denormalize the value from 0.0 and 1.0 using min and max values
  1707. * @param normalized value to denormalize
  1708. * @param min max to denormalize between
  1709. * @param max min to denormalize between
  1710. * @returns the denormalized value
  1711. */
  1712. static Denormalize(normalized: number, min: number, max: number): number;
  1713. /**
  1714. * Calculates the shortest difference between two given angles given in degrees.
  1715. * @param current current angle in degrees
  1716. * @param target target angle in degrees
  1717. * @returns the delta
  1718. */
  1719. static DeltaAngle(current: number, target: number): number;
  1720. /**
  1721. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1722. * @param tx value
  1723. * @param length length
  1724. * @returns The returned value will move back and forth between 0 and length
  1725. */
  1726. static PingPong(tx: number, length: number): number;
  1727. /**
  1728. * Interpolates between min and max with smoothing at the limits.
  1729. *
  1730. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1731. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1732. * @param from from
  1733. * @param to to
  1734. * @param tx value
  1735. * @returns the smooth stepped value
  1736. */
  1737. static SmoothStep(from: number, to: number, tx: number): number;
  1738. /**
  1739. * Moves a value current towards target.
  1740. *
  1741. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1742. * Negative values of maxDelta pushes the value away from target.
  1743. * @param current current value
  1744. * @param target target value
  1745. * @param maxDelta max distance to move
  1746. * @returns resulting value
  1747. */
  1748. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1749. /**
  1750. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1751. *
  1752. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1753. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1754. * @param current current value
  1755. * @param target target value
  1756. * @param maxDelta max distance to move
  1757. * @returns resulting angle
  1758. */
  1759. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1760. /**
  1761. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1762. * @param start start value
  1763. * @param end target value
  1764. * @param amount amount to lerp between
  1765. * @returns the lerped value
  1766. */
  1767. static Lerp(start: number, end: number, amount: number): number;
  1768. /**
  1769. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1770. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1771. * @param start start value
  1772. * @param end target value
  1773. * @param amount amount to lerp between
  1774. * @returns the lerped value
  1775. */
  1776. static LerpAngle(start: number, end: number, amount: number): number;
  1777. /**
  1778. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1779. * @param a start value
  1780. * @param b target value
  1781. * @param value value between a and b
  1782. * @returns the inverseLerp value
  1783. */
  1784. static InverseLerp(a: number, b: number, value: number): number;
  1785. /**
  1786. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1787. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1788. * @param value1 spline value
  1789. * @param tangent1 spline value
  1790. * @param value2 spline value
  1791. * @param tangent2 spline value
  1792. * @param amount input value
  1793. * @returns hermite result
  1794. */
  1795. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1796. /**
  1797. * Returns a random float number between and min and max values
  1798. * @param min min value of random
  1799. * @param max max value of random
  1800. * @returns random value
  1801. */
  1802. static RandomRange(min: number, max: number): number;
  1803. /**
  1804. * This function returns percentage of a number in a given range.
  1805. *
  1806. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1807. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1808. * @param number to convert to percentage
  1809. * @param min min range
  1810. * @param max max range
  1811. * @returns the percentage
  1812. */
  1813. static RangeToPercent(number: number, min: number, max: number): number;
  1814. /**
  1815. * This function returns number that corresponds to the percentage in a given range.
  1816. *
  1817. * PercentToRange(0.34,0,100) will return 34.
  1818. * @param percent to convert to number
  1819. * @param min min range
  1820. * @param max max range
  1821. * @returns the number
  1822. */
  1823. static PercentToRange(percent: number, min: number, max: number): number;
  1824. /**
  1825. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1826. * @param angle The angle to normalize in radian.
  1827. * @return The converted angle.
  1828. */
  1829. static NormalizeRadians(angle: number): number;
  1830. }
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Constant used to convert a value to gamma space
  1835. * @ignorenaming
  1836. */
  1837. export const ToGammaSpace: number;
  1838. /**
  1839. * Constant used to convert a value to linear space
  1840. * @ignorenaming
  1841. */
  1842. export const ToLinearSpace = 2.2;
  1843. /**
  1844. * Constant used to define the minimal number value in Babylon.js
  1845. * @ignorenaming
  1846. */
  1847. let Epsilon: number;
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Class used to represent a viewport on screen
  1852. */
  1853. export class Viewport {
  1854. /** viewport left coordinate */
  1855. x: number;
  1856. /** viewport top coordinate */
  1857. y: number;
  1858. /**viewport width */
  1859. width: number;
  1860. /** viewport height */
  1861. height: number;
  1862. /**
  1863. * Creates a Viewport object located at (x, y) and sized (width, height)
  1864. * @param x defines viewport left coordinate
  1865. * @param y defines viewport top coordinate
  1866. * @param width defines the viewport width
  1867. * @param height defines the viewport height
  1868. */
  1869. constructor(
  1870. /** viewport left coordinate */
  1871. x: number,
  1872. /** viewport top coordinate */
  1873. y: number,
  1874. /**viewport width */
  1875. width: number,
  1876. /** viewport height */
  1877. height: number);
  1878. /**
  1879. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1880. * @param renderWidth defines the rendering width
  1881. * @param renderHeight defines the rendering height
  1882. * @returns a new Viewport
  1883. */
  1884. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1885. /**
  1886. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1887. * @param renderWidth defines the rendering width
  1888. * @param renderHeight defines the rendering height
  1889. * @param ref defines the target viewport
  1890. * @returns the current viewport
  1891. */
  1892. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1893. /**
  1894. * Returns a new Viewport copied from the current one
  1895. * @returns a new Viewport
  1896. */
  1897. clone(): Viewport;
  1898. }
  1899. }
  1900. declare module BABYLON {
  1901. /**
  1902. * Class containing a set of static utilities functions for arrays.
  1903. */
  1904. export class ArrayTools {
  1905. /**
  1906. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1907. * @param size the number of element to construct and put in the array
  1908. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1909. * @returns a new array filled with new objects
  1910. */
  1911. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1912. }
  1913. }
  1914. declare module BABYLON {
  1915. /**
  1916. * Represents a plane by the equation ax + by + cz + d = 0
  1917. */
  1918. export class Plane {
  1919. private static _TmpMatrix;
  1920. /**
  1921. * Normal of the plane (a,b,c)
  1922. */
  1923. normal: Vector3;
  1924. /**
  1925. * d component of the plane
  1926. */
  1927. d: number;
  1928. /**
  1929. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1930. * @param a a component of the plane
  1931. * @param b b component of the plane
  1932. * @param c c component of the plane
  1933. * @param d d component of the plane
  1934. */
  1935. constructor(a: number, b: number, c: number, d: number);
  1936. /**
  1937. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1938. */
  1939. asArray(): number[];
  1940. /**
  1941. * @returns a new plane copied from the current Plane.
  1942. */
  1943. clone(): Plane;
  1944. /**
  1945. * @returns the string "Plane".
  1946. */
  1947. getClassName(): string;
  1948. /**
  1949. * @returns the Plane hash code.
  1950. */
  1951. getHashCode(): number;
  1952. /**
  1953. * Normalize the current Plane in place.
  1954. * @returns the updated Plane.
  1955. */
  1956. normalize(): Plane;
  1957. /**
  1958. * Applies a transformation the plane and returns the result
  1959. * @param transformation the transformation matrix to be applied to the plane
  1960. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1961. */
  1962. transform(transformation: DeepImmutable<Matrix>): Plane;
  1963. /**
  1964. * Compute the dot product between the point and the plane normal
  1965. * @param point point to calculate the dot product with
  1966. * @returns the dot product (float) of the point coordinates and the plane normal.
  1967. */
  1968. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1969. /**
  1970. * Updates the current Plane from the plane defined by the three given points.
  1971. * @param point1 one of the points used to contruct the plane
  1972. * @param point2 one of the points used to contruct the plane
  1973. * @param point3 one of the points used to contruct the plane
  1974. * @returns the updated Plane.
  1975. */
  1976. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1977. /**
  1978. * Checks if the plane is facing a given direction
  1979. * @param direction the direction to check if the plane is facing
  1980. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1981. * @returns True is the vector "direction" is the same side than the plane normal.
  1982. */
  1983. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  1984. /**
  1985. * Calculates the distance to a point
  1986. * @param point point to calculate distance to
  1987. * @returns the signed distance (float) from the given point to the Plane.
  1988. */
  1989. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  1990. /**
  1991. * Creates a plane from an array
  1992. * @param array the array to create a plane from
  1993. * @returns a new Plane from the given array.
  1994. */
  1995. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  1996. /**
  1997. * Creates a plane from three points
  1998. * @param point1 point used to create the plane
  1999. * @param point2 point used to create the plane
  2000. * @param point3 point used to create the plane
  2001. * @returns a new Plane defined by the three given points.
  2002. */
  2003. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2004. /**
  2005. * Creates a plane from an origin point and a normal
  2006. * @param origin origin of the plane to be constructed
  2007. * @param normal normal of the plane to be constructed
  2008. * @returns a new Plane the normal vector to this plane at the given origin point.
  2009. * Note : the vector "normal" is updated because normalized.
  2010. */
  2011. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2012. /**
  2013. * Calculates the distance from a plane and a point
  2014. * @param origin origin of the plane to be constructed
  2015. * @param normal normal of the plane to be constructed
  2016. * @param point point to calculate distance to
  2017. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2018. */
  2019. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2020. }
  2021. }
  2022. declare module BABYLON {
  2023. /**
  2024. * Class representing a vector containing 2 coordinates
  2025. */
  2026. export class Vector2 {
  2027. /** defines the first coordinate */
  2028. x: number;
  2029. /** defines the second coordinate */
  2030. y: number;
  2031. /**
  2032. * Creates a new Vector2 from the given x and y coordinates
  2033. * @param x defines the first coordinate
  2034. * @param y defines the second coordinate
  2035. */
  2036. constructor(
  2037. /** defines the first coordinate */
  2038. x?: number,
  2039. /** defines the second coordinate */
  2040. y?: number);
  2041. /**
  2042. * Gets a string with the Vector2 coordinates
  2043. * @returns a string with the Vector2 coordinates
  2044. */
  2045. toString(): string;
  2046. /**
  2047. * Gets class name
  2048. * @returns the string "Vector2"
  2049. */
  2050. getClassName(): string;
  2051. /**
  2052. * Gets current vector hash code
  2053. * @returns the Vector2 hash code as a number
  2054. */
  2055. getHashCode(): number;
  2056. /**
  2057. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2058. * @param array defines the source array
  2059. * @param index defines the offset in source array
  2060. * @returns the current Vector2
  2061. */
  2062. toArray(array: FloatArray, index?: number): Vector2;
  2063. /**
  2064. * Copy the current vector to an array
  2065. * @returns a new array with 2 elements: the Vector2 coordinates.
  2066. */
  2067. asArray(): number[];
  2068. /**
  2069. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2070. * @param source defines the source Vector2
  2071. * @returns the current updated Vector2
  2072. */
  2073. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2074. /**
  2075. * Sets the Vector2 coordinates with the given floats
  2076. * @param x defines the first coordinate
  2077. * @param y defines the second coordinate
  2078. * @returns the current updated Vector2
  2079. */
  2080. copyFromFloats(x: number, y: number): Vector2;
  2081. /**
  2082. * Sets the Vector2 coordinates with the given floats
  2083. * @param x defines the first coordinate
  2084. * @param y defines the second coordinate
  2085. * @returns the current updated Vector2
  2086. */
  2087. set(x: number, y: number): Vector2;
  2088. /**
  2089. * Add another vector with the current one
  2090. * @param otherVector defines the other vector
  2091. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2092. */
  2093. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2094. /**
  2095. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2096. * @param otherVector defines the other vector
  2097. * @param result defines the target vector
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2101. /**
  2102. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2103. * @param otherVector defines the other vector
  2104. * @returns the current updated Vector2
  2105. */
  2106. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2107. /**
  2108. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2109. * @param otherVector defines the other vector
  2110. * @returns a new Vector2
  2111. */
  2112. addVector3(otherVector: Vector3): Vector2;
  2113. /**
  2114. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2115. * @param otherVector defines the other vector
  2116. * @returns a new Vector2
  2117. */
  2118. subtract(otherVector: Vector2): Vector2;
  2119. /**
  2120. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2121. * @param otherVector defines the other vector
  2122. * @param result defines the target vector
  2123. * @returns the unmodified current Vector2
  2124. */
  2125. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2126. /**
  2127. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2128. * @param otherVector defines the other vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2132. /**
  2133. * Multiplies in place the current Vector2 coordinates by the given ones
  2134. * @param otherVector defines the other vector
  2135. * @returns the current updated Vector2
  2136. */
  2137. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2138. /**
  2139. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2140. * @param otherVector defines the other vector
  2141. * @returns a new Vector2
  2142. */
  2143. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2146. * @param otherVector defines the other vector
  2147. * @param result defines the target vector
  2148. * @returns the unmodified current Vector2
  2149. */
  2150. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2151. /**
  2152. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns a new Vector2
  2156. */
  2157. multiplyByFloats(x: number, y: number): Vector2;
  2158. /**
  2159. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2
  2162. */
  2163. divide(otherVector: Vector2): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Divides the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 with current Vector2 negated coordinates
  2179. * @returns a new Vector2
  2180. */
  2181. negate(): Vector2;
  2182. /**
  2183. * Negate this vector in place
  2184. * @returns this
  2185. */
  2186. negateInPlace(): Vector2;
  2187. /**
  2188. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2189. * @param result defines the Vector3 object where to store the result
  2190. * @returns the current Vector2
  2191. */
  2192. negateToRef(result: Vector2): Vector2;
  2193. /**
  2194. * Multiply the Vector2 coordinates by scale
  2195. * @param scale defines the scaling factor
  2196. * @returns the current updated Vector2
  2197. */
  2198. scaleInPlace(scale: number): Vector2;
  2199. /**
  2200. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2201. * @param scale defines the scaling factor
  2202. * @returns a new Vector2
  2203. */
  2204. scale(scale: number): Vector2;
  2205. /**
  2206. * Scale the current Vector2 values by a factor to a given Vector2
  2207. * @param scale defines the scale factor
  2208. * @param result defines the Vector2 object where to store the result
  2209. * @returns the unmodified current Vector2
  2210. */
  2211. scaleToRef(scale: number, result: Vector2): Vector2;
  2212. /**
  2213. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2214. * @param scale defines the scale factor
  2215. * @param result defines the Vector2 object where to store the result
  2216. * @returns the unmodified current Vector2
  2217. */
  2218. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2219. /**
  2220. * Gets a boolean if two vectors are equals
  2221. * @param otherVector defines the other vector
  2222. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2223. */
  2224. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2225. /**
  2226. * Gets a boolean if two vectors are equals (using an epsilon value)
  2227. * @param otherVector defines the other vector
  2228. * @param epsilon defines the minimal distance to consider equality
  2229. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2230. */
  2231. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2232. /**
  2233. * Gets a new Vector2 from current Vector2 floored values
  2234. * @returns a new Vector2
  2235. */
  2236. floor(): Vector2;
  2237. /**
  2238. * Gets a new Vector2 from current Vector2 floored values
  2239. * @returns a new Vector2
  2240. */
  2241. fract(): Vector2;
  2242. /**
  2243. * Gets the length of the vector
  2244. * @returns the vector length (float)
  2245. */
  2246. length(): number;
  2247. /**
  2248. * Gets the vector squared length
  2249. * @returns the vector squared length (float)
  2250. */
  2251. lengthSquared(): number;
  2252. /**
  2253. * Normalize the vector
  2254. * @returns the current updated Vector2
  2255. */
  2256. normalize(): Vector2;
  2257. /**
  2258. * Gets a new Vector2 copied from the Vector2
  2259. * @returns a new Vector2
  2260. */
  2261. clone(): Vector2;
  2262. /**
  2263. * Gets a new Vector2(0, 0)
  2264. * @returns a new Vector2
  2265. */
  2266. static Zero(): Vector2;
  2267. /**
  2268. * Gets a new Vector2(1, 1)
  2269. * @returns a new Vector2
  2270. */
  2271. static One(): Vector2;
  2272. /**
  2273. * Gets a new Vector2 set from the given index element of the given array
  2274. * @param array defines the data source
  2275. * @param offset defines the offset in the data source
  2276. * @returns a new Vector2
  2277. */
  2278. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2279. /**
  2280. * Sets "result" from the given index element of the given array
  2281. * @param array defines the data source
  2282. * @param offset defines the offset in the data source
  2283. * @param result defines the target vector
  2284. */
  2285. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2286. /**
  2287. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2288. * @param value1 defines 1st point of control
  2289. * @param value2 defines 2nd point of control
  2290. * @param value3 defines 3rd point of control
  2291. * @param value4 defines 4th point of control
  2292. * @param amount defines the interpolation factor
  2293. * @returns a new Vector2
  2294. */
  2295. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2296. /**
  2297. * 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".
  2298. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2299. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2300. * @param value defines the value to clamp
  2301. * @param min defines the lower limit
  2302. * @param max defines the upper limit
  2303. * @returns a new Vector2
  2304. */
  2305. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2306. /**
  2307. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2308. * @param value1 defines the 1st control point
  2309. * @param tangent1 defines the outgoing tangent
  2310. * @param value2 defines the 2nd control point
  2311. * @param tangent2 defines the incoming tangent
  2312. * @param amount defines the interpolation factor
  2313. * @returns a new Vector2
  2314. */
  2315. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2316. /**
  2317. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2318. * @param start defines the start vector
  2319. * @param end defines the end vector
  2320. * @param amount defines the interpolation factor
  2321. * @returns a new Vector2
  2322. */
  2323. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2324. /**
  2325. * Gets the dot product of the vector "left" and the vector "right"
  2326. * @param left defines first vector
  2327. * @param right defines second vector
  2328. * @returns the dot product (float)
  2329. */
  2330. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2331. /**
  2332. * Returns a new Vector2 equal to the normalized given vector
  2333. * @param vector defines the vector to normalize
  2334. * @returns a new Vector2
  2335. */
  2336. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2337. /**
  2338. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2339. * @param left defines 1st vector
  2340. * @param right defines 2nd vector
  2341. * @returns a new Vector2
  2342. */
  2343. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2344. /**
  2345. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2346. * @param left defines 1st vector
  2347. * @param right defines 2nd vector
  2348. * @returns a new Vector2
  2349. */
  2350. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2351. /**
  2352. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2353. * @param vector defines the vector to transform
  2354. * @param transformation defines the matrix to apply
  2355. * @returns a new Vector2
  2356. */
  2357. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2358. /**
  2359. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2360. * @param vector defines the vector to transform
  2361. * @param transformation defines the matrix to apply
  2362. * @param result defines the target vector
  2363. */
  2364. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2365. /**
  2366. * Determines if a given vector is included in a triangle
  2367. * @param p defines the vector to test
  2368. * @param p0 defines 1st triangle point
  2369. * @param p1 defines 2nd triangle point
  2370. * @param p2 defines 3rd triangle point
  2371. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2372. */
  2373. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2374. /**
  2375. * Gets the distance between the vectors "value1" and "value2"
  2376. * @param value1 defines first vector
  2377. * @param value2 defines second vector
  2378. * @returns the distance between vectors
  2379. */
  2380. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2381. /**
  2382. * Returns the squared distance between the vectors "value1" and "value2"
  2383. * @param value1 defines first vector
  2384. * @param value2 defines second vector
  2385. * @returns the squared distance between vectors
  2386. */
  2387. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2388. /**
  2389. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2390. * @param value1 defines first vector
  2391. * @param value2 defines second vector
  2392. * @returns a new Vector2
  2393. */
  2394. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2395. /**
  2396. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2397. * @param p defines the middle point
  2398. * @param segA defines one point of the segment
  2399. * @param segB defines the other point of the segment
  2400. * @returns the shortest distance
  2401. */
  2402. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2403. }
  2404. /**
  2405. * Class used to store (x,y,z) vector representation
  2406. * A Vector3 is the main object used in 3D geometry
  2407. * It can represent etiher the coordinates of a point the space, either a direction
  2408. * Reminder: js uses a left handed forward facing system
  2409. */
  2410. export class Vector3 {
  2411. private static _UpReadOnly;
  2412. private static _ZeroReadOnly;
  2413. /** @hidden */
  2414. _x: number;
  2415. /** @hidden */
  2416. _y: number;
  2417. /** @hidden */
  2418. _z: number;
  2419. /** @hidden */
  2420. _isDirty: boolean;
  2421. /** Gets or sets the x coordinate */
  2422. get x(): number;
  2423. set x(value: number);
  2424. /** Gets or sets the y coordinate */
  2425. get y(): number;
  2426. set y(value: number);
  2427. /** Gets or sets the z coordinate */
  2428. get z(): number;
  2429. set z(value: number);
  2430. /**
  2431. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2432. * @param x defines the first coordinates (on X axis)
  2433. * @param y defines the second coordinates (on Y axis)
  2434. * @param z defines the third coordinates (on Z axis)
  2435. */
  2436. constructor(x?: number, y?: number, z?: number);
  2437. /**
  2438. * Creates a string representation of the Vector3
  2439. * @returns a string with the Vector3 coordinates.
  2440. */
  2441. toString(): string;
  2442. /**
  2443. * Gets the class name
  2444. * @returns the string "Vector3"
  2445. */
  2446. getClassName(): string;
  2447. /**
  2448. * Creates the Vector3 hash code
  2449. * @returns a number which tends to be unique between Vector3 instances
  2450. */
  2451. getHashCode(): number;
  2452. /**
  2453. * Creates an array containing three elements : the coordinates of the Vector3
  2454. * @returns a new array of numbers
  2455. */
  2456. asArray(): number[];
  2457. /**
  2458. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2459. * @param array defines the destination array
  2460. * @param index defines the offset in the destination array
  2461. * @returns the current Vector3
  2462. */
  2463. toArray(array: FloatArray, index?: number): Vector3;
  2464. /**
  2465. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2466. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2467. */
  2468. toQuaternion(): Quaternion;
  2469. /**
  2470. * Adds the given vector to the current Vector3
  2471. * @param otherVector defines the second operand
  2472. * @returns the current updated Vector3
  2473. */
  2474. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2475. /**
  2476. * Adds the given coordinates to the current Vector3
  2477. * @param x defines the x coordinate of the operand
  2478. * @param y defines the y coordinate of the operand
  2479. * @param z defines the z coordinate of the operand
  2480. * @returns the current updated Vector3
  2481. */
  2482. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2483. /**
  2484. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2485. * @param otherVector defines the second operand
  2486. * @returns the resulting Vector3
  2487. */
  2488. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2489. /**
  2490. * Adds the current Vector3 to the given one and stores the result in the 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. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2496. /**
  2497. * Subtract the given vector from the current Vector3
  2498. * @param otherVector defines the second operand
  2499. * @returns the current updated Vector3
  2500. */
  2501. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2502. /**
  2503. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2504. * @param otherVector defines the second operand
  2505. * @returns the resulting Vector3
  2506. */
  2507. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2508. /**
  2509. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2510. * @param otherVector defines the second operand
  2511. * @param result defines the Vector3 object where to store the result
  2512. * @returns the current Vector3
  2513. */
  2514. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2515. /**
  2516. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2517. * @param x defines the x coordinate of the operand
  2518. * @param y defines the y coordinate of the operand
  2519. * @param z defines the z coordinate of the operand
  2520. * @returns the resulting Vector3
  2521. */
  2522. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2523. /**
  2524. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2525. * @param x defines the x coordinate of the operand
  2526. * @param y defines the y coordinate of the operand
  2527. * @param z defines the z coordinate of the operand
  2528. * @param result defines the Vector3 object where to store the result
  2529. * @returns the current Vector3
  2530. */
  2531. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2532. /**
  2533. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2534. * @returns a new Vector3
  2535. */
  2536. negate(): Vector3;
  2537. /**
  2538. * Negate this vector in place
  2539. * @returns this
  2540. */
  2541. negateInPlace(): Vector3;
  2542. /**
  2543. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2544. * @param result defines the Vector3 object where to store the result
  2545. * @returns the current Vector3
  2546. */
  2547. negateToRef(result: Vector3): Vector3;
  2548. /**
  2549. * Multiplies the Vector3 coordinates by the float "scale"
  2550. * @param scale defines the multiplier factor
  2551. * @returns the current updated Vector3
  2552. */
  2553. scaleInPlace(scale: number): Vector3;
  2554. /**
  2555. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2556. * @param scale defines the multiplier factor
  2557. * @returns a new Vector3
  2558. */
  2559. scale(scale: number): Vector3;
  2560. /**
  2561. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2562. * @param scale defines the multiplier factor
  2563. * @param result defines the Vector3 object where to store the result
  2564. * @returns the current Vector3
  2565. */
  2566. scaleToRef(scale: number, result: Vector3): Vector3;
  2567. /**
  2568. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2569. * @param scale defines the scale factor
  2570. * @param result defines the Vector3 object where to store the result
  2571. * @returns the unmodified current Vector3
  2572. */
  2573. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2574. /**
  2575. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2576. * @param origin defines the origin of the projection ray
  2577. * @param plane defines the plane to project to
  2578. * @returns the projected vector3
  2579. */
  2580. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2581. /**
  2582. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2583. * @param origin defines the origin of the projection ray
  2584. * @param plane defines the plane to project to
  2585. * @param result defines the Vector3 where to store the result
  2586. */
  2587. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2588. /**
  2589. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2590. * @param otherVector defines the second operand
  2591. * @returns true if both vectors are equals
  2592. */
  2593. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2594. /**
  2595. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2596. * @param otherVector defines the second operand
  2597. * @param epsilon defines the minimal distance to define values as equals
  2598. * @returns true if both vectors are distant less than epsilon
  2599. */
  2600. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2601. /**
  2602. * Returns true if the current Vector3 coordinates equals the given floats
  2603. * @param x defines the x coordinate of the operand
  2604. * @param y defines the y coordinate of the operand
  2605. * @param z defines the z coordinate of the operand
  2606. * @returns true if both vectors are equals
  2607. */
  2608. equalsToFloats(x: number, y: number, z: number): boolean;
  2609. /**
  2610. * Multiplies the current Vector3 coordinates by the given ones
  2611. * @param otherVector defines the second operand
  2612. * @returns the current updated Vector3
  2613. */
  2614. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2615. /**
  2616. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2617. * @param otherVector defines the second operand
  2618. * @returns the new Vector3
  2619. */
  2620. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2621. /**
  2622. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2623. * @param otherVector defines the second operand
  2624. * @param result defines the Vector3 object where to store the result
  2625. * @returns the current Vector3
  2626. */
  2627. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2628. /**
  2629. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2630. * @param x defines the x coordinate of the operand
  2631. * @param y defines the y coordinate of the operand
  2632. * @param z defines the z coordinate of the operand
  2633. * @returns the new Vector3
  2634. */
  2635. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2636. /**
  2637. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2638. * @param otherVector defines the second operand
  2639. * @returns the new Vector3
  2640. */
  2641. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2642. /**
  2643. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2644. * @param otherVector defines the second operand
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2649. /**
  2650. * Divides the current Vector3 coordinates by the given ones.
  2651. * @param otherVector defines the second operand
  2652. * @returns the current updated Vector3
  2653. */
  2654. divideInPlace(otherVector: Vector3): Vector3;
  2655. /**
  2656. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2657. * @param other defines the second operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2661. /**
  2662. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2663. * @param other defines the second operand
  2664. * @returns the current updated Vector3
  2665. */
  2666. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2669. * @param x defines the x coordinate of the operand
  2670. * @param y defines the y coordinate of the operand
  2671. * @param z defines the z coordinate of the operand
  2672. * @returns the current updated Vector3
  2673. */
  2674. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2675. /**
  2676. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2677. * @param x defines the x coordinate of the operand
  2678. * @param y defines the y coordinate of the operand
  2679. * @param z defines the z coordinate of the operand
  2680. * @returns the current updated Vector3
  2681. */
  2682. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2683. /**
  2684. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2685. * Check if is non uniform within a certain amount of decimal places to account for this
  2686. * @param epsilon the amount the values can differ
  2687. * @returns if the the vector is non uniform to a certain number of decimal places
  2688. */
  2689. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2690. /**
  2691. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2692. */
  2693. get isNonUniform(): boolean;
  2694. /**
  2695. * Gets a new Vector3 from current Vector3 floored values
  2696. * @returns a new Vector3
  2697. */
  2698. floor(): Vector3;
  2699. /**
  2700. * Gets a new Vector3 from current Vector3 floored values
  2701. * @returns a new Vector3
  2702. */
  2703. fract(): Vector3;
  2704. /**
  2705. * Gets the length of the Vector3
  2706. * @returns the length of the Vector3
  2707. */
  2708. length(): number;
  2709. /**
  2710. * Gets the squared length of the Vector3
  2711. * @returns squared length of the Vector3
  2712. */
  2713. lengthSquared(): number;
  2714. /**
  2715. * Normalize the current Vector3.
  2716. * Please note that this is an in place operation.
  2717. * @returns the current updated Vector3
  2718. */
  2719. normalize(): Vector3;
  2720. /**
  2721. * Reorders the x y z properties of the vector in place
  2722. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2723. * @returns the current updated vector
  2724. */
  2725. reorderInPlace(order: string): this;
  2726. /**
  2727. * Rotates the vector around 0,0,0 by a quaternion
  2728. * @param quaternion the rotation quaternion
  2729. * @param result vector to store the result
  2730. * @returns the resulting vector
  2731. */
  2732. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2733. /**
  2734. * Rotates a vector around a given point
  2735. * @param quaternion the rotation quaternion
  2736. * @param point the point to rotate around
  2737. * @param result vector to store the result
  2738. * @returns the resulting vector
  2739. */
  2740. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2741. /**
  2742. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2743. * The cross product is then orthogonal to both current and "other"
  2744. * @param other defines the right operand
  2745. * @returns the cross product
  2746. */
  2747. cross(other: Vector3): Vector3;
  2748. /**
  2749. * Normalize the current Vector3 with the given input length.
  2750. * Please note that this is an in place operation.
  2751. * @param len the length of the vector
  2752. * @returns the current updated Vector3
  2753. */
  2754. normalizeFromLength(len: number): Vector3;
  2755. /**
  2756. * Normalize the current Vector3 to a new vector
  2757. * @returns the new Vector3
  2758. */
  2759. normalizeToNew(): Vector3;
  2760. /**
  2761. * Normalize the current Vector3 to the reference
  2762. * @param reference define the Vector3 to update
  2763. * @returns the updated Vector3
  2764. */
  2765. normalizeToRef(reference: Vector3): Vector3;
  2766. /**
  2767. * Creates a new Vector3 copied from the current Vector3
  2768. * @returns the new Vector3
  2769. */
  2770. clone(): Vector3;
  2771. /**
  2772. * Copies the given vector coordinates to the current Vector3 ones
  2773. * @param source defines the source Vector3
  2774. * @returns the current updated Vector3
  2775. */
  2776. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2777. /**
  2778. * Copies the given floats to the current Vector3 coordinates
  2779. * @param x defines the x coordinate of the operand
  2780. * @param y defines the y coordinate of the operand
  2781. * @param z defines the z coordinate of the operand
  2782. * @returns the current updated Vector3
  2783. */
  2784. copyFromFloats(x: number, y: number, z: number): Vector3;
  2785. /**
  2786. * Copies the given floats to the current Vector3 coordinates
  2787. * @param x defines the x coordinate of the operand
  2788. * @param y defines the y coordinate of the operand
  2789. * @param z defines the z coordinate of the operand
  2790. * @returns the current updated Vector3
  2791. */
  2792. set(x: number, y: number, z: number): Vector3;
  2793. /**
  2794. * Copies the given float to the current Vector3 coordinates
  2795. * @param v defines the x, y and z coordinates of the operand
  2796. * @returns the current updated Vector3
  2797. */
  2798. setAll(v: number): Vector3;
  2799. /**
  2800. * Get the clip factor between two vectors
  2801. * @param vector0 defines the first operand
  2802. * @param vector1 defines the second operand
  2803. * @param axis defines the axis to use
  2804. * @param size defines the size along the axis
  2805. * @returns the clip factor
  2806. */
  2807. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2808. /**
  2809. * Get angle between two vectors
  2810. * @param vector0 angle between vector0 and vector1
  2811. * @param vector1 angle between vector0 and vector1
  2812. * @param normal direction of the normal
  2813. * @return the angle between vector0 and vector1
  2814. */
  2815. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2816. /**
  2817. * Returns a new Vector3 set from the index "offset" of the given array
  2818. * @param array defines the source array
  2819. * @param offset defines the offset in the source array
  2820. * @returns the new Vector3
  2821. */
  2822. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2823. /**
  2824. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2825. * @param array defines the source array
  2826. * @param offset defines the offset in the source array
  2827. * @returns the new Vector3
  2828. * @deprecated Please use FromArray instead.
  2829. */
  2830. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2831. /**
  2832. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2833. * @param array defines the source array
  2834. * @param offset defines the offset in the source array
  2835. * @param result defines the Vector3 where to store the result
  2836. */
  2837. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2838. /**
  2839. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2840. * @param array defines the source array
  2841. * @param offset defines the offset in the source array
  2842. * @param result defines the Vector3 where to store the result
  2843. * @deprecated Please use FromArrayToRef instead.
  2844. */
  2845. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2846. /**
  2847. * Sets the given vector "result" with the given floats.
  2848. * @param x defines the x coordinate of the source
  2849. * @param y defines the y coordinate of the source
  2850. * @param z defines the z coordinate of the source
  2851. * @param result defines the Vector3 where to store the result
  2852. */
  2853. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2854. /**
  2855. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2856. * @returns a new empty Vector3
  2857. */
  2858. static Zero(): Vector3;
  2859. /**
  2860. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2861. * @returns a new unit Vector3
  2862. */
  2863. static One(): Vector3;
  2864. /**
  2865. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2866. * @returns a new up Vector3
  2867. */
  2868. static Up(): Vector3;
  2869. /**
  2870. * Gets a up Vector3 that must not be updated
  2871. */
  2872. static get UpReadOnly(): DeepImmutable<Vector3>;
  2873. /**
  2874. * Gets a zero Vector3 that must not be updated
  2875. */
  2876. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2877. /**
  2878. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2879. * @returns a new down Vector3
  2880. */
  2881. static Down(): Vector3;
  2882. /**
  2883. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2884. * @param rightHandedSystem is the scene right-handed (negative z)
  2885. * @returns a new forward Vector3
  2886. */
  2887. static Forward(rightHandedSystem?: boolean): Vector3;
  2888. /**
  2889. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2890. * @param rightHandedSystem is the scene right-handed (negative-z)
  2891. * @returns a new forward Vector3
  2892. */
  2893. static Backward(rightHandedSystem?: boolean): Vector3;
  2894. /**
  2895. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2896. * @returns a new right Vector3
  2897. */
  2898. static Right(): Vector3;
  2899. /**
  2900. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2901. * @returns a new left Vector3
  2902. */
  2903. static Left(): Vector3;
  2904. /**
  2905. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2906. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2907. * @param vector defines the Vector3 to transform
  2908. * @param transformation defines the transformation matrix
  2909. * @returns the transformed Vector3
  2910. */
  2911. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2912. /**
  2913. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2914. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2915. * @param vector defines the Vector3 to transform
  2916. * @param transformation defines the transformation matrix
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2920. /**
  2921. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2922. * This method computes tranformed coordinates only, not transformed direction vectors
  2923. * @param x define the x coordinate of the source vector
  2924. * @param y define the y coordinate of the source vector
  2925. * @param z define the z coordinate of the source vector
  2926. * @param transformation defines the transformation matrix
  2927. * @param result defines the Vector3 where to store the result
  2928. */
  2929. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2930. /**
  2931. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2932. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2933. * @param vector defines the Vector3 to transform
  2934. * @param transformation defines the transformation matrix
  2935. * @returns the new Vector3
  2936. */
  2937. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2938. /**
  2939. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2940. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2941. * @param vector defines the Vector3 to transform
  2942. * @param transformation defines the transformation matrix
  2943. * @param result defines the Vector3 where to store the result
  2944. */
  2945. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2946. /**
  2947. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2948. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2949. * @param x define the x coordinate of the source vector
  2950. * @param y define the y coordinate of the source vector
  2951. * @param z define the z coordinate of the source vector
  2952. * @param transformation defines the transformation matrix
  2953. * @param result defines the Vector3 where to store the result
  2954. */
  2955. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2956. /**
  2957. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2958. * @param value1 defines the first control point
  2959. * @param value2 defines the second control point
  2960. * @param value3 defines the third control point
  2961. * @param value4 defines the fourth control point
  2962. * @param amount defines the amount on the spline to use
  2963. * @returns the new Vector3
  2964. */
  2965. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2966. /**
  2967. * 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"
  2968. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2969. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2970. * @param value defines the current value
  2971. * @param min defines the lower range value
  2972. * @param max defines the upper range value
  2973. * @returns the new Vector3
  2974. */
  2975. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2976. /**
  2977. * 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"
  2978. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2979. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2980. * @param value defines the current value
  2981. * @param min defines the lower range value
  2982. * @param max defines the upper range value
  2983. * @param result defines the Vector3 where to store the result
  2984. */
  2985. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2986. /**
  2987. * Checks if a given vector is inside a specific range
  2988. * @param v defines the vector to test
  2989. * @param min defines the minimum range
  2990. * @param max defines the maximum range
  2991. */
  2992. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2993. /**
  2994. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2995. * @param value1 defines the first control point
  2996. * @param tangent1 defines the first tangent vector
  2997. * @param value2 defines the second control point
  2998. * @param tangent2 defines the second tangent vector
  2999. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3000. * @returns the new Vector3
  3001. */
  3002. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3003. /**
  3004. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3005. * @param start defines the start value
  3006. * @param end defines the end value
  3007. * @param amount max defines amount between both (between 0 and 1)
  3008. * @returns the new Vector3
  3009. */
  3010. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3011. /**
  3012. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3013. * @param start defines the start value
  3014. * @param end defines the end value
  3015. * @param amount max defines amount between both (between 0 and 1)
  3016. * @param result defines the Vector3 where to store the result
  3017. */
  3018. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3019. /**
  3020. * Returns the dot product (float) between the vectors "left" and "right"
  3021. * @param left defines the left operand
  3022. * @param right defines the right operand
  3023. * @returns the dot product
  3024. */
  3025. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3026. /**
  3027. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3028. * The cross product is then orthogonal to both "left" and "right"
  3029. * @param left defines the left operand
  3030. * @param right defines the right operand
  3031. * @returns the cross product
  3032. */
  3033. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3034. /**
  3035. * Sets the given vector "result" with the cross product of "left" and "right"
  3036. * The cross product is then orthogonal to both "left" and "right"
  3037. * @param left defines the left operand
  3038. * @param right defines the right operand
  3039. * @param result defines the Vector3 where to store the result
  3040. */
  3041. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3042. /**
  3043. * Returns a new Vector3 as the normalization of the given vector
  3044. * @param vector defines the Vector3 to normalize
  3045. * @returns the new Vector3
  3046. */
  3047. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3048. /**
  3049. * Sets the given vector "result" with the normalization of the given first vector
  3050. * @param vector defines the Vector3 to normalize
  3051. * @param result defines the Vector3 where to store the result
  3052. */
  3053. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3054. /**
  3055. * Project a Vector3 onto screen space
  3056. * @param vector defines the Vector3 to project
  3057. * @param world defines the world matrix to use
  3058. * @param transform defines the transform (view x projection) matrix to use
  3059. * @param viewport defines the screen viewport to use
  3060. * @returns the new Vector3
  3061. */
  3062. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3063. /** @hidden */
  3064. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3065. /**
  3066. * Unproject from screen space to object space
  3067. * @param source defines the screen space Vector3 to use
  3068. * @param viewportWidth defines the current width of the viewport
  3069. * @param viewportHeight defines the current height of the viewport
  3070. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3071. * @param transform defines the transform (view x projection) matrix to use
  3072. * @returns the new Vector3
  3073. */
  3074. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3075. /**
  3076. * Unproject from screen space to object space
  3077. * @param source defines the screen space Vector3 to use
  3078. * @param viewportWidth defines the current width of the viewport
  3079. * @param viewportHeight defines the current height of the viewport
  3080. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3081. * @param view defines the view matrix to use
  3082. * @param projection defines the projection matrix to use
  3083. * @returns the new Vector3
  3084. */
  3085. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3086. /**
  3087. * Unproject from screen space to object space
  3088. * @param source defines the screen space Vector3 to use
  3089. * @param viewportWidth defines the current width of the viewport
  3090. * @param viewportHeight defines the current height of the viewport
  3091. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3092. * @param view defines the view matrix to use
  3093. * @param projection defines the projection matrix to use
  3094. * @param result defines the Vector3 where to store the result
  3095. */
  3096. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3097. /**
  3098. * Unproject from screen space to object space
  3099. * @param sourceX defines the screen space x coordinate to use
  3100. * @param sourceY defines the screen space y coordinate to use
  3101. * @param sourceZ defines the screen space z coordinate to use
  3102. * @param viewportWidth defines the current width of the viewport
  3103. * @param viewportHeight defines the current height of the viewport
  3104. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3105. * @param view defines the view matrix to use
  3106. * @param projection defines the projection matrix to use
  3107. * @param result defines the Vector3 where to store the result
  3108. */
  3109. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3110. /**
  3111. * Gets the minimal coordinate values between two Vector3
  3112. * @param left defines the first operand
  3113. * @param right defines the second operand
  3114. * @returns the new Vector3
  3115. */
  3116. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3117. /**
  3118. * Gets the maximal coordinate values between two Vector3
  3119. * @param left defines the first operand
  3120. * @param right defines the second operand
  3121. * @returns the new Vector3
  3122. */
  3123. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3124. /**
  3125. * Returns the distance between the vectors "value1" and "value2"
  3126. * @param value1 defines the first operand
  3127. * @param value2 defines the second operand
  3128. * @returns the distance
  3129. */
  3130. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3131. /**
  3132. * Returns the squared distance between the vectors "value1" and "value2"
  3133. * @param value1 defines the first operand
  3134. * @param value2 defines the second operand
  3135. * @returns the squared distance
  3136. */
  3137. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3138. /**
  3139. * Returns a new Vector3 located at the center between "value1" and "value2"
  3140. * @param value1 defines the first operand
  3141. * @param value2 defines the second operand
  3142. * @returns the new Vector3
  3143. */
  3144. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3145. /**
  3146. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3147. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3148. * to something in order to rotate it from its local system to the given target system
  3149. * Note: axis1, axis2 and axis3 are normalized during this operation
  3150. * @param axis1 defines the first axis
  3151. * @param axis2 defines the second axis
  3152. * @param axis3 defines the third axis
  3153. * @returns a new Vector3
  3154. */
  3155. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3156. /**
  3157. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3158. * @param axis1 defines the first axis
  3159. * @param axis2 defines the second axis
  3160. * @param axis3 defines the third axis
  3161. * @param ref defines the Vector3 where to store the result
  3162. */
  3163. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3164. }
  3165. /**
  3166. * Vector4 class created for EulerAngle class conversion to Quaternion
  3167. */
  3168. export class Vector4 {
  3169. /** x value of the vector */
  3170. x: number;
  3171. /** y value of the vector */
  3172. y: number;
  3173. /** z value of the vector */
  3174. z: number;
  3175. /** w value of the vector */
  3176. w: number;
  3177. /**
  3178. * Creates a Vector4 object from the given floats.
  3179. * @param x x value of the vector
  3180. * @param y y value of the vector
  3181. * @param z z value of the vector
  3182. * @param w w value of the vector
  3183. */
  3184. constructor(
  3185. /** x value of the vector */
  3186. x: number,
  3187. /** y value of the vector */
  3188. y: number,
  3189. /** z value of the vector */
  3190. z: number,
  3191. /** w value of the vector */
  3192. w: number);
  3193. /**
  3194. * Returns the string with the Vector4 coordinates.
  3195. * @returns a string containing all the vector values
  3196. */
  3197. toString(): string;
  3198. /**
  3199. * Returns the string "Vector4".
  3200. * @returns "Vector4"
  3201. */
  3202. getClassName(): string;
  3203. /**
  3204. * Returns the Vector4 hash code.
  3205. * @returns a unique hash code
  3206. */
  3207. getHashCode(): number;
  3208. /**
  3209. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3210. * @returns the resulting array
  3211. */
  3212. asArray(): number[];
  3213. /**
  3214. * Populates the given array from the given index with the Vector4 coordinates.
  3215. * @param array array to populate
  3216. * @param index index of the array to start at (default: 0)
  3217. * @returns the Vector4.
  3218. */
  3219. toArray(array: FloatArray, index?: number): Vector4;
  3220. /**
  3221. * Adds the given vector to the current Vector4.
  3222. * @param otherVector the vector to add
  3223. * @returns the updated Vector4.
  3224. */
  3225. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3226. /**
  3227. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3228. * @param otherVector the vector to add
  3229. * @returns the resulting vector
  3230. */
  3231. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3232. /**
  3233. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3234. * @param otherVector the vector to add
  3235. * @param result the vector to store the result
  3236. * @returns the current Vector4.
  3237. */
  3238. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3239. /**
  3240. * Subtract in place the given vector from the current Vector4.
  3241. * @param otherVector the vector to subtract
  3242. * @returns the updated Vector4.
  3243. */
  3244. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3245. /**
  3246. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3247. * @param otherVector the vector to add
  3248. * @returns the new vector with the result
  3249. */
  3250. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3251. /**
  3252. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3253. * @param otherVector the vector to subtract
  3254. * @param result the vector to store the result
  3255. * @returns the current Vector4.
  3256. */
  3257. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3258. /**
  3259. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3260. */
  3261. /**
  3262. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3263. * @param x value to subtract
  3264. * @param y value to subtract
  3265. * @param z value to subtract
  3266. * @param w value to subtract
  3267. * @returns new vector containing the result
  3268. */
  3269. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3270. /**
  3271. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3272. * @param x value to subtract
  3273. * @param y value to subtract
  3274. * @param z value to subtract
  3275. * @param w value to subtract
  3276. * @param result the vector to store the result in
  3277. * @returns the current Vector4.
  3278. */
  3279. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3280. /**
  3281. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3282. * @returns a new vector with the negated values
  3283. */
  3284. negate(): Vector4;
  3285. /**
  3286. * Negate this vector in place
  3287. * @returns this
  3288. */
  3289. negateInPlace(): Vector4;
  3290. /**
  3291. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3292. * @param result defines the Vector3 object where to store the result
  3293. * @returns the current Vector4
  3294. */
  3295. negateToRef(result: Vector4): Vector4;
  3296. /**
  3297. * Multiplies the current Vector4 coordinates by scale (float).
  3298. * @param scale the number to scale with
  3299. * @returns the updated Vector4.
  3300. */
  3301. scaleInPlace(scale: number): Vector4;
  3302. /**
  3303. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3304. * @param scale the number to scale with
  3305. * @returns a new vector with the result
  3306. */
  3307. scale(scale: number): Vector4;
  3308. /**
  3309. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3310. * @param scale the number to scale with
  3311. * @param result a vector to store the result in
  3312. * @returns the current Vector4.
  3313. */
  3314. scaleToRef(scale: number, result: Vector4): Vector4;
  3315. /**
  3316. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3317. * @param scale defines the scale factor
  3318. * @param result defines the Vector4 object where to store the result
  3319. * @returns the unmodified current Vector4
  3320. */
  3321. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3322. /**
  3323. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3324. * @param otherVector the vector to compare against
  3325. * @returns true if they are equal
  3326. */
  3327. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3328. /**
  3329. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3330. * @param otherVector vector to compare against
  3331. * @param epsilon (Default: very small number)
  3332. * @returns true if they are equal
  3333. */
  3334. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3335. /**
  3336. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3337. * @param x x value to compare against
  3338. * @param y y value to compare against
  3339. * @param z z value to compare against
  3340. * @param w w value to compare against
  3341. * @returns true if equal
  3342. */
  3343. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3344. /**
  3345. * Multiplies in place the current Vector4 by the given one.
  3346. * @param otherVector vector to multiple with
  3347. * @returns the updated Vector4.
  3348. */
  3349. multiplyInPlace(otherVector: Vector4): Vector4;
  3350. /**
  3351. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3352. * @param otherVector vector to multiple with
  3353. * @returns resulting new vector
  3354. */
  3355. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3356. /**
  3357. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3358. * @param otherVector vector to multiple with
  3359. * @param result vector to store the result
  3360. * @returns the current Vector4.
  3361. */
  3362. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3363. /**
  3364. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3365. * @param x x value multiply with
  3366. * @param y y value multiply with
  3367. * @param z z value multiply with
  3368. * @param w w value multiply with
  3369. * @returns resulting new vector
  3370. */
  3371. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3372. /**
  3373. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3374. * @param otherVector vector to devide with
  3375. * @returns resulting new vector
  3376. */
  3377. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3378. /**
  3379. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3380. * @param otherVector vector to devide with
  3381. * @param result vector to store the result
  3382. * @returns the current Vector4.
  3383. */
  3384. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3385. /**
  3386. * Divides the current Vector3 coordinates by the given ones.
  3387. * @param otherVector vector to devide with
  3388. * @returns the updated Vector3.
  3389. */
  3390. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3391. /**
  3392. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3393. * @param other defines the second operand
  3394. * @returns the current updated Vector4
  3395. */
  3396. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3397. /**
  3398. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3399. * @param other defines the second operand
  3400. * @returns the current updated Vector4
  3401. */
  3402. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3403. /**
  3404. * Gets a new Vector4 from current Vector4 floored values
  3405. * @returns a new Vector4
  3406. */
  3407. floor(): Vector4;
  3408. /**
  3409. * Gets a new Vector4 from current Vector3 floored values
  3410. * @returns a new Vector4
  3411. */
  3412. fract(): Vector4;
  3413. /**
  3414. * Returns the Vector4 length (float).
  3415. * @returns the length
  3416. */
  3417. length(): number;
  3418. /**
  3419. * Returns the Vector4 squared length (float).
  3420. * @returns the length squared
  3421. */
  3422. lengthSquared(): number;
  3423. /**
  3424. * Normalizes in place the Vector4.
  3425. * @returns the updated Vector4.
  3426. */
  3427. normalize(): Vector4;
  3428. /**
  3429. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3430. * @returns this converted to a new vector3
  3431. */
  3432. toVector3(): Vector3;
  3433. /**
  3434. * Returns a new Vector4 copied from the current one.
  3435. * @returns the new cloned vector
  3436. */
  3437. clone(): Vector4;
  3438. /**
  3439. * Updates the current Vector4 with the given one coordinates.
  3440. * @param source the source vector to copy from
  3441. * @returns the updated Vector4.
  3442. */
  3443. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the current Vector4 coordinates with the given floats.
  3446. * @param x float to copy from
  3447. * @param y float to copy from
  3448. * @param z float to copy from
  3449. * @param w float to copy from
  3450. * @returns the updated Vector4.
  3451. */
  3452. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3453. /**
  3454. * Updates the current Vector4 coordinates with the given floats.
  3455. * @param x float to set from
  3456. * @param y float to set from
  3457. * @param z float to set from
  3458. * @param w float to set from
  3459. * @returns the updated Vector4.
  3460. */
  3461. set(x: number, y: number, z: number, w: number): Vector4;
  3462. /**
  3463. * Copies the given float to the current Vector3 coordinates
  3464. * @param v defines the x, y, z and w coordinates of the operand
  3465. * @returns the current updated Vector3
  3466. */
  3467. setAll(v: number): Vector4;
  3468. /**
  3469. * Returns a new Vector4 set from the starting index of the given array.
  3470. * @param array the array to pull values from
  3471. * @param offset the offset into the array to start at
  3472. * @returns the new vector
  3473. */
  3474. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3475. /**
  3476. * Updates the given vector "result" from the starting index of the given array.
  3477. * @param array the array to pull values from
  3478. * @param offset the offset into the array to start at
  3479. * @param result the vector to store the result in
  3480. */
  3481. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3482. /**
  3483. * Updates the given vector "result" from the starting index of the given Float32Array.
  3484. * @param array the array to pull values from
  3485. * @param offset the offset into the array to start at
  3486. * @param result the vector to store the result in
  3487. */
  3488. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3489. /**
  3490. * Updates the given vector "result" coordinates from the given floats.
  3491. * @param x float to set from
  3492. * @param y float to set from
  3493. * @param z float to set from
  3494. * @param w float to set from
  3495. * @param result the vector to the floats in
  3496. */
  3497. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3498. /**
  3499. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3500. * @returns the new vector
  3501. */
  3502. static Zero(): Vector4;
  3503. /**
  3504. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3505. * @returns the new vector
  3506. */
  3507. static One(): Vector4;
  3508. /**
  3509. * Returns a new normalized Vector4 from the given one.
  3510. * @param vector the vector to normalize
  3511. * @returns the vector
  3512. */
  3513. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3514. /**
  3515. * Updates the given vector "result" from the normalization of the given one.
  3516. * @param vector the vector to normalize
  3517. * @param result the vector to store the result in
  3518. */
  3519. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3520. /**
  3521. * Returns a vector with the minimum values from the left and right vectors
  3522. * @param left left vector to minimize
  3523. * @param right right vector to minimize
  3524. * @returns a new vector with the minimum of the left and right vector values
  3525. */
  3526. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3527. /**
  3528. * Returns a vector with the maximum values from the left and right vectors
  3529. * @param left left vector to maximize
  3530. * @param right right vector to maximize
  3531. * @returns a new vector with the maximum of the left and right vector values
  3532. */
  3533. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3534. /**
  3535. * Returns the distance (float) between the vectors "value1" and "value2".
  3536. * @param value1 value to calulate the distance between
  3537. * @param value2 value to calulate the distance between
  3538. * @return the distance between the two vectors
  3539. */
  3540. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3541. /**
  3542. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3543. * @param value1 value to calulate the distance between
  3544. * @param value2 value to calulate the distance between
  3545. * @return the distance between the two vectors squared
  3546. */
  3547. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3548. /**
  3549. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3550. * @param value1 value to calulate the center between
  3551. * @param value2 value to calulate the center between
  3552. * @return the center between the two vectors
  3553. */
  3554. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3555. /**
  3556. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3557. * This methods computes transformed normalized direction vectors only.
  3558. * @param vector the vector to transform
  3559. * @param transformation the transformation matrix to apply
  3560. * @returns the new vector
  3561. */
  3562. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3563. /**
  3564. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3565. * This methods computes transformed normalized direction vectors only.
  3566. * @param vector the vector to transform
  3567. * @param transformation the transformation matrix to apply
  3568. * @param result the vector to store the result in
  3569. */
  3570. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3571. /**
  3572. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3573. * This methods computes transformed normalized direction vectors only.
  3574. * @param x value to transform
  3575. * @param y value to transform
  3576. * @param z value to transform
  3577. * @param w value to transform
  3578. * @param transformation the transformation matrix to apply
  3579. * @param result the vector to store the results in
  3580. */
  3581. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3582. /**
  3583. * Creates a new Vector4 from a Vector3
  3584. * @param source defines the source data
  3585. * @param w defines the 4th component (default is 0)
  3586. * @returns a new Vector4
  3587. */
  3588. static FromVector3(source: Vector3, w?: number): Vector4;
  3589. }
  3590. /**
  3591. * Class used to store quaternion data
  3592. * @see https://en.wikipedia.org/wiki/Quaternion
  3593. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3594. */
  3595. export class Quaternion {
  3596. /** @hidden */
  3597. _x: number;
  3598. /** @hidden */
  3599. _y: number;
  3600. /** @hidden */
  3601. _z: number;
  3602. /** @hidden */
  3603. _w: number;
  3604. /** @hidden */
  3605. _isDirty: boolean;
  3606. /** Gets or sets the x coordinate */
  3607. get x(): number;
  3608. set x(value: number);
  3609. /** Gets or sets the y coordinate */
  3610. get y(): number;
  3611. set y(value: number);
  3612. /** Gets or sets the z coordinate */
  3613. get z(): number;
  3614. set z(value: number);
  3615. /** Gets or sets the w coordinate */
  3616. get w(): number;
  3617. set w(value: number);
  3618. /**
  3619. * Creates a new Quaternion from the given floats
  3620. * @param x defines the first component (0 by default)
  3621. * @param y defines the second component (0 by default)
  3622. * @param z defines the third component (0 by default)
  3623. * @param w defines the fourth component (1.0 by default)
  3624. */
  3625. constructor(x?: number, y?: number, z?: number, w?: number);
  3626. /**
  3627. * Gets a string representation for the current quaternion
  3628. * @returns a string with the Quaternion coordinates
  3629. */
  3630. toString(): string;
  3631. /**
  3632. * Gets the class name of the quaternion
  3633. * @returns the string "Quaternion"
  3634. */
  3635. getClassName(): string;
  3636. /**
  3637. * Gets a hash code for this quaternion
  3638. * @returns the quaternion hash code
  3639. */
  3640. getHashCode(): number;
  3641. /**
  3642. * Copy the quaternion to an array
  3643. * @returns a new array populated with 4 elements from the quaternion coordinates
  3644. */
  3645. asArray(): number[];
  3646. /**
  3647. * Check if two quaternions are equals
  3648. * @param otherQuaternion defines the second operand
  3649. * @return true if the current quaternion and the given one coordinates are strictly equals
  3650. */
  3651. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3652. /**
  3653. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3654. * @param otherQuaternion defines the other quaternion
  3655. * @param epsilon defines the minimal distance to consider equality
  3656. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3657. */
  3658. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3659. /**
  3660. * Clone the current quaternion
  3661. * @returns a new quaternion copied from the current one
  3662. */
  3663. clone(): Quaternion;
  3664. /**
  3665. * Copy a quaternion to the current one
  3666. * @param other defines the other quaternion
  3667. * @returns the updated current quaternion
  3668. */
  3669. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3670. /**
  3671. * Updates the current quaternion with the given float coordinates
  3672. * @param x defines the x coordinate
  3673. * @param y defines the y coordinate
  3674. * @param z defines the z coordinate
  3675. * @param w defines the w coordinate
  3676. * @returns the updated current quaternion
  3677. */
  3678. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3679. /**
  3680. * Updates the current quaternion from the given float coordinates
  3681. * @param x defines the x coordinate
  3682. * @param y defines the y coordinate
  3683. * @param z defines the z coordinate
  3684. * @param w defines the w coordinate
  3685. * @returns the updated current quaternion
  3686. */
  3687. set(x: number, y: number, z: number, w: number): Quaternion;
  3688. /**
  3689. * Adds two quaternions
  3690. * @param other defines the second operand
  3691. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3692. */
  3693. add(other: DeepImmutable<Quaternion>): Quaternion;
  3694. /**
  3695. * Add a quaternion to the current one
  3696. * @param other defines the quaternion to add
  3697. * @returns the current quaternion
  3698. */
  3699. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3700. /**
  3701. * Subtract two quaternions
  3702. * @param other defines the second operand
  3703. * @returns a new quaternion as the subtraction result of the given one from the current one
  3704. */
  3705. subtract(other: Quaternion): Quaternion;
  3706. /**
  3707. * Multiplies the current quaternion by a scale factor
  3708. * @param value defines the scale factor
  3709. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3710. */
  3711. scale(value: number): Quaternion;
  3712. /**
  3713. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3714. * @param scale defines the scale factor
  3715. * @param result defines the Quaternion object where to store the result
  3716. * @returns the unmodified current quaternion
  3717. */
  3718. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3719. /**
  3720. * Multiplies in place the current quaternion by a scale factor
  3721. * @param value defines the scale factor
  3722. * @returns the current modified quaternion
  3723. */
  3724. scaleInPlace(value: number): Quaternion;
  3725. /**
  3726. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3727. * @param scale defines the scale factor
  3728. * @param result defines the Quaternion object where to store the result
  3729. * @returns the unmodified current quaternion
  3730. */
  3731. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3732. /**
  3733. * Multiplies two quaternions
  3734. * @param q1 defines the second operand
  3735. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3736. */
  3737. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3738. /**
  3739. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3740. * @param q1 defines the second operand
  3741. * @param result defines the target quaternion
  3742. * @returns the current quaternion
  3743. */
  3744. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3745. /**
  3746. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3747. * @param q1 defines the second operand
  3748. * @returns the currentupdated quaternion
  3749. */
  3750. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3751. /**
  3752. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3753. * @param ref defines the target quaternion
  3754. * @returns the current quaternion
  3755. */
  3756. conjugateToRef(ref: Quaternion): Quaternion;
  3757. /**
  3758. * Conjugates in place (1-q) the current quaternion
  3759. * @returns the current updated quaternion
  3760. */
  3761. conjugateInPlace(): Quaternion;
  3762. /**
  3763. * Conjugates in place (1-q) the current quaternion
  3764. * @returns a new quaternion
  3765. */
  3766. conjugate(): Quaternion;
  3767. /**
  3768. * Gets length of current quaternion
  3769. * @returns the quaternion length (float)
  3770. */
  3771. length(): number;
  3772. /**
  3773. * Normalize in place the current quaternion
  3774. * @returns the current updated quaternion
  3775. */
  3776. normalize(): Quaternion;
  3777. /**
  3778. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3779. * @param order is a reserved parameter and is ignore for now
  3780. * @returns a new Vector3 containing the Euler angles
  3781. */
  3782. toEulerAngles(order?: string): Vector3;
  3783. /**
  3784. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3785. * @param result defines the vector which will be filled with the Euler angles
  3786. * @param order is a reserved parameter and is ignore for now
  3787. * @returns the current unchanged quaternion
  3788. */
  3789. toEulerAnglesToRef(result: Vector3): Quaternion;
  3790. /**
  3791. * Updates the given rotation matrix with the current quaternion values
  3792. * @param result defines the target matrix
  3793. * @returns the current unchanged quaternion
  3794. */
  3795. toRotationMatrix(result: Matrix): Quaternion;
  3796. /**
  3797. * Updates the current quaternion from the given rotation matrix values
  3798. * @param matrix defines the source matrix
  3799. * @returns the current updated quaternion
  3800. */
  3801. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3802. /**
  3803. * Creates a new quaternion from a rotation matrix
  3804. * @param matrix defines the source matrix
  3805. * @returns a new quaternion created from the given rotation matrix values
  3806. */
  3807. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3808. /**
  3809. * Updates the given quaternion with the given rotation matrix values
  3810. * @param matrix defines the source matrix
  3811. * @param result defines the target quaternion
  3812. */
  3813. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3814. /**
  3815. * Returns the dot product (float) between the quaternions "left" and "right"
  3816. * @param left defines the left operand
  3817. * @param right defines the right operand
  3818. * @returns the dot product
  3819. */
  3820. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3821. /**
  3822. * Checks if the two quaternions are close to each other
  3823. * @param quat0 defines the first quaternion to check
  3824. * @param quat1 defines the second quaternion to check
  3825. * @returns true if the two quaternions are close to each other
  3826. */
  3827. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3828. /**
  3829. * Creates an empty quaternion
  3830. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3831. */
  3832. static Zero(): Quaternion;
  3833. /**
  3834. * Inverse a given quaternion
  3835. * @param q defines the source quaternion
  3836. * @returns a new quaternion as the inverted current quaternion
  3837. */
  3838. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3839. /**
  3840. * Inverse a given quaternion
  3841. * @param q defines the source quaternion
  3842. * @param result the quaternion the result will be stored in
  3843. * @returns the result quaternion
  3844. */
  3845. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3846. /**
  3847. * Creates an identity quaternion
  3848. * @returns the identity quaternion
  3849. */
  3850. static Identity(): Quaternion;
  3851. /**
  3852. * Gets a boolean indicating if the given quaternion is identity
  3853. * @param quaternion defines the quaternion to check
  3854. * @returns true if the quaternion is identity
  3855. */
  3856. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3857. /**
  3858. * Creates a quaternion from a rotation around an axis
  3859. * @param axis defines the axis to use
  3860. * @param angle defines the angle to use
  3861. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3862. */
  3863. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3864. /**
  3865. * Creates a rotation around an axis and stores it into the given quaternion
  3866. * @param axis defines the axis to use
  3867. * @param angle defines the angle to use
  3868. * @param result defines the target quaternion
  3869. * @returns the target quaternion
  3870. */
  3871. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3872. /**
  3873. * Creates a new quaternion from data stored into an array
  3874. * @param array defines the data source
  3875. * @param offset defines the offset in the source array where the data starts
  3876. * @returns a new quaternion
  3877. */
  3878. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3879. /**
  3880. * Updates the given quaternion "result" from the starting index of the given array.
  3881. * @param array the array to pull values from
  3882. * @param offset the offset into the array to start at
  3883. * @param result the quaternion to store the result in
  3884. */
  3885. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3886. /**
  3887. * Create a quaternion from Euler rotation angles
  3888. * @param x Pitch
  3889. * @param y Yaw
  3890. * @param z Roll
  3891. * @returns the new Quaternion
  3892. */
  3893. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3894. /**
  3895. * Updates a quaternion from Euler rotation angles
  3896. * @param x Pitch
  3897. * @param y Yaw
  3898. * @param z Roll
  3899. * @param result the quaternion to store the result
  3900. * @returns the updated quaternion
  3901. */
  3902. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3903. /**
  3904. * Create a quaternion from Euler rotation vector
  3905. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3906. * @returns the new Quaternion
  3907. */
  3908. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3909. /**
  3910. * Updates a quaternion from Euler rotation vector
  3911. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3912. * @param result the quaternion to store the result
  3913. * @returns the updated quaternion
  3914. */
  3915. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3916. /**
  3917. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3918. * @param yaw defines the rotation around Y axis
  3919. * @param pitch defines the rotation around X axis
  3920. * @param roll defines the rotation around Z axis
  3921. * @returns the new quaternion
  3922. */
  3923. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3924. /**
  3925. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3926. * @param yaw defines the rotation around Y axis
  3927. * @param pitch defines the rotation around X axis
  3928. * @param roll defines the rotation around Z axis
  3929. * @param result defines the target quaternion
  3930. */
  3931. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3932. /**
  3933. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3934. * @param alpha defines the rotation around first axis
  3935. * @param beta defines the rotation around second axis
  3936. * @param gamma defines the rotation around third axis
  3937. * @returns the new quaternion
  3938. */
  3939. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3940. /**
  3941. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3942. * @param alpha defines the rotation around first axis
  3943. * @param beta defines the rotation around second axis
  3944. * @param gamma defines the rotation around third axis
  3945. * @param result defines the target quaternion
  3946. */
  3947. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3948. /**
  3949. * 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)
  3950. * @param axis1 defines the first axis
  3951. * @param axis2 defines the second axis
  3952. * @param axis3 defines the third axis
  3953. * @returns the new quaternion
  3954. */
  3955. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3956. /**
  3957. * 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
  3958. * @param axis1 defines the first axis
  3959. * @param axis2 defines the second axis
  3960. * @param axis3 defines the third axis
  3961. * @param ref defines the target quaternion
  3962. */
  3963. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3964. /**
  3965. * Interpolates between two quaternions
  3966. * @param left defines first quaternion
  3967. * @param right defines second quaternion
  3968. * @param amount defines the gradient to use
  3969. * @returns the new interpolated quaternion
  3970. */
  3971. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3972. /**
  3973. * Interpolates between two quaternions and stores it into a target quaternion
  3974. * @param left defines first quaternion
  3975. * @param right defines second quaternion
  3976. * @param amount defines the gradient to use
  3977. * @param result defines the target quaternion
  3978. */
  3979. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3980. /**
  3981. * Interpolate between two quaternions using Hermite interpolation
  3982. * @param value1 defines first quaternion
  3983. * @param tangent1 defines the incoming tangent
  3984. * @param value2 defines second quaternion
  3985. * @param tangent2 defines the outgoing tangent
  3986. * @param amount defines the target quaternion
  3987. * @returns the new interpolated quaternion
  3988. */
  3989. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3990. }
  3991. /**
  3992. * Class used to store matrix data (4x4)
  3993. */
  3994. export class Matrix {
  3995. private static _updateFlagSeed;
  3996. private static _identityReadOnly;
  3997. private _isIdentity;
  3998. private _isIdentityDirty;
  3999. private _isIdentity3x2;
  4000. private _isIdentity3x2Dirty;
  4001. /**
  4002. * Gets the update flag of the matrix which is an unique number for the matrix.
  4003. * It will be incremented every time the matrix data change.
  4004. * You can use it to speed the comparison between two versions of the same matrix.
  4005. */
  4006. updateFlag: number;
  4007. private readonly _m;
  4008. /**
  4009. * Gets the internal data of the matrix
  4010. */
  4011. get m(): DeepImmutable<Float32Array>;
  4012. /** @hidden */
  4013. _markAsUpdated(): void;
  4014. /** @hidden */
  4015. private _updateIdentityStatus;
  4016. /**
  4017. * Creates an empty matrix (filled with zeros)
  4018. */
  4019. constructor();
  4020. /**
  4021. * Check if the current matrix is identity
  4022. * @returns true is the matrix is the identity matrix
  4023. */
  4024. isIdentity(): boolean;
  4025. /**
  4026. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4027. * @returns true is the matrix is the identity matrix
  4028. */
  4029. isIdentityAs3x2(): boolean;
  4030. /**
  4031. * Gets the determinant of the matrix
  4032. * @returns the matrix determinant
  4033. */
  4034. determinant(): number;
  4035. /**
  4036. * Returns the matrix as a Float32Array
  4037. * @returns the matrix underlying array
  4038. */
  4039. toArray(): DeepImmutable<Float32Array>;
  4040. /**
  4041. * Returns the matrix as a Float32Array
  4042. * @returns the matrix underlying array.
  4043. */
  4044. asArray(): DeepImmutable<Float32Array>;
  4045. /**
  4046. * Inverts the current matrix in place
  4047. * @returns the current inverted matrix
  4048. */
  4049. invert(): Matrix;
  4050. /**
  4051. * Sets all the matrix elements to zero
  4052. * @returns the current matrix
  4053. */
  4054. reset(): Matrix;
  4055. /**
  4056. * Adds the current matrix with a second one
  4057. * @param other defines the matrix to add
  4058. * @returns a new matrix as the addition of the current matrix and the given one
  4059. */
  4060. add(other: DeepImmutable<Matrix>): Matrix;
  4061. /**
  4062. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4063. * @param other defines the matrix to add
  4064. * @param result defines the target matrix
  4065. * @returns the current matrix
  4066. */
  4067. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4068. /**
  4069. * Adds in place the given matrix to the current matrix
  4070. * @param other defines the second operand
  4071. * @returns the current updated matrix
  4072. */
  4073. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4074. /**
  4075. * Sets the given matrix to the current inverted Matrix
  4076. * @param other defines the target matrix
  4077. * @returns the unmodified current matrix
  4078. */
  4079. invertToRef(other: Matrix): Matrix;
  4080. /**
  4081. * add a value at the specified position in the current Matrix
  4082. * @param index the index of the value within the matrix. between 0 and 15.
  4083. * @param value the value to be added
  4084. * @returns the current updated matrix
  4085. */
  4086. addAtIndex(index: number, value: number): Matrix;
  4087. /**
  4088. * mutiply the specified position in the current Matrix by a value
  4089. * @param index the index of the value within the matrix. between 0 and 15.
  4090. * @param value the value to be added
  4091. * @returns the current updated matrix
  4092. */
  4093. multiplyAtIndex(index: number, value: number): Matrix;
  4094. /**
  4095. * Inserts the translation vector (using 3 floats) in the current matrix
  4096. * @param x defines the 1st component of the translation
  4097. * @param y defines the 2nd component of the translation
  4098. * @param z defines the 3rd component of the translation
  4099. * @returns the current updated matrix
  4100. */
  4101. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4102. /**
  4103. * Adds the translation vector (using 3 floats) in the current matrix
  4104. * @param x defines the 1st component of the translation
  4105. * @param y defines the 2nd component of the translation
  4106. * @param z defines the 3rd component of the translation
  4107. * @returns the current updated matrix
  4108. */
  4109. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4110. /**
  4111. * Inserts the translation vector in the current matrix
  4112. * @param vector3 defines the translation to insert
  4113. * @returns the current updated matrix
  4114. */
  4115. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4116. /**
  4117. * Gets the translation value of the current matrix
  4118. * @returns a new Vector3 as the extracted translation from the matrix
  4119. */
  4120. getTranslation(): Vector3;
  4121. /**
  4122. * Fill a Vector3 with the extracted translation from the matrix
  4123. * @param result defines the Vector3 where to store the translation
  4124. * @returns the current matrix
  4125. */
  4126. getTranslationToRef(result: Vector3): Matrix;
  4127. /**
  4128. * Remove rotation and scaling part from the matrix
  4129. * @returns the updated matrix
  4130. */
  4131. removeRotationAndScaling(): Matrix;
  4132. /**
  4133. * Multiply two matrices
  4134. * @param other defines the second operand
  4135. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4136. */
  4137. multiply(other: DeepImmutable<Matrix>): Matrix;
  4138. /**
  4139. * Copy the current matrix from the given one
  4140. * @param other defines the source matrix
  4141. * @returns the current updated matrix
  4142. */
  4143. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4144. /**
  4145. * Populates the given array from the starting index with the current matrix values
  4146. * @param array defines the target array
  4147. * @param offset defines the offset in the target array where to start storing values
  4148. * @returns the current matrix
  4149. */
  4150. copyToArray(array: Float32Array, offset?: number): Matrix;
  4151. /**
  4152. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4153. * @param other defines the second operand
  4154. * @param result defines the matrix where to store the multiplication
  4155. * @returns the current matrix
  4156. */
  4157. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4158. /**
  4159. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4160. * @param other defines the second operand
  4161. * @param result defines the array where to store the multiplication
  4162. * @param offset defines the offset in the target array where to start storing values
  4163. * @returns the current matrix
  4164. */
  4165. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4166. /**
  4167. * Check equality between this matrix and a second one
  4168. * @param value defines the second matrix to compare
  4169. * @returns true is the current matrix and the given one values are strictly equal
  4170. */
  4171. equals(value: DeepImmutable<Matrix>): boolean;
  4172. /**
  4173. * Clone the current matrix
  4174. * @returns a new matrix from the current matrix
  4175. */
  4176. clone(): Matrix;
  4177. /**
  4178. * Returns the name of the current matrix class
  4179. * @returns the string "Matrix"
  4180. */
  4181. getClassName(): string;
  4182. /**
  4183. * Gets the hash code of the current matrix
  4184. * @returns the hash code
  4185. */
  4186. getHashCode(): number;
  4187. /**
  4188. * Decomposes the current Matrix into a translation, rotation and scaling components
  4189. * @param scale defines the scale vector3 given as a reference to update
  4190. * @param rotation defines the rotation quaternion given as a reference to update
  4191. * @param translation defines the translation vector3 given as a reference to update
  4192. * @returns true if operation was successful
  4193. */
  4194. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4195. /**
  4196. * Gets specific row of the matrix
  4197. * @param index defines the number of the row to get
  4198. * @returns the index-th row of the current matrix as a new Vector4
  4199. */
  4200. getRow(index: number): Nullable<Vector4>;
  4201. /**
  4202. * Sets the index-th row of the current matrix to the vector4 values
  4203. * @param index defines the number of the row to set
  4204. * @param row defines the target vector4
  4205. * @returns the updated current matrix
  4206. */
  4207. setRow(index: number, row: Vector4): Matrix;
  4208. /**
  4209. * Compute the transpose of the matrix
  4210. * @returns the new transposed matrix
  4211. */
  4212. transpose(): Matrix;
  4213. /**
  4214. * Compute the transpose of the matrix and store it in a given matrix
  4215. * @param result defines the target matrix
  4216. * @returns the current matrix
  4217. */
  4218. transposeToRef(result: Matrix): Matrix;
  4219. /**
  4220. * Sets the index-th row of the current matrix with the given 4 x float values
  4221. * @param index defines the row index
  4222. * @param x defines the x component to set
  4223. * @param y defines the y component to set
  4224. * @param z defines the z component to set
  4225. * @param w defines the w component to set
  4226. * @returns the updated current matrix
  4227. */
  4228. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4229. /**
  4230. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4231. * @param scale defines the scale factor
  4232. * @returns a new matrix
  4233. */
  4234. scale(scale: number): Matrix;
  4235. /**
  4236. * Scale the current matrix values by a factor to a given result matrix
  4237. * @param scale defines the scale factor
  4238. * @param result defines the matrix to store the result
  4239. * @returns the current matrix
  4240. */
  4241. scaleToRef(scale: number, result: Matrix): Matrix;
  4242. /**
  4243. * Scale the current matrix values by a factor and add the result to a given matrix
  4244. * @param scale defines the scale factor
  4245. * @param result defines the Matrix to store the result
  4246. * @returns the current matrix
  4247. */
  4248. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4249. /**
  4250. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4251. * @param ref matrix to store the result
  4252. */
  4253. toNormalMatrix(ref: Matrix): void;
  4254. /**
  4255. * Gets only rotation part of the current matrix
  4256. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4257. */
  4258. getRotationMatrix(): Matrix;
  4259. /**
  4260. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4261. * @param result defines the target matrix to store data to
  4262. * @returns the current matrix
  4263. */
  4264. getRotationMatrixToRef(result: Matrix): Matrix;
  4265. /**
  4266. * Toggles model matrix from being right handed to left handed in place and vice versa
  4267. */
  4268. toggleModelMatrixHandInPlace(): void;
  4269. /**
  4270. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4271. */
  4272. toggleProjectionMatrixHandInPlace(): void;
  4273. /**
  4274. * Creates a matrix from an array
  4275. * @param array defines the source array
  4276. * @param offset defines an offset in the source array
  4277. * @returns a new Matrix set from the starting index of the given array
  4278. */
  4279. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4280. /**
  4281. * Copy the content of an array into a given matrix
  4282. * @param array defines the source array
  4283. * @param offset defines an offset in the source array
  4284. * @param result defines the target matrix
  4285. */
  4286. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4287. /**
  4288. * Stores an array into a matrix after having multiplied each component by a given factor
  4289. * @param array defines the source array
  4290. * @param offset defines the offset in the source array
  4291. * @param scale defines the scaling factor
  4292. * @param result defines the target matrix
  4293. */
  4294. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4295. /**
  4296. * Gets an identity matrix that must not be updated
  4297. */
  4298. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4299. /**
  4300. * Stores a list of values (16) inside a given matrix
  4301. * @param initialM11 defines 1st value of 1st row
  4302. * @param initialM12 defines 2nd value of 1st row
  4303. * @param initialM13 defines 3rd value of 1st row
  4304. * @param initialM14 defines 4th value of 1st row
  4305. * @param initialM21 defines 1st value of 2nd row
  4306. * @param initialM22 defines 2nd value of 2nd row
  4307. * @param initialM23 defines 3rd value of 2nd row
  4308. * @param initialM24 defines 4th value of 2nd row
  4309. * @param initialM31 defines 1st value of 3rd row
  4310. * @param initialM32 defines 2nd value of 3rd row
  4311. * @param initialM33 defines 3rd value of 3rd row
  4312. * @param initialM34 defines 4th value of 3rd row
  4313. * @param initialM41 defines 1st value of 4th row
  4314. * @param initialM42 defines 2nd value of 4th row
  4315. * @param initialM43 defines 3rd value of 4th row
  4316. * @param initialM44 defines 4th value of 4th row
  4317. * @param result defines the target matrix
  4318. */
  4319. 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;
  4320. /**
  4321. * Creates new matrix from a list of values (16)
  4322. * @param initialM11 defines 1st value of 1st row
  4323. * @param initialM12 defines 2nd value of 1st row
  4324. * @param initialM13 defines 3rd value of 1st row
  4325. * @param initialM14 defines 4th value of 1st row
  4326. * @param initialM21 defines 1st value of 2nd row
  4327. * @param initialM22 defines 2nd value of 2nd row
  4328. * @param initialM23 defines 3rd value of 2nd row
  4329. * @param initialM24 defines 4th value of 2nd row
  4330. * @param initialM31 defines 1st value of 3rd row
  4331. * @param initialM32 defines 2nd value of 3rd row
  4332. * @param initialM33 defines 3rd value of 3rd row
  4333. * @param initialM34 defines 4th value of 3rd row
  4334. * @param initialM41 defines 1st value of 4th row
  4335. * @param initialM42 defines 2nd value of 4th row
  4336. * @param initialM43 defines 3rd value of 4th row
  4337. * @param initialM44 defines 4th value of 4th row
  4338. * @returns the new matrix
  4339. */
  4340. 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;
  4341. /**
  4342. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4343. * @param scale defines the scale vector3
  4344. * @param rotation defines the rotation quaternion
  4345. * @param translation defines the translation vector3
  4346. * @returns a new matrix
  4347. */
  4348. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4349. /**
  4350. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4351. * @param scale defines the scale vector3
  4352. * @param rotation defines the rotation quaternion
  4353. * @param translation defines the translation vector3
  4354. * @param result defines the target matrix
  4355. */
  4356. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4357. /**
  4358. * Creates a new identity matrix
  4359. * @returns a new identity matrix
  4360. */
  4361. static Identity(): Matrix;
  4362. /**
  4363. * Creates a new identity matrix and stores the result in a given matrix
  4364. * @param result defines the target matrix
  4365. */
  4366. static IdentityToRef(result: Matrix): void;
  4367. /**
  4368. * Creates a new zero matrix
  4369. * @returns a new zero matrix
  4370. */
  4371. static Zero(): Matrix;
  4372. /**
  4373. * Creates a new rotation matrix for "angle" radians around the X axis
  4374. * @param angle defines the angle (in radians) to use
  4375. * @return the new matrix
  4376. */
  4377. static RotationX(angle: number): Matrix;
  4378. /**
  4379. * Creates a new matrix as the invert of a given matrix
  4380. * @param source defines the source matrix
  4381. * @returns the new matrix
  4382. */
  4383. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4384. /**
  4385. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4386. * @param angle defines the angle (in radians) to use
  4387. * @param result defines the target matrix
  4388. */
  4389. static RotationXToRef(angle: number, result: Matrix): void;
  4390. /**
  4391. * Creates a new rotation matrix for "angle" radians around the Y axis
  4392. * @param angle defines the angle (in radians) to use
  4393. * @return the new matrix
  4394. */
  4395. static RotationY(angle: number): Matrix;
  4396. /**
  4397. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4398. * @param angle defines the angle (in radians) to use
  4399. * @param result defines the target matrix
  4400. */
  4401. static RotationYToRef(angle: number, result: Matrix): void;
  4402. /**
  4403. * Creates a new rotation matrix for "angle" radians around the Z axis
  4404. * @param angle defines the angle (in radians) to use
  4405. * @return the new matrix
  4406. */
  4407. static RotationZ(angle: number): Matrix;
  4408. /**
  4409. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4410. * @param angle defines the angle (in radians) to use
  4411. * @param result defines the target matrix
  4412. */
  4413. static RotationZToRef(angle: number, result: Matrix): void;
  4414. /**
  4415. * Creates a new rotation matrix for "angle" radians around the given axis
  4416. * @param axis defines the axis to use
  4417. * @param angle defines the angle (in radians) to use
  4418. * @return the new matrix
  4419. */
  4420. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4421. /**
  4422. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4423. * @param axis defines the axis to use
  4424. * @param angle defines the angle (in radians) to use
  4425. * @param result defines the target matrix
  4426. */
  4427. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4428. /**
  4429. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4430. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4431. * @param from defines the vector to align
  4432. * @param to defines the vector to align to
  4433. * @param result defines the target matrix
  4434. */
  4435. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4436. /**
  4437. * Creates a rotation matrix
  4438. * @param yaw defines the yaw angle in radians (Y axis)
  4439. * @param pitch defines the pitch angle in radians (X axis)
  4440. * @param roll defines the roll angle in radians (X axis)
  4441. * @returns the new rotation matrix
  4442. */
  4443. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4444. /**
  4445. * Creates a rotation matrix and stores it in a given matrix
  4446. * @param yaw defines the yaw angle in radians (Y axis)
  4447. * @param pitch defines the pitch angle in radians (X axis)
  4448. * @param roll defines the roll angle in radians (X axis)
  4449. * @param result defines the target matrix
  4450. */
  4451. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4452. /**
  4453. * Creates a scaling matrix
  4454. * @param x defines the scale factor on X axis
  4455. * @param y defines the scale factor on Y axis
  4456. * @param z defines the scale factor on Z axis
  4457. * @returns the new matrix
  4458. */
  4459. static Scaling(x: number, y: number, z: number): Matrix;
  4460. /**
  4461. * Creates a scaling matrix and stores it in a given matrix
  4462. * @param x defines the scale factor on X axis
  4463. * @param y defines the scale factor on Y axis
  4464. * @param z defines the scale factor on Z axis
  4465. * @param result defines the target matrix
  4466. */
  4467. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4468. /**
  4469. * Creates a translation matrix
  4470. * @param x defines the translation on X axis
  4471. * @param y defines the translation on Y axis
  4472. * @param z defines the translationon Z axis
  4473. * @returns the new matrix
  4474. */
  4475. static Translation(x: number, y: number, z: number): Matrix;
  4476. /**
  4477. * Creates a translation matrix and stores it in a given matrix
  4478. * @param x defines the translation on X axis
  4479. * @param y defines the translation on Y axis
  4480. * @param z defines the translationon Z axis
  4481. * @param result defines the target matrix
  4482. */
  4483. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4484. /**
  4485. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4486. * @param startValue defines the start value
  4487. * @param endValue defines the end value
  4488. * @param gradient defines the gradient factor
  4489. * @returns the new matrix
  4490. */
  4491. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4492. /**
  4493. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4494. * @param startValue defines the start value
  4495. * @param endValue defines the end value
  4496. * @param gradient defines the gradient factor
  4497. * @param result defines the Matrix object where to store data
  4498. */
  4499. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4500. /**
  4501. * Builds a new matrix whose values are computed by:
  4502. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4503. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4504. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4505. * @param startValue defines the first matrix
  4506. * @param endValue defines the second matrix
  4507. * @param gradient defines the gradient between the two matrices
  4508. * @returns the new matrix
  4509. */
  4510. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4511. /**
  4512. * Update a matrix to values which are computed by:
  4513. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4514. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4515. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4516. * @param startValue defines the first matrix
  4517. * @param endValue defines the second matrix
  4518. * @param gradient defines the gradient between the two matrices
  4519. * @param result defines the target matrix
  4520. */
  4521. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4522. /**
  4523. * 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"
  4524. * This function works in left handed mode
  4525. * @param eye defines the final position of the entity
  4526. * @param target defines where the entity should look at
  4527. * @param up defines the up vector for the entity
  4528. * @returns the new matrix
  4529. */
  4530. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4531. /**
  4532. * 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".
  4533. * This function works in left handed mode
  4534. * @param eye defines the final position of the entity
  4535. * @param target defines where the entity should look at
  4536. * @param up defines the up vector for the entity
  4537. * @param result defines the target matrix
  4538. */
  4539. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4540. /**
  4541. * 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"
  4542. * This function works in right handed mode
  4543. * @param eye defines the final position of the entity
  4544. * @param target defines where the entity should look at
  4545. * @param up defines the up vector for the entity
  4546. * @returns the new matrix
  4547. */
  4548. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4549. /**
  4550. * 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".
  4551. * This function works in right handed mode
  4552. * @param eye defines the final position of the entity
  4553. * @param target defines where the entity should look at
  4554. * @param up defines the up vector for the entity
  4555. * @param result defines the target matrix
  4556. */
  4557. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4558. /**
  4559. * Create a left-handed orthographic projection matrix
  4560. * @param width defines the viewport width
  4561. * @param height defines the viewport height
  4562. * @param znear defines the near clip plane
  4563. * @param zfar defines the far clip plane
  4564. * @returns a new matrix as a left-handed orthographic projection matrix
  4565. */
  4566. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4567. /**
  4568. * Store a left-handed orthographic projection to a given matrix
  4569. * @param width defines the viewport width
  4570. * @param height defines the viewport height
  4571. * @param znear defines the near clip plane
  4572. * @param zfar defines the far clip plane
  4573. * @param result defines the target matrix
  4574. */
  4575. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4576. /**
  4577. * Create a left-handed orthographic projection matrix
  4578. * @param left defines the viewport left coordinate
  4579. * @param right defines the viewport right coordinate
  4580. * @param bottom defines the viewport bottom coordinate
  4581. * @param top defines the viewport top coordinate
  4582. * @param znear defines the near clip plane
  4583. * @param zfar defines the far clip plane
  4584. * @returns a new matrix as a left-handed orthographic projection matrix
  4585. */
  4586. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4587. /**
  4588. * Stores a left-handed orthographic projection into a given matrix
  4589. * @param left defines the viewport left coordinate
  4590. * @param right defines the viewport right coordinate
  4591. * @param bottom defines the viewport bottom coordinate
  4592. * @param top defines the viewport top coordinate
  4593. * @param znear defines the near clip plane
  4594. * @param zfar defines the far clip plane
  4595. * @param result defines the target matrix
  4596. */
  4597. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4598. /**
  4599. * Creates a right-handed orthographic projection matrix
  4600. * @param left defines the viewport left coordinate
  4601. * @param right defines the viewport right coordinate
  4602. * @param bottom defines the viewport bottom coordinate
  4603. * @param top defines the viewport top coordinate
  4604. * @param znear defines the near clip plane
  4605. * @param zfar defines the far clip plane
  4606. * @returns a new matrix as a right-handed orthographic projection matrix
  4607. */
  4608. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4609. /**
  4610. * Stores a right-handed orthographic projection into a given matrix
  4611. * @param left defines the viewport left coordinate
  4612. * @param right defines the viewport right coordinate
  4613. * @param bottom defines the viewport bottom coordinate
  4614. * @param top defines the viewport top coordinate
  4615. * @param znear defines the near clip plane
  4616. * @param zfar defines the far clip plane
  4617. * @param result defines the target matrix
  4618. */
  4619. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4620. /**
  4621. * Creates a left-handed perspective projection matrix
  4622. * @param width defines the viewport width
  4623. * @param height defines the viewport height
  4624. * @param znear defines the near clip plane
  4625. * @param zfar defines the far clip plane
  4626. * @returns a new matrix as a left-handed perspective projection matrix
  4627. */
  4628. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4629. /**
  4630. * Creates a left-handed perspective projection matrix
  4631. * @param fov defines the horizontal field of view
  4632. * @param aspect defines the aspect ratio
  4633. * @param znear defines the near clip plane
  4634. * @param zfar defines the far clip plane
  4635. * @returns a new matrix as a left-handed perspective projection matrix
  4636. */
  4637. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4638. /**
  4639. * Stores a left-handed perspective projection into a given matrix
  4640. * @param fov defines the horizontal field of view
  4641. * @param aspect defines the aspect ratio
  4642. * @param znear defines the near clip plane
  4643. * @param zfar defines the far clip plane
  4644. * @param result defines the target matrix
  4645. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4646. */
  4647. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4648. /**
  4649. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4650. * @param fov defines the horizontal field of view
  4651. * @param aspect defines the aspect ratio
  4652. * @param znear defines the near clip plane
  4653. * @param zfar not used as infinity is used as far clip
  4654. * @param result defines the target matrix
  4655. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4656. */
  4657. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4658. /**
  4659. * Creates a right-handed perspective projection matrix
  4660. * @param fov defines the horizontal field of view
  4661. * @param aspect defines the aspect ratio
  4662. * @param znear defines the near clip plane
  4663. * @param zfar defines the far clip plane
  4664. * @returns a new matrix as a right-handed perspective projection matrix
  4665. */
  4666. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4667. /**
  4668. * Stores a right-handed perspective projection into a given matrix
  4669. * @param fov defines the horizontal field of view
  4670. * @param aspect defines the aspect ratio
  4671. * @param znear defines the near clip plane
  4672. * @param zfar defines the far clip plane
  4673. * @param result defines the target matrix
  4674. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4675. */
  4676. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4677. /**
  4678. * Stores a right-handed perspective projection into a given matrix
  4679. * @param fov defines the horizontal field of view
  4680. * @param aspect defines the aspect ratio
  4681. * @param znear defines the near clip plane
  4682. * @param zfar not used as infinity is used as far clip
  4683. * @param result defines the target matrix
  4684. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4685. */
  4686. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4687. /**
  4688. * Stores a perspective projection for WebVR info a given matrix
  4689. * @param fov defines the field of view
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @param result defines the target matrix
  4693. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4694. */
  4695. static PerspectiveFovWebVRToRef(fov: {
  4696. upDegrees: number;
  4697. downDegrees: number;
  4698. leftDegrees: number;
  4699. rightDegrees: number;
  4700. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4701. /**
  4702. * Computes a complete transformation matrix
  4703. * @param viewport defines the viewport to use
  4704. * @param world defines the world matrix
  4705. * @param view defines the view matrix
  4706. * @param projection defines the projection matrix
  4707. * @param zmin defines the near clip plane
  4708. * @param zmax defines the far clip plane
  4709. * @returns the transformation matrix
  4710. */
  4711. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4712. /**
  4713. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4714. * @param matrix defines the matrix to use
  4715. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4716. */
  4717. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4718. /**
  4719. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4720. * @param matrix defines the matrix to use
  4721. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4722. */
  4723. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4724. /**
  4725. * Compute the transpose of a given matrix
  4726. * @param matrix defines the matrix to transpose
  4727. * @returns the new matrix
  4728. */
  4729. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4730. /**
  4731. * Compute the transpose of a matrix and store it in a target matrix
  4732. * @param matrix defines the matrix to transpose
  4733. * @param result defines the target matrix
  4734. */
  4735. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4736. /**
  4737. * Computes a reflection matrix from a plane
  4738. * @param plane defines the reflection plane
  4739. * @returns a new matrix
  4740. */
  4741. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4742. /**
  4743. * Computes a reflection matrix from a plane
  4744. * @param plane defines the reflection plane
  4745. * @param result defines the target matrix
  4746. */
  4747. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4748. /**
  4749. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4750. * @param xaxis defines the value of the 1st axis
  4751. * @param yaxis defines the value of the 2nd axis
  4752. * @param zaxis defines the value of the 3rd axis
  4753. * @param result defines the target matrix
  4754. */
  4755. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4756. /**
  4757. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4758. * @param quat defines the quaternion to use
  4759. * @param result defines the target matrix
  4760. */
  4761. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4762. }
  4763. /**
  4764. * @hidden
  4765. */
  4766. export class TmpVectors {
  4767. static Vector2: Vector2[];
  4768. static Vector3: Vector3[];
  4769. static Vector4: Vector4[];
  4770. static Quaternion: Quaternion[];
  4771. static Matrix: Matrix[];
  4772. }
  4773. }
  4774. declare module BABYLON {
  4775. /**
  4776. * Defines potential orientation for back face culling
  4777. */
  4778. export enum Orientation {
  4779. /**
  4780. * Clockwise
  4781. */
  4782. CW = 0,
  4783. /** Counter clockwise */
  4784. CCW = 1
  4785. }
  4786. /** Class used to represent a Bezier curve */
  4787. export class BezierCurve {
  4788. /**
  4789. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4790. * @param t defines the time
  4791. * @param x1 defines the left coordinate on X axis
  4792. * @param y1 defines the left coordinate on Y axis
  4793. * @param x2 defines the right coordinate on X axis
  4794. * @param y2 defines the right coordinate on Y axis
  4795. * @returns the interpolated value
  4796. */
  4797. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4798. }
  4799. /**
  4800. * Defines angle representation
  4801. */
  4802. export class Angle {
  4803. private _radians;
  4804. /**
  4805. * Creates an Angle object of "radians" radians (float).
  4806. * @param radians the angle in radians
  4807. */
  4808. constructor(radians: number);
  4809. /**
  4810. * Get value in degrees
  4811. * @returns the Angle value in degrees (float)
  4812. */
  4813. degrees(): number;
  4814. /**
  4815. * Get value in radians
  4816. * @returns the Angle value in radians (float)
  4817. */
  4818. radians(): number;
  4819. /**
  4820. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4821. * @param a defines first vector
  4822. * @param b defines second vector
  4823. * @returns a new Angle
  4824. */
  4825. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4826. /**
  4827. * Gets a new Angle object from the given float in radians
  4828. * @param radians defines the angle value in radians
  4829. * @returns a new Angle
  4830. */
  4831. static FromRadians(radians: number): Angle;
  4832. /**
  4833. * Gets a new Angle object from the given float in degrees
  4834. * @param degrees defines the angle value in degrees
  4835. * @returns a new Angle
  4836. */
  4837. static FromDegrees(degrees: number): Angle;
  4838. }
  4839. /**
  4840. * This represents an arc in a 2d space.
  4841. */
  4842. export class Arc2 {
  4843. /** Defines the start point of the arc */
  4844. startPoint: Vector2;
  4845. /** Defines the mid point of the arc */
  4846. midPoint: Vector2;
  4847. /** Defines the end point of the arc */
  4848. endPoint: Vector2;
  4849. /**
  4850. * Defines the center point of the arc.
  4851. */
  4852. centerPoint: Vector2;
  4853. /**
  4854. * Defines the radius of the arc.
  4855. */
  4856. radius: number;
  4857. /**
  4858. * Defines the angle of the arc (from mid point to end point).
  4859. */
  4860. angle: Angle;
  4861. /**
  4862. * Defines the start angle of the arc (from start point to middle point).
  4863. */
  4864. startAngle: Angle;
  4865. /**
  4866. * Defines the orientation of the arc (clock wise/counter clock wise).
  4867. */
  4868. orientation: Orientation;
  4869. /**
  4870. * Creates an Arc object from the three given points : start, middle and end.
  4871. * @param startPoint Defines the start point of the arc
  4872. * @param midPoint Defines the midlle point of the arc
  4873. * @param endPoint Defines the end point of the arc
  4874. */
  4875. constructor(
  4876. /** Defines the start point of the arc */
  4877. startPoint: Vector2,
  4878. /** Defines the mid point of the arc */
  4879. midPoint: Vector2,
  4880. /** Defines the end point of the arc */
  4881. endPoint: Vector2);
  4882. }
  4883. /**
  4884. * Represents a 2D path made up of multiple 2D points
  4885. */
  4886. export class Path2 {
  4887. private _points;
  4888. private _length;
  4889. /**
  4890. * If the path start and end point are the same
  4891. */
  4892. closed: boolean;
  4893. /**
  4894. * Creates a Path2 object from the starting 2D coordinates x and y.
  4895. * @param x the starting points x value
  4896. * @param y the starting points y value
  4897. */
  4898. constructor(x: number, y: number);
  4899. /**
  4900. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4901. * @param x the added points x value
  4902. * @param y the added points y value
  4903. * @returns the updated Path2.
  4904. */
  4905. addLineTo(x: number, y: number): Path2;
  4906. /**
  4907. * 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.
  4908. * @param midX middle point x value
  4909. * @param midY middle point y value
  4910. * @param endX end point x value
  4911. * @param endY end point y value
  4912. * @param numberOfSegments (default: 36)
  4913. * @returns the updated Path2.
  4914. */
  4915. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4916. /**
  4917. * Closes the Path2.
  4918. * @returns the Path2.
  4919. */
  4920. close(): Path2;
  4921. /**
  4922. * Gets the sum of the distance between each sequential point in the path
  4923. * @returns the Path2 total length (float).
  4924. */
  4925. length(): number;
  4926. /**
  4927. * Gets the points which construct the path
  4928. * @returns the Path2 internal array of points.
  4929. */
  4930. getPoints(): Vector2[];
  4931. /**
  4932. * Retreives the point at the distance aways from the starting point
  4933. * @param normalizedLengthPosition the length along the path to retreive the point from
  4934. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4935. */
  4936. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4937. /**
  4938. * Creates a new path starting from an x and y position
  4939. * @param x starting x value
  4940. * @param y starting y value
  4941. * @returns a new Path2 starting at the coordinates (x, y).
  4942. */
  4943. static StartingAt(x: number, y: number): Path2;
  4944. }
  4945. /**
  4946. * Represents a 3D path made up of multiple 3D points
  4947. */
  4948. export class Path3D {
  4949. /**
  4950. * an array of Vector3, the curve axis of the Path3D
  4951. */
  4952. path: Vector3[];
  4953. private _curve;
  4954. private _distances;
  4955. private _tangents;
  4956. private _normals;
  4957. private _binormals;
  4958. private _raw;
  4959. private _alignTangentsWithPath;
  4960. private readonly _pointAtData;
  4961. /**
  4962. * new Path3D(path, normal, raw)
  4963. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4964. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4965. * @param path an array of Vector3, the curve axis of the Path3D
  4966. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4967. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4968. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4969. */
  4970. constructor(
  4971. /**
  4972. * an array of Vector3, the curve axis of the Path3D
  4973. */
  4974. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4975. /**
  4976. * Returns the Path3D array of successive Vector3 designing its curve.
  4977. * @returns the Path3D array of successive Vector3 designing its curve.
  4978. */
  4979. getCurve(): Vector3[];
  4980. /**
  4981. * Returns the Path3D array of successive Vector3 designing its curve.
  4982. * @returns the Path3D array of successive Vector3 designing its curve.
  4983. */
  4984. getPoints(): Vector3[];
  4985. /**
  4986. * @returns the computed length (float) of the path.
  4987. */
  4988. length(): number;
  4989. /**
  4990. * Returns an array populated with tangent vectors on each Path3D curve point.
  4991. * @returns an array populated with tangent vectors on each Path3D curve point.
  4992. */
  4993. getTangents(): Vector3[];
  4994. /**
  4995. * Returns an array populated with normal vectors on each Path3D curve point.
  4996. * @returns an array populated with normal vectors on each Path3D curve point.
  4997. */
  4998. getNormals(): Vector3[];
  4999. /**
  5000. * Returns an array populated with binormal vectors on each Path3D curve point.
  5001. * @returns an array populated with binormal vectors on each Path3D curve point.
  5002. */
  5003. getBinormals(): Vector3[];
  5004. /**
  5005. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5006. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5007. */
  5008. getDistances(): number[];
  5009. /**
  5010. * Returns an interpolated point along this path
  5011. * @param position the position of the point along this path, from 0.0 to 1.0
  5012. * @returns a new Vector3 as the point
  5013. */
  5014. getPointAt(position: number): Vector3;
  5015. /**
  5016. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5017. * @param position the position of the point along this path, from 0.0 to 1.0
  5018. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5019. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5020. */
  5021. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5022. /**
  5023. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5024. * @param position the position of the point along this path, from 0.0 to 1.0
  5025. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5026. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5027. */
  5028. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5029. /**
  5030. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5031. * @param position the position of the point along this path, from 0.0 to 1.0
  5032. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5033. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5034. */
  5035. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5036. /**
  5037. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5038. * @param position the position of the point along this path, from 0.0 to 1.0
  5039. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5040. */
  5041. getDistanceAt(position: number): number;
  5042. /**
  5043. * Returns the array index of the previous point of an interpolated point along this path
  5044. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5045. * @returns the array index
  5046. */
  5047. getPreviousPointIndexAt(position: number): number;
  5048. /**
  5049. * 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)
  5050. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5051. * @returns the sub position
  5052. */
  5053. getSubPositionAt(position: number): number;
  5054. /**
  5055. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5056. * @param target the vector of which to get the closest position to
  5057. * @returns the position of the closest virtual point on this path to the target vector
  5058. */
  5059. getClosestPositionTo(target: Vector3): number;
  5060. /**
  5061. * Returns a sub path (slice) of this path
  5062. * @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
  5063. * @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
  5064. * @returns a sub path (slice) of this path
  5065. */
  5066. slice(start?: number, end?: number): Path3D;
  5067. /**
  5068. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5069. * @param path path which all values are copied into the curves points
  5070. * @param firstNormal which should be projected onto the curve
  5071. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5072. * @returns the same object updated.
  5073. */
  5074. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5075. private _compute;
  5076. private _getFirstNonNullVector;
  5077. private _getLastNonNullVector;
  5078. private _normalVector;
  5079. /**
  5080. * Updates the point at data for an interpolated point along this curve
  5081. * @param position the position of the point along this curve, from 0.0 to 1.0
  5082. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5083. * @returns the (updated) point at data
  5084. */
  5085. private _updatePointAtData;
  5086. /**
  5087. * Updates the point at data from the specified parameters
  5088. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5089. * @param point the interpolated point
  5090. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5091. */
  5092. private _setPointAtData;
  5093. /**
  5094. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5095. */
  5096. private _updateInterpolationMatrix;
  5097. }
  5098. /**
  5099. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5100. * A Curve3 is designed from a series of successive Vector3.
  5101. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5102. */
  5103. export class Curve3 {
  5104. private _points;
  5105. private _length;
  5106. /**
  5107. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5108. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5109. * @param v1 (Vector3) the control point
  5110. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5111. * @param nbPoints (integer) the wanted number of points in the curve
  5112. * @returns the created Curve3
  5113. */
  5114. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5115. /**
  5116. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5117. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5118. * @param v1 (Vector3) the first control point
  5119. * @param v2 (Vector3) the second control point
  5120. * @param v3 (Vector3) the end point of the Cubic Bezier
  5121. * @param nbPoints (integer) the wanted number of points in the curve
  5122. * @returns the created Curve3
  5123. */
  5124. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5125. /**
  5126. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5127. * @param p1 (Vector3) the origin point of the Hermite Spline
  5128. * @param t1 (Vector3) the tangent vector at the origin point
  5129. * @param p2 (Vector3) the end point of the Hermite Spline
  5130. * @param t2 (Vector3) the tangent vector at the end point
  5131. * @param nbPoints (integer) the wanted number of points in the curve
  5132. * @returns the created Curve3
  5133. */
  5134. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5135. /**
  5136. * Returns a Curve3 object along a CatmullRom Spline curve :
  5137. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5138. * @param nbPoints (integer) the wanted number of points between each curve control points
  5139. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5140. * @returns the created Curve3
  5141. */
  5142. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5143. /**
  5144. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5145. * A Curve3 is designed from a series of successive Vector3.
  5146. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5147. * @param points points which make up the curve
  5148. */
  5149. constructor(points: Vector3[]);
  5150. /**
  5151. * @returns the Curve3 stored array of successive Vector3
  5152. */
  5153. getPoints(): Vector3[];
  5154. /**
  5155. * @returns the computed length (float) of the curve.
  5156. */
  5157. length(): number;
  5158. /**
  5159. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5160. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5161. * curveA and curveB keep unchanged.
  5162. * @param curve the curve to continue from this curve
  5163. * @returns the newly constructed curve
  5164. */
  5165. continue(curve: DeepImmutable<Curve3>): Curve3;
  5166. private _computeLength;
  5167. }
  5168. }
  5169. declare module BABYLON {
  5170. /**
  5171. * This represents the main contract an easing function should follow.
  5172. * Easing functions are used throughout the animation system.
  5173. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5174. */
  5175. export interface IEasingFunction {
  5176. /**
  5177. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5178. * of the easing function.
  5179. * The link below provides some of the most common examples of easing functions.
  5180. * @see https://easings.net/
  5181. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5182. * @returns the corresponding value on the curve defined by the easing function
  5183. */
  5184. ease(gradient: number): number;
  5185. }
  5186. /**
  5187. * Base class used for every default easing function.
  5188. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5189. */
  5190. export class EasingFunction implements IEasingFunction {
  5191. /**
  5192. * Interpolation follows the mathematical formula associated with the easing function.
  5193. */
  5194. static readonly EASINGMODE_EASEIN: number;
  5195. /**
  5196. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5197. */
  5198. static readonly EASINGMODE_EASEOUT: number;
  5199. /**
  5200. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5201. */
  5202. static readonly EASINGMODE_EASEINOUT: number;
  5203. private _easingMode;
  5204. /**
  5205. * Sets the easing mode of the current function.
  5206. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5207. */
  5208. setEasingMode(easingMode: number): void;
  5209. /**
  5210. * Gets the current easing mode.
  5211. * @returns the easing mode
  5212. */
  5213. getEasingMode(): number;
  5214. /**
  5215. * @hidden
  5216. */
  5217. easeInCore(gradient: number): number;
  5218. /**
  5219. * Given an input gradient between 0 and 1, this returns the corresponding value
  5220. * of the easing function.
  5221. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5222. * @returns the corresponding value on the curve defined by the easing function
  5223. */
  5224. ease(gradient: number): number;
  5225. }
  5226. /**
  5227. * Easing function with a circle shape (see link below).
  5228. * @see https://easings.net/#easeInCirc
  5229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5230. */
  5231. export class CircleEase extends EasingFunction implements IEasingFunction {
  5232. /** @hidden */
  5233. easeInCore(gradient: number): number;
  5234. }
  5235. /**
  5236. * Easing function with a ease back shape (see link below).
  5237. * @see https://easings.net/#easeInBack
  5238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5239. */
  5240. export class BackEase extends EasingFunction implements IEasingFunction {
  5241. /** Defines the amplitude of the function */
  5242. amplitude: number;
  5243. /**
  5244. * Instantiates a back ease easing
  5245. * @see https://easings.net/#easeInBack
  5246. * @param amplitude Defines the amplitude of the function
  5247. */
  5248. constructor(
  5249. /** Defines the amplitude of the function */
  5250. amplitude?: number);
  5251. /** @hidden */
  5252. easeInCore(gradient: number): number;
  5253. }
  5254. /**
  5255. * Easing function with a bouncing shape (see link below).
  5256. * @see https://easings.net/#easeInBounce
  5257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5258. */
  5259. export class BounceEase extends EasingFunction implements IEasingFunction {
  5260. /** Defines the number of bounces */
  5261. bounces: number;
  5262. /** Defines the amplitude of the bounce */
  5263. bounciness: number;
  5264. /**
  5265. * Instantiates a bounce easing
  5266. * @see https://easings.net/#easeInBounce
  5267. * @param bounces Defines the number of bounces
  5268. * @param bounciness Defines the amplitude of the bounce
  5269. */
  5270. constructor(
  5271. /** Defines the number of bounces */
  5272. bounces?: number,
  5273. /** Defines the amplitude of the bounce */
  5274. bounciness?: number);
  5275. /** @hidden */
  5276. easeInCore(gradient: number): number;
  5277. }
  5278. /**
  5279. * Easing function with a power of 3 shape (see link below).
  5280. * @see https://easings.net/#easeInCubic
  5281. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5282. */
  5283. export class CubicEase extends EasingFunction implements IEasingFunction {
  5284. /** @hidden */
  5285. easeInCore(gradient: number): number;
  5286. }
  5287. /**
  5288. * Easing function with an elastic shape (see link below).
  5289. * @see https://easings.net/#easeInElastic
  5290. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5291. */
  5292. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5293. /** Defines the number of oscillations*/
  5294. oscillations: number;
  5295. /** Defines the amplitude of the oscillations*/
  5296. springiness: number;
  5297. /**
  5298. * Instantiates an elastic easing function
  5299. * @see https://easings.net/#easeInElastic
  5300. * @param oscillations Defines the number of oscillations
  5301. * @param springiness Defines the amplitude of the oscillations
  5302. */
  5303. constructor(
  5304. /** Defines the number of oscillations*/
  5305. oscillations?: number,
  5306. /** Defines the amplitude of the oscillations*/
  5307. springiness?: number);
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with an exponential shape (see link below).
  5313. * @see https://easings.net/#easeInExpo
  5314. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the exponent of the function */
  5318. exponent: number;
  5319. /**
  5320. * Instantiates an exponential easing function
  5321. * @see https://easings.net/#easeInExpo
  5322. * @param exponent Defines the exponent of the function
  5323. */
  5324. constructor(
  5325. /** Defines the exponent of the function */
  5326. exponent?: number);
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a power shape (see link below).
  5332. * @see https://easings.net/#easeInQuad
  5333. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class PowerEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the power of the function */
  5337. power: number;
  5338. /**
  5339. * Instantiates an power base easing function
  5340. * @see https://easings.net/#easeInQuad
  5341. * @param power Defines the power of the function
  5342. */
  5343. constructor(
  5344. /** Defines the power of the function */
  5345. power?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a power of 2 shape (see link below).
  5351. * @see https://easings.net/#easeInQuad
  5352. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5355. /** @hidden */
  5356. easeInCore(gradient: number): number;
  5357. }
  5358. /**
  5359. * Easing function with a power of 4 shape (see link below).
  5360. * @see https://easings.net/#easeInQuart
  5361. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5362. */
  5363. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5364. /** @hidden */
  5365. easeInCore(gradient: number): number;
  5366. }
  5367. /**
  5368. * Easing function with a power of 5 shape (see link below).
  5369. * @see https://easings.net/#easeInQuint
  5370. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5371. */
  5372. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5373. /** @hidden */
  5374. easeInCore(gradient: number): number;
  5375. }
  5376. /**
  5377. * Easing function with a sin shape (see link below).
  5378. * @see https://easings.net/#easeInSine
  5379. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5380. */
  5381. export class SineEase extends EasingFunction implements IEasingFunction {
  5382. /** @hidden */
  5383. easeInCore(gradient: number): number;
  5384. }
  5385. /**
  5386. * Easing function with a bezier shape (see link below).
  5387. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5388. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5389. */
  5390. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5391. /** Defines the x component of the start tangent in the bezier curve */
  5392. x1: number;
  5393. /** Defines the y component of the start tangent in the bezier curve */
  5394. y1: number;
  5395. /** Defines the x component of the end tangent in the bezier curve */
  5396. x2: number;
  5397. /** Defines the y component of the end tangent in the bezier curve */
  5398. y2: number;
  5399. /**
  5400. * Instantiates a bezier function
  5401. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5402. * @param x1 Defines the x component of the start tangent in the bezier curve
  5403. * @param y1 Defines the y component of the start tangent in the bezier curve
  5404. * @param x2 Defines the x component of the end tangent in the bezier curve
  5405. * @param y2 Defines the y component of the end tangent in the bezier curve
  5406. */
  5407. constructor(
  5408. /** Defines the x component of the start tangent in the bezier curve */
  5409. x1?: number,
  5410. /** Defines the y component of the start tangent in the bezier curve */
  5411. y1?: number,
  5412. /** Defines the x component of the end tangent in the bezier curve */
  5413. x2?: number,
  5414. /** Defines the y component of the end tangent in the bezier curve */
  5415. y2?: number);
  5416. /** @hidden */
  5417. easeInCore(gradient: number): number;
  5418. }
  5419. }
  5420. declare module BABYLON {
  5421. /**
  5422. * Class used to hold a RBG color
  5423. */
  5424. export class Color3 {
  5425. /**
  5426. * Defines the red component (between 0 and 1, default is 0)
  5427. */
  5428. r: number;
  5429. /**
  5430. * Defines the green component (between 0 and 1, default is 0)
  5431. */
  5432. g: number;
  5433. /**
  5434. * Defines the blue component (between 0 and 1, default is 0)
  5435. */
  5436. b: number;
  5437. /**
  5438. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5439. * @param r defines the red component (between 0 and 1, default is 0)
  5440. * @param g defines the green component (between 0 and 1, default is 0)
  5441. * @param b defines the blue component (between 0 and 1, default is 0)
  5442. */
  5443. constructor(
  5444. /**
  5445. * Defines the red component (between 0 and 1, default is 0)
  5446. */
  5447. r?: number,
  5448. /**
  5449. * Defines the green component (between 0 and 1, default is 0)
  5450. */
  5451. g?: number,
  5452. /**
  5453. * Defines the blue component (between 0 and 1, default is 0)
  5454. */
  5455. b?: number);
  5456. /**
  5457. * Creates a string with the Color3 current values
  5458. * @returns the string representation of the Color3 object
  5459. */
  5460. toString(): string;
  5461. /**
  5462. * Returns the string "Color3"
  5463. * @returns "Color3"
  5464. */
  5465. getClassName(): string;
  5466. /**
  5467. * Compute the Color3 hash code
  5468. * @returns an unique number that can be used to hash Color3 objects
  5469. */
  5470. getHashCode(): number;
  5471. /**
  5472. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5473. * @param array defines the array where to store the r,g,b components
  5474. * @param index defines an optional index in the target array to define where to start storing values
  5475. * @returns the current Color3 object
  5476. */
  5477. toArray(array: FloatArray, index?: number): Color3;
  5478. /**
  5479. * Returns a new Color4 object from the current Color3 and the given alpha
  5480. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5481. * @returns a new Color4 object
  5482. */
  5483. toColor4(alpha?: number): Color4;
  5484. /**
  5485. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5486. * @returns the new array
  5487. */
  5488. asArray(): number[];
  5489. /**
  5490. * Returns the luminance value
  5491. * @returns a float value
  5492. */
  5493. toLuminance(): number;
  5494. /**
  5495. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5496. * @param otherColor defines the second operand
  5497. * @returns the new Color3 object
  5498. */
  5499. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5500. /**
  5501. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5502. * @param otherColor defines the second operand
  5503. * @param result defines the Color3 object where to store the result
  5504. * @returns the current Color3
  5505. */
  5506. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5507. /**
  5508. * Determines equality between Color3 objects
  5509. * @param otherColor defines the second operand
  5510. * @returns true if the rgb values are equal to the given ones
  5511. */
  5512. equals(otherColor: DeepImmutable<Color3>): boolean;
  5513. /**
  5514. * Determines equality between the current Color3 object and a set of r,b,g values
  5515. * @param r defines the red component to check
  5516. * @param g defines the green component to check
  5517. * @param b defines the blue component to check
  5518. * @returns true if the rgb values are equal to the given ones
  5519. */
  5520. equalsFloats(r: number, g: number, b: number): boolean;
  5521. /**
  5522. * Multiplies in place each rgb value by scale
  5523. * @param scale defines the scaling factor
  5524. * @returns the updated Color3
  5525. */
  5526. scale(scale: number): Color3;
  5527. /**
  5528. * Multiplies the rgb values by scale and stores the result into "result"
  5529. * @param scale defines the scaling factor
  5530. * @param result defines the Color3 object where to store the result
  5531. * @returns the unmodified current Color3
  5532. */
  5533. scaleToRef(scale: number, result: Color3): Color3;
  5534. /**
  5535. * Scale the current Color3 values by a factor and add the result to a given Color3
  5536. * @param scale defines the scale factor
  5537. * @param result defines color to store the result into
  5538. * @returns the unmodified current Color3
  5539. */
  5540. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5541. /**
  5542. * Clamps the rgb values by the min and max values and stores the result into "result"
  5543. * @param min defines minimum clamping value (default is 0)
  5544. * @param max defines maximum clamping value (default is 1)
  5545. * @param result defines color to store the result into
  5546. * @returns the original Color3
  5547. */
  5548. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5549. /**
  5550. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5551. * @param otherColor defines the second operand
  5552. * @returns the new Color3
  5553. */
  5554. add(otherColor: DeepImmutable<Color3>): Color3;
  5555. /**
  5556. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5557. * @param otherColor defines the second operand
  5558. * @param result defines Color3 object to store the result into
  5559. * @returns the unmodified current Color3
  5560. */
  5561. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5562. /**
  5563. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5564. * @param otherColor defines the second operand
  5565. * @returns the new Color3
  5566. */
  5567. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5568. /**
  5569. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5570. * @param otherColor defines the second operand
  5571. * @param result defines Color3 object to store the result into
  5572. * @returns the unmodified current Color3
  5573. */
  5574. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5575. /**
  5576. * Copy the current object
  5577. * @returns a new Color3 copied the current one
  5578. */
  5579. clone(): Color3;
  5580. /**
  5581. * Copies the rgb values from the source in the current Color3
  5582. * @param source defines the source Color3 object
  5583. * @returns the updated Color3 object
  5584. */
  5585. copyFrom(source: DeepImmutable<Color3>): Color3;
  5586. /**
  5587. * Updates the Color3 rgb values from the given floats
  5588. * @param r defines the red component to read from
  5589. * @param g defines the green component to read from
  5590. * @param b defines the blue component to read from
  5591. * @returns the current Color3 object
  5592. */
  5593. copyFromFloats(r: number, g: number, b: number): Color3;
  5594. /**
  5595. * Updates the Color3 rgb values from the given floats
  5596. * @param r defines the red component to read from
  5597. * @param g defines the green component to read from
  5598. * @param b defines the blue component to read from
  5599. * @returns the current Color3 object
  5600. */
  5601. set(r: number, g: number, b: number): Color3;
  5602. /**
  5603. * Compute the Color3 hexadecimal code as a string
  5604. * @returns a string containing the hexadecimal representation of the Color3 object
  5605. */
  5606. toHexString(): string;
  5607. /**
  5608. * Computes a new Color3 converted from the current one to linear space
  5609. * @returns a new Color3 object
  5610. */
  5611. toLinearSpace(): Color3;
  5612. /**
  5613. * Converts current color in rgb space to HSV values
  5614. * @returns a new color3 representing the HSV values
  5615. */
  5616. toHSV(): Color3;
  5617. /**
  5618. * Converts current color in rgb space to HSV values
  5619. * @param result defines the Color3 where to store the HSV values
  5620. */
  5621. toHSVToRef(result: Color3): void;
  5622. /**
  5623. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5624. * @param convertedColor defines the Color3 object where to store the linear space version
  5625. * @returns the unmodified Color3
  5626. */
  5627. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5628. /**
  5629. * Computes a new Color3 converted from the current one to gamma space
  5630. * @returns a new Color3 object
  5631. */
  5632. toGammaSpace(): Color3;
  5633. /**
  5634. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5635. * @param convertedColor defines the Color3 object where to store the gamma space version
  5636. * @returns the unmodified Color3
  5637. */
  5638. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5639. private static _BlackReadOnly;
  5640. /**
  5641. * Convert Hue, saturation and value to a Color3 (RGB)
  5642. * @param hue defines the hue
  5643. * @param saturation defines the saturation
  5644. * @param value defines the value
  5645. * @param result defines the Color3 where to store the RGB values
  5646. */
  5647. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5648. /**
  5649. * Creates a new Color3 from the string containing valid hexadecimal values
  5650. * @param hex defines a string containing valid hexadecimal values
  5651. * @returns a new Color3 object
  5652. */
  5653. static FromHexString(hex: string): Color3;
  5654. /**
  5655. * Creates a new Color3 from the starting index of the given array
  5656. * @param array defines the source array
  5657. * @param offset defines an offset in the source array
  5658. * @returns a new Color3 object
  5659. */
  5660. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5661. /**
  5662. * Creates a new Color3 from integer values (< 256)
  5663. * @param r defines the red component to read from (value between 0 and 255)
  5664. * @param g defines the green component to read from (value between 0 and 255)
  5665. * @param b defines the blue component to read from (value between 0 and 255)
  5666. * @returns a new Color3 object
  5667. */
  5668. static FromInts(r: number, g: number, b: number): Color3;
  5669. /**
  5670. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5671. * @param start defines the start Color3 value
  5672. * @param end defines the end Color3 value
  5673. * @param amount defines the gradient value between start and end
  5674. * @returns a new Color3 object
  5675. */
  5676. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5677. /**
  5678. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5679. * @param left defines the start value
  5680. * @param right defines the end value
  5681. * @param amount defines the gradient factor
  5682. * @param result defines the Color3 object where to store the result
  5683. */
  5684. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5685. /**
  5686. * Returns a Color3 value containing a red color
  5687. * @returns a new Color3 object
  5688. */
  5689. static Red(): Color3;
  5690. /**
  5691. * Returns a Color3 value containing a green color
  5692. * @returns a new Color3 object
  5693. */
  5694. static Green(): Color3;
  5695. /**
  5696. * Returns a Color3 value containing a blue color
  5697. * @returns a new Color3 object
  5698. */
  5699. static Blue(): Color3;
  5700. /**
  5701. * Returns a Color3 value containing a black color
  5702. * @returns a new Color3 object
  5703. */
  5704. static Black(): Color3;
  5705. /**
  5706. * Gets a Color3 value containing a black color that must not be updated
  5707. */
  5708. static get BlackReadOnly(): DeepImmutable<Color3>;
  5709. /**
  5710. * Returns a Color3 value containing a white color
  5711. * @returns a new Color3 object
  5712. */
  5713. static White(): Color3;
  5714. /**
  5715. * Returns a Color3 value containing a purple color
  5716. * @returns a new Color3 object
  5717. */
  5718. static Purple(): Color3;
  5719. /**
  5720. * Returns a Color3 value containing a magenta color
  5721. * @returns a new Color3 object
  5722. */
  5723. static Magenta(): Color3;
  5724. /**
  5725. * Returns a Color3 value containing a yellow color
  5726. * @returns a new Color3 object
  5727. */
  5728. static Yellow(): Color3;
  5729. /**
  5730. * Returns a Color3 value containing a gray color
  5731. * @returns a new Color3 object
  5732. */
  5733. static Gray(): Color3;
  5734. /**
  5735. * Returns a Color3 value containing a teal color
  5736. * @returns a new Color3 object
  5737. */
  5738. static Teal(): Color3;
  5739. /**
  5740. * Returns a Color3 value containing a random color
  5741. * @returns a new Color3 object
  5742. */
  5743. static Random(): Color3;
  5744. }
  5745. /**
  5746. * Class used to hold a RBGA color
  5747. */
  5748. export class Color4 {
  5749. /**
  5750. * Defines the red component (between 0 and 1, default is 0)
  5751. */
  5752. r: number;
  5753. /**
  5754. * Defines the green component (between 0 and 1, default is 0)
  5755. */
  5756. g: number;
  5757. /**
  5758. * Defines the blue component (between 0 and 1, default is 0)
  5759. */
  5760. b: number;
  5761. /**
  5762. * Defines the alpha component (between 0 and 1, default is 1)
  5763. */
  5764. a: number;
  5765. /**
  5766. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5767. * @param r defines the red component (between 0 and 1, default is 0)
  5768. * @param g defines the green component (between 0 and 1, default is 0)
  5769. * @param b defines the blue component (between 0 and 1, default is 0)
  5770. * @param a defines the alpha component (between 0 and 1, default is 1)
  5771. */
  5772. constructor(
  5773. /**
  5774. * Defines the red component (between 0 and 1, default is 0)
  5775. */
  5776. r?: number,
  5777. /**
  5778. * Defines the green component (between 0 and 1, default is 0)
  5779. */
  5780. g?: number,
  5781. /**
  5782. * Defines the blue component (between 0 and 1, default is 0)
  5783. */
  5784. b?: number,
  5785. /**
  5786. * Defines the alpha component (between 0 and 1, default is 1)
  5787. */
  5788. a?: number);
  5789. /**
  5790. * Adds in place the given Color4 values to the current Color4 object
  5791. * @param right defines the second operand
  5792. * @returns the current updated Color4 object
  5793. */
  5794. addInPlace(right: DeepImmutable<Color4>): Color4;
  5795. /**
  5796. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5797. * @returns the new array
  5798. */
  5799. asArray(): number[];
  5800. /**
  5801. * Stores from the starting index in the given array the Color4 successive values
  5802. * @param array defines the array where to store the r,g,b components
  5803. * @param index defines an optional index in the target array to define where to start storing values
  5804. * @returns the current Color4 object
  5805. */
  5806. toArray(array: number[], index?: number): Color4;
  5807. /**
  5808. * Determines equality between Color4 objects
  5809. * @param otherColor defines the second operand
  5810. * @returns true if the rgba values are equal to the given ones
  5811. */
  5812. equals(otherColor: DeepImmutable<Color4>): boolean;
  5813. /**
  5814. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5815. * @param right defines the second operand
  5816. * @returns a new Color4 object
  5817. */
  5818. add(right: DeepImmutable<Color4>): Color4;
  5819. /**
  5820. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5821. * @param right defines the second operand
  5822. * @returns a new Color4 object
  5823. */
  5824. subtract(right: DeepImmutable<Color4>): Color4;
  5825. /**
  5826. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5827. * @param right defines the second operand
  5828. * @param result defines the Color4 object where to store the result
  5829. * @returns the current Color4 object
  5830. */
  5831. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5832. /**
  5833. * Creates a new Color4 with the current Color4 values multiplied by scale
  5834. * @param scale defines the scaling factor to apply
  5835. * @returns a new Color4 object
  5836. */
  5837. scale(scale: number): Color4;
  5838. /**
  5839. * Multiplies the current Color4 values by scale and stores the result in "result"
  5840. * @param scale defines the scaling factor to apply
  5841. * @param result defines the Color4 object where to store the result
  5842. * @returns the current unmodified Color4
  5843. */
  5844. scaleToRef(scale: number, result: Color4): Color4;
  5845. /**
  5846. * Scale the current Color4 values by a factor and add the result to a given Color4
  5847. * @param scale defines the scale factor
  5848. * @param result defines the Color4 object where to store the result
  5849. * @returns the unmodified current Color4
  5850. */
  5851. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5852. /**
  5853. * Clamps the rgb values by the min and max values and stores the result into "result"
  5854. * @param min defines minimum clamping value (default is 0)
  5855. * @param max defines maximum clamping value (default is 1)
  5856. * @param result defines color to store the result into.
  5857. * @returns the cuurent Color4
  5858. */
  5859. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5860. /**
  5861. * Multipy an Color4 value by another and return a new Color4 object
  5862. * @param color defines the Color4 value to multiply by
  5863. * @returns a new Color4 object
  5864. */
  5865. multiply(color: Color4): Color4;
  5866. /**
  5867. * Multipy a Color4 value by another and push the result in a reference value
  5868. * @param color defines the Color4 value to multiply by
  5869. * @param result defines the Color4 to fill the result in
  5870. * @returns the result Color4
  5871. */
  5872. multiplyToRef(color: Color4, result: Color4): Color4;
  5873. /**
  5874. * Creates a string with the Color4 current values
  5875. * @returns the string representation of the Color4 object
  5876. */
  5877. toString(): string;
  5878. /**
  5879. * Returns the string "Color4"
  5880. * @returns "Color4"
  5881. */
  5882. getClassName(): string;
  5883. /**
  5884. * Compute the Color4 hash code
  5885. * @returns an unique number that can be used to hash Color4 objects
  5886. */
  5887. getHashCode(): number;
  5888. /**
  5889. * Creates a new Color4 copied from the current one
  5890. * @returns a new Color4 object
  5891. */
  5892. clone(): Color4;
  5893. /**
  5894. * Copies the given Color4 values into the current one
  5895. * @param source defines the source Color4 object
  5896. * @returns the current updated Color4 object
  5897. */
  5898. copyFrom(source: Color4): Color4;
  5899. /**
  5900. * Copies the given float values into the current one
  5901. * @param r defines the red component to read from
  5902. * @param g defines the green component to read from
  5903. * @param b defines the blue component to read from
  5904. * @param a defines the alpha component to read from
  5905. * @returns the current updated Color4 object
  5906. */
  5907. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5908. /**
  5909. * Copies the given float values into the current one
  5910. * @param r defines the red component to read from
  5911. * @param g defines the green component to read from
  5912. * @param b defines the blue component to read from
  5913. * @param a defines the alpha component to read from
  5914. * @returns the current updated Color4 object
  5915. */
  5916. set(r: number, g: number, b: number, a: number): Color4;
  5917. /**
  5918. * Compute the Color4 hexadecimal code as a string
  5919. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5920. * @returns a string containing the hexadecimal representation of the Color4 object
  5921. */
  5922. toHexString(returnAsColor3?: boolean): string;
  5923. /**
  5924. * Computes a new Color4 converted from the current one to linear space
  5925. * @returns a new Color4 object
  5926. */
  5927. toLinearSpace(): Color4;
  5928. /**
  5929. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5930. * @param convertedColor defines the Color4 object where to store the linear space version
  5931. * @returns the unmodified Color4
  5932. */
  5933. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5934. /**
  5935. * Computes a new Color4 converted from the current one to gamma space
  5936. * @returns a new Color4 object
  5937. */
  5938. toGammaSpace(): Color4;
  5939. /**
  5940. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5941. * @param convertedColor defines the Color4 object where to store the gamma space version
  5942. * @returns the unmodified Color4
  5943. */
  5944. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5945. /**
  5946. * Creates a new Color4 from the string containing valid hexadecimal values
  5947. * @param hex defines a string containing valid hexadecimal values
  5948. * @returns a new Color4 object
  5949. */
  5950. static FromHexString(hex: string): Color4;
  5951. /**
  5952. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5953. * @param left defines the start value
  5954. * @param right defines the end value
  5955. * @param amount defines the gradient factor
  5956. * @returns a new Color4 object
  5957. */
  5958. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5959. /**
  5960. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5961. * @param left defines the start value
  5962. * @param right defines the end value
  5963. * @param amount defines the gradient factor
  5964. * @param result defines the Color4 object where to store data
  5965. */
  5966. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5967. /**
  5968. * Creates a new Color4 from a Color3 and an alpha value
  5969. * @param color3 defines the source Color3 to read from
  5970. * @param alpha defines the alpha component (1.0 by default)
  5971. * @returns a new Color4 object
  5972. */
  5973. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5974. /**
  5975. * Creates a new Color4 from the starting index element of the given array
  5976. * @param array defines the source array to read from
  5977. * @param offset defines the offset in the source array
  5978. * @returns a new Color4 object
  5979. */
  5980. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5981. /**
  5982. * Creates a new Color3 from integer values (< 256)
  5983. * @param r defines the red component to read from (value between 0 and 255)
  5984. * @param g defines the green component to read from (value between 0 and 255)
  5985. * @param b defines the blue component to read from (value between 0 and 255)
  5986. * @param a defines the alpha component to read from (value between 0 and 255)
  5987. * @returns a new Color3 object
  5988. */
  5989. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5990. /**
  5991. * Check the content of a given array and convert it to an array containing RGBA data
  5992. * If the original array was already containing count * 4 values then it is returned directly
  5993. * @param colors defines the array to check
  5994. * @param count defines the number of RGBA data to expect
  5995. * @returns an array containing count * 4 values (RGBA)
  5996. */
  5997. static CheckColors4(colors: number[], count: number): number[];
  5998. }
  5999. /**
  6000. * @hidden
  6001. */
  6002. export class TmpColors {
  6003. static Color3: Color3[];
  6004. static Color4: Color4[];
  6005. }
  6006. }
  6007. declare module BABYLON {
  6008. /**
  6009. * Defines an interface which represents an animation key frame
  6010. */
  6011. export interface IAnimationKey {
  6012. /**
  6013. * Frame of the key frame
  6014. */
  6015. frame: number;
  6016. /**
  6017. * Value at the specifies key frame
  6018. */
  6019. value: any;
  6020. /**
  6021. * The input tangent for the cubic hermite spline
  6022. */
  6023. inTangent?: any;
  6024. /**
  6025. * The output tangent for the cubic hermite spline
  6026. */
  6027. outTangent?: any;
  6028. /**
  6029. * The animation interpolation type
  6030. */
  6031. interpolation?: AnimationKeyInterpolation;
  6032. }
  6033. /**
  6034. * Enum for the animation key frame interpolation type
  6035. */
  6036. export enum AnimationKeyInterpolation {
  6037. /**
  6038. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6039. */
  6040. STEP = 1
  6041. }
  6042. }
  6043. declare module BABYLON {
  6044. /**
  6045. * Represents the range of an animation
  6046. */
  6047. export class AnimationRange {
  6048. /**The name of the animation range**/
  6049. name: string;
  6050. /**The starting frame of the animation */
  6051. from: number;
  6052. /**The ending frame of the animation*/
  6053. to: number;
  6054. /**
  6055. * Initializes the range of an animation
  6056. * @param name The name of the animation range
  6057. * @param from The starting frame of the animation
  6058. * @param to The ending frame of the animation
  6059. */
  6060. constructor(
  6061. /**The name of the animation range**/
  6062. name: string,
  6063. /**The starting frame of the animation */
  6064. from: number,
  6065. /**The ending frame of the animation*/
  6066. to: number);
  6067. /**
  6068. * Makes a copy of the animation range
  6069. * @returns A copy of the animation range
  6070. */
  6071. clone(): AnimationRange;
  6072. }
  6073. }
  6074. declare module BABYLON {
  6075. /**
  6076. * Composed of a frame, and an action function
  6077. */
  6078. export class AnimationEvent {
  6079. /** The frame for which the event is triggered **/
  6080. frame: number;
  6081. /** The event to perform when triggered **/
  6082. action: (currentFrame: number) => void;
  6083. /** Specifies if the event should be triggered only once**/
  6084. onlyOnce?: boolean | undefined;
  6085. /**
  6086. * Specifies if the animation event is done
  6087. */
  6088. isDone: boolean;
  6089. /**
  6090. * Initializes the animation event
  6091. * @param frame The frame for which the event is triggered
  6092. * @param action The event to perform when triggered
  6093. * @param onlyOnce Specifies if the event should be triggered only once
  6094. */
  6095. constructor(
  6096. /** The frame for which the event is triggered **/
  6097. frame: number,
  6098. /** The event to perform when triggered **/
  6099. action: (currentFrame: number) => void,
  6100. /** Specifies if the event should be triggered only once**/
  6101. onlyOnce?: boolean | undefined);
  6102. /** @hidden */
  6103. _clone(): AnimationEvent;
  6104. }
  6105. }
  6106. declare module BABYLON {
  6107. /**
  6108. * Interface used to define a behavior
  6109. */
  6110. export interface Behavior<T> {
  6111. /** gets or sets behavior's name */
  6112. name: string;
  6113. /**
  6114. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6115. */
  6116. init(): void;
  6117. /**
  6118. * Called when the behavior is attached to a target
  6119. * @param target defines the target where the behavior is attached to
  6120. */
  6121. attach(target: T): void;
  6122. /**
  6123. * Called when the behavior is detached from its target
  6124. */
  6125. detach(): void;
  6126. }
  6127. /**
  6128. * Interface implemented by classes supporting behaviors
  6129. */
  6130. export interface IBehaviorAware<T> {
  6131. /**
  6132. * Attach a behavior
  6133. * @param behavior defines the behavior to attach
  6134. * @returns the current host
  6135. */
  6136. addBehavior(behavior: Behavior<T>): T;
  6137. /**
  6138. * Remove a behavior from the current object
  6139. * @param behavior defines the behavior to detach
  6140. * @returns the current host
  6141. */
  6142. removeBehavior(behavior: Behavior<T>): T;
  6143. /**
  6144. * Gets a behavior using its name to search
  6145. * @param name defines the name to search
  6146. * @returns the behavior or null if not found
  6147. */
  6148. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6149. }
  6150. }
  6151. declare module BABYLON {
  6152. /**
  6153. * Defines an array and its length.
  6154. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6155. */
  6156. export interface ISmartArrayLike<T> {
  6157. /**
  6158. * The data of the array.
  6159. */
  6160. data: Array<T>;
  6161. /**
  6162. * The active length of the array.
  6163. */
  6164. length: number;
  6165. }
  6166. /**
  6167. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6168. */
  6169. export class SmartArray<T> implements ISmartArrayLike<T> {
  6170. /**
  6171. * The full set of data from the array.
  6172. */
  6173. data: Array<T>;
  6174. /**
  6175. * The active length of the array.
  6176. */
  6177. length: number;
  6178. protected _id: number;
  6179. /**
  6180. * Instantiates a Smart Array.
  6181. * @param capacity defines the default capacity of the array.
  6182. */
  6183. constructor(capacity: number);
  6184. /**
  6185. * Pushes a value at the end of the active data.
  6186. * @param value defines the object to push in the array.
  6187. */
  6188. push(value: T): void;
  6189. /**
  6190. * Iterates over the active data and apply the lambda to them.
  6191. * @param func defines the action to apply on each value.
  6192. */
  6193. forEach(func: (content: T) => void): void;
  6194. /**
  6195. * Sorts the full sets of data.
  6196. * @param compareFn defines the comparison function to apply.
  6197. */
  6198. sort(compareFn: (a: T, b: T) => number): void;
  6199. /**
  6200. * Resets the active data to an empty array.
  6201. */
  6202. reset(): void;
  6203. /**
  6204. * Releases all the data from the array as well as the array.
  6205. */
  6206. dispose(): void;
  6207. /**
  6208. * Concats the active data with a given array.
  6209. * @param array defines the data to concatenate with.
  6210. */
  6211. concat(array: any): void;
  6212. /**
  6213. * Returns the position of a value in the active data.
  6214. * @param value defines the value to find the index for
  6215. * @returns the index if found in the active data otherwise -1
  6216. */
  6217. indexOf(value: T): number;
  6218. /**
  6219. * Returns whether an element is part of the active data.
  6220. * @param value defines the value to look for
  6221. * @returns true if found in the active data otherwise false
  6222. */
  6223. contains(value: T): boolean;
  6224. private static _GlobalId;
  6225. }
  6226. /**
  6227. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6228. * The data in this array can only be present once
  6229. */
  6230. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6231. private _duplicateId;
  6232. /**
  6233. * Pushes a value at the end of the active data.
  6234. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6235. * @param value defines the object to push in the array.
  6236. */
  6237. push(value: T): void;
  6238. /**
  6239. * Pushes a value at the end of the active data.
  6240. * If the data is already present, it won t be added again
  6241. * @param value defines the object to push in the array.
  6242. * @returns true if added false if it was already present
  6243. */
  6244. pushNoDuplicate(value: T): boolean;
  6245. /**
  6246. * Resets the active data to an empty array.
  6247. */
  6248. reset(): void;
  6249. /**
  6250. * Concats the active data with a given array.
  6251. * This ensures no dupplicate will be present in the result.
  6252. * @param array defines the data to concatenate with.
  6253. */
  6254. concatWithNoDuplicate(array: any): void;
  6255. }
  6256. }
  6257. declare module BABYLON {
  6258. /**
  6259. * @ignore
  6260. * This is a list of all the different input types that are available in the application.
  6261. * Fo instance: ArcRotateCameraGamepadInput...
  6262. */
  6263. export var CameraInputTypes: {};
  6264. /**
  6265. * This is the contract to implement in order to create a new input class.
  6266. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6267. */
  6268. export interface ICameraInput<TCamera extends Camera> {
  6269. /**
  6270. * Defines the camera the input is attached to.
  6271. */
  6272. camera: Nullable<TCamera>;
  6273. /**
  6274. * Gets the class name of the current intput.
  6275. * @returns the class name
  6276. */
  6277. getClassName(): string;
  6278. /**
  6279. * Get the friendly name associated with the input class.
  6280. * @returns the input friendly name
  6281. */
  6282. getSimpleName(): string;
  6283. /**
  6284. * Attach the input controls to a specific dom element to get the input from.
  6285. * @param element Defines the element the controls should be listened from
  6286. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6287. */
  6288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6289. /**
  6290. * Detach the current controls from the specified dom element.
  6291. * @param element Defines the element to stop listening the inputs from
  6292. */
  6293. detachControl(element: Nullable<HTMLElement>): void;
  6294. /**
  6295. * Update the current camera state depending on the inputs that have been used this frame.
  6296. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6297. */
  6298. checkInputs?: () => void;
  6299. }
  6300. /**
  6301. * Represents a map of input types to input instance or input index to input instance.
  6302. */
  6303. export interface CameraInputsMap<TCamera extends Camera> {
  6304. /**
  6305. * Accessor to the input by input type.
  6306. */
  6307. [name: string]: ICameraInput<TCamera>;
  6308. /**
  6309. * Accessor to the input by input index.
  6310. */
  6311. [idx: number]: ICameraInput<TCamera>;
  6312. }
  6313. /**
  6314. * This represents the input manager used within a camera.
  6315. * It helps dealing with all the different kind of input attached to a camera.
  6316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6317. */
  6318. export class CameraInputsManager<TCamera extends Camera> {
  6319. /**
  6320. * Defines the list of inputs attahed to the camera.
  6321. */
  6322. attached: CameraInputsMap<TCamera>;
  6323. /**
  6324. * Defines the dom element the camera is collecting inputs from.
  6325. * This is null if the controls have not been attached.
  6326. */
  6327. attachedElement: Nullable<HTMLElement>;
  6328. /**
  6329. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6330. */
  6331. noPreventDefault: boolean;
  6332. /**
  6333. * Defined the camera the input manager belongs to.
  6334. */
  6335. camera: TCamera;
  6336. /**
  6337. * Update the current camera state depending on the inputs that have been used this frame.
  6338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6339. */
  6340. checkInputs: () => void;
  6341. /**
  6342. * Instantiate a new Camera Input Manager.
  6343. * @param camera Defines the camera the input manager blongs to
  6344. */
  6345. constructor(camera: TCamera);
  6346. /**
  6347. * Add an input method to a camera
  6348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6349. * @param input camera input method
  6350. */
  6351. add(input: ICameraInput<TCamera>): void;
  6352. /**
  6353. * Remove a specific input method from a camera
  6354. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6355. * @param inputToRemove camera input method
  6356. */
  6357. remove(inputToRemove: ICameraInput<TCamera>): void;
  6358. /**
  6359. * Remove a specific input type from a camera
  6360. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6361. * @param inputType the type of the input to remove
  6362. */
  6363. removeByType(inputType: string): void;
  6364. private _addCheckInputs;
  6365. /**
  6366. * Attach the input controls to the currently attached dom element to listen the events from.
  6367. * @param input Defines the input to attach
  6368. */
  6369. attachInput(input: ICameraInput<TCamera>): void;
  6370. /**
  6371. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6372. * @param element Defines the dom element to collect the events from
  6373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6374. */
  6375. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6376. /**
  6377. * Detach the current manager inputs controls from a specific dom element.
  6378. * @param element Defines the dom element to collect the events from
  6379. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6380. */
  6381. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6382. /**
  6383. * Rebuild the dynamic inputCheck function from the current list of
  6384. * defined inputs in the manager.
  6385. */
  6386. rebuildInputCheck(): void;
  6387. /**
  6388. * Remove all attached input methods from a camera
  6389. */
  6390. clear(): void;
  6391. /**
  6392. * Serialize the current input manager attached to a camera.
  6393. * This ensures than once parsed,
  6394. * the input associated to the camera will be identical to the current ones
  6395. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6396. */
  6397. serialize(serializedCamera: any): void;
  6398. /**
  6399. * Parses an input manager serialized JSON to restore the previous list of inputs
  6400. * and states associated to a camera.
  6401. * @param parsedCamera Defines the JSON to parse
  6402. */
  6403. parse(parsedCamera: any): void;
  6404. }
  6405. }
  6406. declare module BABYLON {
  6407. /**
  6408. * Class used to store data that will be store in GPU memory
  6409. */
  6410. export class Buffer {
  6411. private _engine;
  6412. private _buffer;
  6413. /** @hidden */
  6414. _data: Nullable<DataArray>;
  6415. private _updatable;
  6416. private _instanced;
  6417. private _divisor;
  6418. /**
  6419. * Gets the byte stride.
  6420. */
  6421. readonly byteStride: number;
  6422. /**
  6423. * Constructor
  6424. * @param engine the engine
  6425. * @param data the data to use for this buffer
  6426. * @param updatable whether the data is updatable
  6427. * @param stride the stride (optional)
  6428. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6429. * @param instanced whether the buffer is instanced (optional)
  6430. * @param useBytes set to true if the stride in in bytes (optional)
  6431. * @param divisor sets an optional divisor for instances (1 by default)
  6432. */
  6433. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6434. /**
  6435. * Create a new VertexBuffer based on the current buffer
  6436. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6437. * @param offset defines offset in the buffer (0 by default)
  6438. * @param size defines the size in floats of attributes (position is 3 for instance)
  6439. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6440. * @param instanced defines if the vertex buffer contains indexed data
  6441. * @param useBytes defines if the offset and stride are in bytes *
  6442. * @param divisor sets an optional divisor for instances (1 by default)
  6443. * @returns the new vertex buffer
  6444. */
  6445. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6446. /**
  6447. * Gets a boolean indicating if the Buffer is updatable?
  6448. * @returns true if the buffer is updatable
  6449. */
  6450. isUpdatable(): boolean;
  6451. /**
  6452. * Gets current buffer's data
  6453. * @returns a DataArray or null
  6454. */
  6455. getData(): Nullable<DataArray>;
  6456. /**
  6457. * Gets underlying native buffer
  6458. * @returns underlying native buffer
  6459. */
  6460. getBuffer(): Nullable<DataBuffer>;
  6461. /**
  6462. * Gets the stride in float32 units (i.e. byte stride / 4).
  6463. * May not be an integer if the byte stride is not divisible by 4.
  6464. * @returns the stride in float32 units
  6465. * @deprecated Please use byteStride instead.
  6466. */
  6467. getStrideSize(): number;
  6468. /**
  6469. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6470. * @param data defines the data to store
  6471. */
  6472. create(data?: Nullable<DataArray>): void;
  6473. /** @hidden */
  6474. _rebuild(): void;
  6475. /**
  6476. * Update current buffer data
  6477. * @param data defines the data to store
  6478. */
  6479. update(data: DataArray): void;
  6480. /**
  6481. * Updates the data directly.
  6482. * @param data the new data
  6483. * @param offset the new offset
  6484. * @param vertexCount the vertex count (optional)
  6485. * @param useBytes set to true if the offset is in bytes
  6486. */
  6487. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6488. /**
  6489. * Release all resources
  6490. */
  6491. dispose(): void;
  6492. }
  6493. /**
  6494. * Specialized buffer used to store vertex data
  6495. */
  6496. export class VertexBuffer {
  6497. /** @hidden */
  6498. _buffer: Buffer;
  6499. private _kind;
  6500. private _size;
  6501. private _ownsBuffer;
  6502. private _instanced;
  6503. private _instanceDivisor;
  6504. /**
  6505. * The byte type.
  6506. */
  6507. static readonly BYTE: number;
  6508. /**
  6509. * The unsigned byte type.
  6510. */
  6511. static readonly UNSIGNED_BYTE: number;
  6512. /**
  6513. * The short type.
  6514. */
  6515. static readonly SHORT: number;
  6516. /**
  6517. * The unsigned short type.
  6518. */
  6519. static readonly UNSIGNED_SHORT: number;
  6520. /**
  6521. * The integer type.
  6522. */
  6523. static readonly INT: number;
  6524. /**
  6525. * The unsigned integer type.
  6526. */
  6527. static readonly UNSIGNED_INT: number;
  6528. /**
  6529. * The float type.
  6530. */
  6531. static readonly FLOAT: number;
  6532. /**
  6533. * Gets or sets the instance divisor when in instanced mode
  6534. */
  6535. get instanceDivisor(): number;
  6536. set instanceDivisor(value: number);
  6537. /**
  6538. * Gets the byte stride.
  6539. */
  6540. readonly byteStride: number;
  6541. /**
  6542. * Gets the byte offset.
  6543. */
  6544. readonly byteOffset: number;
  6545. /**
  6546. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6547. */
  6548. readonly normalized: boolean;
  6549. /**
  6550. * Gets the data type of each component in the array.
  6551. */
  6552. readonly type: number;
  6553. /**
  6554. * Constructor
  6555. * @param engine the engine
  6556. * @param data the data to use for this vertex buffer
  6557. * @param kind the vertex buffer kind
  6558. * @param updatable whether the data is updatable
  6559. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6560. * @param stride the stride (optional)
  6561. * @param instanced whether the buffer is instanced (optional)
  6562. * @param offset the offset of the data (optional)
  6563. * @param size the number of components (optional)
  6564. * @param type the type of the component (optional)
  6565. * @param normalized whether the data contains normalized data (optional)
  6566. * @param useBytes set to true if stride and offset are in bytes (optional)
  6567. * @param divisor defines the instance divisor to use (1 by default)
  6568. */
  6569. 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);
  6570. /** @hidden */
  6571. _rebuild(): void;
  6572. /**
  6573. * Returns the kind of the VertexBuffer (string)
  6574. * @returns a string
  6575. */
  6576. getKind(): string;
  6577. /**
  6578. * Gets a boolean indicating if the VertexBuffer is updatable?
  6579. * @returns true if the buffer is updatable
  6580. */
  6581. isUpdatable(): boolean;
  6582. /**
  6583. * Gets current buffer's data
  6584. * @returns a DataArray or null
  6585. */
  6586. getData(): Nullable<DataArray>;
  6587. /**
  6588. * Gets underlying native buffer
  6589. * @returns underlying native buffer
  6590. */
  6591. getBuffer(): Nullable<DataBuffer>;
  6592. /**
  6593. * Gets the stride in float32 units (i.e. byte stride / 4).
  6594. * May not be an integer if the byte stride is not divisible by 4.
  6595. * @returns the stride in float32 units
  6596. * @deprecated Please use byteStride instead.
  6597. */
  6598. getStrideSize(): number;
  6599. /**
  6600. * Returns the offset as a multiple of the type byte length.
  6601. * @returns the offset in bytes
  6602. * @deprecated Please use byteOffset instead.
  6603. */
  6604. getOffset(): number;
  6605. /**
  6606. * Returns the number of components per vertex attribute (integer)
  6607. * @returns the size in float
  6608. */
  6609. getSize(): number;
  6610. /**
  6611. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6612. * @returns true if this buffer is instanced
  6613. */
  6614. getIsInstanced(): boolean;
  6615. /**
  6616. * Returns the instancing divisor, zero for non-instanced (integer).
  6617. * @returns a number
  6618. */
  6619. getInstanceDivisor(): number;
  6620. /**
  6621. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6622. * @param data defines the data to store
  6623. */
  6624. create(data?: DataArray): void;
  6625. /**
  6626. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6627. * This function will create a new buffer if the current one is not updatable
  6628. * @param data defines the data to store
  6629. */
  6630. update(data: DataArray): void;
  6631. /**
  6632. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6633. * Returns the directly updated WebGLBuffer.
  6634. * @param data the new data
  6635. * @param offset the new offset
  6636. * @param useBytes set to true if the offset is in bytes
  6637. */
  6638. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6639. /**
  6640. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6641. */
  6642. dispose(): void;
  6643. /**
  6644. * Enumerates each value of this vertex buffer as numbers.
  6645. * @param count the number of values to enumerate
  6646. * @param callback the callback function called for each value
  6647. */
  6648. forEach(count: number, callback: (value: number, index: number) => void): void;
  6649. /**
  6650. * Positions
  6651. */
  6652. static readonly PositionKind: string;
  6653. /**
  6654. * Normals
  6655. */
  6656. static readonly NormalKind: string;
  6657. /**
  6658. * Tangents
  6659. */
  6660. static readonly TangentKind: string;
  6661. /**
  6662. * Texture coordinates
  6663. */
  6664. static readonly UVKind: string;
  6665. /**
  6666. * Texture coordinates 2
  6667. */
  6668. static readonly UV2Kind: string;
  6669. /**
  6670. * Texture coordinates 3
  6671. */
  6672. static readonly UV3Kind: string;
  6673. /**
  6674. * Texture coordinates 4
  6675. */
  6676. static readonly UV4Kind: string;
  6677. /**
  6678. * Texture coordinates 5
  6679. */
  6680. static readonly UV5Kind: string;
  6681. /**
  6682. * Texture coordinates 6
  6683. */
  6684. static readonly UV6Kind: string;
  6685. /**
  6686. * Colors
  6687. */
  6688. static readonly ColorKind: string;
  6689. /**
  6690. * Matrix indices (for bones)
  6691. */
  6692. static readonly MatricesIndicesKind: string;
  6693. /**
  6694. * Matrix weights (for bones)
  6695. */
  6696. static readonly MatricesWeightsKind: string;
  6697. /**
  6698. * Additional matrix indices (for bones)
  6699. */
  6700. static readonly MatricesIndicesExtraKind: string;
  6701. /**
  6702. * Additional matrix weights (for bones)
  6703. */
  6704. static readonly MatricesWeightsExtraKind: string;
  6705. /**
  6706. * Deduces the stride given a kind.
  6707. * @param kind The kind string to deduce
  6708. * @returns The deduced stride
  6709. */
  6710. static DeduceStride(kind: string): number;
  6711. /**
  6712. * Gets the byte length of the given type.
  6713. * @param type the type
  6714. * @returns the number of bytes
  6715. */
  6716. static GetTypeByteLength(type: number): number;
  6717. /**
  6718. * Enumerates each value of the given parameters as numbers.
  6719. * @param data the data to enumerate
  6720. * @param byteOffset the byte offset of the data
  6721. * @param byteStride the byte stride of the data
  6722. * @param componentCount the number of components per element
  6723. * @param componentType the type of the component
  6724. * @param count the number of values to enumerate
  6725. * @param normalized whether the data is normalized
  6726. * @param callback the callback function called for each value
  6727. */
  6728. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6729. private static _GetFloatValue;
  6730. }
  6731. }
  6732. declare module BABYLON {
  6733. /**
  6734. * @hidden
  6735. */
  6736. export class IntersectionInfo {
  6737. bu: Nullable<number>;
  6738. bv: Nullable<number>;
  6739. distance: number;
  6740. faceId: number;
  6741. subMeshId: number;
  6742. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6743. }
  6744. }
  6745. declare module BABYLON {
  6746. /**
  6747. * Class used to store bounding sphere information
  6748. */
  6749. export class BoundingSphere {
  6750. /**
  6751. * Gets the center of the bounding sphere in local space
  6752. */
  6753. readonly center: Vector3;
  6754. /**
  6755. * Radius of the bounding sphere in local space
  6756. */
  6757. radius: number;
  6758. /**
  6759. * Gets the center of the bounding sphere in world space
  6760. */
  6761. readonly centerWorld: Vector3;
  6762. /**
  6763. * Radius of the bounding sphere in world space
  6764. */
  6765. radiusWorld: number;
  6766. /**
  6767. * Gets the minimum vector in local space
  6768. */
  6769. readonly minimum: Vector3;
  6770. /**
  6771. * Gets the maximum vector in local space
  6772. */
  6773. readonly maximum: Vector3;
  6774. private _worldMatrix;
  6775. private static readonly TmpVector3;
  6776. /**
  6777. * Creates a new bounding sphere
  6778. * @param min defines the minimum vector (in local space)
  6779. * @param max defines the maximum vector (in local space)
  6780. * @param worldMatrix defines the new world matrix
  6781. */
  6782. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6783. /**
  6784. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6785. * @param min defines the new minimum vector (in local space)
  6786. * @param max defines the new maximum vector (in local space)
  6787. * @param worldMatrix defines the new world matrix
  6788. */
  6789. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6790. /**
  6791. * Scale the current bounding sphere by applying a scale factor
  6792. * @param factor defines the scale factor to apply
  6793. * @returns the current bounding box
  6794. */
  6795. scale(factor: number): BoundingSphere;
  6796. /**
  6797. * Gets the world matrix of the bounding box
  6798. * @returns a matrix
  6799. */
  6800. getWorldMatrix(): DeepImmutable<Matrix>;
  6801. /** @hidden */
  6802. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6803. /**
  6804. * Tests if the bounding sphere is intersecting the frustum planes
  6805. * @param frustumPlanes defines the frustum planes to test
  6806. * @returns true if there is an intersection
  6807. */
  6808. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6809. /**
  6810. * Tests if the bounding sphere center is in between the frustum planes.
  6811. * Used for optimistic fast inclusion.
  6812. * @param frustumPlanes defines the frustum planes to test
  6813. * @returns true if the sphere center is in between the frustum planes
  6814. */
  6815. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6816. /**
  6817. * Tests if a point is inside the bounding sphere
  6818. * @param point defines the point to test
  6819. * @returns true if the point is inside the bounding sphere
  6820. */
  6821. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6822. /**
  6823. * Checks if two sphere intersct
  6824. * @param sphere0 sphere 0
  6825. * @param sphere1 sphere 1
  6826. * @returns true if the speres intersect
  6827. */
  6828. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6829. }
  6830. }
  6831. declare module BABYLON {
  6832. /**
  6833. * Class used to store bounding box information
  6834. */
  6835. export class BoundingBox implements ICullable {
  6836. /**
  6837. * Gets the 8 vectors representing the bounding box in local space
  6838. */
  6839. readonly vectors: Vector3[];
  6840. /**
  6841. * Gets the center of the bounding box in local space
  6842. */
  6843. readonly center: Vector3;
  6844. /**
  6845. * Gets the center of the bounding box in world space
  6846. */
  6847. readonly centerWorld: Vector3;
  6848. /**
  6849. * Gets the extend size in local space
  6850. */
  6851. readonly extendSize: Vector3;
  6852. /**
  6853. * Gets the extend size in world space
  6854. */
  6855. readonly extendSizeWorld: Vector3;
  6856. /**
  6857. * Gets the OBB (object bounding box) directions
  6858. */
  6859. readonly directions: Vector3[];
  6860. /**
  6861. * Gets the 8 vectors representing the bounding box in world space
  6862. */
  6863. readonly vectorsWorld: Vector3[];
  6864. /**
  6865. * Gets the minimum vector in world space
  6866. */
  6867. readonly minimumWorld: Vector3;
  6868. /**
  6869. * Gets the maximum vector in world space
  6870. */
  6871. readonly maximumWorld: Vector3;
  6872. /**
  6873. * Gets the minimum vector in local space
  6874. */
  6875. readonly minimum: Vector3;
  6876. /**
  6877. * Gets the maximum vector in local space
  6878. */
  6879. readonly maximum: Vector3;
  6880. private _worldMatrix;
  6881. private static readonly TmpVector3;
  6882. /**
  6883. * @hidden
  6884. */
  6885. _tag: number;
  6886. /**
  6887. * Creates a new bounding box
  6888. * @param min defines the minimum vector (in local space)
  6889. * @param max defines the maximum vector (in local space)
  6890. * @param worldMatrix defines the new world matrix
  6891. */
  6892. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6893. /**
  6894. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6895. * @param min defines the new minimum vector (in local space)
  6896. * @param max defines the new maximum vector (in local space)
  6897. * @param worldMatrix defines the new world matrix
  6898. */
  6899. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6900. /**
  6901. * Scale the current bounding box by applying a scale factor
  6902. * @param factor defines the scale factor to apply
  6903. * @returns the current bounding box
  6904. */
  6905. scale(factor: number): BoundingBox;
  6906. /**
  6907. * Gets the world matrix of the bounding box
  6908. * @returns a matrix
  6909. */
  6910. getWorldMatrix(): DeepImmutable<Matrix>;
  6911. /** @hidden */
  6912. _update(world: DeepImmutable<Matrix>): void;
  6913. /**
  6914. * Tests if the bounding box is intersecting the frustum planes
  6915. * @param frustumPlanes defines the frustum planes to test
  6916. * @returns true if there is an intersection
  6917. */
  6918. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6919. /**
  6920. * Tests if the bounding box is entirely inside the frustum planes
  6921. * @param frustumPlanes defines the frustum planes to test
  6922. * @returns true if there is an inclusion
  6923. */
  6924. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6925. /**
  6926. * Tests if a point is inside the bounding box
  6927. * @param point defines the point to test
  6928. * @returns true if the point is inside the bounding box
  6929. */
  6930. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6931. /**
  6932. * Tests if the bounding box intersects with a bounding sphere
  6933. * @param sphere defines the sphere to test
  6934. * @returns true if there is an intersection
  6935. */
  6936. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6937. /**
  6938. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6939. * @param min defines the min vector to use
  6940. * @param max defines the max vector to use
  6941. * @returns true if there is an intersection
  6942. */
  6943. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6944. /**
  6945. * Tests if two bounding boxes are intersections
  6946. * @param box0 defines the first box to test
  6947. * @param box1 defines the second box to test
  6948. * @returns true if there is an intersection
  6949. */
  6950. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6951. /**
  6952. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6953. * @param minPoint defines the minimum vector of the bounding box
  6954. * @param maxPoint defines the maximum vector of the bounding box
  6955. * @param sphereCenter defines the sphere center
  6956. * @param sphereRadius defines the sphere radius
  6957. * @returns true if there is an intersection
  6958. */
  6959. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6960. /**
  6961. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6962. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6963. * @param frustumPlanes defines the frustum planes to test
  6964. * @return true if there is an inclusion
  6965. */
  6966. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6967. /**
  6968. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6969. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6970. * @param frustumPlanes defines the frustum planes to test
  6971. * @return true if there is an intersection
  6972. */
  6973. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6974. }
  6975. }
  6976. declare module BABYLON {
  6977. /** @hidden */
  6978. export class Collider {
  6979. /** Define if a collision was found */
  6980. collisionFound: boolean;
  6981. /**
  6982. * Define last intersection point in local space
  6983. */
  6984. intersectionPoint: Vector3;
  6985. /**
  6986. * Define last collided mesh
  6987. */
  6988. collidedMesh: Nullable<AbstractMesh>;
  6989. private _collisionPoint;
  6990. private _planeIntersectionPoint;
  6991. private _tempVector;
  6992. private _tempVector2;
  6993. private _tempVector3;
  6994. private _tempVector4;
  6995. private _edge;
  6996. private _baseToVertex;
  6997. private _destinationPoint;
  6998. private _slidePlaneNormal;
  6999. private _displacementVector;
  7000. /** @hidden */
  7001. _radius: Vector3;
  7002. /** @hidden */
  7003. _retry: number;
  7004. private _velocity;
  7005. private _basePoint;
  7006. private _epsilon;
  7007. /** @hidden */
  7008. _velocityWorldLength: number;
  7009. /** @hidden */
  7010. _basePointWorld: Vector3;
  7011. private _velocityWorld;
  7012. private _normalizedVelocity;
  7013. /** @hidden */
  7014. _initialVelocity: Vector3;
  7015. /** @hidden */
  7016. _initialPosition: Vector3;
  7017. private _nearestDistance;
  7018. private _collisionMask;
  7019. get collisionMask(): number;
  7020. set collisionMask(mask: number);
  7021. /**
  7022. * Gets the plane normal used to compute the sliding response (in local space)
  7023. */
  7024. get slidePlaneNormal(): Vector3;
  7025. /** @hidden */
  7026. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7027. /** @hidden */
  7028. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7029. /** @hidden */
  7030. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7031. /** @hidden */
  7032. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7033. /** @hidden */
  7034. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7035. /** @hidden */
  7036. _getResponse(pos: Vector3, vel: Vector3): void;
  7037. }
  7038. }
  7039. declare module BABYLON {
  7040. /**
  7041. * Interface for cullable objects
  7042. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7043. */
  7044. export interface ICullable {
  7045. /**
  7046. * Checks if the object or part of the object is in the frustum
  7047. * @param frustumPlanes Camera near/planes
  7048. * @returns true if the object is in frustum otherwise false
  7049. */
  7050. isInFrustum(frustumPlanes: Plane[]): boolean;
  7051. /**
  7052. * Checks if a cullable object (mesh...) is in the camera frustum
  7053. * Unlike isInFrustum this cheks the full bounding box
  7054. * @param frustumPlanes Camera near/planes
  7055. * @returns true if the object is in frustum otherwise false
  7056. */
  7057. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7058. }
  7059. /**
  7060. * Info for a bounding data of a mesh
  7061. */
  7062. export class BoundingInfo implements ICullable {
  7063. /**
  7064. * Bounding box for the mesh
  7065. */
  7066. readonly boundingBox: BoundingBox;
  7067. /**
  7068. * Bounding sphere for the mesh
  7069. */
  7070. readonly boundingSphere: BoundingSphere;
  7071. private _isLocked;
  7072. private static readonly TmpVector3;
  7073. /**
  7074. * Constructs bounding info
  7075. * @param minimum min vector of the bounding box/sphere
  7076. * @param maximum max vector of the bounding box/sphere
  7077. * @param worldMatrix defines the new world matrix
  7078. */
  7079. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7080. /**
  7081. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7082. * @param min defines the new minimum vector (in local space)
  7083. * @param max defines the new maximum vector (in local space)
  7084. * @param worldMatrix defines the new world matrix
  7085. */
  7086. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7087. /**
  7088. * min vector of the bounding box/sphere
  7089. */
  7090. get minimum(): Vector3;
  7091. /**
  7092. * max vector of the bounding box/sphere
  7093. */
  7094. get maximum(): Vector3;
  7095. /**
  7096. * If the info is locked and won't be updated to avoid perf overhead
  7097. */
  7098. get isLocked(): boolean;
  7099. set isLocked(value: boolean);
  7100. /**
  7101. * Updates the bounding sphere and box
  7102. * @param world world matrix to be used to update
  7103. */
  7104. update(world: DeepImmutable<Matrix>): void;
  7105. /**
  7106. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7107. * @param center New center of the bounding info
  7108. * @param extend New extend of the bounding info
  7109. * @returns the current bounding info
  7110. */
  7111. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7112. /**
  7113. * Scale the current bounding info by applying a scale factor
  7114. * @param factor defines the scale factor to apply
  7115. * @returns the current bounding info
  7116. */
  7117. scale(factor: number): BoundingInfo;
  7118. /**
  7119. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7120. * @param frustumPlanes defines the frustum to test
  7121. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7122. * @returns true if the bounding info is in the frustum planes
  7123. */
  7124. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7125. /**
  7126. * Gets the world distance between the min and max points of the bounding box
  7127. */
  7128. get diagonalLength(): number;
  7129. /**
  7130. * Checks if a cullable object (mesh...) is in the camera frustum
  7131. * Unlike isInFrustum this cheks the full bounding box
  7132. * @param frustumPlanes Camera near/planes
  7133. * @returns true if the object is in frustum otherwise false
  7134. */
  7135. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7136. /** @hidden */
  7137. _checkCollision(collider: Collider): boolean;
  7138. /**
  7139. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7140. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7141. * @param point the point to check intersection with
  7142. * @returns if the point intersects
  7143. */
  7144. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7145. /**
  7146. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7147. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7148. * @param boundingInfo the bounding info to check intersection with
  7149. * @param precise if the intersection should be done using OBB
  7150. * @returns if the bounding info intersects
  7151. */
  7152. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7153. }
  7154. }
  7155. declare module BABYLON {
  7156. /**
  7157. * Extracts minimum and maximum values from a list of indexed positions
  7158. * @param positions defines the positions to use
  7159. * @param indices defines the indices to the positions
  7160. * @param indexStart defines the start index
  7161. * @param indexCount defines the end index
  7162. * @param bias defines bias value to add to the result
  7163. * @return minimum and maximum values
  7164. */
  7165. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7166. minimum: Vector3;
  7167. maximum: Vector3;
  7168. };
  7169. /**
  7170. * Extracts minimum and maximum values from a list of positions
  7171. * @param positions defines the positions to use
  7172. * @param start defines the start index in the positions array
  7173. * @param count defines the number of positions to handle
  7174. * @param bias defines bias value to add to the result
  7175. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7176. * @return minimum and maximum values
  7177. */
  7178. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7179. minimum: Vector3;
  7180. maximum: Vector3;
  7181. };
  7182. }
  7183. declare module BABYLON {
  7184. /** @hidden */
  7185. export class WebGLDataBuffer extends DataBuffer {
  7186. private _buffer;
  7187. constructor(resource: WebGLBuffer);
  7188. get underlyingResource(): any;
  7189. }
  7190. }
  7191. declare module BABYLON {
  7192. /** @hidden */
  7193. export class WebGLPipelineContext implements IPipelineContext {
  7194. engine: ThinEngine;
  7195. program: Nullable<WebGLProgram>;
  7196. context?: WebGLRenderingContext;
  7197. vertexShader?: WebGLShader;
  7198. fragmentShader?: WebGLShader;
  7199. isParallelCompiled: boolean;
  7200. onCompiled?: () => void;
  7201. transformFeedback?: WebGLTransformFeedback | null;
  7202. vertexCompilationError: Nullable<string>;
  7203. fragmentCompilationError: Nullable<string>;
  7204. programLinkError: Nullable<string>;
  7205. programValidationError: Nullable<string>;
  7206. get isAsync(): boolean;
  7207. get isReady(): boolean;
  7208. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7209. _getVertexShaderCode(): string | null;
  7210. _getFragmentShaderCode(): string | null;
  7211. }
  7212. }
  7213. declare module BABYLON {
  7214. interface ThinEngine {
  7215. /**
  7216. * Create an uniform buffer
  7217. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7218. * @param elements defines the content of the uniform buffer
  7219. * @returns the webGL uniform buffer
  7220. */
  7221. createUniformBuffer(elements: FloatArray): DataBuffer;
  7222. /**
  7223. * Create a dynamic uniform buffer
  7224. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7225. * @param elements defines the content of the uniform buffer
  7226. * @returns the webGL uniform buffer
  7227. */
  7228. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7229. /**
  7230. * Update an existing uniform buffer
  7231. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7232. * @param uniformBuffer defines the target uniform buffer
  7233. * @param elements defines the content to update
  7234. * @param offset defines the offset in the uniform buffer where update should start
  7235. * @param count defines the size of the data to update
  7236. */
  7237. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7238. /**
  7239. * Bind an uniform buffer to the current webGL context
  7240. * @param buffer defines the buffer to bind
  7241. */
  7242. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7243. /**
  7244. * Bind a buffer to the current webGL context at a given location
  7245. * @param buffer defines the buffer to bind
  7246. * @param location defines the index where to bind the buffer
  7247. */
  7248. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7249. /**
  7250. * Bind a specific block at a given index in a specific shader program
  7251. * @param pipelineContext defines the pipeline context to use
  7252. * @param blockName defines the block name
  7253. * @param index defines the index where to bind the block
  7254. */
  7255. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7256. }
  7257. }
  7258. declare module BABYLON {
  7259. /**
  7260. * Uniform buffer objects.
  7261. *
  7262. * Handles blocks of uniform on the GPU.
  7263. *
  7264. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7265. *
  7266. * For more information, please refer to :
  7267. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7268. */
  7269. export class UniformBuffer {
  7270. private _engine;
  7271. private _buffer;
  7272. private _data;
  7273. private _bufferData;
  7274. private _dynamic?;
  7275. private _uniformLocations;
  7276. private _uniformSizes;
  7277. private _uniformLocationPointer;
  7278. private _needSync;
  7279. private _noUBO;
  7280. private _currentEffect;
  7281. /** @hidden */
  7282. _alreadyBound: boolean;
  7283. private static _MAX_UNIFORM_SIZE;
  7284. private static _tempBuffer;
  7285. /**
  7286. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7291. /**
  7292. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7297. /**
  7298. * Lambda to Update a single float in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateFloat: (name: string, x: number) => void;
  7303. /**
  7304. * Lambda to Update a vec2 of float in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7309. /**
  7310. * Lambda to Update a vec3 of float in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7315. /**
  7316. * Lambda to Update a vec4 of float in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7321. /**
  7322. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateMatrix: (name: string, mat: Matrix) => void;
  7327. /**
  7328. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateVector3: (name: string, vector: Vector3) => void;
  7333. /**
  7334. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateVector4: (name: string, vector: Vector4) => void;
  7339. /**
  7340. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7345. /**
  7346. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7351. /**
  7352. * Instantiates a new Uniform buffer objects.
  7353. *
  7354. * Handles blocks of uniform on the GPU.
  7355. *
  7356. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7357. *
  7358. * For more information, please refer to :
  7359. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7360. * @param engine Define the engine the buffer is associated with
  7361. * @param data Define the data contained in the buffer
  7362. * @param dynamic Define if the buffer is updatable
  7363. */
  7364. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7365. /**
  7366. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7367. * or just falling back on setUniformXXX calls.
  7368. */
  7369. get useUbo(): boolean;
  7370. /**
  7371. * Indicates if the WebGL underlying uniform buffer is in sync
  7372. * with the javascript cache data.
  7373. */
  7374. get isSync(): boolean;
  7375. /**
  7376. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7377. * Also, a dynamic UniformBuffer will disable cache verification and always
  7378. * update the underlying WebGL uniform buffer to the GPU.
  7379. * @returns if Dynamic, otherwise false
  7380. */
  7381. isDynamic(): boolean;
  7382. /**
  7383. * The data cache on JS side.
  7384. * @returns the underlying data as a float array
  7385. */
  7386. getData(): Float32Array;
  7387. /**
  7388. * The underlying WebGL Uniform buffer.
  7389. * @returns the webgl buffer
  7390. */
  7391. getBuffer(): Nullable<DataBuffer>;
  7392. /**
  7393. * std140 layout specifies how to align data within an UBO structure.
  7394. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7395. * for specs.
  7396. */
  7397. private _fillAlignment;
  7398. /**
  7399. * Adds an uniform in the buffer.
  7400. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7401. * for the layout to be correct !
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param size Data size, or data directly.
  7404. */
  7405. addUniform(name: string, size: number | number[]): void;
  7406. /**
  7407. * Adds a Matrix 4x4 to the uniform buffer.
  7408. * @param name Name of the uniform, as used in the uniform block in the shader.
  7409. * @param mat A 4x4 matrix.
  7410. */
  7411. addMatrix(name: string, mat: Matrix): void;
  7412. /**
  7413. * Adds a vec2 to the uniform buffer.
  7414. * @param name Name of the uniform, as used in the uniform block in the shader.
  7415. * @param x Define the x component value of the vec2
  7416. * @param y Define the y component value of the vec2
  7417. */
  7418. addFloat2(name: string, x: number, y: number): void;
  7419. /**
  7420. * Adds a vec3 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. * @param x Define the x component value of the vec3
  7423. * @param y Define the y component value of the vec3
  7424. * @param z Define the z component value of the vec3
  7425. */
  7426. addFloat3(name: string, x: number, y: number, z: number): void;
  7427. /**
  7428. * Adds a vec3 to the uniform buffer.
  7429. * @param name Name of the uniform, as used in the uniform block in the shader.
  7430. * @param color Define the vec3 from a Color
  7431. */
  7432. addColor3(name: string, color: Color3): void;
  7433. /**
  7434. * Adds a vec4 to the uniform buffer.
  7435. * @param name Name of the uniform, as used in the uniform block in the shader.
  7436. * @param color Define the rgb components from a Color
  7437. * @param alpha Define the a component of the vec4
  7438. */
  7439. addColor4(name: string, color: Color3, alpha: number): void;
  7440. /**
  7441. * Adds a vec3 to the uniform buffer.
  7442. * @param name Name of the uniform, as used in the uniform block in the shader.
  7443. * @param vector Define the vec3 components from a Vector
  7444. */
  7445. addVector3(name: string, vector: Vector3): void;
  7446. /**
  7447. * Adds a Matrix 3x3 to the uniform buffer.
  7448. * @param name Name of the uniform, as used in the uniform block in the shader.
  7449. */
  7450. addMatrix3x3(name: string): void;
  7451. /**
  7452. * Adds a Matrix 2x2 to the uniform buffer.
  7453. * @param name Name of the uniform, as used in the uniform block in the shader.
  7454. */
  7455. addMatrix2x2(name: string): void;
  7456. /**
  7457. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7458. */
  7459. create(): void;
  7460. /** @hidden */
  7461. _rebuild(): void;
  7462. /**
  7463. * Updates the WebGL Uniform Buffer on the GPU.
  7464. * If the `dynamic` flag is set to true, no cache comparison is done.
  7465. * Otherwise, the buffer will be updated only if the cache differs.
  7466. */
  7467. update(): void;
  7468. /**
  7469. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7470. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7471. * @param data Define the flattened data
  7472. * @param size Define the size of the data.
  7473. */
  7474. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7475. private _valueCache;
  7476. private _cacheMatrix;
  7477. private _updateMatrix3x3ForUniform;
  7478. private _updateMatrix3x3ForEffect;
  7479. private _updateMatrix2x2ForEffect;
  7480. private _updateMatrix2x2ForUniform;
  7481. private _updateFloatForEffect;
  7482. private _updateFloatForUniform;
  7483. private _updateFloat2ForEffect;
  7484. private _updateFloat2ForUniform;
  7485. private _updateFloat3ForEffect;
  7486. private _updateFloat3ForUniform;
  7487. private _updateFloat4ForEffect;
  7488. private _updateFloat4ForUniform;
  7489. private _updateMatrixForEffect;
  7490. private _updateMatrixForUniform;
  7491. private _updateVector3ForEffect;
  7492. private _updateVector3ForUniform;
  7493. private _updateVector4ForEffect;
  7494. private _updateVector4ForUniform;
  7495. private _updateColor3ForEffect;
  7496. private _updateColor3ForUniform;
  7497. private _updateColor4ForEffect;
  7498. private _updateColor4ForUniform;
  7499. /**
  7500. * Sets a sampler uniform on the effect.
  7501. * @param name Define the name of the sampler.
  7502. * @param texture Define the texture to set in the sampler
  7503. */
  7504. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7505. /**
  7506. * Directly updates the value of the uniform in the cache AND on the GPU.
  7507. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7508. * @param data Define the flattened data
  7509. */
  7510. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7511. /**
  7512. * Binds this uniform buffer to an effect.
  7513. * @param effect Define the effect to bind the buffer to
  7514. * @param name Name of the uniform block in the shader.
  7515. */
  7516. bindToEffect(effect: Effect, name: string): void;
  7517. /**
  7518. * Disposes the uniform buffer.
  7519. */
  7520. dispose(): void;
  7521. }
  7522. }
  7523. declare module BABYLON {
  7524. /**
  7525. * Enum that determines the text-wrapping mode to use.
  7526. */
  7527. export enum InspectableType {
  7528. /**
  7529. * Checkbox for booleans
  7530. */
  7531. Checkbox = 0,
  7532. /**
  7533. * Sliders for numbers
  7534. */
  7535. Slider = 1,
  7536. /**
  7537. * Vector3
  7538. */
  7539. Vector3 = 2,
  7540. /**
  7541. * Quaternions
  7542. */
  7543. Quaternion = 3,
  7544. /**
  7545. * Color3
  7546. */
  7547. Color3 = 4,
  7548. /**
  7549. * String
  7550. */
  7551. String = 5
  7552. }
  7553. /**
  7554. * Interface used to define custom inspectable properties.
  7555. * This interface is used by the inspector to display custom property grids
  7556. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7557. */
  7558. export interface IInspectable {
  7559. /**
  7560. * Gets the label to display
  7561. */
  7562. label: string;
  7563. /**
  7564. * Gets the name of the property to edit
  7565. */
  7566. propertyName: string;
  7567. /**
  7568. * Gets the type of the editor to use
  7569. */
  7570. type: InspectableType;
  7571. /**
  7572. * Gets the minimum value of the property when using in "slider" mode
  7573. */
  7574. min?: number;
  7575. /**
  7576. * Gets the maximum value of the property when using in "slider" mode
  7577. */
  7578. max?: number;
  7579. /**
  7580. * Gets the setp to use when using in "slider" mode
  7581. */
  7582. step?: number;
  7583. }
  7584. }
  7585. declare module BABYLON {
  7586. /**
  7587. * Class used to provide helper for timing
  7588. */
  7589. export class TimingTools {
  7590. /**
  7591. * Polyfill for setImmediate
  7592. * @param action defines the action to execute after the current execution block
  7593. */
  7594. static SetImmediate(action: () => void): void;
  7595. }
  7596. }
  7597. declare module BABYLON {
  7598. /**
  7599. * Class used to enable instatition of objects by class name
  7600. */
  7601. export class InstantiationTools {
  7602. /**
  7603. * Use this object to register external classes like custom textures or material
  7604. * to allow the laoders to instantiate them
  7605. */
  7606. static RegisteredExternalClasses: {
  7607. [key: string]: Object;
  7608. };
  7609. /**
  7610. * Tries to instantiate a new object from a given class name
  7611. * @param className defines the class name to instantiate
  7612. * @returns the new object or null if the system was not able to do the instantiation
  7613. */
  7614. static Instantiate(className: string): any;
  7615. }
  7616. }
  7617. declare module BABYLON {
  7618. /**
  7619. * Define options used to create a depth texture
  7620. */
  7621. export class DepthTextureCreationOptions {
  7622. /** Specifies whether or not a stencil should be allocated in the texture */
  7623. generateStencil?: boolean;
  7624. /** Specifies whether or not bilinear filtering is enable on the texture */
  7625. bilinearFiltering?: boolean;
  7626. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7627. comparisonFunction?: number;
  7628. /** Specifies if the created texture is a cube texture */
  7629. isCube?: boolean;
  7630. }
  7631. }
  7632. declare module BABYLON {
  7633. interface ThinEngine {
  7634. /**
  7635. * Creates a depth stencil cube texture.
  7636. * This is only available in WebGL 2.
  7637. * @param size The size of face edge in the cube texture.
  7638. * @param options The options defining the cube texture.
  7639. * @returns The cube texture
  7640. */
  7641. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7642. /**
  7643. * Creates a cube texture
  7644. * @param rootUrl defines the url where the files to load is located
  7645. * @param scene defines the current scene
  7646. * @param files defines the list of files to load (1 per face)
  7647. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7648. * @param onLoad defines an optional callback raised when the texture is loaded
  7649. * @param onError defines an optional callback raised if there is an issue to load the texture
  7650. * @param format defines the format of the data
  7651. * @param forcedExtension defines the extension to use to pick the right loader
  7652. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7653. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7654. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7655. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7656. * @returns the cube texture as an InternalTexture
  7657. */
  7658. 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;
  7659. /**
  7660. * Creates a cube texture
  7661. * @param rootUrl defines the url where the files to load is located
  7662. * @param scene defines the current scene
  7663. * @param files defines the list of files to load (1 per face)
  7664. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7665. * @param onLoad defines an optional callback raised when the texture is loaded
  7666. * @param onError defines an optional callback raised if there is an issue to load the texture
  7667. * @param format defines the format of the data
  7668. * @param forcedExtension defines the extension to use to pick the right loader
  7669. * @returns the cube texture as an InternalTexture
  7670. */
  7671. 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;
  7672. /**
  7673. * Creates a cube texture
  7674. * @param rootUrl defines the url where the files to load is located
  7675. * @param scene defines the current scene
  7676. * @param files defines the list of files to load (1 per face)
  7677. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7678. * @param onLoad defines an optional callback raised when the texture is loaded
  7679. * @param onError defines an optional callback raised if there is an issue to load the texture
  7680. * @param format defines the format of the data
  7681. * @param forcedExtension defines the extension to use to pick the right loader
  7682. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7683. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7684. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7685. * @returns the cube texture as an InternalTexture
  7686. */
  7687. 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;
  7688. /** @hidden */
  7689. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7690. /** @hidden */
  7691. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7692. /** @hidden */
  7693. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7694. /** @hidden */
  7695. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7696. /**
  7697. * @hidden
  7698. */
  7699. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * Class for creating a cube texture
  7705. */
  7706. export class CubeTexture extends BaseTexture {
  7707. private _delayedOnLoad;
  7708. /**
  7709. * Observable triggered once the texture has been loaded.
  7710. */
  7711. onLoadObservable: Observable<CubeTexture>;
  7712. /**
  7713. * The url of the texture
  7714. */
  7715. url: string;
  7716. /**
  7717. * Gets or sets the center of the bounding box associated with the cube texture.
  7718. * It must define where the camera used to render the texture was set
  7719. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7720. */
  7721. boundingBoxPosition: Vector3;
  7722. private _boundingBoxSize;
  7723. /**
  7724. * Gets or sets the size of the bounding box associated with the cube texture
  7725. * When defined, the cubemap will switch to local mode
  7726. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7727. * @example https://www.babylonjs-playground.com/#RNASML
  7728. */
  7729. set boundingBoxSize(value: Vector3);
  7730. /**
  7731. * Returns the bounding box size
  7732. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7733. */
  7734. get boundingBoxSize(): Vector3;
  7735. protected _rotationY: number;
  7736. /**
  7737. * Sets texture matrix rotation angle around Y axis in radians.
  7738. */
  7739. set rotationY(value: number);
  7740. /**
  7741. * Gets texture matrix rotation angle around Y axis radians.
  7742. */
  7743. get rotationY(): number;
  7744. /**
  7745. * Are mip maps generated for this texture or not.
  7746. */
  7747. get noMipmap(): boolean;
  7748. private _noMipmap;
  7749. private _files;
  7750. protected _forcedExtension: Nullable<string>;
  7751. private _extensions;
  7752. private _textureMatrix;
  7753. private _format;
  7754. private _createPolynomials;
  7755. /**
  7756. * Creates a cube texture from an array of image urls
  7757. * @param files defines an array of image urls
  7758. * @param scene defines the hosting scene
  7759. * @param noMipmap specifies if mip maps are not used
  7760. * @returns a cube texture
  7761. */
  7762. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7763. /**
  7764. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7765. * @param url defines the url of the prefiltered texture
  7766. * @param scene defines the scene the texture is attached to
  7767. * @param forcedExtension defines the extension of the file if different from the url
  7768. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7769. * @return the prefiltered texture
  7770. */
  7771. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7772. /**
  7773. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7774. * as prefiltered data.
  7775. * @param rootUrl defines the url of the texture or the root name of the six images
  7776. * @param null defines the scene or engine the texture is attached to
  7777. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7778. * @param noMipmap defines if mipmaps should be created or not
  7779. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7780. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7781. * @param onError defines a callback triggered in case of error during load
  7782. * @param format defines the internal format to use for the texture once loaded
  7783. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7784. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7785. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7786. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7787. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7788. * @return the cube texture
  7789. */
  7790. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, 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);
  7791. /**
  7792. * Get the current class name of the texture useful for serialization or dynamic coding.
  7793. * @returns "CubeTexture"
  7794. */
  7795. getClassName(): string;
  7796. /**
  7797. * Update the url (and optional buffer) of this texture if url was null during construction.
  7798. * @param url the url of the texture
  7799. * @param forcedExtension defines the extension to use
  7800. * @param onLoad callback called when the texture is loaded (defaults to null)
  7801. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7802. */
  7803. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7804. /**
  7805. * Delays loading of the cube texture
  7806. * @param forcedExtension defines the extension to use
  7807. */
  7808. delayLoad(forcedExtension?: string): void;
  7809. /**
  7810. * Returns the reflection texture matrix
  7811. * @returns the reflection texture matrix
  7812. */
  7813. getReflectionTextureMatrix(): Matrix;
  7814. /**
  7815. * Sets the reflection texture matrix
  7816. * @param value Reflection texture matrix
  7817. */
  7818. setReflectionTextureMatrix(value: Matrix): void;
  7819. /**
  7820. * Parses text to create a cube texture
  7821. * @param parsedTexture define the serialized text to read from
  7822. * @param scene defines the hosting scene
  7823. * @param rootUrl defines the root url of the cube texture
  7824. * @returns a cube texture
  7825. */
  7826. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7827. /**
  7828. * Makes a clone, or deep copy, of the cube texture
  7829. * @returns a new cube texture
  7830. */
  7831. clone(): CubeTexture;
  7832. }
  7833. }
  7834. declare module BABYLON {
  7835. /**
  7836. * Manages the defines for the Material
  7837. */
  7838. export class MaterialDefines {
  7839. /** @hidden */
  7840. protected _keys: string[];
  7841. private _isDirty;
  7842. /** @hidden */
  7843. _renderId: number;
  7844. /** @hidden */
  7845. _areLightsDirty: boolean;
  7846. /** @hidden */
  7847. _areLightsDisposed: boolean;
  7848. /** @hidden */
  7849. _areAttributesDirty: boolean;
  7850. /** @hidden */
  7851. _areTexturesDirty: boolean;
  7852. /** @hidden */
  7853. _areFresnelDirty: boolean;
  7854. /** @hidden */
  7855. _areMiscDirty: boolean;
  7856. /** @hidden */
  7857. _areImageProcessingDirty: boolean;
  7858. /** @hidden */
  7859. _normals: boolean;
  7860. /** @hidden */
  7861. _uvs: boolean;
  7862. /** @hidden */
  7863. _needNormals: boolean;
  7864. /** @hidden */
  7865. _needUVs: boolean;
  7866. [id: string]: any;
  7867. /**
  7868. * Specifies if the material needs to be re-calculated
  7869. */
  7870. get isDirty(): boolean;
  7871. /**
  7872. * Marks the material to indicate that it has been re-calculated
  7873. */
  7874. markAsProcessed(): void;
  7875. /**
  7876. * Marks the material to indicate that it needs to be re-calculated
  7877. */
  7878. markAsUnprocessed(): void;
  7879. /**
  7880. * Marks the material to indicate all of its defines need to be re-calculated
  7881. */
  7882. markAllAsDirty(): void;
  7883. /**
  7884. * Marks the material to indicate that image processing needs to be re-calculated
  7885. */
  7886. markAsImageProcessingDirty(): void;
  7887. /**
  7888. * Marks the material to indicate the lights need to be re-calculated
  7889. * @param disposed Defines whether the light is dirty due to dispose or not
  7890. */
  7891. markAsLightDirty(disposed?: boolean): void;
  7892. /**
  7893. * Marks the attribute state as changed
  7894. */
  7895. markAsAttributesDirty(): void;
  7896. /**
  7897. * Marks the texture state as changed
  7898. */
  7899. markAsTexturesDirty(): void;
  7900. /**
  7901. * Marks the fresnel state as changed
  7902. */
  7903. markAsFresnelDirty(): void;
  7904. /**
  7905. * Marks the misc state as changed
  7906. */
  7907. markAsMiscDirty(): void;
  7908. /**
  7909. * Rebuilds the material defines
  7910. */
  7911. rebuild(): void;
  7912. /**
  7913. * Specifies if two material defines are equal
  7914. * @param other - A material define instance to compare to
  7915. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7916. */
  7917. isEqual(other: MaterialDefines): boolean;
  7918. /**
  7919. * Clones this instance's defines to another instance
  7920. * @param other - material defines to clone values to
  7921. */
  7922. cloneTo(other: MaterialDefines): void;
  7923. /**
  7924. * Resets the material define values
  7925. */
  7926. reset(): void;
  7927. /**
  7928. * Converts the material define values to a string
  7929. * @returns - String of material define information
  7930. */
  7931. toString(): string;
  7932. }
  7933. }
  7934. declare module BABYLON {
  7935. /**
  7936. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7937. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7938. * 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;
  7939. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7940. */
  7941. export class ColorCurves {
  7942. private _dirty;
  7943. private _tempColor;
  7944. private _globalCurve;
  7945. private _highlightsCurve;
  7946. private _midtonesCurve;
  7947. private _shadowsCurve;
  7948. private _positiveCurve;
  7949. private _negativeCurve;
  7950. private _globalHue;
  7951. private _globalDensity;
  7952. private _globalSaturation;
  7953. private _globalExposure;
  7954. /**
  7955. * Gets the global Hue value.
  7956. * 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).
  7957. */
  7958. get globalHue(): number;
  7959. /**
  7960. * Sets the global Hue value.
  7961. * 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).
  7962. */
  7963. set globalHue(value: number);
  7964. /**
  7965. * Gets the global Density value.
  7966. * 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.
  7967. * Values less than zero provide a filter of opposite hue.
  7968. */
  7969. get globalDensity(): number;
  7970. /**
  7971. * Sets the global Density value.
  7972. * 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.
  7973. * Values less than zero provide a filter of opposite hue.
  7974. */
  7975. set globalDensity(value: number);
  7976. /**
  7977. * Gets the global Saturation value.
  7978. * 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.
  7979. */
  7980. get globalSaturation(): number;
  7981. /**
  7982. * Sets the global Saturation value.
  7983. * 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.
  7984. */
  7985. set globalSaturation(value: number);
  7986. /**
  7987. * Gets the global Exposure value.
  7988. * 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.
  7989. */
  7990. get globalExposure(): number;
  7991. /**
  7992. * Sets the global Exposure value.
  7993. * 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.
  7994. */
  7995. set globalExposure(value: number);
  7996. private _highlightsHue;
  7997. private _highlightsDensity;
  7998. private _highlightsSaturation;
  7999. private _highlightsExposure;
  8000. /**
  8001. * Gets the highlights Hue value.
  8002. * 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).
  8003. */
  8004. get highlightsHue(): number;
  8005. /**
  8006. * Sets the highlights Hue value.
  8007. * 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).
  8008. */
  8009. set highlightsHue(value: number);
  8010. /**
  8011. * Gets the highlights Density value.
  8012. * 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.
  8013. * Values less than zero provide a filter of opposite hue.
  8014. */
  8015. get highlightsDensity(): number;
  8016. /**
  8017. * Sets the highlights Density value.
  8018. * 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.
  8019. * Values less than zero provide a filter of opposite hue.
  8020. */
  8021. set highlightsDensity(value: number);
  8022. /**
  8023. * Gets the highlights Saturation value.
  8024. * 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.
  8025. */
  8026. get highlightsSaturation(): number;
  8027. /**
  8028. * Sets the highlights Saturation value.
  8029. * 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.
  8030. */
  8031. set highlightsSaturation(value: number);
  8032. /**
  8033. * Gets the highlights Exposure value.
  8034. * 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.
  8035. */
  8036. get highlightsExposure(): number;
  8037. /**
  8038. * Sets the highlights Exposure value.
  8039. * 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.
  8040. */
  8041. set highlightsExposure(value: number);
  8042. private _midtonesHue;
  8043. private _midtonesDensity;
  8044. private _midtonesSaturation;
  8045. private _midtonesExposure;
  8046. /**
  8047. * Gets the midtones Hue value.
  8048. * 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).
  8049. */
  8050. get midtonesHue(): number;
  8051. /**
  8052. * Sets the midtones Hue value.
  8053. * 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).
  8054. */
  8055. set midtonesHue(value: number);
  8056. /**
  8057. * Gets the midtones Density value.
  8058. * 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.
  8059. * Values less than zero provide a filter of opposite hue.
  8060. */
  8061. get midtonesDensity(): number;
  8062. /**
  8063. * Sets the midtones Density value.
  8064. * 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.
  8065. * Values less than zero provide a filter of opposite hue.
  8066. */
  8067. set midtonesDensity(value: number);
  8068. /**
  8069. * Gets the midtones Saturation value.
  8070. * 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.
  8071. */
  8072. get midtonesSaturation(): number;
  8073. /**
  8074. * Sets the midtones Saturation value.
  8075. * 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.
  8076. */
  8077. set midtonesSaturation(value: number);
  8078. /**
  8079. * Gets the midtones Exposure value.
  8080. * 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.
  8081. */
  8082. get midtonesExposure(): number;
  8083. /**
  8084. * Sets the midtones Exposure value.
  8085. * 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.
  8086. */
  8087. set midtonesExposure(value: number);
  8088. private _shadowsHue;
  8089. private _shadowsDensity;
  8090. private _shadowsSaturation;
  8091. private _shadowsExposure;
  8092. /**
  8093. * Gets the shadows Hue value.
  8094. * 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).
  8095. */
  8096. get shadowsHue(): number;
  8097. /**
  8098. * Sets the shadows Hue value.
  8099. * 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).
  8100. */
  8101. set shadowsHue(value: number);
  8102. /**
  8103. * Gets the shadows Density value.
  8104. * 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.
  8105. * Values less than zero provide a filter of opposite hue.
  8106. */
  8107. get shadowsDensity(): number;
  8108. /**
  8109. * Sets the shadows Density value.
  8110. * 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.
  8111. * Values less than zero provide a filter of opposite hue.
  8112. */
  8113. set shadowsDensity(value: number);
  8114. /**
  8115. * Gets the shadows Saturation value.
  8116. * 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.
  8117. */
  8118. get shadowsSaturation(): number;
  8119. /**
  8120. * Sets the shadows Saturation value.
  8121. * 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.
  8122. */
  8123. set shadowsSaturation(value: number);
  8124. /**
  8125. * Gets the shadows Exposure value.
  8126. * 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.
  8127. */
  8128. get shadowsExposure(): number;
  8129. /**
  8130. * Sets the shadows Exposure value.
  8131. * 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.
  8132. */
  8133. set shadowsExposure(value: number);
  8134. /**
  8135. * Returns the class name
  8136. * @returns The class name
  8137. */
  8138. getClassName(): string;
  8139. /**
  8140. * Binds the color curves to the shader.
  8141. * @param colorCurves The color curve to bind
  8142. * @param effect The effect to bind to
  8143. * @param positiveUniform The positive uniform shader parameter
  8144. * @param neutralUniform The neutral uniform shader parameter
  8145. * @param negativeUniform The negative uniform shader parameter
  8146. */
  8147. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8148. /**
  8149. * Prepare the list of uniforms associated with the ColorCurves effects.
  8150. * @param uniformsList The list of uniforms used in the effect
  8151. */
  8152. static PrepareUniforms(uniformsList: string[]): void;
  8153. /**
  8154. * Returns color grading data based on a hue, density, saturation and exposure value.
  8155. * @param filterHue The hue of the color filter.
  8156. * @param filterDensity The density of the color filter.
  8157. * @param saturation The saturation.
  8158. * @param exposure The exposure.
  8159. * @param result The result data container.
  8160. */
  8161. private getColorGradingDataToRef;
  8162. /**
  8163. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8164. * @param value The input slider value in range [-100,100].
  8165. * @returns Adjusted value.
  8166. */
  8167. private static applyColorGradingSliderNonlinear;
  8168. /**
  8169. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8170. * @param hue The hue (H) input.
  8171. * @param saturation The saturation (S) input.
  8172. * @param brightness The brightness (B) input.
  8173. * @result An RGBA color represented as Vector4.
  8174. */
  8175. private static fromHSBToRef;
  8176. /**
  8177. * Returns a value clamped between min and max
  8178. * @param value The value to clamp
  8179. * @param min The minimum of value
  8180. * @param max The maximum of value
  8181. * @returns The clamped value.
  8182. */
  8183. private static clamp;
  8184. /**
  8185. * Clones the current color curve instance.
  8186. * @return The cloned curves
  8187. */
  8188. clone(): ColorCurves;
  8189. /**
  8190. * Serializes the current color curve instance to a json representation.
  8191. * @return a JSON representation
  8192. */
  8193. serialize(): any;
  8194. /**
  8195. * Parses the color curve from a json representation.
  8196. * @param source the JSON source to parse
  8197. * @return The parsed curves
  8198. */
  8199. static Parse(source: any): ColorCurves;
  8200. }
  8201. }
  8202. declare module BABYLON {
  8203. /**
  8204. * Interface to follow in your material defines to integrate easily the
  8205. * Image proccessing functions.
  8206. * @hidden
  8207. */
  8208. export interface IImageProcessingConfigurationDefines {
  8209. IMAGEPROCESSING: boolean;
  8210. VIGNETTE: boolean;
  8211. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8212. VIGNETTEBLENDMODEOPAQUE: boolean;
  8213. TONEMAPPING: boolean;
  8214. TONEMAPPING_ACES: boolean;
  8215. CONTRAST: boolean;
  8216. EXPOSURE: boolean;
  8217. COLORCURVES: boolean;
  8218. COLORGRADING: boolean;
  8219. COLORGRADING3D: boolean;
  8220. SAMPLER3DGREENDEPTH: boolean;
  8221. SAMPLER3DBGRMAP: boolean;
  8222. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8223. }
  8224. /**
  8225. * @hidden
  8226. */
  8227. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8228. IMAGEPROCESSING: boolean;
  8229. VIGNETTE: boolean;
  8230. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8231. VIGNETTEBLENDMODEOPAQUE: boolean;
  8232. TONEMAPPING: boolean;
  8233. TONEMAPPING_ACES: boolean;
  8234. CONTRAST: boolean;
  8235. COLORCURVES: boolean;
  8236. COLORGRADING: boolean;
  8237. COLORGRADING3D: boolean;
  8238. SAMPLER3DGREENDEPTH: boolean;
  8239. SAMPLER3DBGRMAP: boolean;
  8240. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8241. EXPOSURE: boolean;
  8242. constructor();
  8243. }
  8244. /**
  8245. * This groups together the common properties used for image processing either in direct forward pass
  8246. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8247. * or not.
  8248. */
  8249. export class ImageProcessingConfiguration {
  8250. /**
  8251. * Default tone mapping applied in BabylonJS.
  8252. */
  8253. static readonly TONEMAPPING_STANDARD: number;
  8254. /**
  8255. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8256. * to other engines rendering to increase portability.
  8257. */
  8258. static readonly TONEMAPPING_ACES: number;
  8259. /**
  8260. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8261. */
  8262. colorCurves: Nullable<ColorCurves>;
  8263. private _colorCurvesEnabled;
  8264. /**
  8265. * Gets wether the color curves effect is enabled.
  8266. */
  8267. get colorCurvesEnabled(): boolean;
  8268. /**
  8269. * Sets wether the color curves effect is enabled.
  8270. */
  8271. set colorCurvesEnabled(value: boolean);
  8272. private _colorGradingTexture;
  8273. /**
  8274. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8275. */
  8276. get colorGradingTexture(): Nullable<BaseTexture>;
  8277. /**
  8278. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8279. */
  8280. set colorGradingTexture(value: Nullable<BaseTexture>);
  8281. private _colorGradingEnabled;
  8282. /**
  8283. * Gets wether the color grading effect is enabled.
  8284. */
  8285. get colorGradingEnabled(): boolean;
  8286. /**
  8287. * Sets wether the color grading effect is enabled.
  8288. */
  8289. set colorGradingEnabled(value: boolean);
  8290. private _colorGradingWithGreenDepth;
  8291. /**
  8292. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8293. */
  8294. get colorGradingWithGreenDepth(): boolean;
  8295. /**
  8296. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8297. */
  8298. set colorGradingWithGreenDepth(value: boolean);
  8299. private _colorGradingBGR;
  8300. /**
  8301. * Gets wether the color grading texture contains BGR values.
  8302. */
  8303. get colorGradingBGR(): boolean;
  8304. /**
  8305. * Sets wether the color grading texture contains BGR values.
  8306. */
  8307. set colorGradingBGR(value: boolean);
  8308. /** @hidden */
  8309. _exposure: number;
  8310. /**
  8311. * Gets the Exposure used in the effect.
  8312. */
  8313. get exposure(): number;
  8314. /**
  8315. * Sets the Exposure used in the effect.
  8316. */
  8317. set exposure(value: number);
  8318. private _toneMappingEnabled;
  8319. /**
  8320. * Gets wether the tone mapping effect is enabled.
  8321. */
  8322. get toneMappingEnabled(): boolean;
  8323. /**
  8324. * Sets wether the tone mapping effect is enabled.
  8325. */
  8326. set toneMappingEnabled(value: boolean);
  8327. private _toneMappingType;
  8328. /**
  8329. * Gets the type of tone mapping effect.
  8330. */
  8331. get toneMappingType(): number;
  8332. /**
  8333. * Sets the type of tone mapping effect used in BabylonJS.
  8334. */
  8335. set toneMappingType(value: number);
  8336. protected _contrast: number;
  8337. /**
  8338. * Gets the contrast used in the effect.
  8339. */
  8340. get contrast(): number;
  8341. /**
  8342. * Sets the contrast used in the effect.
  8343. */
  8344. set contrast(value: number);
  8345. /**
  8346. * Vignette stretch size.
  8347. */
  8348. vignetteStretch: number;
  8349. /**
  8350. * Vignette centre X Offset.
  8351. */
  8352. vignetteCentreX: number;
  8353. /**
  8354. * Vignette centre Y Offset.
  8355. */
  8356. vignetteCentreY: number;
  8357. /**
  8358. * Vignette weight or intensity of the vignette effect.
  8359. */
  8360. vignetteWeight: number;
  8361. /**
  8362. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8363. * if vignetteEnabled is set to true.
  8364. */
  8365. vignetteColor: Color4;
  8366. /**
  8367. * Camera field of view used by the Vignette effect.
  8368. */
  8369. vignetteCameraFov: number;
  8370. private _vignetteBlendMode;
  8371. /**
  8372. * Gets the vignette blend mode allowing different kind of effect.
  8373. */
  8374. get vignetteBlendMode(): number;
  8375. /**
  8376. * Sets the vignette blend mode allowing different kind of effect.
  8377. */
  8378. set vignetteBlendMode(value: number);
  8379. private _vignetteEnabled;
  8380. /**
  8381. * Gets wether the vignette effect is enabled.
  8382. */
  8383. get vignetteEnabled(): boolean;
  8384. /**
  8385. * Sets wether the vignette effect is enabled.
  8386. */
  8387. set vignetteEnabled(value: boolean);
  8388. private _applyByPostProcess;
  8389. /**
  8390. * Gets wether the image processing is applied through a post process or not.
  8391. */
  8392. get applyByPostProcess(): boolean;
  8393. /**
  8394. * Sets wether the image processing is applied through a post process or not.
  8395. */
  8396. set applyByPostProcess(value: boolean);
  8397. private _isEnabled;
  8398. /**
  8399. * Gets wether the image processing is enabled or not.
  8400. */
  8401. get isEnabled(): boolean;
  8402. /**
  8403. * Sets wether the image processing is enabled or not.
  8404. */
  8405. set isEnabled(value: boolean);
  8406. /**
  8407. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8408. */
  8409. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8410. /**
  8411. * Method called each time the image processing information changes requires to recompile the effect.
  8412. */
  8413. protected _updateParameters(): void;
  8414. /**
  8415. * Gets the current class name.
  8416. * @return "ImageProcessingConfiguration"
  8417. */
  8418. getClassName(): string;
  8419. /**
  8420. * Prepare the list of uniforms associated with the Image Processing effects.
  8421. * @param uniforms The list of uniforms used in the effect
  8422. * @param defines the list of defines currently in use
  8423. */
  8424. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8425. /**
  8426. * Prepare the list of samplers associated with the Image Processing effects.
  8427. * @param samplersList The list of uniforms used in the effect
  8428. * @param defines the list of defines currently in use
  8429. */
  8430. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8431. /**
  8432. * Prepare the list of defines associated to the shader.
  8433. * @param defines the list of defines to complete
  8434. * @param forPostProcess Define if we are currently in post process mode or not
  8435. */
  8436. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8437. /**
  8438. * Returns true if all the image processing information are ready.
  8439. * @returns True if ready, otherwise, false
  8440. */
  8441. isReady(): boolean;
  8442. /**
  8443. * Binds the image processing to the shader.
  8444. * @param effect The effect to bind to
  8445. * @param overrideAspectRatio Override the aspect ratio of the effect
  8446. */
  8447. bind(effect: Effect, overrideAspectRatio?: number): void;
  8448. /**
  8449. * Clones the current image processing instance.
  8450. * @return The cloned image processing
  8451. */
  8452. clone(): ImageProcessingConfiguration;
  8453. /**
  8454. * Serializes the current image processing instance to a json representation.
  8455. * @return a JSON representation
  8456. */
  8457. serialize(): any;
  8458. /**
  8459. * Parses the image processing from a json representation.
  8460. * @param source the JSON source to parse
  8461. * @return The parsed image processing
  8462. */
  8463. static Parse(source: any): ImageProcessingConfiguration;
  8464. private static _VIGNETTEMODE_MULTIPLY;
  8465. private static _VIGNETTEMODE_OPAQUE;
  8466. /**
  8467. * Used to apply the vignette as a mix with the pixel color.
  8468. */
  8469. static get VIGNETTEMODE_MULTIPLY(): number;
  8470. /**
  8471. * Used to apply the vignette as a replacement of the pixel color.
  8472. */
  8473. static get VIGNETTEMODE_OPAQUE(): number;
  8474. }
  8475. }
  8476. declare module BABYLON {
  8477. /** @hidden */
  8478. export var postprocessVertexShader: {
  8479. name: string;
  8480. shader: string;
  8481. };
  8482. }
  8483. declare module BABYLON {
  8484. interface ThinEngine {
  8485. /**
  8486. * Creates a new render target texture
  8487. * @param size defines the size of the texture
  8488. * @param options defines the options used to create the texture
  8489. * @returns a new render target texture stored in an InternalTexture
  8490. */
  8491. createRenderTargetTexture(size: number | {
  8492. width: number;
  8493. height: number;
  8494. layers?: number;
  8495. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8496. /**
  8497. * Creates a depth stencil texture.
  8498. * This is only available in WebGL 2 or with the depth texture extension available.
  8499. * @param size The size of face edge in the texture.
  8500. * @param options The options defining the texture.
  8501. * @returns The texture
  8502. */
  8503. createDepthStencilTexture(size: number | {
  8504. width: number;
  8505. height: number;
  8506. layers?: number;
  8507. }, options: DepthTextureCreationOptions): InternalTexture;
  8508. /** @hidden */
  8509. _createDepthStencilTexture(size: number | {
  8510. width: number;
  8511. height: number;
  8512. layers?: number;
  8513. }, options: DepthTextureCreationOptions): InternalTexture;
  8514. }
  8515. }
  8516. declare module BABYLON {
  8517. /**
  8518. * Defines the kind of connection point for node based material
  8519. */
  8520. export enum NodeMaterialBlockConnectionPointTypes {
  8521. /** Float */
  8522. Float = 1,
  8523. /** Int */
  8524. Int = 2,
  8525. /** Vector2 */
  8526. Vector2 = 4,
  8527. /** Vector3 */
  8528. Vector3 = 8,
  8529. /** Vector4 */
  8530. Vector4 = 16,
  8531. /** Color3 */
  8532. Color3 = 32,
  8533. /** Color4 */
  8534. Color4 = 64,
  8535. /** Matrix */
  8536. Matrix = 128,
  8537. /** Custom object */
  8538. Object = 256,
  8539. /** Detect type based on connection */
  8540. AutoDetect = 1024,
  8541. /** Output type that will be defined by input type */
  8542. BasedOnInput = 2048
  8543. }
  8544. }
  8545. declare module BABYLON {
  8546. /**
  8547. * Enum used to define the target of a block
  8548. */
  8549. export enum NodeMaterialBlockTargets {
  8550. /** Vertex shader */
  8551. Vertex = 1,
  8552. /** Fragment shader */
  8553. Fragment = 2,
  8554. /** Neutral */
  8555. Neutral = 4,
  8556. /** Vertex and Fragment */
  8557. VertexAndFragment = 3
  8558. }
  8559. }
  8560. declare module BABYLON {
  8561. /**
  8562. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8563. */
  8564. export enum NodeMaterialBlockConnectionPointMode {
  8565. /** Value is an uniform */
  8566. Uniform = 0,
  8567. /** Value is a mesh attribute */
  8568. Attribute = 1,
  8569. /** Value is a varying between vertex and fragment shaders */
  8570. Varying = 2,
  8571. /** Mode is undefined */
  8572. Undefined = 3
  8573. }
  8574. }
  8575. declare module BABYLON {
  8576. /**
  8577. * Enum used to define system values e.g. values automatically provided by the system
  8578. */
  8579. export enum NodeMaterialSystemValues {
  8580. /** World */
  8581. World = 1,
  8582. /** View */
  8583. View = 2,
  8584. /** Projection */
  8585. Projection = 3,
  8586. /** ViewProjection */
  8587. ViewProjection = 4,
  8588. /** WorldView */
  8589. WorldView = 5,
  8590. /** WorldViewProjection */
  8591. WorldViewProjection = 6,
  8592. /** CameraPosition */
  8593. CameraPosition = 7,
  8594. /** Fog Color */
  8595. FogColor = 8,
  8596. /** Delta time */
  8597. DeltaTime = 9
  8598. }
  8599. }
  8600. declare module BABYLON {
  8601. /** Defines supported spaces */
  8602. export enum Space {
  8603. /** Local (object) space */
  8604. LOCAL = 0,
  8605. /** World space */
  8606. WORLD = 1,
  8607. /** Bone space */
  8608. BONE = 2
  8609. }
  8610. /** Defines the 3 main axes */
  8611. export class Axis {
  8612. /** X axis */
  8613. static X: Vector3;
  8614. /** Y axis */
  8615. static Y: Vector3;
  8616. /** Z axis */
  8617. static Z: Vector3;
  8618. }
  8619. }
  8620. declare module BABYLON {
  8621. /**
  8622. * Represents a camera frustum
  8623. */
  8624. export class Frustum {
  8625. /**
  8626. * Gets the planes representing the frustum
  8627. * @param transform matrix to be applied to the returned planes
  8628. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8629. */
  8630. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8631. /**
  8632. * Gets the near frustum plane transformed by the transform matrix
  8633. * @param transform transformation matrix to be applied to the resulting frustum plane
  8634. * @param frustumPlane the resuling frustum plane
  8635. */
  8636. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8637. /**
  8638. * Gets the far frustum plane transformed by the transform matrix
  8639. * @param transform transformation matrix to be applied to the resulting frustum plane
  8640. * @param frustumPlane the resuling frustum plane
  8641. */
  8642. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8643. /**
  8644. * Gets the left frustum plane transformed by the transform matrix
  8645. * @param transform transformation matrix to be applied to the resulting frustum plane
  8646. * @param frustumPlane the resuling frustum plane
  8647. */
  8648. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8649. /**
  8650. * Gets the right frustum plane transformed by the transform matrix
  8651. * @param transform transformation matrix to be applied to the resulting frustum plane
  8652. * @param frustumPlane the resuling frustum plane
  8653. */
  8654. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8655. /**
  8656. * Gets the top frustum plane transformed by the transform matrix
  8657. * @param transform transformation matrix to be applied to the resulting frustum plane
  8658. * @param frustumPlane the resuling frustum plane
  8659. */
  8660. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8661. /**
  8662. * Gets the bottom frustum plane transformed by the transform matrix
  8663. * @param transform transformation matrix to be applied to the resulting frustum plane
  8664. * @param frustumPlane the resuling frustum plane
  8665. */
  8666. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8667. /**
  8668. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8669. * @param transform transformation matrix to be applied to the resulting frustum planes
  8670. * @param frustumPlanes the resuling frustum planes
  8671. */
  8672. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8673. }
  8674. }
  8675. declare module BABYLON {
  8676. /**
  8677. * Interface for the size containing width and height
  8678. */
  8679. export interface ISize {
  8680. /**
  8681. * Width
  8682. */
  8683. width: number;
  8684. /**
  8685. * Heighht
  8686. */
  8687. height: number;
  8688. }
  8689. /**
  8690. * Size containing widht and height
  8691. */
  8692. export class Size implements ISize {
  8693. /**
  8694. * Width
  8695. */
  8696. width: number;
  8697. /**
  8698. * Height
  8699. */
  8700. height: number;
  8701. /**
  8702. * Creates a Size object from the given width and height (floats).
  8703. * @param width width of the new size
  8704. * @param height height of the new size
  8705. */
  8706. constructor(width: number, height: number);
  8707. /**
  8708. * Returns a string with the Size width and height
  8709. * @returns a string with the Size width and height
  8710. */
  8711. toString(): string;
  8712. /**
  8713. * "Size"
  8714. * @returns the string "Size"
  8715. */
  8716. getClassName(): string;
  8717. /**
  8718. * Returns the Size hash code.
  8719. * @returns a hash code for a unique width and height
  8720. */
  8721. getHashCode(): number;
  8722. /**
  8723. * Updates the current size from the given one.
  8724. * @param src the given size
  8725. */
  8726. copyFrom(src: Size): void;
  8727. /**
  8728. * Updates in place the current Size from the given floats.
  8729. * @param width width of the new size
  8730. * @param height height of the new size
  8731. * @returns the updated Size.
  8732. */
  8733. copyFromFloats(width: number, height: number): Size;
  8734. /**
  8735. * Updates in place the current Size from the given floats.
  8736. * @param width width to set
  8737. * @param height height to set
  8738. * @returns the updated Size.
  8739. */
  8740. set(width: number, height: number): Size;
  8741. /**
  8742. * Multiplies the width and height by numbers
  8743. * @param w factor to multiple the width by
  8744. * @param h factor to multiple the height by
  8745. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8746. */
  8747. multiplyByFloats(w: number, h: number): Size;
  8748. /**
  8749. * Clones the size
  8750. * @returns a new Size copied from the given one.
  8751. */
  8752. clone(): Size;
  8753. /**
  8754. * True if the current Size and the given one width and height are strictly equal.
  8755. * @param other the other size to compare against
  8756. * @returns True if the current Size and the given one width and height are strictly equal.
  8757. */
  8758. equals(other: Size): boolean;
  8759. /**
  8760. * The surface of the Size : width * height (float).
  8761. */
  8762. get surface(): number;
  8763. /**
  8764. * Create a new size of zero
  8765. * @returns a new Size set to (0.0, 0.0)
  8766. */
  8767. static Zero(): Size;
  8768. /**
  8769. * Sums the width and height of two sizes
  8770. * @param otherSize size to add to this size
  8771. * @returns a new Size set as the addition result of the current Size and the given one.
  8772. */
  8773. add(otherSize: Size): Size;
  8774. /**
  8775. * Subtracts the width and height of two
  8776. * @param otherSize size to subtract to this size
  8777. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8778. */
  8779. subtract(otherSize: Size): Size;
  8780. /**
  8781. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8782. * @param start starting size to lerp between
  8783. * @param end end size to lerp between
  8784. * @param amount amount to lerp between the start and end values
  8785. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8786. */
  8787. static Lerp(start: Size, end: Size, amount: number): Size;
  8788. }
  8789. }
  8790. declare module BABYLON {
  8791. /**
  8792. * Contains position and normal vectors for a vertex
  8793. */
  8794. export class PositionNormalVertex {
  8795. /** the position of the vertex (defaut: 0,0,0) */
  8796. position: Vector3;
  8797. /** the normal of the vertex (defaut: 0,1,0) */
  8798. normal: Vector3;
  8799. /**
  8800. * Creates a PositionNormalVertex
  8801. * @param position the position of the vertex (defaut: 0,0,0)
  8802. * @param normal the normal of the vertex (defaut: 0,1,0)
  8803. */
  8804. constructor(
  8805. /** the position of the vertex (defaut: 0,0,0) */
  8806. position?: Vector3,
  8807. /** the normal of the vertex (defaut: 0,1,0) */
  8808. normal?: Vector3);
  8809. /**
  8810. * Clones the PositionNormalVertex
  8811. * @returns the cloned PositionNormalVertex
  8812. */
  8813. clone(): PositionNormalVertex;
  8814. }
  8815. /**
  8816. * Contains position, normal and uv vectors for a vertex
  8817. */
  8818. export class PositionNormalTextureVertex {
  8819. /** the position of the vertex (defaut: 0,0,0) */
  8820. position: Vector3;
  8821. /** the normal of the vertex (defaut: 0,1,0) */
  8822. normal: Vector3;
  8823. /** the uv of the vertex (default: 0,0) */
  8824. uv: Vector2;
  8825. /**
  8826. * Creates a PositionNormalTextureVertex
  8827. * @param position the position of the vertex (defaut: 0,0,0)
  8828. * @param normal the normal of the vertex (defaut: 0,1,0)
  8829. * @param uv the uv of the vertex (default: 0,0)
  8830. */
  8831. constructor(
  8832. /** the position of the vertex (defaut: 0,0,0) */
  8833. position?: Vector3,
  8834. /** the normal of the vertex (defaut: 0,1,0) */
  8835. normal?: Vector3,
  8836. /** the uv of the vertex (default: 0,0) */
  8837. uv?: Vector2);
  8838. /**
  8839. * Clones the PositionNormalTextureVertex
  8840. * @returns the cloned PositionNormalTextureVertex
  8841. */
  8842. clone(): PositionNormalTextureVertex;
  8843. }
  8844. }
  8845. declare module BABYLON {
  8846. /**
  8847. * Enum defining the type of animations supported by InputBlock
  8848. */
  8849. export enum AnimatedInputBlockTypes {
  8850. /** No animation */
  8851. None = 0,
  8852. /** Time based animation. Will only work for floats */
  8853. Time = 1
  8854. }
  8855. }
  8856. declare module BABYLON {
  8857. /**
  8858. * Interface describing all the common properties and methods a shadow light needs to implement.
  8859. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8860. * as well as binding the different shadow properties to the effects.
  8861. */
  8862. export interface IShadowLight extends Light {
  8863. /**
  8864. * The light id in the scene (used in scene.findLighById for instance)
  8865. */
  8866. id: string;
  8867. /**
  8868. * The position the shdow will be casted from.
  8869. */
  8870. position: Vector3;
  8871. /**
  8872. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8873. */
  8874. direction: Vector3;
  8875. /**
  8876. * The transformed position. Position of the light in world space taking parenting in account.
  8877. */
  8878. transformedPosition: Vector3;
  8879. /**
  8880. * The transformed direction. Direction of the light in world space taking parenting in account.
  8881. */
  8882. transformedDirection: Vector3;
  8883. /**
  8884. * The friendly name of the light in the scene.
  8885. */
  8886. name: string;
  8887. /**
  8888. * Defines the shadow projection clipping minimum z value.
  8889. */
  8890. shadowMinZ: number;
  8891. /**
  8892. * Defines the shadow projection clipping maximum z value.
  8893. */
  8894. shadowMaxZ: number;
  8895. /**
  8896. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8897. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8898. */
  8899. computeTransformedInformation(): boolean;
  8900. /**
  8901. * Gets the scene the light belongs to.
  8902. * @returns The scene
  8903. */
  8904. getScene(): Scene;
  8905. /**
  8906. * Callback defining a custom Projection Matrix Builder.
  8907. * This can be used to override the default projection matrix computation.
  8908. */
  8909. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8910. /**
  8911. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8912. * @param matrix The materix to updated with the projection information
  8913. * @param viewMatrix The transform matrix of the light
  8914. * @param renderList The list of mesh to render in the map
  8915. * @returns The current light
  8916. */
  8917. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8918. /**
  8919. * Gets the current depth scale used in ESM.
  8920. * @returns The scale
  8921. */
  8922. getDepthScale(): number;
  8923. /**
  8924. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8925. * @returns true if a cube texture needs to be use
  8926. */
  8927. needCube(): boolean;
  8928. /**
  8929. * Detects if the projection matrix requires to be recomputed this frame.
  8930. * @returns true if it requires to be recomputed otherwise, false.
  8931. */
  8932. needProjectionMatrixCompute(): boolean;
  8933. /**
  8934. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8935. */
  8936. forceProjectionMatrixCompute(): void;
  8937. /**
  8938. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8939. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8940. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8941. */
  8942. getShadowDirection(faceIndex?: number): Vector3;
  8943. /**
  8944. * Gets the minZ used for shadow according to both the scene and the light.
  8945. * @param activeCamera The camera we are returning the min for
  8946. * @returns the depth min z
  8947. */
  8948. getDepthMinZ(activeCamera: Camera): number;
  8949. /**
  8950. * Gets the maxZ used for shadow according to both the scene and the light.
  8951. * @param activeCamera The camera we are returning the max for
  8952. * @returns the depth max z
  8953. */
  8954. getDepthMaxZ(activeCamera: Camera): number;
  8955. }
  8956. /**
  8957. * Base implementation IShadowLight
  8958. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8959. */
  8960. export abstract class ShadowLight extends Light implements IShadowLight {
  8961. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8962. protected _position: Vector3;
  8963. protected _setPosition(value: Vector3): void;
  8964. /**
  8965. * Sets the position the shadow will be casted from. Also use as the light position for both
  8966. * point and spot lights.
  8967. */
  8968. get position(): Vector3;
  8969. /**
  8970. * Sets the position the shadow will be casted from. Also use as the light position for both
  8971. * point and spot lights.
  8972. */
  8973. set position(value: Vector3);
  8974. protected _direction: Vector3;
  8975. protected _setDirection(value: Vector3): void;
  8976. /**
  8977. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8978. * Also use as the light direction on spot and directional lights.
  8979. */
  8980. get direction(): Vector3;
  8981. /**
  8982. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8983. * Also use as the light direction on spot and directional lights.
  8984. */
  8985. set direction(value: Vector3);
  8986. protected _shadowMinZ: number;
  8987. /**
  8988. * Gets the shadow projection clipping minimum z value.
  8989. */
  8990. get shadowMinZ(): number;
  8991. /**
  8992. * Sets the shadow projection clipping minimum z value.
  8993. */
  8994. set shadowMinZ(value: number);
  8995. protected _shadowMaxZ: number;
  8996. /**
  8997. * Sets the shadow projection clipping maximum z value.
  8998. */
  8999. get shadowMaxZ(): number;
  9000. /**
  9001. * Gets the shadow projection clipping maximum z value.
  9002. */
  9003. set shadowMaxZ(value: number);
  9004. /**
  9005. * Callback defining a custom Projection Matrix Builder.
  9006. * This can be used to override the default projection matrix computation.
  9007. */
  9008. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9009. /**
  9010. * The transformed position. Position of the light in world space taking parenting in account.
  9011. */
  9012. transformedPosition: Vector3;
  9013. /**
  9014. * The transformed direction. Direction of the light in world space taking parenting in account.
  9015. */
  9016. transformedDirection: Vector3;
  9017. private _needProjectionMatrixCompute;
  9018. /**
  9019. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9020. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9021. */
  9022. computeTransformedInformation(): boolean;
  9023. /**
  9024. * Return the depth scale used for the shadow map.
  9025. * @returns the depth scale.
  9026. */
  9027. getDepthScale(): number;
  9028. /**
  9029. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9030. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9031. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9032. */
  9033. getShadowDirection(faceIndex?: number): Vector3;
  9034. /**
  9035. * Returns the ShadowLight absolute position in the World.
  9036. * @returns the position vector in world space
  9037. */
  9038. getAbsolutePosition(): Vector3;
  9039. /**
  9040. * Sets the ShadowLight direction toward the passed target.
  9041. * @param target The point to target in local space
  9042. * @returns the updated ShadowLight direction
  9043. */
  9044. setDirectionToTarget(target: Vector3): Vector3;
  9045. /**
  9046. * Returns the light rotation in euler definition.
  9047. * @returns the x y z rotation in local space.
  9048. */
  9049. getRotation(): Vector3;
  9050. /**
  9051. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9052. * @returns true if a cube texture needs to be use
  9053. */
  9054. needCube(): boolean;
  9055. /**
  9056. * Detects if the projection matrix requires to be recomputed this frame.
  9057. * @returns true if it requires to be recomputed otherwise, false.
  9058. */
  9059. needProjectionMatrixCompute(): boolean;
  9060. /**
  9061. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9062. */
  9063. forceProjectionMatrixCompute(): void;
  9064. /** @hidden */
  9065. _initCache(): void;
  9066. /** @hidden */
  9067. _isSynchronized(): boolean;
  9068. /**
  9069. * Computes the world matrix of the node
  9070. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9071. * @returns the world matrix
  9072. */
  9073. computeWorldMatrix(force?: boolean): Matrix;
  9074. /**
  9075. * Gets the minZ used for shadow according to both the scene and the light.
  9076. * @param activeCamera The camera we are returning the min for
  9077. * @returns the depth min z
  9078. */
  9079. getDepthMinZ(activeCamera: Camera): number;
  9080. /**
  9081. * Gets the maxZ used for shadow according to both the scene and the light.
  9082. * @param activeCamera The camera we are returning the max for
  9083. * @returns the depth max z
  9084. */
  9085. getDepthMaxZ(activeCamera: Camera): number;
  9086. /**
  9087. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9088. * @param matrix The materix to updated with the projection information
  9089. * @param viewMatrix The transform matrix of the light
  9090. * @param renderList The list of mesh to render in the map
  9091. * @returns The current light
  9092. */
  9093. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9094. }
  9095. }
  9096. declare module BABYLON {
  9097. /** @hidden */
  9098. export var packingFunctions: {
  9099. name: string;
  9100. shader: string;
  9101. };
  9102. }
  9103. declare module BABYLON {
  9104. /** @hidden */
  9105. export var bayerDitherFunctions: {
  9106. name: string;
  9107. shader: string;
  9108. };
  9109. }
  9110. declare module BABYLON {
  9111. /** @hidden */
  9112. export var shadowMapFragmentDeclaration: {
  9113. name: string;
  9114. shader: string;
  9115. };
  9116. }
  9117. declare module BABYLON {
  9118. /** @hidden */
  9119. export var clipPlaneFragmentDeclaration: {
  9120. name: string;
  9121. shader: string;
  9122. };
  9123. }
  9124. declare module BABYLON {
  9125. /** @hidden */
  9126. export var clipPlaneFragment: {
  9127. name: string;
  9128. shader: string;
  9129. };
  9130. }
  9131. declare module BABYLON {
  9132. /** @hidden */
  9133. export var shadowMapFragment: {
  9134. name: string;
  9135. shader: string;
  9136. };
  9137. }
  9138. declare module BABYLON {
  9139. /** @hidden */
  9140. export var shadowMapPixelShader: {
  9141. name: string;
  9142. shader: string;
  9143. };
  9144. }
  9145. declare module BABYLON {
  9146. /** @hidden */
  9147. export var bonesDeclaration: {
  9148. name: string;
  9149. shader: string;
  9150. };
  9151. }
  9152. declare module BABYLON {
  9153. /** @hidden */
  9154. export var morphTargetsVertexGlobalDeclaration: {
  9155. name: string;
  9156. shader: string;
  9157. };
  9158. }
  9159. declare module BABYLON {
  9160. /** @hidden */
  9161. export var morphTargetsVertexDeclaration: {
  9162. name: string;
  9163. shader: string;
  9164. };
  9165. }
  9166. declare module BABYLON {
  9167. /** @hidden */
  9168. export var instancesDeclaration: {
  9169. name: string;
  9170. shader: string;
  9171. };
  9172. }
  9173. declare module BABYLON {
  9174. /** @hidden */
  9175. export var helperFunctions: {
  9176. name: string;
  9177. shader: string;
  9178. };
  9179. }
  9180. declare module BABYLON {
  9181. /** @hidden */
  9182. export var shadowMapVertexDeclaration: {
  9183. name: string;
  9184. shader: string;
  9185. };
  9186. }
  9187. declare module BABYLON {
  9188. /** @hidden */
  9189. export var clipPlaneVertexDeclaration: {
  9190. name: string;
  9191. shader: string;
  9192. };
  9193. }
  9194. declare module BABYLON {
  9195. /** @hidden */
  9196. export var morphTargetsVertex: {
  9197. name: string;
  9198. shader: string;
  9199. };
  9200. }
  9201. declare module BABYLON {
  9202. /** @hidden */
  9203. export var instancesVertex: {
  9204. name: string;
  9205. shader: string;
  9206. };
  9207. }
  9208. declare module BABYLON {
  9209. /** @hidden */
  9210. export var bonesVertex: {
  9211. name: string;
  9212. shader: string;
  9213. };
  9214. }
  9215. declare module BABYLON {
  9216. /** @hidden */
  9217. export var shadowMapVertexNormalBias: {
  9218. name: string;
  9219. shader: string;
  9220. };
  9221. }
  9222. declare module BABYLON {
  9223. /** @hidden */
  9224. export var shadowMapVertexMetric: {
  9225. name: string;
  9226. shader: string;
  9227. };
  9228. }
  9229. declare module BABYLON {
  9230. /** @hidden */
  9231. export var clipPlaneVertex: {
  9232. name: string;
  9233. shader: string;
  9234. };
  9235. }
  9236. declare module BABYLON {
  9237. /** @hidden */
  9238. export var shadowMapVertexShader: {
  9239. name: string;
  9240. shader: string;
  9241. };
  9242. }
  9243. declare module BABYLON {
  9244. /** @hidden */
  9245. export var depthBoxBlurPixelShader: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module BABYLON {
  9251. /** @hidden */
  9252. export var shadowMapFragmentSoftTransparentShadow: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module BABYLON {
  9258. /**
  9259. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9260. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9261. */
  9262. export class EffectFallbacks implements IEffectFallbacks {
  9263. private _defines;
  9264. private _currentRank;
  9265. private _maxRank;
  9266. private _mesh;
  9267. /**
  9268. * Removes the fallback from the bound mesh.
  9269. */
  9270. unBindMesh(): void;
  9271. /**
  9272. * Adds a fallback on the specified property.
  9273. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9274. * @param define The name of the define in the shader
  9275. */
  9276. addFallback(rank: number, define: string): void;
  9277. /**
  9278. * Sets the mesh to use CPU skinning when needing to fallback.
  9279. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9280. * @param mesh The mesh to use the fallbacks.
  9281. */
  9282. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9283. /**
  9284. * Checks to see if more fallbacks are still availible.
  9285. */
  9286. get hasMoreFallbacks(): boolean;
  9287. /**
  9288. * Removes the defines that should be removed when falling back.
  9289. * @param currentDefines defines the current define statements for the shader.
  9290. * @param effect defines the current effect we try to compile
  9291. * @returns The resulting defines with defines of the current rank removed.
  9292. */
  9293. reduce(currentDefines: string, effect: Effect): string;
  9294. }
  9295. }
  9296. declare module BABYLON {
  9297. /**
  9298. * Interface used to define Action
  9299. */
  9300. export interface IAction {
  9301. /**
  9302. * Trigger for the action
  9303. */
  9304. trigger: number;
  9305. /** Options of the trigger */
  9306. triggerOptions: any;
  9307. /**
  9308. * Gets the trigger parameters
  9309. * @returns the trigger parameters
  9310. */
  9311. getTriggerParameter(): any;
  9312. /**
  9313. * Internal only - executes current action event
  9314. * @hidden
  9315. */
  9316. _executeCurrent(evt?: ActionEvent): void;
  9317. /**
  9318. * Serialize placeholder for child classes
  9319. * @param parent of child
  9320. * @returns the serialized object
  9321. */
  9322. serialize(parent: any): any;
  9323. /**
  9324. * Internal only
  9325. * @hidden
  9326. */
  9327. _prepare(): void;
  9328. /**
  9329. * Internal only - manager for action
  9330. * @hidden
  9331. */
  9332. _actionManager: AbstractActionManager;
  9333. /**
  9334. * Adds action to chain of actions, may be a DoNothingAction
  9335. * @param action defines the next action to execute
  9336. * @returns The action passed in
  9337. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9338. */
  9339. then(action: IAction): IAction;
  9340. }
  9341. /**
  9342. * The action to be carried out following a trigger
  9343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9344. */
  9345. export class Action implements IAction {
  9346. /** the trigger, with or without parameters, for the action */
  9347. triggerOptions: any;
  9348. /**
  9349. * Trigger for the action
  9350. */
  9351. trigger: number;
  9352. /**
  9353. * Internal only - manager for action
  9354. * @hidden
  9355. */
  9356. _actionManager: ActionManager;
  9357. private _nextActiveAction;
  9358. private _child;
  9359. private _condition?;
  9360. private _triggerParameter;
  9361. /**
  9362. * An event triggered prior to action being executed.
  9363. */
  9364. onBeforeExecuteObservable: Observable<Action>;
  9365. /**
  9366. * Creates a new Action
  9367. * @param triggerOptions the trigger, with or without parameters, for the action
  9368. * @param condition an optional determinant of action
  9369. */
  9370. constructor(
  9371. /** the trigger, with or without parameters, for the action */
  9372. triggerOptions: any, condition?: Condition);
  9373. /**
  9374. * Internal only
  9375. * @hidden
  9376. */
  9377. _prepare(): void;
  9378. /**
  9379. * Gets the trigger parameters
  9380. * @returns the trigger parameters
  9381. */
  9382. getTriggerParameter(): any;
  9383. /**
  9384. * Internal only - executes current action event
  9385. * @hidden
  9386. */
  9387. _executeCurrent(evt?: ActionEvent): void;
  9388. /**
  9389. * Execute placeholder for child classes
  9390. * @param evt optional action event
  9391. */
  9392. execute(evt?: ActionEvent): void;
  9393. /**
  9394. * Skips to next active action
  9395. */
  9396. skipToNextActiveAction(): void;
  9397. /**
  9398. * Adds action to chain of actions, may be a DoNothingAction
  9399. * @param action defines the next action to execute
  9400. * @returns The action passed in
  9401. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9402. */
  9403. then(action: Action): Action;
  9404. /**
  9405. * Internal only
  9406. * @hidden
  9407. */
  9408. _getProperty(propertyPath: string): string;
  9409. /**
  9410. * Internal only
  9411. * @hidden
  9412. */
  9413. _getEffectiveTarget(target: any, propertyPath: string): any;
  9414. /**
  9415. * Serialize placeholder for child classes
  9416. * @param parent of child
  9417. * @returns the serialized object
  9418. */
  9419. serialize(parent: any): any;
  9420. /**
  9421. * Internal only called by serialize
  9422. * @hidden
  9423. */
  9424. protected _serialize(serializedAction: any, parent?: any): any;
  9425. /**
  9426. * Internal only
  9427. * @hidden
  9428. */
  9429. static _SerializeValueAsString: (value: any) => string;
  9430. /**
  9431. * Internal only
  9432. * @hidden
  9433. */
  9434. static _GetTargetProperty: (target: Node | Scene) => {
  9435. name: string;
  9436. targetType: string;
  9437. value: string;
  9438. };
  9439. }
  9440. }
  9441. declare module BABYLON {
  9442. /**
  9443. * A Condition applied to an Action
  9444. */
  9445. export class Condition {
  9446. /**
  9447. * Internal only - manager for action
  9448. * @hidden
  9449. */
  9450. _actionManager: ActionManager;
  9451. /**
  9452. * Internal only
  9453. * @hidden
  9454. */
  9455. _evaluationId: number;
  9456. /**
  9457. * Internal only
  9458. * @hidden
  9459. */
  9460. _currentResult: boolean;
  9461. /**
  9462. * Creates a new Condition
  9463. * @param actionManager the manager of the action the condition is applied to
  9464. */
  9465. constructor(actionManager: ActionManager);
  9466. /**
  9467. * Check if the current condition is valid
  9468. * @returns a boolean
  9469. */
  9470. isValid(): boolean;
  9471. /**
  9472. * Internal only
  9473. * @hidden
  9474. */
  9475. _getProperty(propertyPath: string): string;
  9476. /**
  9477. * Internal only
  9478. * @hidden
  9479. */
  9480. _getEffectiveTarget(target: any, propertyPath: string): any;
  9481. /**
  9482. * Serialize placeholder for child classes
  9483. * @returns the serialized object
  9484. */
  9485. serialize(): any;
  9486. /**
  9487. * Internal only
  9488. * @hidden
  9489. */
  9490. protected _serialize(serializedCondition: any): any;
  9491. }
  9492. /**
  9493. * Defines specific conditional operators as extensions of Condition
  9494. */
  9495. export class ValueCondition extends Condition {
  9496. /** path to specify the property of the target the conditional operator uses */
  9497. propertyPath: string;
  9498. /** the value compared by the conditional operator against the current value of the property */
  9499. value: any;
  9500. /** the conditional operator, default ValueCondition.IsEqual */
  9501. operator: number;
  9502. /**
  9503. * Internal only
  9504. * @hidden
  9505. */
  9506. private static _IsEqual;
  9507. /**
  9508. * Internal only
  9509. * @hidden
  9510. */
  9511. private static _IsDifferent;
  9512. /**
  9513. * Internal only
  9514. * @hidden
  9515. */
  9516. private static _IsGreater;
  9517. /**
  9518. * Internal only
  9519. * @hidden
  9520. */
  9521. private static _IsLesser;
  9522. /**
  9523. * returns the number for IsEqual
  9524. */
  9525. static get IsEqual(): number;
  9526. /**
  9527. * Returns the number for IsDifferent
  9528. */
  9529. static get IsDifferent(): number;
  9530. /**
  9531. * Returns the number for IsGreater
  9532. */
  9533. static get IsGreater(): number;
  9534. /**
  9535. * Returns the number for IsLesser
  9536. */
  9537. static get IsLesser(): number;
  9538. /**
  9539. * Internal only The action manager for the condition
  9540. * @hidden
  9541. */
  9542. _actionManager: ActionManager;
  9543. /**
  9544. * Internal only
  9545. * @hidden
  9546. */
  9547. private _target;
  9548. /**
  9549. * Internal only
  9550. * @hidden
  9551. */
  9552. private _effectiveTarget;
  9553. /**
  9554. * Internal only
  9555. * @hidden
  9556. */
  9557. private _property;
  9558. /**
  9559. * Creates a new ValueCondition
  9560. * @param actionManager manager for the action the condition applies to
  9561. * @param target for the action
  9562. * @param propertyPath path to specify the property of the target the conditional operator uses
  9563. * @param value the value compared by the conditional operator against the current value of the property
  9564. * @param operator the conditional operator, default ValueCondition.IsEqual
  9565. */
  9566. constructor(actionManager: ActionManager, target: any,
  9567. /** path to specify the property of the target the conditional operator uses */
  9568. propertyPath: string,
  9569. /** the value compared by the conditional operator against the current value of the property */
  9570. value: any,
  9571. /** the conditional operator, default ValueCondition.IsEqual */
  9572. operator?: number);
  9573. /**
  9574. * Compares the given value with the property value for the specified conditional operator
  9575. * @returns the result of the comparison
  9576. */
  9577. isValid(): boolean;
  9578. /**
  9579. * Serialize the ValueCondition into a JSON compatible object
  9580. * @returns serialization object
  9581. */
  9582. serialize(): any;
  9583. /**
  9584. * Gets the name of the conditional operator for the ValueCondition
  9585. * @param operator the conditional operator
  9586. * @returns the name
  9587. */
  9588. static GetOperatorName(operator: number): string;
  9589. }
  9590. /**
  9591. * Defines a predicate condition as an extension of Condition
  9592. */
  9593. export class PredicateCondition extends Condition {
  9594. /** defines the predicate function used to validate the condition */
  9595. predicate: () => boolean;
  9596. /**
  9597. * Internal only - manager for action
  9598. * @hidden
  9599. */
  9600. _actionManager: ActionManager;
  9601. /**
  9602. * Creates a new PredicateCondition
  9603. * @param actionManager manager for the action the condition applies to
  9604. * @param predicate defines the predicate function used to validate the condition
  9605. */
  9606. constructor(actionManager: ActionManager,
  9607. /** defines the predicate function used to validate the condition */
  9608. predicate: () => boolean);
  9609. /**
  9610. * @returns the validity of the predicate condition
  9611. */
  9612. isValid(): boolean;
  9613. }
  9614. /**
  9615. * Defines a state condition as an extension of Condition
  9616. */
  9617. export class StateCondition extends Condition {
  9618. /** Value to compare with target state */
  9619. value: string;
  9620. /**
  9621. * Internal only - manager for action
  9622. * @hidden
  9623. */
  9624. _actionManager: ActionManager;
  9625. /**
  9626. * Internal only
  9627. * @hidden
  9628. */
  9629. private _target;
  9630. /**
  9631. * Creates a new StateCondition
  9632. * @param actionManager manager for the action the condition applies to
  9633. * @param target of the condition
  9634. * @param value to compare with target state
  9635. */
  9636. constructor(actionManager: ActionManager, target: any,
  9637. /** Value to compare with target state */
  9638. value: string);
  9639. /**
  9640. * Gets a boolean indicating if the current condition is met
  9641. * @returns the validity of the state
  9642. */
  9643. isValid(): boolean;
  9644. /**
  9645. * Serialize the StateCondition into a JSON compatible object
  9646. * @returns serialization object
  9647. */
  9648. serialize(): any;
  9649. }
  9650. }
  9651. declare module BABYLON {
  9652. /**
  9653. * This defines an action responsible to toggle a boolean once triggered.
  9654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9655. */
  9656. export class SwitchBooleanAction extends Action {
  9657. /**
  9658. * The path to the boolean property in the target object
  9659. */
  9660. propertyPath: string;
  9661. private _target;
  9662. private _effectiveTarget;
  9663. private _property;
  9664. /**
  9665. * Instantiate the action
  9666. * @param triggerOptions defines the trigger options
  9667. * @param target defines the object containing the boolean
  9668. * @param propertyPath defines the path to the boolean property in the target object
  9669. * @param condition defines the trigger related conditions
  9670. */
  9671. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9672. /** @hidden */
  9673. _prepare(): void;
  9674. /**
  9675. * Execute the action toggle the boolean value.
  9676. */
  9677. execute(): void;
  9678. /**
  9679. * Serializes the actions and its related information.
  9680. * @param parent defines the object to serialize in
  9681. * @returns the serialized object
  9682. */
  9683. serialize(parent: any): any;
  9684. }
  9685. /**
  9686. * This defines an action responsible to set a the state field of the target
  9687. * to a desired value once triggered.
  9688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9689. */
  9690. export class SetStateAction extends Action {
  9691. /**
  9692. * The value to store in the state field.
  9693. */
  9694. value: string;
  9695. private _target;
  9696. /**
  9697. * Instantiate the action
  9698. * @param triggerOptions defines the trigger options
  9699. * @param target defines the object containing the state property
  9700. * @param value defines the value to store in the state field
  9701. * @param condition defines the trigger related conditions
  9702. */
  9703. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9704. /**
  9705. * Execute the action and store the value on the target state property.
  9706. */
  9707. execute(): void;
  9708. /**
  9709. * Serializes the actions and its related information.
  9710. * @param parent defines the object to serialize in
  9711. * @returns the serialized object
  9712. */
  9713. serialize(parent: any): any;
  9714. }
  9715. /**
  9716. * This defines an action responsible to set a property of the target
  9717. * to a desired value once triggered.
  9718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9719. */
  9720. export class SetValueAction extends Action {
  9721. /**
  9722. * The path of the property to set in the target.
  9723. */
  9724. propertyPath: string;
  9725. /**
  9726. * The value to set in the property
  9727. */
  9728. value: any;
  9729. private _target;
  9730. private _effectiveTarget;
  9731. private _property;
  9732. /**
  9733. * Instantiate the action
  9734. * @param triggerOptions defines the trigger options
  9735. * @param target defines the object containing the property
  9736. * @param propertyPath defines the path of the property to set in the target
  9737. * @param value defines the value to set in the property
  9738. * @param condition defines the trigger related conditions
  9739. */
  9740. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9741. /** @hidden */
  9742. _prepare(): void;
  9743. /**
  9744. * Execute the action and set the targetted property to the desired value.
  9745. */
  9746. execute(): void;
  9747. /**
  9748. * Serializes the actions and its related information.
  9749. * @param parent defines the object to serialize in
  9750. * @returns the serialized object
  9751. */
  9752. serialize(parent: any): any;
  9753. }
  9754. /**
  9755. * This defines an action responsible to increment the target value
  9756. * to a desired value once triggered.
  9757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9758. */
  9759. export class IncrementValueAction extends Action {
  9760. /**
  9761. * The path of the property to increment in the target.
  9762. */
  9763. propertyPath: string;
  9764. /**
  9765. * The value we should increment the property by.
  9766. */
  9767. value: any;
  9768. private _target;
  9769. private _effectiveTarget;
  9770. private _property;
  9771. /**
  9772. * Instantiate the action
  9773. * @param triggerOptions defines the trigger options
  9774. * @param target defines the object containing the property
  9775. * @param propertyPath defines the path of the property to increment in the target
  9776. * @param value defines the value value we should increment the property by
  9777. * @param condition defines the trigger related conditions
  9778. */
  9779. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9780. /** @hidden */
  9781. _prepare(): void;
  9782. /**
  9783. * Execute the action and increment the target of the value amount.
  9784. */
  9785. execute(): void;
  9786. /**
  9787. * Serializes the actions and its related information.
  9788. * @param parent defines the object to serialize in
  9789. * @returns the serialized object
  9790. */
  9791. serialize(parent: any): any;
  9792. }
  9793. /**
  9794. * This defines an action responsible to start an animation once triggered.
  9795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9796. */
  9797. export class PlayAnimationAction extends Action {
  9798. /**
  9799. * Where the animation should start (animation frame)
  9800. */
  9801. from: number;
  9802. /**
  9803. * Where the animation should stop (animation frame)
  9804. */
  9805. to: number;
  9806. /**
  9807. * Define if the animation should loop or stop after the first play.
  9808. */
  9809. loop?: boolean;
  9810. private _target;
  9811. /**
  9812. * Instantiate the action
  9813. * @param triggerOptions defines the trigger options
  9814. * @param target defines the target animation or animation name
  9815. * @param from defines from where the animation should start (animation frame)
  9816. * @param end defines where the animation should stop (animation frame)
  9817. * @param loop defines if the animation should loop or stop after the first play
  9818. * @param condition defines the trigger related conditions
  9819. */
  9820. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9821. /** @hidden */
  9822. _prepare(): void;
  9823. /**
  9824. * Execute the action and play the animation.
  9825. */
  9826. execute(): void;
  9827. /**
  9828. * Serializes the actions and its related information.
  9829. * @param parent defines the object to serialize in
  9830. * @returns the serialized object
  9831. */
  9832. serialize(parent: any): any;
  9833. }
  9834. /**
  9835. * This defines an action responsible to stop an animation once triggered.
  9836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9837. */
  9838. export class StopAnimationAction extends Action {
  9839. private _target;
  9840. /**
  9841. * Instantiate the action
  9842. * @param triggerOptions defines the trigger options
  9843. * @param target defines the target animation or animation name
  9844. * @param condition defines the trigger related conditions
  9845. */
  9846. constructor(triggerOptions: any, target: any, condition?: Condition);
  9847. /** @hidden */
  9848. _prepare(): void;
  9849. /**
  9850. * Execute the action and stop the animation.
  9851. */
  9852. execute(): void;
  9853. /**
  9854. * Serializes the actions and its related information.
  9855. * @param parent defines the object to serialize in
  9856. * @returns the serialized object
  9857. */
  9858. serialize(parent: any): any;
  9859. }
  9860. /**
  9861. * This defines an action responsible that does nothing once triggered.
  9862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9863. */
  9864. export class DoNothingAction extends Action {
  9865. /**
  9866. * Instantiate the action
  9867. * @param triggerOptions defines the trigger options
  9868. * @param condition defines the trigger related conditions
  9869. */
  9870. constructor(triggerOptions?: any, condition?: Condition);
  9871. /**
  9872. * Execute the action and do nothing.
  9873. */
  9874. execute(): void;
  9875. /**
  9876. * Serializes the actions and its related information.
  9877. * @param parent defines the object to serialize in
  9878. * @returns the serialized object
  9879. */
  9880. serialize(parent: any): any;
  9881. }
  9882. /**
  9883. * This defines an action responsible to trigger several actions once triggered.
  9884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9885. */
  9886. export class CombineAction extends Action {
  9887. /**
  9888. * The list of aggregated animations to run.
  9889. */
  9890. children: Action[];
  9891. /**
  9892. * Instantiate the action
  9893. * @param triggerOptions defines the trigger options
  9894. * @param children defines the list of aggregated animations to run
  9895. * @param condition defines the trigger related conditions
  9896. */
  9897. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9898. /** @hidden */
  9899. _prepare(): void;
  9900. /**
  9901. * Execute the action and executes all the aggregated actions.
  9902. */
  9903. execute(evt: ActionEvent): void;
  9904. /**
  9905. * Serializes the actions and its related information.
  9906. * @param parent defines the object to serialize in
  9907. * @returns the serialized object
  9908. */
  9909. serialize(parent: any): any;
  9910. }
  9911. /**
  9912. * This defines an action responsible to run code (external event) once triggered.
  9913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9914. */
  9915. export class ExecuteCodeAction extends Action {
  9916. /**
  9917. * The callback function to run.
  9918. */
  9919. func: (evt: ActionEvent) => void;
  9920. /**
  9921. * Instantiate the action
  9922. * @param triggerOptions defines the trigger options
  9923. * @param func defines the callback function to run
  9924. * @param condition defines the trigger related conditions
  9925. */
  9926. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9927. /**
  9928. * Execute the action and run the attached code.
  9929. */
  9930. execute(evt: ActionEvent): void;
  9931. }
  9932. /**
  9933. * This defines an action responsible to set the parent property of the target once triggered.
  9934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9935. */
  9936. export class SetParentAction extends Action {
  9937. private _parent;
  9938. private _target;
  9939. /**
  9940. * Instantiate the action
  9941. * @param triggerOptions defines the trigger options
  9942. * @param target defines the target containing the parent property
  9943. * @param parent defines from where the animation should start (animation frame)
  9944. * @param condition defines the trigger related conditions
  9945. */
  9946. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9947. /** @hidden */
  9948. _prepare(): void;
  9949. /**
  9950. * Execute the action and set the parent property.
  9951. */
  9952. execute(): void;
  9953. /**
  9954. * Serializes the actions and its related information.
  9955. * @param parent defines the object to serialize in
  9956. * @returns the serialized object
  9957. */
  9958. serialize(parent: any): any;
  9959. }
  9960. }
  9961. declare module BABYLON {
  9962. /**
  9963. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9964. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9966. */
  9967. export class ActionManager extends AbstractActionManager {
  9968. /**
  9969. * Nothing
  9970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9971. */
  9972. static readonly NothingTrigger: number;
  9973. /**
  9974. * On pick
  9975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9976. */
  9977. static readonly OnPickTrigger: number;
  9978. /**
  9979. * On left pick
  9980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9981. */
  9982. static readonly OnLeftPickTrigger: number;
  9983. /**
  9984. * On right pick
  9985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9986. */
  9987. static readonly OnRightPickTrigger: number;
  9988. /**
  9989. * On center pick
  9990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9991. */
  9992. static readonly OnCenterPickTrigger: number;
  9993. /**
  9994. * On pick down
  9995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9996. */
  9997. static readonly OnPickDownTrigger: number;
  9998. /**
  9999. * On double pick
  10000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10001. */
  10002. static readonly OnDoublePickTrigger: number;
  10003. /**
  10004. * On pick up
  10005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10006. */
  10007. static readonly OnPickUpTrigger: number;
  10008. /**
  10009. * On pick out.
  10010. * This trigger will only be raised if you also declared a OnPickDown
  10011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10012. */
  10013. static readonly OnPickOutTrigger: number;
  10014. /**
  10015. * On long press
  10016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10017. */
  10018. static readonly OnLongPressTrigger: number;
  10019. /**
  10020. * On pointer over
  10021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10022. */
  10023. static readonly OnPointerOverTrigger: number;
  10024. /**
  10025. * On pointer out
  10026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10027. */
  10028. static readonly OnPointerOutTrigger: number;
  10029. /**
  10030. * On every frame
  10031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10032. */
  10033. static readonly OnEveryFrameTrigger: number;
  10034. /**
  10035. * On intersection enter
  10036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10037. */
  10038. static readonly OnIntersectionEnterTrigger: number;
  10039. /**
  10040. * On intersection exit
  10041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10042. */
  10043. static readonly OnIntersectionExitTrigger: number;
  10044. /**
  10045. * On key down
  10046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10047. */
  10048. static readonly OnKeyDownTrigger: number;
  10049. /**
  10050. * On key up
  10051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10052. */
  10053. static readonly OnKeyUpTrigger: number;
  10054. private _scene;
  10055. /**
  10056. * Creates a new action manager
  10057. * @param scene defines the hosting scene
  10058. */
  10059. constructor(scene: Scene);
  10060. /**
  10061. * Releases all associated resources
  10062. */
  10063. dispose(): void;
  10064. /**
  10065. * Gets hosting scene
  10066. * @returns the hosting scene
  10067. */
  10068. getScene(): Scene;
  10069. /**
  10070. * Does this action manager handles actions of any of the given triggers
  10071. * @param triggers defines the triggers to be tested
  10072. * @return a boolean indicating whether one (or more) of the triggers is handled
  10073. */
  10074. hasSpecificTriggers(triggers: number[]): boolean;
  10075. /**
  10076. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10077. * speed.
  10078. * @param triggerA defines the trigger to be tested
  10079. * @param triggerB defines the trigger to be tested
  10080. * @return a boolean indicating whether one (or more) of the triggers is handled
  10081. */
  10082. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10083. /**
  10084. * Does this action manager handles actions of a given trigger
  10085. * @param trigger defines the trigger to be tested
  10086. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10087. * @return whether the trigger is handled
  10088. */
  10089. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10090. /**
  10091. * Does this action manager has pointer triggers
  10092. */
  10093. get hasPointerTriggers(): boolean;
  10094. /**
  10095. * Does this action manager has pick triggers
  10096. */
  10097. get hasPickTriggers(): boolean;
  10098. /**
  10099. * Registers an action to this action manager
  10100. * @param action defines the action to be registered
  10101. * @return the action amended (prepared) after registration
  10102. */
  10103. registerAction(action: IAction): Nullable<IAction>;
  10104. /**
  10105. * Unregisters an action to this action manager
  10106. * @param action defines the action to be unregistered
  10107. * @return a boolean indicating whether the action has been unregistered
  10108. */
  10109. unregisterAction(action: IAction): Boolean;
  10110. /**
  10111. * Process a specific trigger
  10112. * @param trigger defines the trigger to process
  10113. * @param evt defines the event details to be processed
  10114. */
  10115. processTrigger(trigger: number, evt?: IActionEvent): void;
  10116. /** @hidden */
  10117. _getEffectiveTarget(target: any, propertyPath: string): any;
  10118. /** @hidden */
  10119. _getProperty(propertyPath: string): string;
  10120. /**
  10121. * Serialize this manager to a JSON object
  10122. * @param name defines the property name to store this manager
  10123. * @returns a JSON representation of this manager
  10124. */
  10125. serialize(name: string): any;
  10126. /**
  10127. * Creates a new ActionManager from a JSON data
  10128. * @param parsedActions defines the JSON data to read from
  10129. * @param object defines the hosting mesh
  10130. * @param scene defines the hosting scene
  10131. */
  10132. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10133. /**
  10134. * Get a trigger name by index
  10135. * @param trigger defines the trigger index
  10136. * @returns a trigger name
  10137. */
  10138. static GetTriggerName(trigger: number): string;
  10139. }
  10140. }
  10141. declare module BABYLON {
  10142. /**
  10143. * Class used to represent a sprite
  10144. * @see http://doc.babylonjs.com/babylon101/sprites
  10145. */
  10146. export class Sprite implements IAnimatable {
  10147. /** defines the name */
  10148. name: string;
  10149. /** Gets or sets the current world position */
  10150. position: Vector3;
  10151. /** Gets or sets the main color */
  10152. color: Color4;
  10153. /** Gets or sets the width */
  10154. width: number;
  10155. /** Gets or sets the height */
  10156. height: number;
  10157. /** Gets or sets rotation angle */
  10158. angle: number;
  10159. /** Gets or sets the cell index in the sprite sheet */
  10160. cellIndex: number;
  10161. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10162. cellRef: string;
  10163. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10164. invertU: boolean;
  10165. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10166. invertV: boolean;
  10167. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10168. disposeWhenFinishedAnimating: boolean;
  10169. /** Gets the list of attached animations */
  10170. animations: Nullable<Array<Animation>>;
  10171. /** Gets or sets a boolean indicating if the sprite can be picked */
  10172. isPickable: boolean;
  10173. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10174. useAlphaForPicking: boolean;
  10175. /** @hidden */
  10176. _xOffset: number;
  10177. /** @hidden */
  10178. _yOffset: number;
  10179. /** @hidden */
  10180. _xSize: number;
  10181. /** @hidden */
  10182. _ySize: number;
  10183. /**
  10184. * Gets or sets the associated action manager
  10185. */
  10186. actionManager: Nullable<ActionManager>;
  10187. /**
  10188. * An event triggered when the control has been disposed
  10189. */
  10190. onDisposeObservable: Observable<Sprite>;
  10191. private _animationStarted;
  10192. private _loopAnimation;
  10193. private _fromIndex;
  10194. private _toIndex;
  10195. private _delay;
  10196. private _direction;
  10197. private _manager;
  10198. private _time;
  10199. private _onAnimationEnd;
  10200. /**
  10201. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10202. */
  10203. isVisible: boolean;
  10204. /**
  10205. * Gets or sets the sprite size
  10206. */
  10207. get size(): number;
  10208. set size(value: number);
  10209. /**
  10210. * Returns a boolean indicating if the animation is started
  10211. */
  10212. get animationStarted(): boolean;
  10213. /**
  10214. * Gets or sets the unique id of the sprite
  10215. */
  10216. uniqueId: number;
  10217. /**
  10218. * Gets the manager of this sprite
  10219. */
  10220. get manager(): ISpriteManager;
  10221. /**
  10222. * Creates a new Sprite
  10223. * @param name defines the name
  10224. * @param manager defines the manager
  10225. */
  10226. constructor(
  10227. /** defines the name */
  10228. name: string, manager: ISpriteManager);
  10229. /**
  10230. * Returns the string "Sprite"
  10231. * @returns "Sprite"
  10232. */
  10233. getClassName(): string;
  10234. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10235. get fromIndex(): number;
  10236. set fromIndex(value: number);
  10237. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10238. get toIndex(): number;
  10239. set toIndex(value: number);
  10240. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10241. get loopAnimation(): boolean;
  10242. set loopAnimation(value: boolean);
  10243. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10244. get delay(): number;
  10245. set delay(value: number);
  10246. /**
  10247. * Starts an animation
  10248. * @param from defines the initial key
  10249. * @param to defines the end key
  10250. * @param loop defines if the animation must loop
  10251. * @param delay defines the start delay (in ms)
  10252. * @param onAnimationEnd defines a callback to call when animation ends
  10253. */
  10254. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10255. /** Stops current animation (if any) */
  10256. stopAnimation(): void;
  10257. /** @hidden */
  10258. _animate(deltaTime: number): void;
  10259. /** Release associated resources */
  10260. dispose(): void;
  10261. /**
  10262. * Serializes the sprite to a JSON object
  10263. * @returns the JSON object
  10264. */
  10265. serialize(): any;
  10266. /**
  10267. * Parses a JSON object to create a new sprite
  10268. * @param parsedSprite The JSON object to parse
  10269. * @param manager defines the hosting manager
  10270. * @returns the new sprite
  10271. */
  10272. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10273. }
  10274. }
  10275. declare module BABYLON {
  10276. /**
  10277. * Information about the result of picking within a scene
  10278. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10279. */
  10280. export class PickingInfo {
  10281. /** @hidden */
  10282. _pickingUnavailable: boolean;
  10283. /**
  10284. * If the pick collided with an object
  10285. */
  10286. hit: boolean;
  10287. /**
  10288. * Distance away where the pick collided
  10289. */
  10290. distance: number;
  10291. /**
  10292. * The location of pick collision
  10293. */
  10294. pickedPoint: Nullable<Vector3>;
  10295. /**
  10296. * The mesh corresponding the the pick collision
  10297. */
  10298. pickedMesh: Nullable<AbstractMesh>;
  10299. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10300. bu: number;
  10301. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10302. bv: number;
  10303. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10304. faceId: number;
  10305. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10306. subMeshFaceId: number;
  10307. /** Id of the the submesh that was picked */
  10308. subMeshId: number;
  10309. /** If a sprite was picked, this will be the sprite the pick collided with */
  10310. pickedSprite: Nullable<Sprite>;
  10311. /**
  10312. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10313. */
  10314. originMesh: Nullable<AbstractMesh>;
  10315. /**
  10316. * The ray that was used to perform the picking.
  10317. */
  10318. ray: Nullable<Ray>;
  10319. /**
  10320. * Gets the normal correspodning to the face the pick collided with
  10321. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10322. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10323. * @returns The normal correspodning to the face the pick collided with
  10324. */
  10325. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10326. /**
  10327. * Gets the texture coordinates of where the pick occured
  10328. * @returns the vector containing the coordnates of the texture
  10329. */
  10330. getTextureCoordinates(): Nullable<Vector2>;
  10331. }
  10332. }
  10333. declare module BABYLON {
  10334. /**
  10335. * Class representing a ray with position and direction
  10336. */
  10337. export class Ray {
  10338. /** origin point */
  10339. origin: Vector3;
  10340. /** direction */
  10341. direction: Vector3;
  10342. /** length of the ray */
  10343. length: number;
  10344. private static readonly TmpVector3;
  10345. private _tmpRay;
  10346. /**
  10347. * Creates a new ray
  10348. * @param origin origin point
  10349. * @param direction direction
  10350. * @param length length of the ray
  10351. */
  10352. constructor(
  10353. /** origin point */
  10354. origin: Vector3,
  10355. /** direction */
  10356. direction: Vector3,
  10357. /** length of the ray */
  10358. length?: number);
  10359. /**
  10360. * Checks if the ray intersects a box
  10361. * This does not account for the ray lenght by design to improve perfs.
  10362. * @param minimum bound of the box
  10363. * @param maximum bound of the box
  10364. * @param intersectionTreshold extra extend to be added to the box in all direction
  10365. * @returns if the box was hit
  10366. */
  10367. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10368. /**
  10369. * Checks if the ray intersects a box
  10370. * This does not account for the ray lenght by design to improve perfs.
  10371. * @param box the bounding box to check
  10372. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10373. * @returns if the box was hit
  10374. */
  10375. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10376. /**
  10377. * If the ray hits a sphere
  10378. * @param sphere the bounding sphere to check
  10379. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10380. * @returns true if it hits the sphere
  10381. */
  10382. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10383. /**
  10384. * If the ray hits a triange
  10385. * @param vertex0 triangle vertex
  10386. * @param vertex1 triangle vertex
  10387. * @param vertex2 triangle vertex
  10388. * @returns intersection information if hit
  10389. */
  10390. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10391. /**
  10392. * Checks if ray intersects a plane
  10393. * @param plane the plane to check
  10394. * @returns the distance away it was hit
  10395. */
  10396. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10397. /**
  10398. * Calculate the intercept of a ray on a given axis
  10399. * @param axis to check 'x' | 'y' | 'z'
  10400. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10401. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10402. */
  10403. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10404. /**
  10405. * Checks if ray intersects a mesh
  10406. * @param mesh the mesh to check
  10407. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10408. * @returns picking info of the intersecton
  10409. */
  10410. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10411. /**
  10412. * Checks if ray intersects a mesh
  10413. * @param meshes the meshes to check
  10414. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10415. * @param results array to store result in
  10416. * @returns Array of picking infos
  10417. */
  10418. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10419. private _comparePickingInfo;
  10420. private static smallnum;
  10421. private static rayl;
  10422. /**
  10423. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10424. * @param sega the first point of the segment to test the intersection against
  10425. * @param segb the second point of the segment to test the intersection against
  10426. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10427. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10428. */
  10429. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10430. /**
  10431. * Update the ray from viewport position
  10432. * @param x position
  10433. * @param y y position
  10434. * @param viewportWidth viewport width
  10435. * @param viewportHeight viewport height
  10436. * @param world world matrix
  10437. * @param view view matrix
  10438. * @param projection projection matrix
  10439. * @returns this ray updated
  10440. */
  10441. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10442. /**
  10443. * Creates a ray with origin and direction of 0,0,0
  10444. * @returns the new ray
  10445. */
  10446. static Zero(): Ray;
  10447. /**
  10448. * Creates a new ray from screen space and viewport
  10449. * @param x position
  10450. * @param y y position
  10451. * @param viewportWidth viewport width
  10452. * @param viewportHeight viewport height
  10453. * @param world world matrix
  10454. * @param view view matrix
  10455. * @param projection projection matrix
  10456. * @returns new ray
  10457. */
  10458. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10459. /**
  10460. * 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
  10461. * transformed to the given world matrix.
  10462. * @param origin The origin point
  10463. * @param end The end point
  10464. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10465. * @returns the new ray
  10466. */
  10467. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10468. /**
  10469. * Transforms a ray by a matrix
  10470. * @param ray ray to transform
  10471. * @param matrix matrix to apply
  10472. * @returns the resulting new ray
  10473. */
  10474. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10475. /**
  10476. * Transforms a ray by a matrix
  10477. * @param ray ray to transform
  10478. * @param matrix matrix to apply
  10479. * @param result ray to store result in
  10480. */
  10481. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10482. /**
  10483. * Unproject a ray from screen space to object space
  10484. * @param sourceX defines the screen space x coordinate to use
  10485. * @param sourceY defines the screen space y coordinate to use
  10486. * @param viewportWidth defines the current width of the viewport
  10487. * @param viewportHeight defines the current height of the viewport
  10488. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10489. * @param view defines the view matrix to use
  10490. * @param projection defines the projection matrix to use
  10491. */
  10492. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10493. }
  10494. /**
  10495. * Type used to define predicate used to select faces when a mesh intersection is detected
  10496. */
  10497. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10498. interface Scene {
  10499. /** @hidden */
  10500. _tempPickingRay: Nullable<Ray>;
  10501. /** @hidden */
  10502. _cachedRayForTransform: Ray;
  10503. /** @hidden */
  10504. _pickWithRayInverseMatrix: Matrix;
  10505. /** @hidden */
  10506. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10507. /** @hidden */
  10508. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10509. }
  10510. }
  10511. declare module BABYLON {
  10512. /**
  10513. * Groups all the scene component constants in one place to ease maintenance.
  10514. * @hidden
  10515. */
  10516. export class SceneComponentConstants {
  10517. static readonly NAME_EFFECTLAYER: string;
  10518. static readonly NAME_LAYER: string;
  10519. static readonly NAME_LENSFLARESYSTEM: string;
  10520. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10521. static readonly NAME_PARTICLESYSTEM: string;
  10522. static readonly NAME_GAMEPAD: string;
  10523. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10524. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10525. static readonly NAME_DEPTHRENDERER: string;
  10526. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10527. static readonly NAME_SPRITE: string;
  10528. static readonly NAME_OUTLINERENDERER: string;
  10529. static readonly NAME_PROCEDURALTEXTURE: string;
  10530. static readonly NAME_SHADOWGENERATOR: string;
  10531. static readonly NAME_OCTREE: string;
  10532. static readonly NAME_PHYSICSENGINE: string;
  10533. static readonly NAME_AUDIO: string;
  10534. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10535. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10536. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10537. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10538. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10539. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10540. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10541. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10542. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10543. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10544. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10545. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10546. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10547. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10548. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10549. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10550. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10551. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10552. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10553. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10554. static readonly STEP_AFTERRENDER_AUDIO: number;
  10555. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10556. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10557. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10558. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10559. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10560. static readonly STEP_POINTERMOVE_SPRITE: number;
  10561. static readonly STEP_POINTERDOWN_SPRITE: number;
  10562. static readonly STEP_POINTERUP_SPRITE: number;
  10563. }
  10564. /**
  10565. * This represents a scene component.
  10566. *
  10567. * This is used to decouple the dependency the scene is having on the different workloads like
  10568. * layers, post processes...
  10569. */
  10570. export interface ISceneComponent {
  10571. /**
  10572. * The name of the component. Each component must have a unique name.
  10573. */
  10574. name: string;
  10575. /**
  10576. * The scene the component belongs to.
  10577. */
  10578. scene: Scene;
  10579. /**
  10580. * Register the component to one instance of a scene.
  10581. */
  10582. register(): void;
  10583. /**
  10584. * Rebuilds the elements related to this component in case of
  10585. * context lost for instance.
  10586. */
  10587. rebuild(): void;
  10588. /**
  10589. * Disposes the component and the associated ressources.
  10590. */
  10591. dispose(): void;
  10592. }
  10593. /**
  10594. * This represents a SERIALIZABLE scene component.
  10595. *
  10596. * This extends Scene Component to add Serialization methods on top.
  10597. */
  10598. export interface ISceneSerializableComponent extends ISceneComponent {
  10599. /**
  10600. * Adds all the elements from the container to the scene
  10601. * @param container the container holding the elements
  10602. */
  10603. addFromContainer(container: AbstractScene): void;
  10604. /**
  10605. * Removes all the elements in the container from the scene
  10606. * @param container contains the elements to remove
  10607. * @param dispose if the removed element should be disposed (default: false)
  10608. */
  10609. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10610. /**
  10611. * Serializes the component data to the specified json object
  10612. * @param serializationObject The object to serialize to
  10613. */
  10614. serialize(serializationObject: any): void;
  10615. }
  10616. /**
  10617. * Strong typing of a Mesh related stage step action
  10618. */
  10619. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10620. /**
  10621. * Strong typing of a Evaluate Sub Mesh related stage step action
  10622. */
  10623. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10624. /**
  10625. * Strong typing of a Active Mesh related stage step action
  10626. */
  10627. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10628. /**
  10629. * Strong typing of a Camera related stage step action
  10630. */
  10631. export type CameraStageAction = (camera: Camera) => void;
  10632. /**
  10633. * Strong typing of a Camera Frame buffer related stage step action
  10634. */
  10635. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10636. /**
  10637. * Strong typing of a Render Target related stage step action
  10638. */
  10639. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10640. /**
  10641. * Strong typing of a RenderingGroup related stage step action
  10642. */
  10643. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10644. /**
  10645. * Strong typing of a Mesh Render related stage step action
  10646. */
  10647. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10648. /**
  10649. * Strong typing of a simple stage step action
  10650. */
  10651. export type SimpleStageAction = () => void;
  10652. /**
  10653. * Strong typing of a render target action.
  10654. */
  10655. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10656. /**
  10657. * Strong typing of a pointer move action.
  10658. */
  10659. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10660. /**
  10661. * Strong typing of a pointer up/down action.
  10662. */
  10663. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10664. /**
  10665. * Representation of a stage in the scene (Basically a list of ordered steps)
  10666. * @hidden
  10667. */
  10668. export class Stage<T extends Function> extends Array<{
  10669. index: number;
  10670. component: ISceneComponent;
  10671. action: T;
  10672. }> {
  10673. /**
  10674. * Hide ctor from the rest of the world.
  10675. * @param items The items to add.
  10676. */
  10677. private constructor();
  10678. /**
  10679. * Creates a new Stage.
  10680. * @returns A new instance of a Stage
  10681. */
  10682. static Create<T extends Function>(): Stage<T>;
  10683. /**
  10684. * Registers a step in an ordered way in the targeted stage.
  10685. * @param index Defines the position to register the step in
  10686. * @param component Defines the component attached to the step
  10687. * @param action Defines the action to launch during the step
  10688. */
  10689. registerStep(index: number, component: ISceneComponent, action: T): void;
  10690. /**
  10691. * Clears all the steps from the stage.
  10692. */
  10693. clear(): void;
  10694. }
  10695. }
  10696. declare module BABYLON {
  10697. interface Scene {
  10698. /** @hidden */
  10699. _pointerOverSprite: Nullable<Sprite>;
  10700. /** @hidden */
  10701. _pickedDownSprite: Nullable<Sprite>;
  10702. /** @hidden */
  10703. _tempSpritePickingRay: Nullable<Ray>;
  10704. /**
  10705. * All of the sprite managers added to this scene
  10706. * @see http://doc.babylonjs.com/babylon101/sprites
  10707. */
  10708. spriteManagers: Array<ISpriteManager>;
  10709. /**
  10710. * An event triggered when sprites rendering is about to start
  10711. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10712. */
  10713. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10714. /**
  10715. * An event triggered when sprites rendering is done
  10716. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10717. */
  10718. onAfterSpritesRenderingObservable: Observable<Scene>;
  10719. /** @hidden */
  10720. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10721. /** Launch a ray to try to pick a sprite in the scene
  10722. * @param x position on screen
  10723. * @param y position on screen
  10724. * @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
  10725. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10726. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10727. * @returns a PickingInfo
  10728. */
  10729. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10730. /** Use the given ray to pick a sprite in the scene
  10731. * @param ray The ray (in world space) to use to pick meshes
  10732. * @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
  10733. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10734. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10735. * @returns a PickingInfo
  10736. */
  10737. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10738. /** @hidden */
  10739. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10740. /** Launch a ray to try to pick sprites in the scene
  10741. * @param x position on screen
  10742. * @param y position on screen
  10743. * @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
  10744. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10745. * @returns a PickingInfo array
  10746. */
  10747. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10748. /** Use the given ray to pick sprites in the scene
  10749. * @param ray The ray (in world space) to use to pick meshes
  10750. * @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
  10751. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10752. * @returns a PickingInfo array
  10753. */
  10754. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10755. /**
  10756. * Force the sprite under the pointer
  10757. * @param sprite defines the sprite to use
  10758. */
  10759. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10760. /**
  10761. * Gets the sprite under the pointer
  10762. * @returns a Sprite or null if no sprite is under the pointer
  10763. */
  10764. getPointerOverSprite(): Nullable<Sprite>;
  10765. }
  10766. /**
  10767. * Defines the sprite scene component responsible to manage sprites
  10768. * in a given scene.
  10769. */
  10770. export class SpriteSceneComponent implements ISceneComponent {
  10771. /**
  10772. * The component name helpfull to identify the component in the list of scene components.
  10773. */
  10774. readonly name: string;
  10775. /**
  10776. * The scene the component belongs to.
  10777. */
  10778. scene: Scene;
  10779. /** @hidden */
  10780. private _spritePredicate;
  10781. /**
  10782. * Creates a new instance of the component for the given scene
  10783. * @param scene Defines the scene to register the component in
  10784. */
  10785. constructor(scene: Scene);
  10786. /**
  10787. * Registers the component in a given scene
  10788. */
  10789. register(): void;
  10790. /**
  10791. * Rebuilds the elements related to this component in case of
  10792. * context lost for instance.
  10793. */
  10794. rebuild(): void;
  10795. /**
  10796. * Disposes the component and the associated ressources.
  10797. */
  10798. dispose(): void;
  10799. private _pickSpriteButKeepRay;
  10800. private _pointerMove;
  10801. private _pointerDown;
  10802. private _pointerUp;
  10803. }
  10804. }
  10805. declare module BABYLON {
  10806. /** @hidden */
  10807. export var fogFragmentDeclaration: {
  10808. name: string;
  10809. shader: string;
  10810. };
  10811. }
  10812. declare module BABYLON {
  10813. /** @hidden */
  10814. export var fogFragment: {
  10815. name: string;
  10816. shader: string;
  10817. };
  10818. }
  10819. declare module BABYLON {
  10820. /** @hidden */
  10821. export var spritesPixelShader: {
  10822. name: string;
  10823. shader: string;
  10824. };
  10825. }
  10826. declare module BABYLON {
  10827. /** @hidden */
  10828. export var fogVertexDeclaration: {
  10829. name: string;
  10830. shader: string;
  10831. };
  10832. }
  10833. declare module BABYLON {
  10834. /** @hidden */
  10835. export var spritesVertexShader: {
  10836. name: string;
  10837. shader: string;
  10838. };
  10839. }
  10840. declare module BABYLON {
  10841. /**
  10842. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10843. */
  10844. export interface ISpriteManager extends IDisposable {
  10845. /**
  10846. * Gets manager's name
  10847. */
  10848. name: string;
  10849. /**
  10850. * Restricts the camera to viewing objects with the same layerMask.
  10851. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10852. */
  10853. layerMask: number;
  10854. /**
  10855. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10856. */
  10857. isPickable: boolean;
  10858. /**
  10859. * Gets the hosting scene
  10860. */
  10861. scene: Scene;
  10862. /**
  10863. * Specifies the rendering group id for this mesh (0 by default)
  10864. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10865. */
  10866. renderingGroupId: number;
  10867. /**
  10868. * Defines the list of sprites managed by the manager.
  10869. */
  10870. sprites: Array<Sprite>;
  10871. /**
  10872. * Gets or sets the spritesheet texture
  10873. */
  10874. texture: Texture;
  10875. /** Defines the default width of a cell in the spritesheet */
  10876. cellWidth: number;
  10877. /** Defines the default height of a cell in the spritesheet */
  10878. cellHeight: number;
  10879. /**
  10880. * Tests the intersection of a sprite with a specific ray.
  10881. * @param ray The ray we are sending to test the collision
  10882. * @param camera The camera space we are sending rays in
  10883. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10884. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10885. * @returns picking info or null.
  10886. */
  10887. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10888. /**
  10889. * Intersects the sprites with a ray
  10890. * @param ray defines the ray to intersect with
  10891. * @param camera defines the current active camera
  10892. * @param predicate defines a predicate used to select candidate sprites
  10893. * @returns null if no hit or a PickingInfo array
  10894. */
  10895. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10896. /**
  10897. * Renders the list of sprites on screen.
  10898. */
  10899. render(): void;
  10900. }
  10901. /**
  10902. * Class used to manage multiple sprites on the same spritesheet
  10903. * @see http://doc.babylonjs.com/babylon101/sprites
  10904. */
  10905. export class SpriteManager implements ISpriteManager {
  10906. /** defines the manager's name */
  10907. name: string;
  10908. /** Define the Url to load snippets */
  10909. static SnippetUrl: string;
  10910. /** Snippet ID if the manager was created from the snippet server */
  10911. snippetId: string;
  10912. /** Gets the list of sprites */
  10913. sprites: Sprite[];
  10914. /** Gets or sets the rendering group id (0 by default) */
  10915. renderingGroupId: number;
  10916. /** Gets or sets camera layer mask */
  10917. layerMask: number;
  10918. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10919. fogEnabled: boolean;
  10920. /** Gets or sets a boolean indicating if the sprites are pickable */
  10921. isPickable: boolean;
  10922. /** Defines the default width of a cell in the spritesheet */
  10923. cellWidth: number;
  10924. /** Defines the default height of a cell in the spritesheet */
  10925. cellHeight: number;
  10926. /** Associative array from JSON sprite data file */
  10927. private _cellData;
  10928. /** Array of sprite names from JSON sprite data file */
  10929. private _spriteMap;
  10930. /** True when packed cell data from JSON file is ready*/
  10931. private _packedAndReady;
  10932. private _textureContent;
  10933. /**
  10934. * An event triggered when the manager is disposed.
  10935. */
  10936. onDisposeObservable: Observable<SpriteManager>;
  10937. private _onDisposeObserver;
  10938. /**
  10939. * Callback called when the manager is disposed
  10940. */
  10941. set onDispose(callback: () => void);
  10942. private _capacity;
  10943. private _fromPacked;
  10944. private _spriteTexture;
  10945. private _epsilon;
  10946. private _scene;
  10947. private _vertexData;
  10948. private _buffer;
  10949. private _vertexBuffers;
  10950. private _indexBuffer;
  10951. private _effectBase;
  10952. private _effectFog;
  10953. /**
  10954. * Gets or sets the unique id of the sprite
  10955. */
  10956. uniqueId: number;
  10957. /**
  10958. * Gets the array of sprites
  10959. */
  10960. get children(): Sprite[];
  10961. /**
  10962. * Gets the hosting scene
  10963. */
  10964. get scene(): Scene;
  10965. /**
  10966. * Gets the capacity of the manager
  10967. */
  10968. get capacity(): number;
  10969. /**
  10970. * Gets or sets the spritesheet texture
  10971. */
  10972. get texture(): Texture;
  10973. set texture(value: Texture);
  10974. private _blendMode;
  10975. /**
  10976. * Blend mode use to render the particle, it can be any of
  10977. * the static Constants.ALPHA_x properties provided in this class.
  10978. * Default value is Constants.ALPHA_COMBINE
  10979. */
  10980. get blendMode(): number;
  10981. set blendMode(blendMode: number);
  10982. /** Disables writing to the depth buffer when rendering the sprites.
  10983. * It can be handy to disable depth writing when using textures without alpha channel
  10984. * and setting some specific blend modes.
  10985. */
  10986. disableDepthWrite: boolean;
  10987. /**
  10988. * Creates a new sprite manager
  10989. * @param name defines the manager's name
  10990. * @param imgUrl defines the sprite sheet url
  10991. * @param capacity defines the maximum allowed number of sprites
  10992. * @param cellSize defines the size of a sprite cell
  10993. * @param scene defines the hosting scene
  10994. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10995. * @param samplingMode defines the smapling mode to use with spritesheet
  10996. * @param fromPacked set to false; do not alter
  10997. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10998. */
  10999. constructor(
  11000. /** defines the manager's name */
  11001. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11002. /**
  11003. * Returns the string "SpriteManager"
  11004. * @returns "SpriteManager"
  11005. */
  11006. getClassName(): string;
  11007. private _makePacked;
  11008. private _appendSpriteVertex;
  11009. private _checkTextureAlpha;
  11010. /**
  11011. * Intersects the sprites with a ray
  11012. * @param ray defines the ray to intersect with
  11013. * @param camera defines the current active camera
  11014. * @param predicate defines a predicate used to select candidate sprites
  11015. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11016. * @returns null if no hit or a PickingInfo
  11017. */
  11018. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11019. /**
  11020. * Intersects the sprites with a ray
  11021. * @param ray defines the ray to intersect with
  11022. * @param camera defines the current active camera
  11023. * @param predicate defines a predicate used to select candidate sprites
  11024. * @returns null if no hit or a PickingInfo array
  11025. */
  11026. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11027. /**
  11028. * Render all child sprites
  11029. */
  11030. render(): void;
  11031. /**
  11032. * Release associated resources
  11033. */
  11034. dispose(): void;
  11035. /**
  11036. * Serializes the sprite manager to a JSON object
  11037. * @param serializeTexture defines if the texture must be serialized as well
  11038. * @returns the JSON object
  11039. */
  11040. serialize(serializeTexture?: boolean): any;
  11041. /**
  11042. * Parses a JSON object to create a new sprite manager.
  11043. * @param parsedManager The JSON object to parse
  11044. * @param scene The scene to create the sprite managerin
  11045. * @param rootUrl The root url to use to load external dependencies like texture
  11046. * @returns the new sprite manager
  11047. */
  11048. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11049. /**
  11050. * Creates a sprite manager from a snippet saved in a remote file
  11051. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11052. * @param url defines the url to load from
  11053. * @param scene defines the hosting scene
  11054. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11055. * @returns a promise that will resolve to the new sprite manager
  11056. */
  11057. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11058. /**
  11059. * Creates a sprite manager from a snippet saved by the sprite editor
  11060. * @param snippetId defines the snippet to load
  11061. * @param scene defines the hosting scene
  11062. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11063. * @returns a promise that will resolve to the new sprite manager
  11064. */
  11065. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11066. }
  11067. }
  11068. declare module BABYLON {
  11069. /** Interface used by value gradients (color, factor, ...) */
  11070. export interface IValueGradient {
  11071. /**
  11072. * Gets or sets the gradient value (between 0 and 1)
  11073. */
  11074. gradient: number;
  11075. }
  11076. /** Class used to store color4 gradient */
  11077. export class ColorGradient implements IValueGradient {
  11078. /**
  11079. * Gets or sets the gradient value (between 0 and 1)
  11080. */
  11081. gradient: number;
  11082. /**
  11083. * Gets or sets first associated color
  11084. */
  11085. color1: Color4;
  11086. /**
  11087. * Gets or sets second associated color
  11088. */
  11089. color2?: Color4 | undefined;
  11090. /**
  11091. * Creates a new color4 gradient
  11092. * @param gradient gets or sets the gradient value (between 0 and 1)
  11093. * @param color1 gets or sets first associated color
  11094. * @param color2 gets or sets first second color
  11095. */
  11096. constructor(
  11097. /**
  11098. * Gets or sets the gradient value (between 0 and 1)
  11099. */
  11100. gradient: number,
  11101. /**
  11102. * Gets or sets first associated color
  11103. */
  11104. color1: Color4,
  11105. /**
  11106. * Gets or sets second associated color
  11107. */
  11108. color2?: Color4 | undefined);
  11109. /**
  11110. * Will get a color picked randomly between color1 and color2.
  11111. * If color2 is undefined then color1 will be used
  11112. * @param result defines the target Color4 to store the result in
  11113. */
  11114. getColorToRef(result: Color4): void;
  11115. }
  11116. /** Class used to store color 3 gradient */
  11117. export class Color3Gradient implements IValueGradient {
  11118. /**
  11119. * Gets or sets the gradient value (between 0 and 1)
  11120. */
  11121. gradient: number;
  11122. /**
  11123. * Gets or sets the associated color
  11124. */
  11125. color: Color3;
  11126. /**
  11127. * Creates a new color3 gradient
  11128. * @param gradient gets or sets the gradient value (between 0 and 1)
  11129. * @param color gets or sets associated color
  11130. */
  11131. constructor(
  11132. /**
  11133. * Gets or sets the gradient value (between 0 and 1)
  11134. */
  11135. gradient: number,
  11136. /**
  11137. * Gets or sets the associated color
  11138. */
  11139. color: Color3);
  11140. }
  11141. /** Class used to store factor gradient */
  11142. export class FactorGradient implements IValueGradient {
  11143. /**
  11144. * Gets or sets the gradient value (between 0 and 1)
  11145. */
  11146. gradient: number;
  11147. /**
  11148. * Gets or sets first associated factor
  11149. */
  11150. factor1: number;
  11151. /**
  11152. * Gets or sets second associated factor
  11153. */
  11154. factor2?: number | undefined;
  11155. /**
  11156. * Creates a new factor gradient
  11157. * @param gradient gets or sets the gradient value (between 0 and 1)
  11158. * @param factor1 gets or sets first associated factor
  11159. * @param factor2 gets or sets second associated factor
  11160. */
  11161. constructor(
  11162. /**
  11163. * Gets or sets the gradient value (between 0 and 1)
  11164. */
  11165. gradient: number,
  11166. /**
  11167. * Gets or sets first associated factor
  11168. */
  11169. factor1: number,
  11170. /**
  11171. * Gets or sets second associated factor
  11172. */
  11173. factor2?: number | undefined);
  11174. /**
  11175. * Will get a number picked randomly between factor1 and factor2.
  11176. * If factor2 is undefined then factor1 will be used
  11177. * @returns the picked number
  11178. */
  11179. getFactor(): number;
  11180. }
  11181. /**
  11182. * Helper used to simplify some generic gradient tasks
  11183. */
  11184. export class GradientHelper {
  11185. /**
  11186. * Gets the current gradient from an array of IValueGradient
  11187. * @param ratio defines the current ratio to get
  11188. * @param gradients defines the array of IValueGradient
  11189. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11190. */
  11191. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11192. }
  11193. }
  11194. declare module BABYLON {
  11195. interface ThinEngine {
  11196. /**
  11197. * Creates a dynamic texture
  11198. * @param width defines the width of the texture
  11199. * @param height defines the height of the texture
  11200. * @param generateMipMaps defines if the engine should generate the mip levels
  11201. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11202. * @returns the dynamic texture inside an InternalTexture
  11203. */
  11204. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11205. /**
  11206. * Update the content of a dynamic texture
  11207. * @param texture defines the texture to update
  11208. * @param canvas defines the canvas containing the source
  11209. * @param invertY defines if data must be stored with Y axis inverted
  11210. * @param premulAlpha defines if alpha is stored as premultiplied
  11211. * @param format defines the format of the data
  11212. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11213. */
  11214. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11215. }
  11216. }
  11217. declare module BABYLON {
  11218. /**
  11219. * Helper class used to generate a canvas to manipulate images
  11220. */
  11221. export class CanvasGenerator {
  11222. /**
  11223. * Create a new canvas (or offscreen canvas depending on the context)
  11224. * @param width defines the expected width
  11225. * @param height defines the expected height
  11226. * @return a new canvas or offscreen canvas
  11227. */
  11228. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11229. }
  11230. }
  11231. declare module BABYLON {
  11232. /**
  11233. * A class extending Texture allowing drawing on a texture
  11234. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11235. */
  11236. export class DynamicTexture extends Texture {
  11237. private _generateMipMaps;
  11238. private _canvas;
  11239. private _context;
  11240. /**
  11241. * Creates a DynamicTexture
  11242. * @param name defines the name of the texture
  11243. * @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
  11244. * @param scene defines the scene where you want the texture
  11245. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11246. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11247. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11248. */
  11249. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11250. /**
  11251. * Get the current class name of the texture useful for serialization or dynamic coding.
  11252. * @returns "DynamicTexture"
  11253. */
  11254. getClassName(): string;
  11255. /**
  11256. * Gets the current state of canRescale
  11257. */
  11258. get canRescale(): boolean;
  11259. private _recreate;
  11260. /**
  11261. * Scales the texture
  11262. * @param ratio the scale factor to apply to both width and height
  11263. */
  11264. scale(ratio: number): void;
  11265. /**
  11266. * Resizes the texture
  11267. * @param width the new width
  11268. * @param height the new height
  11269. */
  11270. scaleTo(width: number, height: number): void;
  11271. /**
  11272. * Gets the context of the canvas used by the texture
  11273. * @returns the canvas context of the dynamic texture
  11274. */
  11275. getContext(): CanvasRenderingContext2D;
  11276. /**
  11277. * Clears the texture
  11278. */
  11279. clear(): void;
  11280. /**
  11281. * Updates the texture
  11282. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11283. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11284. */
  11285. update(invertY?: boolean, premulAlpha?: boolean): void;
  11286. /**
  11287. * Draws text onto the texture
  11288. * @param text defines the text to be drawn
  11289. * @param x defines the placement of the text from the left
  11290. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11291. * @param font defines the font to be used with font-style, font-size, font-name
  11292. * @param color defines the color used for the text
  11293. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11294. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11295. * @param update defines whether texture is immediately update (default is true)
  11296. */
  11297. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11298. /**
  11299. * Clones the texture
  11300. * @returns the clone of the texture.
  11301. */
  11302. clone(): DynamicTexture;
  11303. /**
  11304. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11305. * @returns a serialized dynamic texture object
  11306. */
  11307. serialize(): any;
  11308. private _IsCanvasElement;
  11309. /** @hidden */
  11310. _rebuild(): void;
  11311. }
  11312. }
  11313. declare module BABYLON {
  11314. interface ThinEngine {
  11315. /**
  11316. * Creates a raw texture
  11317. * @param data defines the data to store in the texture
  11318. * @param width defines the width of the texture
  11319. * @param height defines the height of the texture
  11320. * @param format defines the format of the data
  11321. * @param generateMipMaps defines if the engine should generate the mip levels
  11322. * @param invertY defines if data must be stored with Y axis inverted
  11323. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11324. * @param compression defines the compression used (null by default)
  11325. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11326. * @returns the raw texture inside an InternalTexture
  11327. */
  11328. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11329. /**
  11330. * Update a raw texture
  11331. * @param texture defines the texture to update
  11332. * @param data defines the data to store in the texture
  11333. * @param format defines the format of the data
  11334. * @param invertY defines if data must be stored with Y axis inverted
  11335. */
  11336. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11337. /**
  11338. * Update a raw texture
  11339. * @param texture defines the texture to update
  11340. * @param data defines the data to store in the texture
  11341. * @param format defines the format of the data
  11342. * @param invertY defines if data must be stored with Y axis inverted
  11343. * @param compression defines the compression used (null by default)
  11344. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11345. */
  11346. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11347. /**
  11348. * Creates a new raw cube texture
  11349. * @param data defines the array of data to use to create each face
  11350. * @param size defines the size of the textures
  11351. * @param format defines the format of the data
  11352. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11353. * @param generateMipMaps defines if the engine should generate the mip levels
  11354. * @param invertY defines if data must be stored with Y axis inverted
  11355. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11356. * @param compression defines the compression used (null by default)
  11357. * @returns the cube texture as an InternalTexture
  11358. */
  11359. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11360. /**
  11361. * Update a raw cube texture
  11362. * @param texture defines the texture to udpdate
  11363. * @param data defines the data to store
  11364. * @param format defines the data format
  11365. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11366. * @param invertY defines if data must be stored with Y axis inverted
  11367. */
  11368. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11369. /**
  11370. * Update a raw cube texture
  11371. * @param texture defines the texture to udpdate
  11372. * @param data defines the data to store
  11373. * @param format defines the data format
  11374. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11375. * @param invertY defines if data must be stored with Y axis inverted
  11376. * @param compression defines the compression used (null by default)
  11377. */
  11378. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11379. /**
  11380. * Update a raw cube texture
  11381. * @param texture defines the texture to udpdate
  11382. * @param data defines the data to store
  11383. * @param format defines the data format
  11384. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11385. * @param invertY defines if data must be stored with Y axis inverted
  11386. * @param compression defines the compression used (null by default)
  11387. * @param level defines which level of the texture to update
  11388. */
  11389. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11390. /**
  11391. * Creates a new raw cube texture from a specified url
  11392. * @param url defines the url where the data is located
  11393. * @param scene defines the current scene
  11394. * @param size defines the size of the textures
  11395. * @param format defines the format of the data
  11396. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11397. * @param noMipmap defines if the engine should avoid generating the mip levels
  11398. * @param callback defines a callback used to extract texture data from loaded data
  11399. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11400. * @param onLoad defines a callback called when texture is loaded
  11401. * @param onError defines a callback called if there is an error
  11402. * @returns the cube texture as an InternalTexture
  11403. */
  11404. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  11405. /**
  11406. * Creates a new raw cube texture from a specified url
  11407. * @param url defines the url where the data is located
  11408. * @param scene defines the current scene
  11409. * @param size defines the size of the textures
  11410. * @param format defines the format of the data
  11411. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11412. * @param noMipmap defines if the engine should avoid generating the mip levels
  11413. * @param callback defines a callback used to extract texture data from loaded data
  11414. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11415. * @param onLoad defines a callback called when texture is loaded
  11416. * @param onError defines a callback called if there is an error
  11417. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11418. * @param invertY defines if data must be stored with Y axis inverted
  11419. * @returns the cube texture as an InternalTexture
  11420. */
  11421. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  11422. /**
  11423. * Creates a new raw 3D texture
  11424. * @param data defines the data used to create the texture
  11425. * @param width defines the width of the texture
  11426. * @param height defines the height of the texture
  11427. * @param depth defines the depth of the texture
  11428. * @param format defines the format of the texture
  11429. * @param generateMipMaps defines if the engine must generate mip levels
  11430. * @param invertY defines if data must be stored with Y axis inverted
  11431. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11432. * @param compression defines the compressed used (can be null)
  11433. * @param textureType defines the compressed used (can be null)
  11434. * @returns a new raw 3D texture (stored in an InternalTexture)
  11435. */
  11436. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11437. /**
  11438. * Update a raw 3D texture
  11439. * @param texture defines the texture to update
  11440. * @param data defines the data to store
  11441. * @param format defines the data format
  11442. * @param invertY defines if data must be stored with Y axis inverted
  11443. */
  11444. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11445. /**
  11446. * Update a raw 3D texture
  11447. * @param texture defines the texture to update
  11448. * @param data defines the data to store
  11449. * @param format defines the data format
  11450. * @param invertY defines if data must be stored with Y axis inverted
  11451. * @param compression defines the used compression (can be null)
  11452. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11453. */
  11454. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11455. /**
  11456. * Creates a new raw 2D array texture
  11457. * @param data defines the data used to create the texture
  11458. * @param width defines the width of the texture
  11459. * @param height defines the height of the texture
  11460. * @param depth defines the number of layers of the texture
  11461. * @param format defines the format of the texture
  11462. * @param generateMipMaps defines if the engine must generate mip levels
  11463. * @param invertY defines if data must be stored with Y axis inverted
  11464. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11465. * @param compression defines the compressed used (can be null)
  11466. * @param textureType defines the compressed used (can be null)
  11467. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11468. */
  11469. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11470. /**
  11471. * Update a raw 2D array texture
  11472. * @param texture defines the texture to update
  11473. * @param data defines the data to store
  11474. * @param format defines the data format
  11475. * @param invertY defines if data must be stored with Y axis inverted
  11476. */
  11477. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11478. /**
  11479. * Update a raw 2D array texture
  11480. * @param texture defines the texture to update
  11481. * @param data defines the data to store
  11482. * @param format defines the data format
  11483. * @param invertY defines if data must be stored with Y axis inverted
  11484. * @param compression defines the used compression (can be null)
  11485. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11486. */
  11487. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11488. }
  11489. }
  11490. declare module BABYLON {
  11491. /**
  11492. * Raw texture can help creating a texture directly from an array of data.
  11493. * This can be super useful if you either get the data from an uncompressed source or
  11494. * if you wish to create your texture pixel by pixel.
  11495. */
  11496. export class RawTexture extends Texture {
  11497. /**
  11498. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11499. */
  11500. format: number;
  11501. /**
  11502. * Instantiates a new RawTexture.
  11503. * Raw texture can help creating a texture directly from an array of data.
  11504. * This can be super useful if you either get the data from an uncompressed source or
  11505. * if you wish to create your texture pixel by pixel.
  11506. * @param data define the array of data to use to create the texture
  11507. * @param width define the width of the texture
  11508. * @param height define the height of the texture
  11509. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11510. * @param scene define the scene the texture belongs to
  11511. * @param generateMipMaps define whether mip maps should be generated or not
  11512. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11513. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11514. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11515. */
  11516. constructor(data: ArrayBufferView, width: number, height: number,
  11517. /**
  11518. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11519. */
  11520. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11521. /**
  11522. * Updates the texture underlying data.
  11523. * @param data Define the new data of the texture
  11524. */
  11525. update(data: ArrayBufferView): void;
  11526. /**
  11527. * Creates a luminance texture from some data.
  11528. * @param data Define the texture data
  11529. * @param width Define the width of the texture
  11530. * @param height Define the height of the texture
  11531. * @param scene Define the scene the texture belongs to
  11532. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11533. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11534. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11535. * @returns the luminance texture
  11536. */
  11537. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11538. /**
  11539. * Creates a luminance alpha texture from some data.
  11540. * @param data Define the texture data
  11541. * @param width Define the width of the texture
  11542. * @param height Define the height of the texture
  11543. * @param scene Define the scene the texture belongs to
  11544. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11547. * @returns the luminance alpha texture
  11548. */
  11549. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11550. /**
  11551. * Creates an alpha texture from some data.
  11552. * @param data Define the texture data
  11553. * @param width Define the width of the texture
  11554. * @param height Define the height of the texture
  11555. * @param scene Define the scene the texture belongs to
  11556. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11557. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11558. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11559. * @returns the alpha texture
  11560. */
  11561. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11562. /**
  11563. * Creates a RGB texture from some data.
  11564. * @param data Define the texture data
  11565. * @param width Define the width of the texture
  11566. * @param height Define the height of the texture
  11567. * @param scene Define the scene the texture belongs to
  11568. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11569. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11570. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11571. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11572. * @returns the RGB alpha texture
  11573. */
  11574. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11575. /**
  11576. * Creates a RGBA texture from some data.
  11577. * @param data Define the texture data
  11578. * @param width Define the width of the texture
  11579. * @param height Define the height of the texture
  11580. * @param scene Define the scene the texture belongs to
  11581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11585. * @returns the RGBA texture
  11586. */
  11587. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11588. /**
  11589. * Creates a R texture from some data.
  11590. * @param data Define the texture data
  11591. * @param width Define the width of the texture
  11592. * @param height Define the height of the texture
  11593. * @param scene Define the scene the texture belongs to
  11594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11597. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11598. * @returns the R texture
  11599. */
  11600. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11601. }
  11602. }
  11603. declare module BABYLON {
  11604. interface AbstractScene {
  11605. /**
  11606. * The list of procedural textures added to the scene
  11607. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11608. */
  11609. proceduralTextures: Array<ProceduralTexture>;
  11610. }
  11611. /**
  11612. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11613. * in a given scene.
  11614. */
  11615. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11616. /**
  11617. * The component name helpfull to identify the component in the list of scene components.
  11618. */
  11619. readonly name: string;
  11620. /**
  11621. * The scene the component belongs to.
  11622. */
  11623. scene: Scene;
  11624. /**
  11625. * Creates a new instance of the component for the given scene
  11626. * @param scene Defines the scene to register the component in
  11627. */
  11628. constructor(scene: Scene);
  11629. /**
  11630. * Registers the component in a given scene
  11631. */
  11632. register(): void;
  11633. /**
  11634. * Rebuilds the elements related to this component in case of
  11635. * context lost for instance.
  11636. */
  11637. rebuild(): void;
  11638. /**
  11639. * Disposes the component and the associated ressources.
  11640. */
  11641. dispose(): void;
  11642. private _beforeClear;
  11643. }
  11644. }
  11645. declare module BABYLON {
  11646. interface ThinEngine {
  11647. /**
  11648. * Creates a new render target cube texture
  11649. * @param size defines the size of the texture
  11650. * @param options defines the options used to create the texture
  11651. * @returns a new render target cube texture stored in an InternalTexture
  11652. */
  11653. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11654. }
  11655. }
  11656. declare module BABYLON {
  11657. /** @hidden */
  11658. export var proceduralVertexShader: {
  11659. name: string;
  11660. shader: string;
  11661. };
  11662. }
  11663. declare module BABYLON {
  11664. /**
  11665. * 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.
  11666. * This is the base class of any Procedural texture and contains most of the shareable code.
  11667. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11668. */
  11669. export class ProceduralTexture extends Texture {
  11670. isCube: boolean;
  11671. /**
  11672. * Define if the texture is enabled or not (disabled texture will not render)
  11673. */
  11674. isEnabled: boolean;
  11675. /**
  11676. * Define if the texture must be cleared before rendering (default is true)
  11677. */
  11678. autoClear: boolean;
  11679. /**
  11680. * Callback called when the texture is generated
  11681. */
  11682. onGenerated: () => void;
  11683. /**
  11684. * Event raised when the texture is generated
  11685. */
  11686. onGeneratedObservable: Observable<ProceduralTexture>;
  11687. /** @hidden */
  11688. _generateMipMaps: boolean;
  11689. /** @hidden **/
  11690. _effect: Effect;
  11691. /** @hidden */
  11692. _textures: {
  11693. [key: string]: Texture;
  11694. };
  11695. /** @hidden */
  11696. protected _fallbackTexture: Nullable<Texture>;
  11697. private _size;
  11698. private _currentRefreshId;
  11699. private _frameId;
  11700. private _refreshRate;
  11701. private _vertexBuffers;
  11702. private _indexBuffer;
  11703. private _uniforms;
  11704. private _samplers;
  11705. private _fragment;
  11706. private _floats;
  11707. private _ints;
  11708. private _floatsArrays;
  11709. private _colors3;
  11710. private _colors4;
  11711. private _vectors2;
  11712. private _vectors3;
  11713. private _matrices;
  11714. private _fallbackTextureUsed;
  11715. private _fullEngine;
  11716. private _cachedDefines;
  11717. private _contentUpdateId;
  11718. private _contentData;
  11719. /**
  11720. * Instantiates a new procedural texture.
  11721. * 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.
  11722. * This is the base class of any Procedural texture and contains most of the shareable code.
  11723. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11724. * @param name Define the name of the texture
  11725. * @param size Define the size of the texture to create
  11726. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11727. * @param scene Define the scene the texture belongs to
  11728. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11729. * @param generateMipMaps Define if the texture should creates mip maps or not
  11730. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11731. */
  11732. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11733. /**
  11734. * The effect that is created when initializing the post process.
  11735. * @returns The created effect corresponding the the postprocess.
  11736. */
  11737. getEffect(): Effect;
  11738. /**
  11739. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11740. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11741. */
  11742. getContent(): Nullable<ArrayBufferView>;
  11743. private _createIndexBuffer;
  11744. /** @hidden */
  11745. _rebuild(): void;
  11746. /**
  11747. * Resets the texture in order to recreate its associated resources.
  11748. * This can be called in case of context loss
  11749. */
  11750. reset(): void;
  11751. protected _getDefines(): string;
  11752. /**
  11753. * Is the texture ready to be used ? (rendered at least once)
  11754. * @returns true if ready, otherwise, false.
  11755. */
  11756. isReady(): boolean;
  11757. /**
  11758. * Resets the refresh counter of the texture and start bak from scratch.
  11759. * Could be useful to regenerate the texture if it is setup to render only once.
  11760. */
  11761. resetRefreshCounter(): void;
  11762. /**
  11763. * Set the fragment shader to use in order to render the texture.
  11764. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11765. */
  11766. setFragment(fragment: any): void;
  11767. /**
  11768. * Define the refresh rate of the texture or the rendering frequency.
  11769. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11770. */
  11771. get refreshRate(): number;
  11772. set refreshRate(value: number);
  11773. /** @hidden */
  11774. _shouldRender(): boolean;
  11775. /**
  11776. * Get the size the texture is rendering at.
  11777. * @returns the size (texture is always squared)
  11778. */
  11779. getRenderSize(): number;
  11780. /**
  11781. * Resize the texture to new value.
  11782. * @param size Define the new size the texture should have
  11783. * @param generateMipMaps Define whether the new texture should create mip maps
  11784. */
  11785. resize(size: number, generateMipMaps: boolean): void;
  11786. private _checkUniform;
  11787. /**
  11788. * Set a texture in the shader program used to render.
  11789. * @param name Define the name of the uniform samplers as defined in the shader
  11790. * @param texture Define the texture to bind to this sampler
  11791. * @return the texture itself allowing "fluent" like uniform updates
  11792. */
  11793. setTexture(name: string, texture: Texture): ProceduralTexture;
  11794. /**
  11795. * Set a float in the shader.
  11796. * @param name Define the name of the uniform as defined in the shader
  11797. * @param value Define the value to give to the uniform
  11798. * @return the texture itself allowing "fluent" like uniform updates
  11799. */
  11800. setFloat(name: string, value: number): ProceduralTexture;
  11801. /**
  11802. * Set a int in the shader.
  11803. * @param name Define the name of the uniform as defined in the shader
  11804. * @param value Define the value to give to the uniform
  11805. * @return the texture itself allowing "fluent" like uniform updates
  11806. */
  11807. setInt(name: string, value: number): ProceduralTexture;
  11808. /**
  11809. * Set an array of floats in the shader.
  11810. * @param name Define the name of the uniform as defined in the shader
  11811. * @param value Define the value to give to the uniform
  11812. * @return the texture itself allowing "fluent" like uniform updates
  11813. */
  11814. setFloats(name: string, value: number[]): ProceduralTexture;
  11815. /**
  11816. * Set a vec3 in the shader from a Color3.
  11817. * @param name Define the name of the uniform as defined in the shader
  11818. * @param value Define the value to give to the uniform
  11819. * @return the texture itself allowing "fluent" like uniform updates
  11820. */
  11821. setColor3(name: string, value: Color3): ProceduralTexture;
  11822. /**
  11823. * Set a vec4 in the shader from a Color4.
  11824. * @param name Define the name of the uniform as defined in the shader
  11825. * @param value Define the value to give to the uniform
  11826. * @return the texture itself allowing "fluent" like uniform updates
  11827. */
  11828. setColor4(name: string, value: Color4): ProceduralTexture;
  11829. /**
  11830. * Set a vec2 in the shader from a Vector2.
  11831. * @param name Define the name of the uniform as defined in the shader
  11832. * @param value Define the value to give to the uniform
  11833. * @return the texture itself allowing "fluent" like uniform updates
  11834. */
  11835. setVector2(name: string, value: Vector2): ProceduralTexture;
  11836. /**
  11837. * Set a vec3 in the shader from a Vector3.
  11838. * @param name Define the name of the uniform as defined in the shader
  11839. * @param value Define the value to give to the uniform
  11840. * @return the texture itself allowing "fluent" like uniform updates
  11841. */
  11842. setVector3(name: string, value: Vector3): ProceduralTexture;
  11843. /**
  11844. * Set a mat4 in the shader from a MAtrix.
  11845. * @param name Define the name of the uniform as defined in the shader
  11846. * @param value Define the value to give to the uniform
  11847. * @return the texture itself allowing "fluent" like uniform updates
  11848. */
  11849. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11850. /**
  11851. * Render the texture to its associated render target.
  11852. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11853. */
  11854. render(useCameraPostProcess?: boolean): void;
  11855. /**
  11856. * Clone the texture.
  11857. * @returns the cloned texture
  11858. */
  11859. clone(): ProceduralTexture;
  11860. /**
  11861. * Dispose the texture and release its asoociated resources.
  11862. */
  11863. dispose(): void;
  11864. }
  11865. }
  11866. declare module BABYLON {
  11867. /**
  11868. * This represents the base class for particle system in Babylon.
  11869. * 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.
  11870. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11871. * @example https://doc.babylonjs.com/babylon101/particles
  11872. */
  11873. export class BaseParticleSystem {
  11874. /**
  11875. * Source color is added to the destination color without alpha affecting the result
  11876. */
  11877. static BLENDMODE_ONEONE: number;
  11878. /**
  11879. * Blend current color and particle color using particle’s alpha
  11880. */
  11881. static BLENDMODE_STANDARD: number;
  11882. /**
  11883. * Add current color and particle color multiplied by particle’s alpha
  11884. */
  11885. static BLENDMODE_ADD: number;
  11886. /**
  11887. * Multiply current color with particle color
  11888. */
  11889. static BLENDMODE_MULTIPLY: number;
  11890. /**
  11891. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11892. */
  11893. static BLENDMODE_MULTIPLYADD: number;
  11894. /**
  11895. * List of animations used by the particle system.
  11896. */
  11897. animations: Animation[];
  11898. /**
  11899. * Gets or sets the unique id of the particle system
  11900. */
  11901. uniqueId: number;
  11902. /**
  11903. * The id of the Particle system.
  11904. */
  11905. id: string;
  11906. /**
  11907. * The friendly name of the Particle system.
  11908. */
  11909. name: string;
  11910. /**
  11911. * Snippet ID if the particle system was created from the snippet server
  11912. */
  11913. snippetId: string;
  11914. /**
  11915. * The rendering group used by the Particle system to chose when to render.
  11916. */
  11917. renderingGroupId: number;
  11918. /**
  11919. * The emitter represents the Mesh or position we are attaching the particle system to.
  11920. */
  11921. emitter: Nullable<AbstractMesh | Vector3>;
  11922. /**
  11923. * The maximum number of particles to emit per frame
  11924. */
  11925. emitRate: number;
  11926. /**
  11927. * If you want to launch only a few particles at once, that can be done, as well.
  11928. */
  11929. manualEmitCount: number;
  11930. /**
  11931. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11932. */
  11933. updateSpeed: number;
  11934. /**
  11935. * The amount of time the particle system is running (depends of the overall update speed).
  11936. */
  11937. targetStopDuration: number;
  11938. /**
  11939. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11940. */
  11941. disposeOnStop: boolean;
  11942. /**
  11943. * Minimum power of emitting particles.
  11944. */
  11945. minEmitPower: number;
  11946. /**
  11947. * Maximum power of emitting particles.
  11948. */
  11949. maxEmitPower: number;
  11950. /**
  11951. * Minimum life time of emitting particles.
  11952. */
  11953. minLifeTime: number;
  11954. /**
  11955. * Maximum life time of emitting particles.
  11956. */
  11957. maxLifeTime: number;
  11958. /**
  11959. * Minimum Size of emitting particles.
  11960. */
  11961. minSize: number;
  11962. /**
  11963. * Maximum Size of emitting particles.
  11964. */
  11965. maxSize: number;
  11966. /**
  11967. * Minimum scale of emitting particles on X axis.
  11968. */
  11969. minScaleX: number;
  11970. /**
  11971. * Maximum scale of emitting particles on X axis.
  11972. */
  11973. maxScaleX: number;
  11974. /**
  11975. * Minimum scale of emitting particles on Y axis.
  11976. */
  11977. minScaleY: number;
  11978. /**
  11979. * Maximum scale of emitting particles on Y axis.
  11980. */
  11981. maxScaleY: number;
  11982. /**
  11983. * Gets or sets the minimal initial rotation in radians.
  11984. */
  11985. minInitialRotation: number;
  11986. /**
  11987. * Gets or sets the maximal initial rotation in radians.
  11988. */
  11989. maxInitialRotation: number;
  11990. /**
  11991. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11992. */
  11993. minAngularSpeed: number;
  11994. /**
  11995. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11996. */
  11997. maxAngularSpeed: number;
  11998. /**
  11999. * The texture used to render each particle. (this can be a spritesheet)
  12000. */
  12001. particleTexture: Nullable<Texture>;
  12002. /**
  12003. * The layer mask we are rendering the particles through.
  12004. */
  12005. layerMask: number;
  12006. /**
  12007. * This can help using your own shader to render the particle system.
  12008. * The according effect will be created
  12009. */
  12010. customShader: any;
  12011. /**
  12012. * By default particle system starts as soon as they are created. This prevents the
  12013. * automatic start to happen and let you decide when to start emitting particles.
  12014. */
  12015. preventAutoStart: boolean;
  12016. private _noiseTexture;
  12017. /**
  12018. * Gets or sets a texture used to add random noise to particle positions
  12019. */
  12020. get noiseTexture(): Nullable<ProceduralTexture>;
  12021. set noiseTexture(value: Nullable<ProceduralTexture>);
  12022. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12023. noiseStrength: Vector3;
  12024. /**
  12025. * Callback triggered when the particle animation is ending.
  12026. */
  12027. onAnimationEnd: Nullable<() => void>;
  12028. /**
  12029. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12030. */
  12031. blendMode: number;
  12032. /**
  12033. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12034. * to override the particles.
  12035. */
  12036. forceDepthWrite: boolean;
  12037. /** 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 */
  12038. preWarmCycles: number;
  12039. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12040. preWarmStepOffset: number;
  12041. /**
  12042. * 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)
  12043. */
  12044. spriteCellChangeSpeed: number;
  12045. /**
  12046. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12047. */
  12048. startSpriteCellID: number;
  12049. /**
  12050. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12051. */
  12052. endSpriteCellID: number;
  12053. /**
  12054. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12055. */
  12056. spriteCellWidth: number;
  12057. /**
  12058. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12059. */
  12060. spriteCellHeight: number;
  12061. /**
  12062. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12063. */
  12064. spriteRandomStartCell: boolean;
  12065. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12066. translationPivot: Vector2;
  12067. /** @hidden */
  12068. protected _isAnimationSheetEnabled: boolean;
  12069. /**
  12070. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12071. */
  12072. beginAnimationOnStart: boolean;
  12073. /**
  12074. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12075. */
  12076. beginAnimationFrom: number;
  12077. /**
  12078. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12079. */
  12080. beginAnimationTo: number;
  12081. /**
  12082. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12083. */
  12084. beginAnimationLoop: boolean;
  12085. /**
  12086. * Gets or sets a world offset applied to all particles
  12087. */
  12088. worldOffset: Vector3;
  12089. /**
  12090. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12091. */
  12092. get isAnimationSheetEnabled(): boolean;
  12093. set isAnimationSheetEnabled(value: boolean);
  12094. /**
  12095. * Get hosting scene
  12096. * @returns the scene
  12097. */
  12098. getScene(): Scene;
  12099. /**
  12100. * You can use gravity if you want to give an orientation to your particles.
  12101. */
  12102. gravity: Vector3;
  12103. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12104. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12105. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12106. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12107. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12108. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12109. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12110. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12111. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12112. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12113. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12114. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12115. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12116. /**
  12117. * Defines the delay in milliseconds before starting the system (0 by default)
  12118. */
  12119. startDelay: number;
  12120. /**
  12121. * Gets the current list of drag gradients.
  12122. * You must use addDragGradient and removeDragGradient to udpate this list
  12123. * @returns the list of drag gradients
  12124. */
  12125. getDragGradients(): Nullable<Array<FactorGradient>>;
  12126. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12127. limitVelocityDamping: number;
  12128. /**
  12129. * Gets the current list of limit velocity gradients.
  12130. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12131. * @returns the list of limit velocity gradients
  12132. */
  12133. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12134. /**
  12135. * Gets the current list of color gradients.
  12136. * You must use addColorGradient and removeColorGradient to udpate this list
  12137. * @returns the list of color gradients
  12138. */
  12139. getColorGradients(): Nullable<Array<ColorGradient>>;
  12140. /**
  12141. * Gets the current list of size gradients.
  12142. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12143. * @returns the list of size gradients
  12144. */
  12145. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12146. /**
  12147. * Gets the current list of color remap gradients.
  12148. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12149. * @returns the list of color remap gradients
  12150. */
  12151. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12152. /**
  12153. * Gets the current list of alpha remap gradients.
  12154. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12155. * @returns the list of alpha remap gradients
  12156. */
  12157. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12158. /**
  12159. * Gets the current list of life time gradients.
  12160. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12161. * @returns the list of life time gradients
  12162. */
  12163. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12164. /**
  12165. * Gets the current list of angular speed gradients.
  12166. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12167. * @returns the list of angular speed gradients
  12168. */
  12169. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12170. /**
  12171. * Gets the current list of velocity gradients.
  12172. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12173. * @returns the list of velocity gradients
  12174. */
  12175. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12176. /**
  12177. * Gets the current list of start size gradients.
  12178. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12179. * @returns the list of start size gradients
  12180. */
  12181. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12182. /**
  12183. * Gets the current list of emit rate gradients.
  12184. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12185. * @returns the list of emit rate gradients
  12186. */
  12187. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12188. /**
  12189. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12190. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12191. */
  12192. get direction1(): Vector3;
  12193. set direction1(value: Vector3);
  12194. /**
  12195. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12196. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12197. */
  12198. get direction2(): Vector3;
  12199. set direction2(value: Vector3);
  12200. /**
  12201. * 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.
  12202. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12203. */
  12204. get minEmitBox(): Vector3;
  12205. set minEmitBox(value: Vector3);
  12206. /**
  12207. * 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.
  12208. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12209. */
  12210. get maxEmitBox(): Vector3;
  12211. set maxEmitBox(value: Vector3);
  12212. /**
  12213. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12214. */
  12215. color1: Color4;
  12216. /**
  12217. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12218. */
  12219. color2: Color4;
  12220. /**
  12221. * Color the particle will have at the end of its lifetime
  12222. */
  12223. colorDead: Color4;
  12224. /**
  12225. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12226. */
  12227. textureMask: Color4;
  12228. /**
  12229. * The particle emitter type defines the emitter used by the particle system.
  12230. * It can be for example box, sphere, or cone...
  12231. */
  12232. particleEmitterType: IParticleEmitterType;
  12233. /** @hidden */
  12234. _isSubEmitter: boolean;
  12235. /**
  12236. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12237. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12238. */
  12239. billboardMode: number;
  12240. protected _isBillboardBased: boolean;
  12241. /**
  12242. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12243. */
  12244. get isBillboardBased(): boolean;
  12245. set isBillboardBased(value: boolean);
  12246. /**
  12247. * The scene the particle system belongs to.
  12248. */
  12249. protected _scene: Scene;
  12250. /**
  12251. * Local cache of defines for image processing.
  12252. */
  12253. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12254. /**
  12255. * Default configuration related to image processing available in the standard Material.
  12256. */
  12257. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12258. /**
  12259. * Gets the image processing configuration used either in this material.
  12260. */
  12261. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12262. /**
  12263. * Sets the Default image processing configuration used either in the this material.
  12264. *
  12265. * If sets to null, the scene one is in use.
  12266. */
  12267. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12268. /**
  12269. * Attaches a new image processing configuration to the Standard Material.
  12270. * @param configuration
  12271. */
  12272. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12273. /** @hidden */
  12274. protected _reset(): void;
  12275. /** @hidden */
  12276. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12277. /**
  12278. * Instantiates a particle system.
  12279. * 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.
  12280. * @param name The name of the particle system
  12281. */
  12282. constructor(name: string);
  12283. /**
  12284. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12285. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12286. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12287. * @returns the emitter
  12288. */
  12289. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12290. /**
  12291. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12292. * @param radius The radius of the hemisphere to emit from
  12293. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12294. * @returns the emitter
  12295. */
  12296. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12297. /**
  12298. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12299. * @param radius The radius of the sphere to emit from
  12300. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12301. * @returns the emitter
  12302. */
  12303. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12304. /**
  12305. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12306. * @param radius The radius of the sphere to emit from
  12307. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12308. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12309. * @returns the emitter
  12310. */
  12311. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12312. /**
  12313. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12314. * @param radius The radius of the emission cylinder
  12315. * @param height The height of the emission cylinder
  12316. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12317. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12318. * @returns the emitter
  12319. */
  12320. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12321. /**
  12322. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12323. * @param radius The radius of the cylinder to emit from
  12324. * @param height The height of the emission cylinder
  12325. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12326. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12327. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12328. * @returns the emitter
  12329. */
  12330. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12331. /**
  12332. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12333. * @param radius The radius of the cone to emit from
  12334. * @param angle The base angle of the cone
  12335. * @returns the emitter
  12336. */
  12337. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12338. /**
  12339. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12342. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12343. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12344. * @returns the emitter
  12345. */
  12346. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12347. }
  12348. }
  12349. declare module BABYLON {
  12350. /**
  12351. * Type of sub emitter
  12352. */
  12353. export enum SubEmitterType {
  12354. /**
  12355. * Attached to the particle over it's lifetime
  12356. */
  12357. ATTACHED = 0,
  12358. /**
  12359. * Created when the particle dies
  12360. */
  12361. END = 1
  12362. }
  12363. /**
  12364. * Sub emitter class used to emit particles from an existing particle
  12365. */
  12366. export class SubEmitter {
  12367. /**
  12368. * the particle system to be used by the sub emitter
  12369. */
  12370. particleSystem: ParticleSystem;
  12371. /**
  12372. * Type of the submitter (Default: END)
  12373. */
  12374. type: SubEmitterType;
  12375. /**
  12376. * 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)
  12377. * Note: This only is supported when using an emitter of type Mesh
  12378. */
  12379. inheritDirection: boolean;
  12380. /**
  12381. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12382. */
  12383. inheritedVelocityAmount: number;
  12384. /**
  12385. * Creates a sub emitter
  12386. * @param particleSystem the particle system to be used by the sub emitter
  12387. */
  12388. constructor(
  12389. /**
  12390. * the particle system to be used by the sub emitter
  12391. */
  12392. particleSystem: ParticleSystem);
  12393. /**
  12394. * Clones the sub emitter
  12395. * @returns the cloned sub emitter
  12396. */
  12397. clone(): SubEmitter;
  12398. /**
  12399. * Serialize current object to a JSON object
  12400. * @returns the serialized object
  12401. */
  12402. serialize(): any;
  12403. /** @hidden */
  12404. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12405. /**
  12406. * Creates a new SubEmitter from a serialized JSON version
  12407. * @param serializationObject defines the JSON object to read from
  12408. * @param scene defines the hosting scene
  12409. * @param rootUrl defines the rootUrl for data loading
  12410. * @returns a new SubEmitter
  12411. */
  12412. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12413. /** Release associated resources */
  12414. dispose(): void;
  12415. }
  12416. }
  12417. declare module BABYLON {
  12418. /** @hidden */
  12419. export var imageProcessingDeclaration: {
  12420. name: string;
  12421. shader: string;
  12422. };
  12423. }
  12424. declare module BABYLON {
  12425. /** @hidden */
  12426. export var imageProcessingFunctions: {
  12427. name: string;
  12428. shader: string;
  12429. };
  12430. }
  12431. declare module BABYLON {
  12432. /** @hidden */
  12433. export var particlesPixelShader: {
  12434. name: string;
  12435. shader: string;
  12436. };
  12437. }
  12438. declare module BABYLON {
  12439. /** @hidden */
  12440. export var particlesVertexShader: {
  12441. name: string;
  12442. shader: string;
  12443. };
  12444. }
  12445. declare module BABYLON {
  12446. /**
  12447. * This represents a particle system in Babylon.
  12448. * 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.
  12449. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12450. * @example https://doc.babylonjs.com/babylon101/particles
  12451. */
  12452. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12453. /**
  12454. * Billboard mode will only apply to Y axis
  12455. */
  12456. static readonly BILLBOARDMODE_Y: number;
  12457. /**
  12458. * Billboard mode will apply to all axes
  12459. */
  12460. static readonly BILLBOARDMODE_ALL: number;
  12461. /**
  12462. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12463. */
  12464. static readonly BILLBOARDMODE_STRETCHED: number;
  12465. /**
  12466. * This function can be defined to provide custom update for active particles.
  12467. * This function will be called instead of regular update (age, position, color, etc.).
  12468. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12469. */
  12470. updateFunction: (particles: Particle[]) => void;
  12471. private _emitterWorldMatrix;
  12472. /**
  12473. * This function can be defined to specify initial direction for every new particle.
  12474. * It by default use the emitterType defined function
  12475. */
  12476. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12477. /**
  12478. * This function can be defined to specify initial position for every new particle.
  12479. * It by default use the emitterType defined function
  12480. */
  12481. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12482. /**
  12483. * @hidden
  12484. */
  12485. _inheritedVelocityOffset: Vector3;
  12486. /**
  12487. * An event triggered when the system is disposed
  12488. */
  12489. onDisposeObservable: Observable<IParticleSystem>;
  12490. private _onDisposeObserver;
  12491. /**
  12492. * Sets a callback that will be triggered when the system is disposed
  12493. */
  12494. set onDispose(callback: () => void);
  12495. private _particles;
  12496. private _epsilon;
  12497. private _capacity;
  12498. private _stockParticles;
  12499. private _newPartsExcess;
  12500. private _vertexData;
  12501. private _vertexBuffer;
  12502. private _vertexBuffers;
  12503. private _spriteBuffer;
  12504. private _indexBuffer;
  12505. private _effect;
  12506. private _customEffect;
  12507. private _cachedDefines;
  12508. private _scaledColorStep;
  12509. private _colorDiff;
  12510. private _scaledDirection;
  12511. private _scaledGravity;
  12512. private _currentRenderId;
  12513. private _alive;
  12514. private _useInstancing;
  12515. private _started;
  12516. private _stopped;
  12517. private _actualFrame;
  12518. private _scaledUpdateSpeed;
  12519. private _vertexBufferSize;
  12520. /** @hidden */
  12521. _currentEmitRateGradient: Nullable<FactorGradient>;
  12522. /** @hidden */
  12523. _currentEmitRate1: number;
  12524. /** @hidden */
  12525. _currentEmitRate2: number;
  12526. /** @hidden */
  12527. _currentStartSizeGradient: Nullable<FactorGradient>;
  12528. /** @hidden */
  12529. _currentStartSize1: number;
  12530. /** @hidden */
  12531. _currentStartSize2: number;
  12532. private readonly _rawTextureWidth;
  12533. private _rampGradientsTexture;
  12534. private _useRampGradients;
  12535. /** Gets or sets a boolean indicating that ramp gradients must be used
  12536. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12537. */
  12538. get useRampGradients(): boolean;
  12539. set useRampGradients(value: boolean);
  12540. /**
  12541. * 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.
  12542. * 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: [])
  12543. */
  12544. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12545. private _subEmitters;
  12546. /**
  12547. * @hidden
  12548. * If the particle systems emitter should be disposed when the particle system is disposed
  12549. */
  12550. _disposeEmitterOnDispose: boolean;
  12551. /**
  12552. * The current active Sub-systems, this property is used by the root particle system only.
  12553. */
  12554. activeSubSystems: Array<ParticleSystem>;
  12555. /**
  12556. * Specifies if the particles are updated in emitter local space or world space
  12557. */
  12558. isLocal: boolean;
  12559. private _rootParticleSystem;
  12560. /**
  12561. * Gets the current list of active particles
  12562. */
  12563. get particles(): Particle[];
  12564. /**
  12565. * Gets the number of particles active at the same time.
  12566. * @returns The number of active particles.
  12567. */
  12568. getActiveCount(): number;
  12569. /**
  12570. * Returns the string "ParticleSystem"
  12571. * @returns a string containing the class name
  12572. */
  12573. getClassName(): string;
  12574. /**
  12575. * Gets a boolean indicating that the system is stopping
  12576. * @returns true if the system is currently stopping
  12577. */
  12578. isStopping(): boolean;
  12579. /**
  12580. * Gets the custom effect used to render the particles
  12581. * @param blendMode Blend mode for which the effect should be retrieved
  12582. * @returns The effect
  12583. */
  12584. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12585. /**
  12586. * Sets the custom effect used to render the particles
  12587. * @param effect The effect to set
  12588. * @param blendMode Blend mode for which the effect should be set
  12589. */
  12590. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12591. /** @hidden */
  12592. private _onBeforeDrawParticlesObservable;
  12593. /**
  12594. * Observable that will be called just before the particles are drawn
  12595. */
  12596. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12597. /**
  12598. * Gets the name of the particle vertex shader
  12599. */
  12600. get vertexShaderName(): string;
  12601. /**
  12602. * Instantiates a particle system.
  12603. * 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.
  12604. * @param name The name of the particle system
  12605. * @param capacity The max number of particles alive at the same time
  12606. * @param scene The scene the particle system belongs to
  12607. * @param customEffect a custom effect used to change the way particles are rendered by default
  12608. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12609. * @param epsilon Offset used to render the particles
  12610. */
  12611. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12612. private _addFactorGradient;
  12613. private _removeFactorGradient;
  12614. /**
  12615. * Adds a new life time gradient
  12616. * @param gradient defines the gradient to use (between 0 and 1)
  12617. * @param factor defines the life time factor to affect to the specified gradient
  12618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12619. * @returns the current particle system
  12620. */
  12621. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12622. /**
  12623. * Remove a specific life time gradient
  12624. * @param gradient defines the gradient to remove
  12625. * @returns the current particle system
  12626. */
  12627. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12628. /**
  12629. * Adds a new size gradient
  12630. * @param gradient defines the gradient to use (between 0 and 1)
  12631. * @param factor defines the size factor to affect to the specified gradient
  12632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12633. * @returns the current particle system
  12634. */
  12635. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12636. /**
  12637. * Remove a specific size gradient
  12638. * @param gradient defines the gradient to remove
  12639. * @returns the current particle system
  12640. */
  12641. removeSizeGradient(gradient: number): IParticleSystem;
  12642. /**
  12643. * Adds a new color remap gradient
  12644. * @param gradient defines the gradient to use (between 0 and 1)
  12645. * @param min defines the color remap minimal range
  12646. * @param max defines the color remap maximal range
  12647. * @returns the current particle system
  12648. */
  12649. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12650. /**
  12651. * Remove a specific color remap gradient
  12652. * @param gradient defines the gradient to remove
  12653. * @returns the current particle system
  12654. */
  12655. removeColorRemapGradient(gradient: number): IParticleSystem;
  12656. /**
  12657. * Adds a new alpha remap gradient
  12658. * @param gradient defines the gradient to use (between 0 and 1)
  12659. * @param min defines the alpha remap minimal range
  12660. * @param max defines the alpha remap maximal range
  12661. * @returns the current particle system
  12662. */
  12663. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12664. /**
  12665. * Remove a specific alpha remap gradient
  12666. * @param gradient defines the gradient to remove
  12667. * @returns the current particle system
  12668. */
  12669. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12670. /**
  12671. * Adds a new angular speed gradient
  12672. * @param gradient defines the gradient to use (between 0 and 1)
  12673. * @param factor defines the angular speed to affect to the specified gradient
  12674. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12675. * @returns the current particle system
  12676. */
  12677. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12678. /**
  12679. * Remove a specific angular speed gradient
  12680. * @param gradient defines the gradient to remove
  12681. * @returns the current particle system
  12682. */
  12683. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12684. /**
  12685. * Adds a new velocity gradient
  12686. * @param gradient defines the gradient to use (between 0 and 1)
  12687. * @param factor defines the velocity to affect to the specified gradient
  12688. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12689. * @returns the current particle system
  12690. */
  12691. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12692. /**
  12693. * Remove a specific velocity gradient
  12694. * @param gradient defines the gradient to remove
  12695. * @returns the current particle system
  12696. */
  12697. removeVelocityGradient(gradient: number): IParticleSystem;
  12698. /**
  12699. * Adds a new limit velocity gradient
  12700. * @param gradient defines the gradient to use (between 0 and 1)
  12701. * @param factor defines the limit velocity value to affect to the specified gradient
  12702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12703. * @returns the current particle system
  12704. */
  12705. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12706. /**
  12707. * Remove a specific limit velocity gradient
  12708. * @param gradient defines the gradient to remove
  12709. * @returns the current particle system
  12710. */
  12711. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12712. /**
  12713. * Adds a new drag gradient
  12714. * @param gradient defines the gradient to use (between 0 and 1)
  12715. * @param factor defines the drag value to affect to the specified gradient
  12716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12717. * @returns the current particle system
  12718. */
  12719. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12720. /**
  12721. * Remove a specific drag gradient
  12722. * @param gradient defines the gradient to remove
  12723. * @returns the current particle system
  12724. */
  12725. removeDragGradient(gradient: number): IParticleSystem;
  12726. /**
  12727. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12728. * @param gradient defines the gradient to use (between 0 and 1)
  12729. * @param factor defines the emit rate value to affect to the specified gradient
  12730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12731. * @returns the current particle system
  12732. */
  12733. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12734. /**
  12735. * Remove a specific emit rate gradient
  12736. * @param gradient defines the gradient to remove
  12737. * @returns the current particle system
  12738. */
  12739. removeEmitRateGradient(gradient: number): IParticleSystem;
  12740. /**
  12741. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12742. * @param gradient defines the gradient to use (between 0 and 1)
  12743. * @param factor defines the start size value to affect to the specified gradient
  12744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12745. * @returns the current particle system
  12746. */
  12747. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12748. /**
  12749. * Remove a specific start size gradient
  12750. * @param gradient defines the gradient to remove
  12751. * @returns the current particle system
  12752. */
  12753. removeStartSizeGradient(gradient: number): IParticleSystem;
  12754. private _createRampGradientTexture;
  12755. /**
  12756. * Gets the current list of ramp gradients.
  12757. * You must use addRampGradient and removeRampGradient to udpate this list
  12758. * @returns the list of ramp gradients
  12759. */
  12760. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12761. /** Force the system to rebuild all gradients that need to be resync */
  12762. forceRefreshGradients(): void;
  12763. private _syncRampGradientTexture;
  12764. /**
  12765. * Adds a new ramp gradient used to remap particle colors
  12766. * @param gradient defines the gradient to use (between 0 and 1)
  12767. * @param color defines the color to affect to the specified gradient
  12768. * @returns the current particle system
  12769. */
  12770. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12771. /**
  12772. * Remove a specific ramp gradient
  12773. * @param gradient defines the gradient to remove
  12774. * @returns the current particle system
  12775. */
  12776. removeRampGradient(gradient: number): ParticleSystem;
  12777. /**
  12778. * Adds a new color gradient
  12779. * @param gradient defines the gradient to use (between 0 and 1)
  12780. * @param color1 defines the color to affect to the specified gradient
  12781. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12782. * @returns this particle system
  12783. */
  12784. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12785. /**
  12786. * Remove a specific color gradient
  12787. * @param gradient defines the gradient to remove
  12788. * @returns this particle system
  12789. */
  12790. removeColorGradient(gradient: number): IParticleSystem;
  12791. private _fetchR;
  12792. protected _reset(): void;
  12793. private _resetEffect;
  12794. private _createVertexBuffers;
  12795. private _createIndexBuffer;
  12796. /**
  12797. * Gets the maximum number of particles active at the same time.
  12798. * @returns The max number of active particles.
  12799. */
  12800. getCapacity(): number;
  12801. /**
  12802. * Gets whether there are still active particles in the system.
  12803. * @returns True if it is alive, otherwise false.
  12804. */
  12805. isAlive(): boolean;
  12806. /**
  12807. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12808. * @returns True if it has been started, otherwise false.
  12809. */
  12810. isStarted(): boolean;
  12811. private _prepareSubEmitterInternalArray;
  12812. /**
  12813. * Starts the particle system and begins to emit
  12814. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12815. */
  12816. start(delay?: number): void;
  12817. /**
  12818. * Stops the particle system.
  12819. * @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.
  12820. */
  12821. stop(stopSubEmitters?: boolean): void;
  12822. /**
  12823. * Remove all active particles
  12824. */
  12825. reset(): void;
  12826. /**
  12827. * @hidden (for internal use only)
  12828. */
  12829. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12830. /**
  12831. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12832. * Its lifetime will start back at 0.
  12833. */
  12834. recycleParticle: (particle: Particle) => void;
  12835. private _stopSubEmitters;
  12836. private _createParticle;
  12837. private _removeFromRoot;
  12838. private _emitFromParticle;
  12839. private _update;
  12840. /** @hidden */
  12841. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12842. /** @hidden */
  12843. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12844. /**
  12845. * Fill the defines array according to the current settings of the particle system
  12846. * @param defines Array to be updated
  12847. * @param blendMode blend mode to take into account when updating the array
  12848. */
  12849. fillDefines(defines: Array<string>, blendMode: number): void;
  12850. /**
  12851. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12852. * @param uniforms Uniforms array to fill
  12853. * @param attributes Attributes array to fill
  12854. * @param samplers Samplers array to fill
  12855. */
  12856. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12857. /** @hidden */
  12858. private _getEffect;
  12859. /**
  12860. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12861. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12862. */
  12863. animate(preWarmOnly?: boolean): void;
  12864. private _appendParticleVertices;
  12865. /**
  12866. * Rebuilds the particle system.
  12867. */
  12868. rebuild(): void;
  12869. /**
  12870. * Is this system ready to be used/rendered
  12871. * @return true if the system is ready
  12872. */
  12873. isReady(): boolean;
  12874. private _render;
  12875. /**
  12876. * Renders the particle system in its current state.
  12877. * @returns the current number of particles
  12878. */
  12879. render(): number;
  12880. /**
  12881. * Disposes the particle system and free the associated resources
  12882. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12883. */
  12884. dispose(disposeTexture?: boolean): void;
  12885. /**
  12886. * Clones the particle system.
  12887. * @param name The name of the cloned object
  12888. * @param newEmitter The new emitter to use
  12889. * @returns the cloned particle system
  12890. */
  12891. clone(name: string, newEmitter: any): ParticleSystem;
  12892. /**
  12893. * Serializes the particle system to a JSON object
  12894. * @param serializeTexture defines if the texture must be serialized as well
  12895. * @returns the JSON object
  12896. */
  12897. serialize(serializeTexture?: boolean): any;
  12898. /** @hidden */
  12899. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12900. /** @hidden */
  12901. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12902. /**
  12903. * Parses a JSON object to create a particle system.
  12904. * @param parsedParticleSystem The JSON object to parse
  12905. * @param scene The scene to create the particle system in
  12906. * @param rootUrl The root url to use to load external dependencies like texture
  12907. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12908. * @returns the Parsed particle system
  12909. */
  12910. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12911. }
  12912. }
  12913. declare module BABYLON {
  12914. /**
  12915. * A particle represents one of the element emitted by a particle system.
  12916. * This is mainly define by its coordinates, direction, velocity and age.
  12917. */
  12918. export class Particle {
  12919. /**
  12920. * The particle system the particle belongs to.
  12921. */
  12922. particleSystem: ParticleSystem;
  12923. private static _Count;
  12924. /**
  12925. * Unique ID of the particle
  12926. */
  12927. id: number;
  12928. /**
  12929. * The world position of the particle in the scene.
  12930. */
  12931. position: Vector3;
  12932. /**
  12933. * The world direction of the particle in the scene.
  12934. */
  12935. direction: Vector3;
  12936. /**
  12937. * The color of the particle.
  12938. */
  12939. color: Color4;
  12940. /**
  12941. * The color change of the particle per step.
  12942. */
  12943. colorStep: Color4;
  12944. /**
  12945. * Defines how long will the life of the particle be.
  12946. */
  12947. lifeTime: number;
  12948. /**
  12949. * The current age of the particle.
  12950. */
  12951. age: number;
  12952. /**
  12953. * The current size of the particle.
  12954. */
  12955. size: number;
  12956. /**
  12957. * The current scale of the particle.
  12958. */
  12959. scale: Vector2;
  12960. /**
  12961. * The current angle of the particle.
  12962. */
  12963. angle: number;
  12964. /**
  12965. * Defines how fast is the angle changing.
  12966. */
  12967. angularSpeed: number;
  12968. /**
  12969. * Defines the cell index used by the particle to be rendered from a sprite.
  12970. */
  12971. cellIndex: number;
  12972. /**
  12973. * The information required to support color remapping
  12974. */
  12975. remapData: Vector4;
  12976. /** @hidden */
  12977. _randomCellOffset?: number;
  12978. /** @hidden */
  12979. _initialDirection: Nullable<Vector3>;
  12980. /** @hidden */
  12981. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12982. /** @hidden */
  12983. _initialStartSpriteCellID: number;
  12984. /** @hidden */
  12985. _initialEndSpriteCellID: number;
  12986. /** @hidden */
  12987. _currentColorGradient: Nullable<ColorGradient>;
  12988. /** @hidden */
  12989. _currentColor1: Color4;
  12990. /** @hidden */
  12991. _currentColor2: Color4;
  12992. /** @hidden */
  12993. _currentSizeGradient: Nullable<FactorGradient>;
  12994. /** @hidden */
  12995. _currentSize1: number;
  12996. /** @hidden */
  12997. _currentSize2: number;
  12998. /** @hidden */
  12999. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13000. /** @hidden */
  13001. _currentAngularSpeed1: number;
  13002. /** @hidden */
  13003. _currentAngularSpeed2: number;
  13004. /** @hidden */
  13005. _currentVelocityGradient: Nullable<FactorGradient>;
  13006. /** @hidden */
  13007. _currentVelocity1: number;
  13008. /** @hidden */
  13009. _currentVelocity2: number;
  13010. /** @hidden */
  13011. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13012. /** @hidden */
  13013. _currentLimitVelocity1: number;
  13014. /** @hidden */
  13015. _currentLimitVelocity2: number;
  13016. /** @hidden */
  13017. _currentDragGradient: Nullable<FactorGradient>;
  13018. /** @hidden */
  13019. _currentDrag1: number;
  13020. /** @hidden */
  13021. _currentDrag2: number;
  13022. /** @hidden */
  13023. _randomNoiseCoordinates1: Vector3;
  13024. /** @hidden */
  13025. _randomNoiseCoordinates2: Vector3;
  13026. /** @hidden */
  13027. _localPosition?: Vector3;
  13028. /**
  13029. * Creates a new instance Particle
  13030. * @param particleSystem the particle system the particle belongs to
  13031. */
  13032. constructor(
  13033. /**
  13034. * The particle system the particle belongs to.
  13035. */
  13036. particleSystem: ParticleSystem);
  13037. private updateCellInfoFromSystem;
  13038. /**
  13039. * Defines how the sprite cell index is updated for the particle
  13040. */
  13041. updateCellIndex(): void;
  13042. /** @hidden */
  13043. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13044. /** @hidden */
  13045. _inheritParticleInfoToSubEmitters(): void;
  13046. /** @hidden */
  13047. _reset(): void;
  13048. /**
  13049. * Copy the properties of particle to another one.
  13050. * @param other the particle to copy the information to.
  13051. */
  13052. copyTo(other: Particle): void;
  13053. }
  13054. }
  13055. declare module BABYLON {
  13056. /**
  13057. * Particle emitter represents a volume emitting particles.
  13058. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13059. */
  13060. export interface IParticleEmitterType {
  13061. /**
  13062. * Called by the particle System when the direction is computed for the created particle.
  13063. * @param worldMatrix is the world matrix of the particle system
  13064. * @param directionToUpdate is the direction vector to update with the result
  13065. * @param particle is the particle we are computed the direction for
  13066. * @param isLocal defines if the direction should be set in local space
  13067. */
  13068. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13069. /**
  13070. * Called by the particle System when the position is computed for the created particle.
  13071. * @param worldMatrix is the world matrix of the particle system
  13072. * @param positionToUpdate is the position vector to update with the result
  13073. * @param particle is the particle we are computed the position for
  13074. * @param isLocal defines if the position should be set in local space
  13075. */
  13076. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13077. /**
  13078. * Clones the current emitter and returns a copy of it
  13079. * @returns the new emitter
  13080. */
  13081. clone(): IParticleEmitterType;
  13082. /**
  13083. * Called by the GPUParticleSystem to setup the update shader
  13084. * @param effect defines the update shader
  13085. */
  13086. applyToShader(effect: Effect): void;
  13087. /**
  13088. * Returns a string to use to update the GPU particles update shader
  13089. * @returns the effect defines string
  13090. */
  13091. getEffectDefines(): string;
  13092. /**
  13093. * Returns a string representing the class name
  13094. * @returns a string containing the class name
  13095. */
  13096. getClassName(): string;
  13097. /**
  13098. * Serializes the particle system to a JSON object.
  13099. * @returns the JSON object
  13100. */
  13101. serialize(): any;
  13102. /**
  13103. * Parse properties from a JSON object
  13104. * @param serializationObject defines the JSON object
  13105. * @param scene defines the hosting scene
  13106. */
  13107. parse(serializationObject: any, scene: Scene): void;
  13108. }
  13109. }
  13110. declare module BABYLON {
  13111. /**
  13112. * Particle emitter emitting particles from the inside of a box.
  13113. * It emits the particles randomly between 2 given directions.
  13114. */
  13115. export class BoxParticleEmitter implements IParticleEmitterType {
  13116. /**
  13117. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13118. */
  13119. direction1: Vector3;
  13120. /**
  13121. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13122. */
  13123. direction2: Vector3;
  13124. /**
  13125. * 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.
  13126. */
  13127. minEmitBox: Vector3;
  13128. /**
  13129. * 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.
  13130. */
  13131. maxEmitBox: Vector3;
  13132. /**
  13133. * Creates a new instance BoxParticleEmitter
  13134. */
  13135. constructor();
  13136. /**
  13137. * Called by the particle System when the direction is computed for the created particle.
  13138. * @param worldMatrix is the world matrix of the particle system
  13139. * @param directionToUpdate is the direction vector to update with the result
  13140. * @param particle is the particle we are computed the direction for
  13141. * @param isLocal defines if the direction should be set in local space
  13142. */
  13143. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13144. /**
  13145. * Called by the particle System when the position is computed for the created particle.
  13146. * @param worldMatrix is the world matrix of the particle system
  13147. * @param positionToUpdate is the position vector to update with the result
  13148. * @param particle is the particle we are computed the position for
  13149. * @param isLocal defines if the position should be set in local space
  13150. */
  13151. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13152. /**
  13153. * Clones the current emitter and returns a copy of it
  13154. * @returns the new emitter
  13155. */
  13156. clone(): BoxParticleEmitter;
  13157. /**
  13158. * Called by the GPUParticleSystem to setup the update shader
  13159. * @param effect defines the update shader
  13160. */
  13161. applyToShader(effect: Effect): void;
  13162. /**
  13163. * Returns a string to use to update the GPU particles update shader
  13164. * @returns a string containng the defines string
  13165. */
  13166. getEffectDefines(): string;
  13167. /**
  13168. * Returns the string "BoxParticleEmitter"
  13169. * @returns a string containing the class name
  13170. */
  13171. getClassName(): string;
  13172. /**
  13173. * Serializes the particle system to a JSON object.
  13174. * @returns the JSON object
  13175. */
  13176. serialize(): any;
  13177. /**
  13178. * Parse properties from a JSON object
  13179. * @param serializationObject defines the JSON object
  13180. */
  13181. parse(serializationObject: any): void;
  13182. }
  13183. }
  13184. declare module BABYLON {
  13185. /**
  13186. * Particle emitter emitting particles from the inside of a cone.
  13187. * It emits the particles alongside the cone volume from the base to the particle.
  13188. * The emission direction might be randomized.
  13189. */
  13190. export class ConeParticleEmitter implements IParticleEmitterType {
  13191. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13192. directionRandomizer: number;
  13193. private _radius;
  13194. private _angle;
  13195. private _height;
  13196. /**
  13197. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13198. */
  13199. radiusRange: number;
  13200. /**
  13201. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13202. */
  13203. heightRange: number;
  13204. /**
  13205. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13206. */
  13207. emitFromSpawnPointOnly: boolean;
  13208. /**
  13209. * Gets or sets the radius of the emission cone
  13210. */
  13211. get radius(): number;
  13212. set radius(value: number);
  13213. /**
  13214. * Gets or sets the angle of the emission cone
  13215. */
  13216. get angle(): number;
  13217. set angle(value: number);
  13218. private _buildHeight;
  13219. /**
  13220. * Creates a new instance ConeParticleEmitter
  13221. * @param radius the radius of the emission cone (1 by default)
  13222. * @param angle the cone base angle (PI by default)
  13223. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13224. */
  13225. constructor(radius?: number, angle?: number,
  13226. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13227. directionRandomizer?: number);
  13228. /**
  13229. * Called by the particle System when the direction is computed for the created particle.
  13230. * @param worldMatrix is the world matrix of the particle system
  13231. * @param directionToUpdate is the direction vector to update with the result
  13232. * @param particle is the particle we are computed the direction for
  13233. * @param isLocal defines if the direction should be set in local space
  13234. */
  13235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13236. /**
  13237. * Called by the particle System when the position is computed for the created particle.
  13238. * @param worldMatrix is the world matrix of the particle system
  13239. * @param positionToUpdate is the position vector to update with the result
  13240. * @param particle is the particle we are computed the position for
  13241. * @param isLocal defines if the position should be set in local space
  13242. */
  13243. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13244. /**
  13245. * Clones the current emitter and returns a copy of it
  13246. * @returns the new emitter
  13247. */
  13248. clone(): ConeParticleEmitter;
  13249. /**
  13250. * Called by the GPUParticleSystem to setup the update shader
  13251. * @param effect defines the update shader
  13252. */
  13253. applyToShader(effect: Effect): void;
  13254. /**
  13255. * Returns a string to use to update the GPU particles update shader
  13256. * @returns a string containng the defines string
  13257. */
  13258. getEffectDefines(): string;
  13259. /**
  13260. * Returns the string "ConeParticleEmitter"
  13261. * @returns a string containing the class name
  13262. */
  13263. getClassName(): string;
  13264. /**
  13265. * Serializes the particle system to a JSON object.
  13266. * @returns the JSON object
  13267. */
  13268. serialize(): any;
  13269. /**
  13270. * Parse properties from a JSON object
  13271. * @param serializationObject defines the JSON object
  13272. */
  13273. parse(serializationObject: any): void;
  13274. }
  13275. }
  13276. declare module BABYLON {
  13277. /**
  13278. * Particle emitter emitting particles from the inside of a cylinder.
  13279. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13280. */
  13281. export class CylinderParticleEmitter implements IParticleEmitterType {
  13282. /**
  13283. * The radius of the emission cylinder.
  13284. */
  13285. radius: number;
  13286. /**
  13287. * The height of the emission cylinder.
  13288. */
  13289. height: number;
  13290. /**
  13291. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13292. */
  13293. radiusRange: number;
  13294. /**
  13295. * How much to randomize the particle direction [0-1].
  13296. */
  13297. directionRandomizer: number;
  13298. /**
  13299. * Creates a new instance CylinderParticleEmitter
  13300. * @param radius the radius of the emission cylinder (1 by default)
  13301. * @param height the height of the emission cylinder (1 by default)
  13302. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13304. */
  13305. constructor(
  13306. /**
  13307. * The radius of the emission cylinder.
  13308. */
  13309. radius?: number,
  13310. /**
  13311. * The height of the emission cylinder.
  13312. */
  13313. height?: number,
  13314. /**
  13315. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13316. */
  13317. radiusRange?: number,
  13318. /**
  13319. * How much to randomize the particle direction [0-1].
  13320. */
  13321. directionRandomizer?: number);
  13322. /**
  13323. * Called by the particle System when the direction is computed for the created particle.
  13324. * @param worldMatrix is the world matrix of the particle system
  13325. * @param directionToUpdate is the direction vector to update with the result
  13326. * @param particle is the particle we are computed the direction for
  13327. * @param isLocal defines if the direction should be set in local space
  13328. */
  13329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13330. /**
  13331. * Called by the particle System when the position is computed for the created particle.
  13332. * @param worldMatrix is the world matrix of the particle system
  13333. * @param positionToUpdate is the position vector to update with the result
  13334. * @param particle is the particle we are computed the position for
  13335. * @param isLocal defines if the position should be set in local space
  13336. */
  13337. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13338. /**
  13339. * Clones the current emitter and returns a copy of it
  13340. * @returns the new emitter
  13341. */
  13342. clone(): CylinderParticleEmitter;
  13343. /**
  13344. * Called by the GPUParticleSystem to setup the update shader
  13345. * @param effect defines the update shader
  13346. */
  13347. applyToShader(effect: Effect): void;
  13348. /**
  13349. * Returns a string to use to update the GPU particles update shader
  13350. * @returns a string containng the defines string
  13351. */
  13352. getEffectDefines(): string;
  13353. /**
  13354. * Returns the string "CylinderParticleEmitter"
  13355. * @returns a string containing the class name
  13356. */
  13357. getClassName(): string;
  13358. /**
  13359. * Serializes the particle system to a JSON object.
  13360. * @returns the JSON object
  13361. */
  13362. serialize(): any;
  13363. /**
  13364. * Parse properties from a JSON object
  13365. * @param serializationObject defines the JSON object
  13366. */
  13367. parse(serializationObject: any): void;
  13368. }
  13369. /**
  13370. * Particle emitter emitting particles from the inside of a cylinder.
  13371. * It emits the particles randomly between two vectors.
  13372. */
  13373. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13374. /**
  13375. * The min limit of the emission direction.
  13376. */
  13377. direction1: Vector3;
  13378. /**
  13379. * The max limit of the emission direction.
  13380. */
  13381. direction2: Vector3;
  13382. /**
  13383. * Creates a new instance CylinderDirectedParticleEmitter
  13384. * @param radius the radius of the emission cylinder (1 by default)
  13385. * @param height the height of the emission cylinder (1 by default)
  13386. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13387. * @param direction1 the min limit of the emission direction (up vector by default)
  13388. * @param direction2 the max limit of the emission direction (up vector by default)
  13389. */
  13390. constructor(radius?: number, height?: number, radiusRange?: number,
  13391. /**
  13392. * The min limit of the emission direction.
  13393. */
  13394. direction1?: Vector3,
  13395. /**
  13396. * The max limit of the emission direction.
  13397. */
  13398. direction2?: Vector3);
  13399. /**
  13400. * Called by the particle System when the direction is computed for the created particle.
  13401. * @param worldMatrix is the world matrix of the particle system
  13402. * @param directionToUpdate is the direction vector to update with the result
  13403. * @param particle is the particle we are computed the direction for
  13404. */
  13405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13406. /**
  13407. * Clones the current emitter and returns a copy of it
  13408. * @returns the new emitter
  13409. */
  13410. clone(): CylinderDirectedParticleEmitter;
  13411. /**
  13412. * Called by the GPUParticleSystem to setup the update shader
  13413. * @param effect defines the update shader
  13414. */
  13415. applyToShader(effect: Effect): void;
  13416. /**
  13417. * Returns a string to use to update the GPU particles update shader
  13418. * @returns a string containng the defines string
  13419. */
  13420. getEffectDefines(): string;
  13421. /**
  13422. * Returns the string "CylinderDirectedParticleEmitter"
  13423. * @returns a string containing the class name
  13424. */
  13425. getClassName(): string;
  13426. /**
  13427. * Serializes the particle system to a JSON object.
  13428. * @returns the JSON object
  13429. */
  13430. serialize(): any;
  13431. /**
  13432. * Parse properties from a JSON object
  13433. * @param serializationObject defines the JSON object
  13434. */
  13435. parse(serializationObject: any): void;
  13436. }
  13437. }
  13438. declare module BABYLON {
  13439. /**
  13440. * Particle emitter emitting particles from the inside of a hemisphere.
  13441. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13442. */
  13443. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13444. /**
  13445. * The radius of the emission hemisphere.
  13446. */
  13447. radius: number;
  13448. /**
  13449. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13450. */
  13451. radiusRange: number;
  13452. /**
  13453. * How much to randomize the particle direction [0-1].
  13454. */
  13455. directionRandomizer: number;
  13456. /**
  13457. * Creates a new instance HemisphericParticleEmitter
  13458. * @param radius the radius of the emission hemisphere (1 by default)
  13459. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13460. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13461. */
  13462. constructor(
  13463. /**
  13464. * The radius of the emission hemisphere.
  13465. */
  13466. radius?: number,
  13467. /**
  13468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13469. */
  13470. radiusRange?: number,
  13471. /**
  13472. * How much to randomize the particle direction [0-1].
  13473. */
  13474. directionRandomizer?: number);
  13475. /**
  13476. * Called by the particle System when the direction is computed for the created particle.
  13477. * @param worldMatrix is the world matrix of the particle system
  13478. * @param directionToUpdate is the direction vector to update with the result
  13479. * @param particle is the particle we are computed the direction for
  13480. * @param isLocal defines if the direction should be set in local space
  13481. */
  13482. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13483. /**
  13484. * Called by the particle System when the position is computed for the created particle.
  13485. * @param worldMatrix is the world matrix of the particle system
  13486. * @param positionToUpdate is the position vector to update with the result
  13487. * @param particle is the particle we are computed the position for
  13488. * @param isLocal defines if the position should be set in local space
  13489. */
  13490. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13491. /**
  13492. * Clones the current emitter and returns a copy of it
  13493. * @returns the new emitter
  13494. */
  13495. clone(): HemisphericParticleEmitter;
  13496. /**
  13497. * Called by the GPUParticleSystem to setup the update shader
  13498. * @param effect defines the update shader
  13499. */
  13500. applyToShader(effect: Effect): void;
  13501. /**
  13502. * Returns a string to use to update the GPU particles update shader
  13503. * @returns a string containng the defines string
  13504. */
  13505. getEffectDefines(): string;
  13506. /**
  13507. * Returns the string "HemisphericParticleEmitter"
  13508. * @returns a string containing the class name
  13509. */
  13510. getClassName(): string;
  13511. /**
  13512. * Serializes the particle system to a JSON object.
  13513. * @returns the JSON object
  13514. */
  13515. serialize(): any;
  13516. /**
  13517. * Parse properties from a JSON object
  13518. * @param serializationObject defines the JSON object
  13519. */
  13520. parse(serializationObject: any): void;
  13521. }
  13522. }
  13523. declare module BABYLON {
  13524. /**
  13525. * Particle emitter emitting particles from a point.
  13526. * It emits the particles randomly between 2 given directions.
  13527. */
  13528. export class PointParticleEmitter implements IParticleEmitterType {
  13529. /**
  13530. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13531. */
  13532. direction1: Vector3;
  13533. /**
  13534. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13535. */
  13536. direction2: Vector3;
  13537. /**
  13538. * Creates a new instance PointParticleEmitter
  13539. */
  13540. constructor();
  13541. /**
  13542. * Called by the particle System when the direction is computed for the created particle.
  13543. * @param worldMatrix is the world matrix of the particle system
  13544. * @param directionToUpdate is the direction vector to update with the result
  13545. * @param particle is the particle we are computed the direction for
  13546. * @param isLocal defines if the direction should be set in local space
  13547. */
  13548. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13549. /**
  13550. * Called by the particle System when the position is computed for the created particle.
  13551. * @param worldMatrix is the world matrix of the particle system
  13552. * @param positionToUpdate is the position vector to update with the result
  13553. * @param particle is the particle we are computed the position for
  13554. * @param isLocal defines if the position should be set in local space
  13555. */
  13556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13557. /**
  13558. * Clones the current emitter and returns a copy of it
  13559. * @returns the new emitter
  13560. */
  13561. clone(): PointParticleEmitter;
  13562. /**
  13563. * Called by the GPUParticleSystem to setup the update shader
  13564. * @param effect defines the update shader
  13565. */
  13566. applyToShader(effect: Effect): void;
  13567. /**
  13568. * Returns a string to use to update the GPU particles update shader
  13569. * @returns a string containng the defines string
  13570. */
  13571. getEffectDefines(): string;
  13572. /**
  13573. * Returns the string "PointParticleEmitter"
  13574. * @returns a string containing the class name
  13575. */
  13576. getClassName(): string;
  13577. /**
  13578. * Serializes the particle system to a JSON object.
  13579. * @returns the JSON object
  13580. */
  13581. serialize(): any;
  13582. /**
  13583. * Parse properties from a JSON object
  13584. * @param serializationObject defines the JSON object
  13585. */
  13586. parse(serializationObject: any): void;
  13587. }
  13588. }
  13589. declare module BABYLON {
  13590. /**
  13591. * Particle emitter emitting particles from the inside of a sphere.
  13592. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13593. */
  13594. export class SphereParticleEmitter implements IParticleEmitterType {
  13595. /**
  13596. * The radius of the emission sphere.
  13597. */
  13598. radius: number;
  13599. /**
  13600. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13601. */
  13602. radiusRange: number;
  13603. /**
  13604. * How much to randomize the particle direction [0-1].
  13605. */
  13606. directionRandomizer: number;
  13607. /**
  13608. * Creates a new instance SphereParticleEmitter
  13609. * @param radius the radius of the emission sphere (1 by default)
  13610. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13611. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13612. */
  13613. constructor(
  13614. /**
  13615. * The radius of the emission sphere.
  13616. */
  13617. radius?: number,
  13618. /**
  13619. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13620. */
  13621. radiusRange?: number,
  13622. /**
  13623. * How much to randomize the particle direction [0-1].
  13624. */
  13625. directionRandomizer?: number);
  13626. /**
  13627. * Called by the particle System when the direction is computed for the created particle.
  13628. * @param worldMatrix is the world matrix of the particle system
  13629. * @param directionToUpdate is the direction vector to update with the result
  13630. * @param particle is the particle we are computed the direction for
  13631. * @param isLocal defines if the direction should be set in local space
  13632. */
  13633. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13634. /**
  13635. * Called by the particle System when the position is computed for the created particle.
  13636. * @param worldMatrix is the world matrix of the particle system
  13637. * @param positionToUpdate is the position vector to update with the result
  13638. * @param particle is the particle we are computed the position for
  13639. * @param isLocal defines if the position should be set in local space
  13640. */
  13641. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13642. /**
  13643. * Clones the current emitter and returns a copy of it
  13644. * @returns the new emitter
  13645. */
  13646. clone(): SphereParticleEmitter;
  13647. /**
  13648. * Called by the GPUParticleSystem to setup the update shader
  13649. * @param effect defines the update shader
  13650. */
  13651. applyToShader(effect: Effect): void;
  13652. /**
  13653. * Returns a string to use to update the GPU particles update shader
  13654. * @returns a string containng the defines string
  13655. */
  13656. getEffectDefines(): string;
  13657. /**
  13658. * Returns the string "SphereParticleEmitter"
  13659. * @returns a string containing the class name
  13660. */
  13661. getClassName(): string;
  13662. /**
  13663. * Serializes the particle system to a JSON object.
  13664. * @returns the JSON object
  13665. */
  13666. serialize(): any;
  13667. /**
  13668. * Parse properties from a JSON object
  13669. * @param serializationObject defines the JSON object
  13670. */
  13671. parse(serializationObject: any): void;
  13672. }
  13673. /**
  13674. * Particle emitter emitting particles from the inside of a sphere.
  13675. * It emits the particles randomly between two vectors.
  13676. */
  13677. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13678. /**
  13679. * The min limit of the emission direction.
  13680. */
  13681. direction1: Vector3;
  13682. /**
  13683. * The max limit of the emission direction.
  13684. */
  13685. direction2: Vector3;
  13686. /**
  13687. * Creates a new instance SphereDirectedParticleEmitter
  13688. * @param radius the radius of the emission sphere (1 by default)
  13689. * @param direction1 the min limit of the emission direction (up vector by default)
  13690. * @param direction2 the max limit of the emission direction (up vector by default)
  13691. */
  13692. constructor(radius?: number,
  13693. /**
  13694. * The min limit of the emission direction.
  13695. */
  13696. direction1?: Vector3,
  13697. /**
  13698. * The max limit of the emission direction.
  13699. */
  13700. direction2?: Vector3);
  13701. /**
  13702. * Called by the particle System when the direction is computed for the created particle.
  13703. * @param worldMatrix is the world matrix of the particle system
  13704. * @param directionToUpdate is the direction vector to update with the result
  13705. * @param particle is the particle we are computed the direction for
  13706. */
  13707. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13708. /**
  13709. * Clones the current emitter and returns a copy of it
  13710. * @returns the new emitter
  13711. */
  13712. clone(): SphereDirectedParticleEmitter;
  13713. /**
  13714. * Called by the GPUParticleSystem to setup the update shader
  13715. * @param effect defines the update shader
  13716. */
  13717. applyToShader(effect: Effect): void;
  13718. /**
  13719. * Returns a string to use to update the GPU particles update shader
  13720. * @returns a string containng the defines string
  13721. */
  13722. getEffectDefines(): string;
  13723. /**
  13724. * Returns the string "SphereDirectedParticleEmitter"
  13725. * @returns a string containing the class name
  13726. */
  13727. getClassName(): string;
  13728. /**
  13729. * Serializes the particle system to a JSON object.
  13730. * @returns the JSON object
  13731. */
  13732. serialize(): any;
  13733. /**
  13734. * Parse properties from a JSON object
  13735. * @param serializationObject defines the JSON object
  13736. */
  13737. parse(serializationObject: any): void;
  13738. }
  13739. }
  13740. declare module BABYLON {
  13741. /**
  13742. * Particle emitter emitting particles from a custom list of positions.
  13743. */
  13744. export class CustomParticleEmitter implements IParticleEmitterType {
  13745. /**
  13746. * Gets or sets the position generator that will create the inital position of each particle.
  13747. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13748. */
  13749. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13750. /**
  13751. * Gets or sets the destination generator that will create the final destination of each particle.
  13752. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13753. */
  13754. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13755. /**
  13756. * Creates a new instance CustomParticleEmitter
  13757. */
  13758. constructor();
  13759. /**
  13760. * Called by the particle System when the direction is computed for the created particle.
  13761. * @param worldMatrix is the world matrix of the particle system
  13762. * @param directionToUpdate is the direction vector to update with the result
  13763. * @param particle is the particle we are computed the direction for
  13764. * @param isLocal defines if the direction should be set in local space
  13765. */
  13766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13767. /**
  13768. * Called by the particle System when the position is computed for the created particle.
  13769. * @param worldMatrix is the world matrix of the particle system
  13770. * @param positionToUpdate is the position vector to update with the result
  13771. * @param particle is the particle we are computed the position for
  13772. * @param isLocal defines if the position should be set in local space
  13773. */
  13774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13775. /**
  13776. * Clones the current emitter and returns a copy of it
  13777. * @returns the new emitter
  13778. */
  13779. clone(): CustomParticleEmitter;
  13780. /**
  13781. * Called by the GPUParticleSystem to setup the update shader
  13782. * @param effect defines the update shader
  13783. */
  13784. applyToShader(effect: Effect): void;
  13785. /**
  13786. * Returns a string to use to update the GPU particles update shader
  13787. * @returns a string containng the defines string
  13788. */
  13789. getEffectDefines(): string;
  13790. /**
  13791. * Returns the string "PointParticleEmitter"
  13792. * @returns a string containing the class name
  13793. */
  13794. getClassName(): string;
  13795. /**
  13796. * Serializes the particle system to a JSON object.
  13797. * @returns the JSON object
  13798. */
  13799. serialize(): any;
  13800. /**
  13801. * Parse properties from a JSON object
  13802. * @param serializationObject defines the JSON object
  13803. */
  13804. parse(serializationObject: any): void;
  13805. }
  13806. }
  13807. declare module BABYLON {
  13808. /**
  13809. * Particle emitter emitting particles from the inside of a box.
  13810. * It emits the particles randomly between 2 given directions.
  13811. */
  13812. export class MeshParticleEmitter implements IParticleEmitterType {
  13813. private _indices;
  13814. private _positions;
  13815. private _normals;
  13816. private _storedNormal;
  13817. private _mesh;
  13818. /**
  13819. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13820. */
  13821. direction1: Vector3;
  13822. /**
  13823. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13824. */
  13825. direction2: Vector3;
  13826. /**
  13827. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13828. */
  13829. useMeshNormalsForDirection: boolean;
  13830. /** Defines the mesh to use as source */
  13831. get mesh(): Nullable<AbstractMesh>;
  13832. set mesh(value: Nullable<AbstractMesh>);
  13833. /**
  13834. * Creates a new instance MeshParticleEmitter
  13835. * @param mesh defines the mesh to use as source
  13836. */
  13837. constructor(mesh?: Nullable<AbstractMesh>);
  13838. /**
  13839. * Called by the particle System when the direction is computed for the created particle.
  13840. * @param worldMatrix is the world matrix of the particle system
  13841. * @param directionToUpdate is the direction vector to update with the result
  13842. * @param particle is the particle we are computed the direction for
  13843. * @param isLocal defines if the direction should be set in local space
  13844. */
  13845. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13846. /**
  13847. * Called by the particle System when the position is computed for the created particle.
  13848. * @param worldMatrix is the world matrix of the particle system
  13849. * @param positionToUpdate is the position vector to update with the result
  13850. * @param particle is the particle we are computed the position for
  13851. * @param isLocal defines if the position should be set in local space
  13852. */
  13853. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13854. /**
  13855. * Clones the current emitter and returns a copy of it
  13856. * @returns the new emitter
  13857. */
  13858. clone(): MeshParticleEmitter;
  13859. /**
  13860. * Called by the GPUParticleSystem to setup the update shader
  13861. * @param effect defines the update shader
  13862. */
  13863. applyToShader(effect: Effect): void;
  13864. /**
  13865. * Returns a string to use to update the GPU particles update shader
  13866. * @returns a string containng the defines string
  13867. */
  13868. getEffectDefines(): string;
  13869. /**
  13870. * Returns the string "BoxParticleEmitter"
  13871. * @returns a string containing the class name
  13872. */
  13873. getClassName(): string;
  13874. /**
  13875. * Serializes the particle system to a JSON object.
  13876. * @returns the JSON object
  13877. */
  13878. serialize(): any;
  13879. /**
  13880. * Parse properties from a JSON object
  13881. * @param serializationObject defines the JSON object
  13882. * @param scene defines the hosting scene
  13883. */
  13884. parse(serializationObject: any, scene: Scene): void;
  13885. }
  13886. }
  13887. declare module BABYLON {
  13888. /**
  13889. * Interface representing a particle system in Babylon.js.
  13890. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13891. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13892. */
  13893. export interface IParticleSystem {
  13894. /**
  13895. * List of animations used by the particle system.
  13896. */
  13897. animations: Animation[];
  13898. /**
  13899. * The id of the Particle system.
  13900. */
  13901. id: string;
  13902. /**
  13903. * The name of the Particle system.
  13904. */
  13905. name: string;
  13906. /**
  13907. * The emitter represents the Mesh or position we are attaching the particle system to.
  13908. */
  13909. emitter: Nullable<AbstractMesh | Vector3>;
  13910. /**
  13911. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13912. */
  13913. isBillboardBased: boolean;
  13914. /**
  13915. * The rendering group used by the Particle system to chose when to render.
  13916. */
  13917. renderingGroupId: number;
  13918. /**
  13919. * The layer mask we are rendering the particles through.
  13920. */
  13921. layerMask: number;
  13922. /**
  13923. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13924. */
  13925. updateSpeed: number;
  13926. /**
  13927. * The amount of time the particle system is running (depends of the overall update speed).
  13928. */
  13929. targetStopDuration: number;
  13930. /**
  13931. * The texture used to render each particle. (this can be a spritesheet)
  13932. */
  13933. particleTexture: Nullable<Texture>;
  13934. /**
  13935. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13936. */
  13937. blendMode: number;
  13938. /**
  13939. * Minimum life time of emitting particles.
  13940. */
  13941. minLifeTime: number;
  13942. /**
  13943. * Maximum life time of emitting particles.
  13944. */
  13945. maxLifeTime: number;
  13946. /**
  13947. * Minimum Size of emitting particles.
  13948. */
  13949. minSize: number;
  13950. /**
  13951. * Maximum Size of emitting particles.
  13952. */
  13953. maxSize: number;
  13954. /**
  13955. * Minimum scale of emitting particles on X axis.
  13956. */
  13957. minScaleX: number;
  13958. /**
  13959. * Maximum scale of emitting particles on X axis.
  13960. */
  13961. maxScaleX: number;
  13962. /**
  13963. * Minimum scale of emitting particles on Y axis.
  13964. */
  13965. minScaleY: number;
  13966. /**
  13967. * Maximum scale of emitting particles on Y axis.
  13968. */
  13969. maxScaleY: number;
  13970. /**
  13971. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13972. */
  13973. color1: Color4;
  13974. /**
  13975. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13976. */
  13977. color2: Color4;
  13978. /**
  13979. * Color the particle will have at the end of its lifetime.
  13980. */
  13981. colorDead: Color4;
  13982. /**
  13983. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13984. */
  13985. emitRate: number;
  13986. /**
  13987. * You can use gravity if you want to give an orientation to your particles.
  13988. */
  13989. gravity: Vector3;
  13990. /**
  13991. * Minimum power of emitting particles.
  13992. */
  13993. minEmitPower: number;
  13994. /**
  13995. * Maximum power of emitting particles.
  13996. */
  13997. maxEmitPower: number;
  13998. /**
  13999. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14000. */
  14001. minAngularSpeed: number;
  14002. /**
  14003. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14004. */
  14005. maxAngularSpeed: number;
  14006. /**
  14007. * Gets or sets the minimal initial rotation in radians.
  14008. */
  14009. minInitialRotation: number;
  14010. /**
  14011. * Gets or sets the maximal initial rotation in radians.
  14012. */
  14013. maxInitialRotation: number;
  14014. /**
  14015. * The particle emitter type defines the emitter used by the particle system.
  14016. * It can be for example box, sphere, or cone...
  14017. */
  14018. particleEmitterType: Nullable<IParticleEmitterType>;
  14019. /**
  14020. * Defines the delay in milliseconds before starting the system (0 by default)
  14021. */
  14022. startDelay: number;
  14023. /**
  14024. * 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
  14025. */
  14026. preWarmCycles: number;
  14027. /**
  14028. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14029. */
  14030. preWarmStepOffset: number;
  14031. /**
  14032. * 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)
  14033. */
  14034. spriteCellChangeSpeed: number;
  14035. /**
  14036. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14037. */
  14038. startSpriteCellID: number;
  14039. /**
  14040. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14041. */
  14042. endSpriteCellID: number;
  14043. /**
  14044. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14045. */
  14046. spriteCellWidth: number;
  14047. /**
  14048. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14049. */
  14050. spriteCellHeight: number;
  14051. /**
  14052. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14053. */
  14054. spriteRandomStartCell: boolean;
  14055. /**
  14056. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14057. */
  14058. isAnimationSheetEnabled: boolean;
  14059. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14060. translationPivot: Vector2;
  14061. /**
  14062. * Gets or sets a texture used to add random noise to particle positions
  14063. */
  14064. noiseTexture: Nullable<BaseTexture>;
  14065. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14066. noiseStrength: Vector3;
  14067. /**
  14068. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14069. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14070. */
  14071. billboardMode: number;
  14072. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14073. limitVelocityDamping: number;
  14074. /**
  14075. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14076. */
  14077. beginAnimationOnStart: boolean;
  14078. /**
  14079. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14080. */
  14081. beginAnimationFrom: number;
  14082. /**
  14083. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14084. */
  14085. beginAnimationTo: number;
  14086. /**
  14087. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14088. */
  14089. beginAnimationLoop: boolean;
  14090. /**
  14091. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14092. */
  14093. disposeOnStop: boolean;
  14094. /**
  14095. * Specifies if the particles are updated in emitter local space or world space
  14096. */
  14097. isLocal: boolean;
  14098. /** Snippet ID if the particle system was created from the snippet server */
  14099. snippetId: string;
  14100. /**
  14101. * Gets the maximum number of particles active at the same time.
  14102. * @returns The max number of active particles.
  14103. */
  14104. getCapacity(): number;
  14105. /**
  14106. * Gets the number of particles active at the same time.
  14107. * @returns The number of active particles.
  14108. */
  14109. getActiveCount(): number;
  14110. /**
  14111. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14112. * @returns True if it has been started, otherwise false.
  14113. */
  14114. isStarted(): boolean;
  14115. /**
  14116. * Animates the particle system for this frame.
  14117. */
  14118. animate(): void;
  14119. /**
  14120. * Renders the particle system in its current state.
  14121. * @returns the current number of particles
  14122. */
  14123. render(): number;
  14124. /**
  14125. * Dispose the particle system and frees its associated resources.
  14126. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14127. */
  14128. dispose(disposeTexture?: boolean): void;
  14129. /**
  14130. * An event triggered when the system is disposed
  14131. */
  14132. onDisposeObservable: Observable<IParticleSystem>;
  14133. /**
  14134. * Clones the particle system.
  14135. * @param name The name of the cloned object
  14136. * @param newEmitter The new emitter to use
  14137. * @returns the cloned particle system
  14138. */
  14139. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14140. /**
  14141. * Serializes the particle system to a JSON object
  14142. * @param serializeTexture defines if the texture must be serialized as well
  14143. * @returns the JSON object
  14144. */
  14145. serialize(serializeTexture: boolean): any;
  14146. /**
  14147. * Rebuild the particle system
  14148. */
  14149. rebuild(): void;
  14150. /** Force the system to rebuild all gradients that need to be resync */
  14151. forceRefreshGradients(): void;
  14152. /**
  14153. * Starts the particle system and begins to emit
  14154. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14155. */
  14156. start(delay?: number): void;
  14157. /**
  14158. * Stops the particle system.
  14159. */
  14160. stop(): void;
  14161. /**
  14162. * Remove all active particles
  14163. */
  14164. reset(): void;
  14165. /**
  14166. * Gets a boolean indicating that the system is stopping
  14167. * @returns true if the system is currently stopping
  14168. */
  14169. isStopping(): boolean;
  14170. /**
  14171. * Is this system ready to be used/rendered
  14172. * @return true if the system is ready
  14173. */
  14174. isReady(): boolean;
  14175. /**
  14176. * Returns the string "ParticleSystem"
  14177. * @returns a string containing the class name
  14178. */
  14179. getClassName(): string;
  14180. /**
  14181. * Gets the custom effect used to render the particles
  14182. * @param blendMode Blend mode for which the effect should be retrieved
  14183. * @returns The effect
  14184. */
  14185. getCustomEffect(blendMode: number): Nullable<Effect>;
  14186. /**
  14187. * Sets the custom effect used to render the particles
  14188. * @param effect The effect to set
  14189. * @param blendMode Blend mode for which the effect should be set
  14190. */
  14191. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14192. /**
  14193. * Fill the defines array according to the current settings of the particle system
  14194. * @param defines Array to be updated
  14195. * @param blendMode blend mode to take into account when updating the array
  14196. */
  14197. fillDefines(defines: Array<string>, blendMode: number): void;
  14198. /**
  14199. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14200. * @param uniforms Uniforms array to fill
  14201. * @param attributes Attributes array to fill
  14202. * @param samplers Samplers array to fill
  14203. */
  14204. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14205. /**
  14206. * Observable that will be called just before the particles are drawn
  14207. */
  14208. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14209. /**
  14210. * Gets the name of the particle vertex shader
  14211. */
  14212. vertexShaderName: string;
  14213. /**
  14214. * Adds a new color gradient
  14215. * @param gradient defines the gradient to use (between 0 and 1)
  14216. * @param color1 defines the color to affect to the specified gradient
  14217. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14218. * @returns the current particle system
  14219. */
  14220. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14221. /**
  14222. * Remove a specific color gradient
  14223. * @param gradient defines the gradient to remove
  14224. * @returns the current particle system
  14225. */
  14226. removeColorGradient(gradient: number): IParticleSystem;
  14227. /**
  14228. * Adds a new size gradient
  14229. * @param gradient defines the gradient to use (between 0 and 1)
  14230. * @param factor defines the size factor to affect to the specified gradient
  14231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14232. * @returns the current particle system
  14233. */
  14234. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14235. /**
  14236. * Remove a specific size gradient
  14237. * @param gradient defines the gradient to remove
  14238. * @returns the current particle system
  14239. */
  14240. removeSizeGradient(gradient: number): IParticleSystem;
  14241. /**
  14242. * Gets the current list of color gradients.
  14243. * You must use addColorGradient and removeColorGradient to udpate this list
  14244. * @returns the list of color gradients
  14245. */
  14246. getColorGradients(): Nullable<Array<ColorGradient>>;
  14247. /**
  14248. * Gets the current list of size gradients.
  14249. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14250. * @returns the list of size gradients
  14251. */
  14252. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14253. /**
  14254. * Gets the current list of angular speed gradients.
  14255. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14256. * @returns the list of angular speed gradients
  14257. */
  14258. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14259. /**
  14260. * Adds a new angular speed gradient
  14261. * @param gradient defines the gradient to use (between 0 and 1)
  14262. * @param factor defines the angular speed to affect to the specified gradient
  14263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14264. * @returns the current particle system
  14265. */
  14266. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14267. /**
  14268. * Remove a specific angular speed gradient
  14269. * @param gradient defines the gradient to remove
  14270. * @returns the current particle system
  14271. */
  14272. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14273. /**
  14274. * Gets the current list of velocity gradients.
  14275. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14276. * @returns the list of velocity gradients
  14277. */
  14278. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14279. /**
  14280. * Adds a new velocity gradient
  14281. * @param gradient defines the gradient to use (between 0 and 1)
  14282. * @param factor defines the velocity to affect to the specified gradient
  14283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14284. * @returns the current particle system
  14285. */
  14286. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14287. /**
  14288. * Remove a specific velocity gradient
  14289. * @param gradient defines the gradient to remove
  14290. * @returns the current particle system
  14291. */
  14292. removeVelocityGradient(gradient: number): IParticleSystem;
  14293. /**
  14294. * Gets the current list of limit velocity gradients.
  14295. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14296. * @returns the list of limit velocity gradients
  14297. */
  14298. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14299. /**
  14300. * Adds a new limit velocity gradient
  14301. * @param gradient defines the gradient to use (between 0 and 1)
  14302. * @param factor defines the limit velocity to affect to the specified gradient
  14303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14304. * @returns the current particle system
  14305. */
  14306. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14307. /**
  14308. * Remove a specific limit velocity gradient
  14309. * @param gradient defines the gradient to remove
  14310. * @returns the current particle system
  14311. */
  14312. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14313. /**
  14314. * Adds a new drag gradient
  14315. * @param gradient defines the gradient to use (between 0 and 1)
  14316. * @param factor defines the drag to affect to the specified gradient
  14317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14318. * @returns the current particle system
  14319. */
  14320. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14321. /**
  14322. * Remove a specific drag gradient
  14323. * @param gradient defines the gradient to remove
  14324. * @returns the current particle system
  14325. */
  14326. removeDragGradient(gradient: number): IParticleSystem;
  14327. /**
  14328. * Gets the current list of drag gradients.
  14329. * You must use addDragGradient and removeDragGradient to udpate this list
  14330. * @returns the list of drag gradients
  14331. */
  14332. getDragGradients(): Nullable<Array<FactorGradient>>;
  14333. /**
  14334. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14335. * @param gradient defines the gradient to use (between 0 and 1)
  14336. * @param factor defines the emit rate to affect to the specified gradient
  14337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14338. * @returns the current particle system
  14339. */
  14340. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14341. /**
  14342. * Remove a specific emit rate gradient
  14343. * @param gradient defines the gradient to remove
  14344. * @returns the current particle system
  14345. */
  14346. removeEmitRateGradient(gradient: number): IParticleSystem;
  14347. /**
  14348. * Gets the current list of emit rate gradients.
  14349. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14350. * @returns the list of emit rate gradients
  14351. */
  14352. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14353. /**
  14354. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14355. * @param gradient defines the gradient to use (between 0 and 1)
  14356. * @param factor defines the start size to affect to the specified gradient
  14357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14358. * @returns the current particle system
  14359. */
  14360. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14361. /**
  14362. * Remove a specific start size gradient
  14363. * @param gradient defines the gradient to remove
  14364. * @returns the current particle system
  14365. */
  14366. removeStartSizeGradient(gradient: number): IParticleSystem;
  14367. /**
  14368. * Gets the current list of start size gradients.
  14369. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14370. * @returns the list of start size gradients
  14371. */
  14372. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14373. /**
  14374. * Adds a new life time gradient
  14375. * @param gradient defines the gradient to use (between 0 and 1)
  14376. * @param factor defines the life time factor to affect to the specified gradient
  14377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14378. * @returns the current particle system
  14379. */
  14380. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14381. /**
  14382. * Remove a specific life time gradient
  14383. * @param gradient defines the gradient to remove
  14384. * @returns the current particle system
  14385. */
  14386. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14387. /**
  14388. * Gets the current list of life time gradients.
  14389. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14390. * @returns the list of life time gradients
  14391. */
  14392. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14393. /**
  14394. * Gets the current list of color gradients.
  14395. * You must use addColorGradient and removeColorGradient to udpate this list
  14396. * @returns the list of color gradients
  14397. */
  14398. getColorGradients(): Nullable<Array<ColorGradient>>;
  14399. /**
  14400. * Adds a new ramp gradient used to remap particle colors
  14401. * @param gradient defines the gradient to use (between 0 and 1)
  14402. * @param color defines the color to affect to the specified gradient
  14403. * @returns the current particle system
  14404. */
  14405. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14406. /**
  14407. * Gets the current list of ramp gradients.
  14408. * You must use addRampGradient and removeRampGradient to udpate this list
  14409. * @returns the list of ramp gradients
  14410. */
  14411. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14412. /** Gets or sets a boolean indicating that ramp gradients must be used
  14413. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14414. */
  14415. useRampGradients: boolean;
  14416. /**
  14417. * Adds a new color remap gradient
  14418. * @param gradient defines the gradient to use (between 0 and 1)
  14419. * @param min defines the color remap minimal range
  14420. * @param max defines the color remap maximal range
  14421. * @returns the current particle system
  14422. */
  14423. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14424. /**
  14425. * Gets the current list of color remap gradients.
  14426. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14427. * @returns the list of color remap gradients
  14428. */
  14429. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14430. /**
  14431. * Adds a new alpha remap gradient
  14432. * @param gradient defines the gradient to use (between 0 and 1)
  14433. * @param min defines the alpha remap minimal range
  14434. * @param max defines the alpha remap maximal range
  14435. * @returns the current particle system
  14436. */
  14437. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14438. /**
  14439. * Gets the current list of alpha remap gradients.
  14440. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14441. * @returns the list of alpha remap gradients
  14442. */
  14443. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14444. /**
  14445. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14446. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14447. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14448. * @returns the emitter
  14449. */
  14450. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14451. /**
  14452. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14453. * @param radius The radius of the hemisphere to emit from
  14454. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14455. * @returns the emitter
  14456. */
  14457. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14458. /**
  14459. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14460. * @param radius The radius of the sphere to emit from
  14461. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14462. * @returns the emitter
  14463. */
  14464. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14465. /**
  14466. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14467. * @param radius The radius of the sphere to emit from
  14468. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14469. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14470. * @returns the emitter
  14471. */
  14472. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14473. /**
  14474. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14475. * @param radius The radius of the emission cylinder
  14476. * @param height The height of the emission cylinder
  14477. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14478. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14479. * @returns the emitter
  14480. */
  14481. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14482. /**
  14483. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14484. * @param radius The radius of the cylinder to emit from
  14485. * @param height The height of the emission cylinder
  14486. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14487. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14488. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14489. * @returns the emitter
  14490. */
  14491. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14492. /**
  14493. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14494. * @param radius The radius of the cone to emit from
  14495. * @param angle The base angle of the cone
  14496. * @returns the emitter
  14497. */
  14498. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14499. /**
  14500. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14501. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14502. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14503. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14504. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14505. * @returns the emitter
  14506. */
  14507. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14508. /**
  14509. * Get hosting scene
  14510. * @returns the scene
  14511. */
  14512. getScene(): Scene;
  14513. }
  14514. }
  14515. declare module BABYLON {
  14516. /**
  14517. * 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.
  14518. * @see https://doc.babylonjs.com/how_to/transformnode
  14519. */
  14520. export class TransformNode extends Node {
  14521. /**
  14522. * Object will not rotate to face the camera
  14523. */
  14524. static BILLBOARDMODE_NONE: number;
  14525. /**
  14526. * Object will rotate to face the camera but only on the x axis
  14527. */
  14528. static BILLBOARDMODE_X: number;
  14529. /**
  14530. * Object will rotate to face the camera but only on the y axis
  14531. */
  14532. static BILLBOARDMODE_Y: number;
  14533. /**
  14534. * Object will rotate to face the camera but only on the z axis
  14535. */
  14536. static BILLBOARDMODE_Z: number;
  14537. /**
  14538. * Object will rotate to face the camera
  14539. */
  14540. static BILLBOARDMODE_ALL: number;
  14541. /**
  14542. * Object will rotate to face the camera's position instead of orientation
  14543. */
  14544. static BILLBOARDMODE_USE_POSITION: number;
  14545. private static _TmpRotation;
  14546. private static _TmpScaling;
  14547. private static _TmpTranslation;
  14548. private _forward;
  14549. private _forwardInverted;
  14550. private _up;
  14551. private _right;
  14552. private _rightInverted;
  14553. private _position;
  14554. private _rotation;
  14555. private _rotationQuaternion;
  14556. protected _scaling: Vector3;
  14557. protected _isDirty: boolean;
  14558. private _transformToBoneReferal;
  14559. private _isAbsoluteSynced;
  14560. private _billboardMode;
  14561. /**
  14562. * Gets or sets the billboard mode. Default is 0.
  14563. *
  14564. * | Value | Type | Description |
  14565. * | --- | --- | --- |
  14566. * | 0 | BILLBOARDMODE_NONE | |
  14567. * | 1 | BILLBOARDMODE_X | |
  14568. * | 2 | BILLBOARDMODE_Y | |
  14569. * | 4 | BILLBOARDMODE_Z | |
  14570. * | 7 | BILLBOARDMODE_ALL | |
  14571. *
  14572. */
  14573. get billboardMode(): number;
  14574. set billboardMode(value: number);
  14575. private _preserveParentRotationForBillboard;
  14576. /**
  14577. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14578. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14579. */
  14580. get preserveParentRotationForBillboard(): boolean;
  14581. set preserveParentRotationForBillboard(value: boolean);
  14582. /**
  14583. * 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
  14584. */
  14585. scalingDeterminant: number;
  14586. private _infiniteDistance;
  14587. /**
  14588. * Gets or sets the distance of the object to max, often used by skybox
  14589. */
  14590. get infiniteDistance(): boolean;
  14591. set infiniteDistance(value: boolean);
  14592. /**
  14593. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14594. * By default the system will update normals to compensate
  14595. */
  14596. ignoreNonUniformScaling: boolean;
  14597. /**
  14598. * 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
  14599. */
  14600. reIntegrateRotationIntoRotationQuaternion: boolean;
  14601. /** @hidden */
  14602. _poseMatrix: Nullable<Matrix>;
  14603. /** @hidden */
  14604. _localMatrix: Matrix;
  14605. private _usePivotMatrix;
  14606. private _absolutePosition;
  14607. private _absoluteScaling;
  14608. private _absoluteRotationQuaternion;
  14609. private _pivotMatrix;
  14610. private _pivotMatrixInverse;
  14611. protected _postMultiplyPivotMatrix: boolean;
  14612. protected _isWorldMatrixFrozen: boolean;
  14613. /** @hidden */
  14614. _indexInSceneTransformNodesArray: number;
  14615. /**
  14616. * An event triggered after the world matrix is updated
  14617. */
  14618. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14619. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14620. /**
  14621. * Gets a string identifying the name of the class
  14622. * @returns "TransformNode" string
  14623. */
  14624. getClassName(): string;
  14625. /**
  14626. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14627. */
  14628. get position(): Vector3;
  14629. set position(newPosition: Vector3);
  14630. /**
  14631. * 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)).
  14632. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14633. */
  14634. get rotation(): Vector3;
  14635. set rotation(newRotation: Vector3);
  14636. /**
  14637. * 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)).
  14638. */
  14639. get scaling(): Vector3;
  14640. set scaling(newScaling: Vector3);
  14641. /**
  14642. * 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).
  14643. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14644. */
  14645. get rotationQuaternion(): Nullable<Quaternion>;
  14646. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14647. /**
  14648. * The forward direction of that transform in world space.
  14649. */
  14650. get forward(): Vector3;
  14651. /**
  14652. * The up direction of that transform in world space.
  14653. */
  14654. get up(): Vector3;
  14655. /**
  14656. * The right direction of that transform in world space.
  14657. */
  14658. get right(): Vector3;
  14659. /**
  14660. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14661. * @param matrix the matrix to copy the pose from
  14662. * @returns this TransformNode.
  14663. */
  14664. updatePoseMatrix(matrix: Matrix): TransformNode;
  14665. /**
  14666. * Returns the mesh Pose matrix.
  14667. * @returns the pose matrix
  14668. */
  14669. getPoseMatrix(): Matrix;
  14670. /** @hidden */
  14671. _isSynchronized(): boolean;
  14672. /** @hidden */
  14673. _initCache(): void;
  14674. /**
  14675. * Flag the transform node as dirty (Forcing it to update everything)
  14676. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14677. * @returns this transform node
  14678. */
  14679. markAsDirty(property: string): TransformNode;
  14680. /**
  14681. * Returns the current mesh absolute position.
  14682. * Returns a Vector3.
  14683. */
  14684. get absolutePosition(): Vector3;
  14685. /**
  14686. * Returns the current mesh absolute scaling.
  14687. * Returns a Vector3.
  14688. */
  14689. get absoluteScaling(): Vector3;
  14690. /**
  14691. * Returns the current mesh absolute rotation.
  14692. * Returns a Quaternion.
  14693. */
  14694. get absoluteRotationQuaternion(): Quaternion;
  14695. /**
  14696. * Sets a new matrix to apply before all other transformation
  14697. * @param matrix defines the transform matrix
  14698. * @returns the current TransformNode
  14699. */
  14700. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14701. /**
  14702. * Sets a new pivot matrix to the current node
  14703. * @param matrix defines the new pivot matrix to use
  14704. * @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
  14705. * @returns the current TransformNode
  14706. */
  14707. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14708. /**
  14709. * Returns the mesh pivot matrix.
  14710. * Default : Identity.
  14711. * @returns the matrix
  14712. */
  14713. getPivotMatrix(): Matrix;
  14714. /**
  14715. * Instantiate (when possible) or clone that node with its hierarchy
  14716. * @param newParent defines the new parent to use for the instance (or clone)
  14717. * @param options defines options to configure how copy is done
  14718. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14719. * @returns an instance (or a clone) of the current node with its hiearchy
  14720. */
  14721. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14722. doNotInstantiate: boolean;
  14723. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14724. /**
  14725. * Prevents the World matrix to be computed any longer
  14726. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14727. * @returns the TransformNode.
  14728. */
  14729. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14730. /**
  14731. * Allows back the World matrix computation.
  14732. * @returns the TransformNode.
  14733. */
  14734. unfreezeWorldMatrix(): this;
  14735. /**
  14736. * True if the World matrix has been frozen.
  14737. */
  14738. get isWorldMatrixFrozen(): boolean;
  14739. /**
  14740. * Retuns the mesh absolute position in the World.
  14741. * @returns a Vector3.
  14742. */
  14743. getAbsolutePosition(): Vector3;
  14744. /**
  14745. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14746. * @param absolutePosition the absolute position to set
  14747. * @returns the TransformNode.
  14748. */
  14749. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14750. /**
  14751. * Sets the mesh position in its local space.
  14752. * @param vector3 the position to set in localspace
  14753. * @returns the TransformNode.
  14754. */
  14755. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14756. /**
  14757. * Returns the mesh position in the local space from the current World matrix values.
  14758. * @returns a new Vector3.
  14759. */
  14760. getPositionExpressedInLocalSpace(): Vector3;
  14761. /**
  14762. * Translates the mesh along the passed Vector3 in its local space.
  14763. * @param vector3 the distance to translate in localspace
  14764. * @returns the TransformNode.
  14765. */
  14766. locallyTranslate(vector3: Vector3): TransformNode;
  14767. private static _lookAtVectorCache;
  14768. /**
  14769. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14770. * @param targetPoint the position (must be in same space as current mesh) to look at
  14771. * @param yawCor optional yaw (y-axis) correction in radians
  14772. * @param pitchCor optional pitch (x-axis) correction in radians
  14773. * @param rollCor optional roll (z-axis) correction in radians
  14774. * @param space the choosen space of the target
  14775. * @returns the TransformNode.
  14776. */
  14777. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14778. /**
  14779. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14780. * This Vector3 is expressed in the World space.
  14781. * @param localAxis axis to rotate
  14782. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14783. */
  14784. getDirection(localAxis: Vector3): Vector3;
  14785. /**
  14786. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14787. * localAxis is expressed in the mesh local space.
  14788. * result is computed in the Wordl space from the mesh World matrix.
  14789. * @param localAxis axis to rotate
  14790. * @param result the resulting transformnode
  14791. * @returns this TransformNode.
  14792. */
  14793. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14794. /**
  14795. * Sets this transform node rotation to the given local axis.
  14796. * @param localAxis the axis in local space
  14797. * @param yawCor optional yaw (y-axis) correction in radians
  14798. * @param pitchCor optional pitch (x-axis) correction in radians
  14799. * @param rollCor optional roll (z-axis) correction in radians
  14800. * @returns this TransformNode
  14801. */
  14802. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14803. /**
  14804. * Sets a new pivot point to the current node
  14805. * @param point defines the new pivot point to use
  14806. * @param space defines if the point is in world or local space (local by default)
  14807. * @returns the current TransformNode
  14808. */
  14809. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14810. /**
  14811. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14812. * @returns the pivot point
  14813. */
  14814. getPivotPoint(): Vector3;
  14815. /**
  14816. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14817. * @param result the vector3 to store the result
  14818. * @returns this TransformNode.
  14819. */
  14820. getPivotPointToRef(result: Vector3): TransformNode;
  14821. /**
  14822. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14823. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14824. */
  14825. getAbsolutePivotPoint(): Vector3;
  14826. /**
  14827. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14828. * @param result vector3 to store the result
  14829. * @returns this TransformNode.
  14830. */
  14831. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14832. /**
  14833. * Defines the passed node as the parent of the current node.
  14834. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14835. * @see https://doc.babylonjs.com/how_to/parenting
  14836. * @param node the node ot set as the parent
  14837. * @returns this TransformNode.
  14838. */
  14839. setParent(node: Nullable<Node>): TransformNode;
  14840. private _nonUniformScaling;
  14841. /**
  14842. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14843. */
  14844. get nonUniformScaling(): boolean;
  14845. /** @hidden */
  14846. _updateNonUniformScalingState(value: boolean): boolean;
  14847. /**
  14848. * Attach the current TransformNode to another TransformNode associated with a bone
  14849. * @param bone Bone affecting the TransformNode
  14850. * @param affectedTransformNode TransformNode associated with the bone
  14851. * @returns this object
  14852. */
  14853. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14854. /**
  14855. * Detach the transform node if its associated with a bone
  14856. * @returns this object
  14857. */
  14858. detachFromBone(): TransformNode;
  14859. private static _rotationAxisCache;
  14860. /**
  14861. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14862. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14863. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14864. * The passed axis is also normalized.
  14865. * @param axis the axis to rotate around
  14866. * @param amount the amount to rotate in radians
  14867. * @param space Space to rotate in (Default: local)
  14868. * @returns the TransformNode.
  14869. */
  14870. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14871. /**
  14872. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14873. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14874. * The passed axis is also normalized. .
  14875. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14876. * @param point the point to rotate around
  14877. * @param axis the axis to rotate around
  14878. * @param amount the amount to rotate in radians
  14879. * @returns the TransformNode
  14880. */
  14881. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14882. /**
  14883. * Translates the mesh along the axis vector for the passed distance in the given space.
  14884. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14885. * @param axis the axis to translate in
  14886. * @param distance the distance to translate
  14887. * @param space Space to rotate in (Default: local)
  14888. * @returns the TransformNode.
  14889. */
  14890. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14891. /**
  14892. * Adds a rotation step to the mesh current rotation.
  14893. * x, y, z are Euler angles expressed in radians.
  14894. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14895. * This means this rotation is made in the mesh local space only.
  14896. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14897. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14898. * ```javascript
  14899. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14900. * ```
  14901. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14902. * 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.
  14903. * @param x Rotation to add
  14904. * @param y Rotation to add
  14905. * @param z Rotation to add
  14906. * @returns the TransformNode.
  14907. */
  14908. addRotation(x: number, y: number, z: number): TransformNode;
  14909. /**
  14910. * @hidden
  14911. */
  14912. protected _getEffectiveParent(): Nullable<Node>;
  14913. /**
  14914. * Computes the world matrix of the node
  14915. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14916. * @returns the world matrix
  14917. */
  14918. computeWorldMatrix(force?: boolean): Matrix;
  14919. /**
  14920. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14921. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14922. */
  14923. resetLocalMatrix(independentOfChildren?: boolean): void;
  14924. protected _afterComputeWorldMatrix(): void;
  14925. /**
  14926. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14927. * @param func callback function to add
  14928. *
  14929. * @returns the TransformNode.
  14930. */
  14931. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14932. /**
  14933. * Removes a registered callback function.
  14934. * @param func callback function to remove
  14935. * @returns the TransformNode.
  14936. */
  14937. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14938. /**
  14939. * Gets the position of the current mesh in camera space
  14940. * @param camera defines the camera to use
  14941. * @returns a position
  14942. */
  14943. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14944. /**
  14945. * Returns the distance from the mesh to the active camera
  14946. * @param camera defines the camera to use
  14947. * @returns the distance
  14948. */
  14949. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14950. /**
  14951. * Clone the current transform node
  14952. * @param name Name of the new clone
  14953. * @param newParent New parent for the clone
  14954. * @param doNotCloneChildren Do not clone children hierarchy
  14955. * @returns the new transform node
  14956. */
  14957. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14958. /**
  14959. * Serializes the objects information.
  14960. * @param currentSerializationObject defines the object to serialize in
  14961. * @returns the serialized object
  14962. */
  14963. serialize(currentSerializationObject?: any): any;
  14964. /**
  14965. * Returns a new TransformNode object parsed from the source provided.
  14966. * @param parsedTransformNode is the source.
  14967. * @param scene the scne the object belongs to
  14968. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14969. * @returns a new TransformNode object parsed from the source provided.
  14970. */
  14971. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14972. /**
  14973. * Get all child-transformNodes of this node
  14974. * @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
  14975. * @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
  14976. * @returns an array of TransformNode
  14977. */
  14978. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14979. /**
  14980. * Releases resources associated with this transform node.
  14981. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14982. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14983. */
  14984. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14985. /**
  14986. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14987. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14988. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14989. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14990. * @returns the current mesh
  14991. */
  14992. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14993. private _syncAbsoluteScalingAndRotation;
  14994. }
  14995. }
  14996. declare module BABYLON {
  14997. /**
  14998. * Class used to override all child animations of a given target
  14999. */
  15000. export class AnimationPropertiesOverride {
  15001. /**
  15002. * Gets or sets a value indicating if animation blending must be used
  15003. */
  15004. enableBlending: boolean;
  15005. /**
  15006. * Gets or sets the blending speed to use when enableBlending is true
  15007. */
  15008. blendingSpeed: number;
  15009. /**
  15010. * Gets or sets the default loop mode to use
  15011. */
  15012. loopMode: number;
  15013. }
  15014. }
  15015. declare module BABYLON {
  15016. /**
  15017. * Class used to store bone information
  15018. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15019. */
  15020. export class Bone extends Node {
  15021. /**
  15022. * defines the bone name
  15023. */
  15024. name: string;
  15025. private static _tmpVecs;
  15026. private static _tmpQuat;
  15027. private static _tmpMats;
  15028. /**
  15029. * Gets the list of child bones
  15030. */
  15031. children: Bone[];
  15032. /** Gets the animations associated with this bone */
  15033. animations: Animation[];
  15034. /**
  15035. * Gets or sets bone length
  15036. */
  15037. length: number;
  15038. /**
  15039. * @hidden Internal only
  15040. * Set this value to map this bone to a different index in the transform matrices
  15041. * Set this value to -1 to exclude the bone from the transform matrices
  15042. */
  15043. _index: Nullable<number>;
  15044. private _skeleton;
  15045. private _localMatrix;
  15046. private _restPose;
  15047. private _baseMatrix;
  15048. private _absoluteTransform;
  15049. private _invertedAbsoluteTransform;
  15050. private _parent;
  15051. private _scalingDeterminant;
  15052. private _worldTransform;
  15053. private _localScaling;
  15054. private _localRotation;
  15055. private _localPosition;
  15056. private _needToDecompose;
  15057. private _needToCompose;
  15058. /** @hidden */
  15059. _linkedTransformNode: Nullable<TransformNode>;
  15060. /** @hidden */
  15061. _waitingTransformNodeId: Nullable<string>;
  15062. /** @hidden */
  15063. get _matrix(): Matrix;
  15064. /** @hidden */
  15065. set _matrix(value: Matrix);
  15066. /**
  15067. * Create a new bone
  15068. * @param name defines the bone name
  15069. * @param skeleton defines the parent skeleton
  15070. * @param parentBone defines the parent (can be null if the bone is the root)
  15071. * @param localMatrix defines the local matrix
  15072. * @param restPose defines the rest pose matrix
  15073. * @param baseMatrix defines the base matrix
  15074. * @param index defines index of the bone in the hiearchy
  15075. */
  15076. constructor(
  15077. /**
  15078. * defines the bone name
  15079. */
  15080. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15081. /**
  15082. * Gets the current object class name.
  15083. * @return the class name
  15084. */
  15085. getClassName(): string;
  15086. /**
  15087. * Gets the parent skeleton
  15088. * @returns a skeleton
  15089. */
  15090. getSkeleton(): Skeleton;
  15091. /**
  15092. * Gets parent bone
  15093. * @returns a bone or null if the bone is the root of the bone hierarchy
  15094. */
  15095. getParent(): Nullable<Bone>;
  15096. /**
  15097. * Returns an array containing the root bones
  15098. * @returns an array containing the root bones
  15099. */
  15100. getChildren(): Array<Bone>;
  15101. /**
  15102. * Gets the node index in matrix array generated for rendering
  15103. * @returns the node index
  15104. */
  15105. getIndex(): number;
  15106. /**
  15107. * Sets the parent bone
  15108. * @param parent defines the parent (can be null if the bone is the root)
  15109. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15110. */
  15111. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15112. /**
  15113. * Gets the local matrix
  15114. * @returns a matrix
  15115. */
  15116. getLocalMatrix(): Matrix;
  15117. /**
  15118. * Gets the base matrix (initial matrix which remains unchanged)
  15119. * @returns a matrix
  15120. */
  15121. getBaseMatrix(): Matrix;
  15122. /**
  15123. * Gets the rest pose matrix
  15124. * @returns a matrix
  15125. */
  15126. getRestPose(): Matrix;
  15127. /**
  15128. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15129. */
  15130. getWorldMatrix(): Matrix;
  15131. /**
  15132. * Sets the local matrix to rest pose matrix
  15133. */
  15134. returnToRest(): void;
  15135. /**
  15136. * Gets the inverse of the absolute transform matrix.
  15137. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15138. * @returns a matrix
  15139. */
  15140. getInvertedAbsoluteTransform(): Matrix;
  15141. /**
  15142. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15143. * @returns a matrix
  15144. */
  15145. getAbsoluteTransform(): Matrix;
  15146. /**
  15147. * Links with the given transform node.
  15148. * The local matrix of this bone is copied from the transform node every frame.
  15149. * @param transformNode defines the transform node to link to
  15150. */
  15151. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15152. /**
  15153. * Gets the node used to drive the bone's transformation
  15154. * @returns a transform node or null
  15155. */
  15156. getTransformNode(): Nullable<TransformNode>;
  15157. /** Gets or sets current position (in local space) */
  15158. get position(): Vector3;
  15159. set position(newPosition: Vector3);
  15160. /** Gets or sets current rotation (in local space) */
  15161. get rotation(): Vector3;
  15162. set rotation(newRotation: Vector3);
  15163. /** Gets or sets current rotation quaternion (in local space) */
  15164. get rotationQuaternion(): Quaternion;
  15165. set rotationQuaternion(newRotation: Quaternion);
  15166. /** Gets or sets current scaling (in local space) */
  15167. get scaling(): Vector3;
  15168. set scaling(newScaling: Vector3);
  15169. /**
  15170. * Gets the animation properties override
  15171. */
  15172. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15173. private _decompose;
  15174. private _compose;
  15175. /**
  15176. * Update the base and local matrices
  15177. * @param matrix defines the new base or local matrix
  15178. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15179. * @param updateLocalMatrix defines if the local matrix should be updated
  15180. */
  15181. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15182. /** @hidden */
  15183. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15184. /**
  15185. * Flag the bone as dirty (Forcing it to update everything)
  15186. */
  15187. markAsDirty(): void;
  15188. /** @hidden */
  15189. _markAsDirtyAndCompose(): void;
  15190. private _markAsDirtyAndDecompose;
  15191. /**
  15192. * Translate the bone in local or world space
  15193. * @param vec The amount to translate the bone
  15194. * @param space The space that the translation is in
  15195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15196. */
  15197. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15198. /**
  15199. * Set the postion of the bone in local or world space
  15200. * @param position The position to set the bone
  15201. * @param space The space that the position is in
  15202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15203. */
  15204. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15205. /**
  15206. * Set the absolute position of the bone (world space)
  15207. * @param position The position to set the bone
  15208. * @param mesh The mesh that this bone is attached to
  15209. */
  15210. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15211. /**
  15212. * Scale the bone on the x, y and z axes (in local space)
  15213. * @param x The amount to scale the bone on the x axis
  15214. * @param y The amount to scale the bone on the y axis
  15215. * @param z The amount to scale the bone on the z axis
  15216. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15217. */
  15218. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15219. /**
  15220. * Set the bone scaling in local space
  15221. * @param scale defines the scaling vector
  15222. */
  15223. setScale(scale: Vector3): void;
  15224. /**
  15225. * Gets the current scaling in local space
  15226. * @returns the current scaling vector
  15227. */
  15228. getScale(): Vector3;
  15229. /**
  15230. * Gets the current scaling in local space and stores it in a target vector
  15231. * @param result defines the target vector
  15232. */
  15233. getScaleToRef(result: Vector3): void;
  15234. /**
  15235. * Set the yaw, pitch, and roll of the bone in local or world space
  15236. * @param yaw The rotation of the bone on the y axis
  15237. * @param pitch The rotation of the bone on the x axis
  15238. * @param roll The rotation of the bone on the z axis
  15239. * @param space The space that the axes of rotation are in
  15240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15241. */
  15242. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15243. /**
  15244. * Add a rotation to the bone on an axis in local or world space
  15245. * @param axis The axis to rotate the bone on
  15246. * @param amount The amount to rotate the bone
  15247. * @param space The space that the axis is in
  15248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15249. */
  15250. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15251. /**
  15252. * Set the rotation of the bone to a particular axis angle in local or world space
  15253. * @param axis The axis to rotate the bone on
  15254. * @param angle The angle that the bone should be rotated to
  15255. * @param space The space that the axis is in
  15256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15257. */
  15258. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15259. /**
  15260. * Set the euler rotation of the bone in local of world space
  15261. * @param rotation The euler rotation that the bone should be set to
  15262. * @param space The space that the rotation is in
  15263. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15264. */
  15265. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15266. /**
  15267. * Set the quaternion rotation of the bone in local of world space
  15268. * @param quat The quaternion rotation that the bone should be set to
  15269. * @param space The space that the rotation is in
  15270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15271. */
  15272. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15273. /**
  15274. * Set the rotation matrix of the bone in local of world space
  15275. * @param rotMat The rotation matrix that the bone should be set to
  15276. * @param space The space that the rotation is in
  15277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15278. */
  15279. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15280. private _rotateWithMatrix;
  15281. private _getNegativeRotationToRef;
  15282. /**
  15283. * Get the position of the bone in local or world space
  15284. * @param space The space that the returned position is in
  15285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15286. * @returns The position of the bone
  15287. */
  15288. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15289. /**
  15290. * Copy the position of the bone to a vector3 in local or world space
  15291. * @param space The space that the returned position is in
  15292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15293. * @param result The vector3 to copy the position to
  15294. */
  15295. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15296. /**
  15297. * Get the absolute position of the bone (world space)
  15298. * @param mesh The mesh that this bone is attached to
  15299. * @returns The absolute position of the bone
  15300. */
  15301. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15302. /**
  15303. * Copy the absolute position of the bone (world space) to the result param
  15304. * @param mesh The mesh that this bone is attached to
  15305. * @param result The vector3 to copy the absolute position to
  15306. */
  15307. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15308. /**
  15309. * Compute the absolute transforms of this bone and its children
  15310. */
  15311. computeAbsoluteTransforms(): void;
  15312. /**
  15313. * Get the world direction from an axis that is in the local space of the bone
  15314. * @param localAxis The local direction that is used to compute the world direction
  15315. * @param mesh The mesh that this bone is attached to
  15316. * @returns The world direction
  15317. */
  15318. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15319. /**
  15320. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15321. * @param localAxis The local direction that is used to compute the world direction
  15322. * @param mesh The mesh that this bone is attached to
  15323. * @param result The vector3 that the world direction will be copied to
  15324. */
  15325. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15326. /**
  15327. * Get the euler rotation of the bone in local or world space
  15328. * @param space The space that the rotation should be in
  15329. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15330. * @returns The euler rotation
  15331. */
  15332. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15333. /**
  15334. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15335. * @param space The space that the rotation should be in
  15336. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15337. * @param result The vector3 that the rotation should be copied to
  15338. */
  15339. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15340. /**
  15341. * Get the quaternion rotation of the bone in either local or world space
  15342. * @param space The space that the rotation should be in
  15343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15344. * @returns The quaternion rotation
  15345. */
  15346. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15347. /**
  15348. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15349. * @param space The space that the rotation should be in
  15350. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15351. * @param result The quaternion that the rotation should be copied to
  15352. */
  15353. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15354. /**
  15355. * Get the rotation matrix of the bone in local or world space
  15356. * @param space The space that the rotation should be in
  15357. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15358. * @returns The rotation matrix
  15359. */
  15360. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15361. /**
  15362. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15363. * @param space The space that the rotation should be in
  15364. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15365. * @param result The quaternion that the rotation should be copied to
  15366. */
  15367. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15368. /**
  15369. * Get the world position of a point that is in the local space of the bone
  15370. * @param position The local position
  15371. * @param mesh The mesh that this bone is attached to
  15372. * @returns The world position
  15373. */
  15374. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15375. /**
  15376. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15377. * @param position The local position
  15378. * @param mesh The mesh that this bone is attached to
  15379. * @param result The vector3 that the world position should be copied to
  15380. */
  15381. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15382. /**
  15383. * Get the local position of a point that is in world space
  15384. * @param position The world position
  15385. * @param mesh The mesh that this bone is attached to
  15386. * @returns The local position
  15387. */
  15388. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15389. /**
  15390. * Get the local position of a point that is in world space and copy it to the result param
  15391. * @param position The world position
  15392. * @param mesh The mesh that this bone is attached to
  15393. * @param result The vector3 that the local position should be copied to
  15394. */
  15395. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15396. }
  15397. }
  15398. declare module BABYLON {
  15399. /**
  15400. * Defines a runtime animation
  15401. */
  15402. export class RuntimeAnimation {
  15403. private _events;
  15404. /**
  15405. * The current frame of the runtime animation
  15406. */
  15407. private _currentFrame;
  15408. /**
  15409. * The animation used by the runtime animation
  15410. */
  15411. private _animation;
  15412. /**
  15413. * The target of the runtime animation
  15414. */
  15415. private _target;
  15416. /**
  15417. * The initiating animatable
  15418. */
  15419. private _host;
  15420. /**
  15421. * The original value of the runtime animation
  15422. */
  15423. private _originalValue;
  15424. /**
  15425. * The original blend value of the runtime animation
  15426. */
  15427. private _originalBlendValue;
  15428. /**
  15429. * The offsets cache of the runtime animation
  15430. */
  15431. private _offsetsCache;
  15432. /**
  15433. * The high limits cache of the runtime animation
  15434. */
  15435. private _highLimitsCache;
  15436. /**
  15437. * Specifies if the runtime animation has been stopped
  15438. */
  15439. private _stopped;
  15440. /**
  15441. * The blending factor of the runtime animation
  15442. */
  15443. private _blendingFactor;
  15444. /**
  15445. * The BabylonJS scene
  15446. */
  15447. private _scene;
  15448. /**
  15449. * The current value of the runtime animation
  15450. */
  15451. private _currentValue;
  15452. /** @hidden */
  15453. _animationState: _IAnimationState;
  15454. /**
  15455. * The active target of the runtime animation
  15456. */
  15457. private _activeTargets;
  15458. private _currentActiveTarget;
  15459. private _directTarget;
  15460. /**
  15461. * The target path of the runtime animation
  15462. */
  15463. private _targetPath;
  15464. /**
  15465. * The weight of the runtime animation
  15466. */
  15467. private _weight;
  15468. /**
  15469. * The ratio offset of the runtime animation
  15470. */
  15471. private _ratioOffset;
  15472. /**
  15473. * The previous delay of the runtime animation
  15474. */
  15475. private _previousDelay;
  15476. /**
  15477. * The previous ratio of the runtime animation
  15478. */
  15479. private _previousRatio;
  15480. private _enableBlending;
  15481. private _keys;
  15482. private _minFrame;
  15483. private _maxFrame;
  15484. private _minValue;
  15485. private _maxValue;
  15486. private _targetIsArray;
  15487. /**
  15488. * Gets the current frame of the runtime animation
  15489. */
  15490. get currentFrame(): number;
  15491. /**
  15492. * Gets the weight of the runtime animation
  15493. */
  15494. get weight(): number;
  15495. /**
  15496. * Gets the current value of the runtime animation
  15497. */
  15498. get currentValue(): any;
  15499. /**
  15500. * Gets the target path of the runtime animation
  15501. */
  15502. get targetPath(): string;
  15503. /**
  15504. * Gets the actual target of the runtime animation
  15505. */
  15506. get target(): any;
  15507. /**
  15508. * Gets the additive state of the runtime animation
  15509. */
  15510. get isAdditive(): boolean;
  15511. /** @hidden */
  15512. _onLoop: () => void;
  15513. /**
  15514. * Create a new RuntimeAnimation object
  15515. * @param target defines the target of the animation
  15516. * @param animation defines the source animation object
  15517. * @param scene defines the hosting scene
  15518. * @param host defines the initiating Animatable
  15519. */
  15520. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15521. private _preparePath;
  15522. /**
  15523. * Gets the animation from the runtime animation
  15524. */
  15525. get animation(): Animation;
  15526. /**
  15527. * Resets the runtime animation to the beginning
  15528. * @param restoreOriginal defines whether to restore the target property to the original value
  15529. */
  15530. reset(restoreOriginal?: boolean): void;
  15531. /**
  15532. * Specifies if the runtime animation is stopped
  15533. * @returns Boolean specifying if the runtime animation is stopped
  15534. */
  15535. isStopped(): boolean;
  15536. /**
  15537. * Disposes of the runtime animation
  15538. */
  15539. dispose(): void;
  15540. /**
  15541. * Apply the interpolated value to the target
  15542. * @param currentValue defines the value computed by the animation
  15543. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15544. */
  15545. setValue(currentValue: any, weight: number): void;
  15546. private _getOriginalValues;
  15547. private _setValue;
  15548. /**
  15549. * Gets the loop pmode of the runtime animation
  15550. * @returns Loop Mode
  15551. */
  15552. private _getCorrectLoopMode;
  15553. /**
  15554. * Move the current animation to a given frame
  15555. * @param frame defines the frame to move to
  15556. */
  15557. goToFrame(frame: number): void;
  15558. /**
  15559. * @hidden Internal use only
  15560. */
  15561. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15562. /**
  15563. * Execute the current animation
  15564. * @param delay defines the delay to add to the current frame
  15565. * @param from defines the lower bound of the animation range
  15566. * @param to defines the upper bound of the animation range
  15567. * @param loop defines if the current animation must loop
  15568. * @param speedRatio defines the current speed ratio
  15569. * @param weight defines the weight of the animation (default is -1 so no weight)
  15570. * @param onLoop optional callback called when animation loops
  15571. * @returns a boolean indicating if the animation is running
  15572. */
  15573. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15574. }
  15575. }
  15576. declare module BABYLON {
  15577. /**
  15578. * Class used to store an actual running animation
  15579. */
  15580. export class Animatable {
  15581. /** defines the target object */
  15582. target: any;
  15583. /** defines the starting frame number (default is 0) */
  15584. fromFrame: number;
  15585. /** defines the ending frame number (default is 100) */
  15586. toFrame: number;
  15587. /** defines if the animation must loop (default is false) */
  15588. loopAnimation: boolean;
  15589. /** defines a callback to call when animation ends if it is not looping */
  15590. onAnimationEnd?: (() => void) | null | undefined;
  15591. /** defines a callback to call when animation loops */
  15592. onAnimationLoop?: (() => void) | null | undefined;
  15593. /** defines whether the animation should be evaluated additively */
  15594. isAdditive: boolean;
  15595. private _localDelayOffset;
  15596. private _pausedDelay;
  15597. private _runtimeAnimations;
  15598. private _paused;
  15599. private _scene;
  15600. private _speedRatio;
  15601. private _weight;
  15602. private _syncRoot;
  15603. /**
  15604. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15605. * This will only apply for non looping animation (default is true)
  15606. */
  15607. disposeOnEnd: boolean;
  15608. /**
  15609. * Gets a boolean indicating if the animation has started
  15610. */
  15611. animationStarted: boolean;
  15612. /**
  15613. * Observer raised when the animation ends
  15614. */
  15615. onAnimationEndObservable: Observable<Animatable>;
  15616. /**
  15617. * Observer raised when the animation loops
  15618. */
  15619. onAnimationLoopObservable: Observable<Animatable>;
  15620. /**
  15621. * Gets the root Animatable used to synchronize and normalize animations
  15622. */
  15623. get syncRoot(): Nullable<Animatable>;
  15624. /**
  15625. * Gets the current frame of the first RuntimeAnimation
  15626. * Used to synchronize Animatables
  15627. */
  15628. get masterFrame(): number;
  15629. /**
  15630. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15631. */
  15632. get weight(): number;
  15633. set weight(value: number);
  15634. /**
  15635. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15636. */
  15637. get speedRatio(): number;
  15638. set speedRatio(value: number);
  15639. /**
  15640. * Creates a new Animatable
  15641. * @param scene defines the hosting scene
  15642. * @param target defines the target object
  15643. * @param fromFrame defines the starting frame number (default is 0)
  15644. * @param toFrame defines the ending frame number (default is 100)
  15645. * @param loopAnimation defines if the animation must loop (default is false)
  15646. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15647. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15648. * @param animations defines a group of animation to add to the new Animatable
  15649. * @param onAnimationLoop defines a callback to call when animation loops
  15650. * @param isAdditive defines whether the animation should be evaluated additively
  15651. */
  15652. constructor(scene: Scene,
  15653. /** defines the target object */
  15654. target: any,
  15655. /** defines the starting frame number (default is 0) */
  15656. fromFrame?: number,
  15657. /** defines the ending frame number (default is 100) */
  15658. toFrame?: number,
  15659. /** defines if the animation must loop (default is false) */
  15660. loopAnimation?: boolean, speedRatio?: number,
  15661. /** defines a callback to call when animation ends if it is not looping */
  15662. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15663. /** defines a callback to call when animation loops */
  15664. onAnimationLoop?: (() => void) | null | undefined,
  15665. /** defines whether the animation should be evaluated additively */
  15666. isAdditive?: boolean);
  15667. /**
  15668. * Synchronize and normalize current Animatable with a source Animatable
  15669. * This is useful when using animation weights and when animations are not of the same length
  15670. * @param root defines the root Animatable to synchronize with
  15671. * @returns the current Animatable
  15672. */
  15673. syncWith(root: Animatable): Animatable;
  15674. /**
  15675. * Gets the list of runtime animations
  15676. * @returns an array of RuntimeAnimation
  15677. */
  15678. getAnimations(): RuntimeAnimation[];
  15679. /**
  15680. * Adds more animations to the current animatable
  15681. * @param target defines the target of the animations
  15682. * @param animations defines the new animations to add
  15683. */
  15684. appendAnimations(target: any, animations: Animation[]): void;
  15685. /**
  15686. * Gets the source animation for a specific property
  15687. * @param property defines the propertyu to look for
  15688. * @returns null or the source animation for the given property
  15689. */
  15690. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15691. /**
  15692. * Gets the runtime animation for a specific property
  15693. * @param property defines the propertyu to look for
  15694. * @returns null or the runtime animation for the given property
  15695. */
  15696. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15697. /**
  15698. * Resets the animatable to its original state
  15699. */
  15700. reset(): void;
  15701. /**
  15702. * Allows the animatable to blend with current running animations
  15703. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15704. * @param blendingSpeed defines the blending speed to use
  15705. */
  15706. enableBlending(blendingSpeed: number): void;
  15707. /**
  15708. * Disable animation blending
  15709. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15710. */
  15711. disableBlending(): void;
  15712. /**
  15713. * Jump directly to a given frame
  15714. * @param frame defines the frame to jump to
  15715. */
  15716. goToFrame(frame: number): void;
  15717. /**
  15718. * Pause the animation
  15719. */
  15720. pause(): void;
  15721. /**
  15722. * Restart the animation
  15723. */
  15724. restart(): void;
  15725. private _raiseOnAnimationEnd;
  15726. /**
  15727. * Stop and delete the current animation
  15728. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15729. * @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)
  15730. */
  15731. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15732. /**
  15733. * Wait asynchronously for the animation to end
  15734. * @returns a promise which will be fullfilled when the animation ends
  15735. */
  15736. waitAsync(): Promise<Animatable>;
  15737. /** @hidden */
  15738. _animate(delay: number): boolean;
  15739. }
  15740. interface Scene {
  15741. /** @hidden */
  15742. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15743. /** @hidden */
  15744. _processLateAnimationBindingsForMatrices(holder: {
  15745. totalWeight: number;
  15746. totalAdditiveWeight: number;
  15747. animations: RuntimeAnimation[];
  15748. additiveAnimations: RuntimeAnimation[];
  15749. originalValue: Matrix;
  15750. }): any;
  15751. /** @hidden */
  15752. _processLateAnimationBindingsForQuaternions(holder: {
  15753. totalWeight: number;
  15754. totalAdditiveWeight: number;
  15755. animations: RuntimeAnimation[];
  15756. additiveAnimations: RuntimeAnimation[];
  15757. originalValue: Quaternion;
  15758. }, refQuaternion: Quaternion): Quaternion;
  15759. /** @hidden */
  15760. _processLateAnimationBindings(): void;
  15761. /**
  15762. * Will start the animation sequence of a given target
  15763. * @param target defines the target
  15764. * @param from defines from which frame should animation start
  15765. * @param to defines until which frame should animation run.
  15766. * @param weight defines the weight to apply to the animation (1.0 by default)
  15767. * @param loop defines if the animation loops
  15768. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15769. * @param onAnimationEnd defines the function to be executed when the animation ends
  15770. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15771. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15772. * @param onAnimationLoop defines the callback to call when an animation loops
  15773. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15774. * @returns the animatable object created for this animation
  15775. */
  15776. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15777. /**
  15778. * Will start the animation sequence of a given target
  15779. * @param target defines the target
  15780. * @param from defines from which frame should animation start
  15781. * @param to defines until which frame should animation run.
  15782. * @param loop defines if the animation loops
  15783. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15784. * @param onAnimationEnd defines the function to be executed when the animation ends
  15785. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15786. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15787. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15788. * @param onAnimationLoop defines the callback to call when an animation loops
  15789. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15790. * @returns the animatable object created for this animation
  15791. */
  15792. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15793. /**
  15794. * Will start the animation sequence of a given target and its hierarchy
  15795. * @param target defines the target
  15796. * @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.
  15797. * @param from defines from which frame should animation start
  15798. * @param to defines until which frame should animation run.
  15799. * @param loop defines if the animation loops
  15800. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15801. * @param onAnimationEnd defines the function to be executed when the animation ends
  15802. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15803. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15804. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15805. * @param onAnimationLoop defines the callback to call when an animation loops
  15806. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15807. * @returns the list of created animatables
  15808. */
  15809. 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, isAdditive?: boolean): Animatable[];
  15810. /**
  15811. * Begin a new animation on a given node
  15812. * @param target defines the target where the animation will take place
  15813. * @param animations defines the list of animations to start
  15814. * @param from defines the initial value
  15815. * @param to defines the final value
  15816. * @param loop defines if you want animation to loop (off by default)
  15817. * @param speedRatio defines the speed ratio to apply to all animations
  15818. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15819. * @param onAnimationLoop defines the callback to call when an animation loops
  15820. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15821. * @returns the list of created animatables
  15822. */
  15823. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15824. /**
  15825. * Begin a new animation on a given node and its hierarchy
  15826. * @param target defines the root node where the animation will take place
  15827. * @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.
  15828. * @param animations defines the list of animations to start
  15829. * @param from defines the initial value
  15830. * @param to defines the final value
  15831. * @param loop defines if you want animation to loop (off by default)
  15832. * @param speedRatio defines the speed ratio to apply to all animations
  15833. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15834. * @param onAnimationLoop defines the callback to call when an animation loops
  15835. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15836. * @returns the list of animatables created for all nodes
  15837. */
  15838. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15839. /**
  15840. * Gets the animatable associated with a specific target
  15841. * @param target defines the target of the animatable
  15842. * @returns the required animatable if found
  15843. */
  15844. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15845. /**
  15846. * Gets all animatables associated with a given target
  15847. * @param target defines the target to look animatables for
  15848. * @returns an array of Animatables
  15849. */
  15850. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15851. /**
  15852. * Stops and removes all animations that have been applied to the scene
  15853. */
  15854. stopAllAnimations(): void;
  15855. /**
  15856. * Gets the current delta time used by animation engine
  15857. */
  15858. deltaTime: number;
  15859. }
  15860. interface Bone {
  15861. /**
  15862. * Copy an animation range from another bone
  15863. * @param source defines the source bone
  15864. * @param rangeName defines the range name to copy
  15865. * @param frameOffset defines the frame offset
  15866. * @param rescaleAsRequired defines if rescaling must be applied if required
  15867. * @param skelDimensionsRatio defines the scaling ratio
  15868. * @returns true if operation was successful
  15869. */
  15870. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15871. }
  15872. }
  15873. declare module BABYLON {
  15874. /**
  15875. * Class used to handle skinning animations
  15876. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15877. */
  15878. export class Skeleton implements IAnimatable {
  15879. /** defines the skeleton name */
  15880. name: string;
  15881. /** defines the skeleton Id */
  15882. id: string;
  15883. /**
  15884. * Defines the list of child bones
  15885. */
  15886. bones: Bone[];
  15887. /**
  15888. * Defines an estimate of the dimension of the skeleton at rest
  15889. */
  15890. dimensionsAtRest: Vector3;
  15891. /**
  15892. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15893. */
  15894. needInitialSkinMatrix: boolean;
  15895. /**
  15896. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15897. */
  15898. overrideMesh: Nullable<AbstractMesh>;
  15899. /**
  15900. * Gets the list of animations attached to this skeleton
  15901. */
  15902. animations: Array<Animation>;
  15903. private _scene;
  15904. private _isDirty;
  15905. private _transformMatrices;
  15906. private _transformMatrixTexture;
  15907. private _meshesWithPoseMatrix;
  15908. private _animatables;
  15909. private _identity;
  15910. private _synchronizedWithMesh;
  15911. private _ranges;
  15912. private _lastAbsoluteTransformsUpdateId;
  15913. private _canUseTextureForBones;
  15914. private _uniqueId;
  15915. /** @hidden */
  15916. _numBonesWithLinkedTransformNode: number;
  15917. /** @hidden */
  15918. _hasWaitingData: Nullable<boolean>;
  15919. /**
  15920. * Specifies if the skeleton should be serialized
  15921. */
  15922. doNotSerialize: boolean;
  15923. private _useTextureToStoreBoneMatrices;
  15924. /**
  15925. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15926. * Please note that this option is not available if the hardware does not support it
  15927. */
  15928. get useTextureToStoreBoneMatrices(): boolean;
  15929. set useTextureToStoreBoneMatrices(value: boolean);
  15930. private _animationPropertiesOverride;
  15931. /**
  15932. * Gets or sets the animation properties override
  15933. */
  15934. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15935. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15936. /**
  15937. * List of inspectable custom properties (used by the Inspector)
  15938. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15939. */
  15940. inspectableCustomProperties: IInspectable[];
  15941. /**
  15942. * An observable triggered before computing the skeleton's matrices
  15943. */
  15944. onBeforeComputeObservable: Observable<Skeleton>;
  15945. /**
  15946. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15947. */
  15948. get isUsingTextureForMatrices(): boolean;
  15949. /**
  15950. * Gets the unique ID of this skeleton
  15951. */
  15952. get uniqueId(): number;
  15953. /**
  15954. * Creates a new skeleton
  15955. * @param name defines the skeleton name
  15956. * @param id defines the skeleton Id
  15957. * @param scene defines the hosting scene
  15958. */
  15959. constructor(
  15960. /** defines the skeleton name */
  15961. name: string,
  15962. /** defines the skeleton Id */
  15963. id: string, scene: Scene);
  15964. /**
  15965. * Gets the current object class name.
  15966. * @return the class name
  15967. */
  15968. getClassName(): string;
  15969. /**
  15970. * Returns an array containing the root bones
  15971. * @returns an array containing the root bones
  15972. */
  15973. getChildren(): Array<Bone>;
  15974. /**
  15975. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15976. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15977. * @returns a Float32Array containing matrices data
  15978. */
  15979. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15980. /**
  15981. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15982. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15983. * @returns a raw texture containing the data
  15984. */
  15985. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15986. /**
  15987. * Gets the current hosting scene
  15988. * @returns a scene object
  15989. */
  15990. getScene(): Scene;
  15991. /**
  15992. * Gets a string representing the current skeleton data
  15993. * @param fullDetails defines a boolean indicating if we want a verbose version
  15994. * @returns a string representing the current skeleton data
  15995. */
  15996. toString(fullDetails?: boolean): string;
  15997. /**
  15998. * Get bone's index searching by name
  15999. * @param name defines bone's name to search for
  16000. * @return the indice of the bone. Returns -1 if not found
  16001. */
  16002. getBoneIndexByName(name: string): number;
  16003. /**
  16004. * Creater a new animation range
  16005. * @param name defines the name of the range
  16006. * @param from defines the start key
  16007. * @param to defines the end key
  16008. */
  16009. createAnimationRange(name: string, from: number, to: number): void;
  16010. /**
  16011. * Delete a specific animation range
  16012. * @param name defines the name of the range
  16013. * @param deleteFrames defines if frames must be removed as well
  16014. */
  16015. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16016. /**
  16017. * Gets a specific animation range
  16018. * @param name defines the name of the range to look for
  16019. * @returns the requested animation range or null if not found
  16020. */
  16021. getAnimationRange(name: string): Nullable<AnimationRange>;
  16022. /**
  16023. * Gets the list of all animation ranges defined on this skeleton
  16024. * @returns an array
  16025. */
  16026. getAnimationRanges(): Nullable<AnimationRange>[];
  16027. /**
  16028. * Copy animation range from a source skeleton.
  16029. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16030. * @param source defines the source skeleton
  16031. * @param name defines the name of the range to copy
  16032. * @param rescaleAsRequired defines if rescaling must be applied if required
  16033. * @returns true if operation was successful
  16034. */
  16035. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16036. /**
  16037. * Forces the skeleton to go to rest pose
  16038. */
  16039. returnToRest(): void;
  16040. private _getHighestAnimationFrame;
  16041. /**
  16042. * Begin a specific animation range
  16043. * @param name defines the name of the range to start
  16044. * @param loop defines if looping must be turned on (false by default)
  16045. * @param speedRatio defines the speed ratio to apply (1 by default)
  16046. * @param onAnimationEnd defines a callback which will be called when animation will end
  16047. * @returns a new animatable
  16048. */
  16049. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16050. /**
  16051. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16052. * @param skeleton defines the Skeleton containing the animation range to convert
  16053. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16054. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16055. * @returns the original skeleton
  16056. */
  16057. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16058. /** @hidden */
  16059. _markAsDirty(): void;
  16060. /** @hidden */
  16061. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16062. /** @hidden */
  16063. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16064. private _computeTransformMatrices;
  16065. /**
  16066. * Build all resources required to render a skeleton
  16067. */
  16068. prepare(): void;
  16069. /**
  16070. * Gets the list of animatables currently running for this skeleton
  16071. * @returns an array of animatables
  16072. */
  16073. getAnimatables(): IAnimatable[];
  16074. /**
  16075. * Clone the current skeleton
  16076. * @param name defines the name of the new skeleton
  16077. * @param id defines the id of the new skeleton
  16078. * @returns the new skeleton
  16079. */
  16080. clone(name: string, id?: string): Skeleton;
  16081. /**
  16082. * Enable animation blending for this skeleton
  16083. * @param blendingSpeed defines the blending speed to apply
  16084. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16085. */
  16086. enableBlending(blendingSpeed?: number): void;
  16087. /**
  16088. * Releases all resources associated with the current skeleton
  16089. */
  16090. dispose(): void;
  16091. /**
  16092. * Serialize the skeleton in a JSON object
  16093. * @returns a JSON object
  16094. */
  16095. serialize(): any;
  16096. /**
  16097. * Creates a new skeleton from serialized data
  16098. * @param parsedSkeleton defines the serialized data
  16099. * @param scene defines the hosting scene
  16100. * @returns a new skeleton
  16101. */
  16102. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16103. /**
  16104. * Compute all node absolute transforms
  16105. * @param forceUpdate defines if computation must be done even if cache is up to date
  16106. */
  16107. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16108. /**
  16109. * Gets the root pose matrix
  16110. * @returns a matrix
  16111. */
  16112. getPoseMatrix(): Nullable<Matrix>;
  16113. /**
  16114. * Sorts bones per internal index
  16115. */
  16116. sortBones(): void;
  16117. private _sortBones;
  16118. }
  16119. }
  16120. declare module BABYLON {
  16121. /**
  16122. * Creates an instance based on a source mesh.
  16123. */
  16124. export class InstancedMesh extends AbstractMesh {
  16125. private _sourceMesh;
  16126. private _currentLOD;
  16127. /** @hidden */
  16128. _indexInSourceMeshInstanceArray: number;
  16129. constructor(name: string, source: Mesh);
  16130. /**
  16131. * Returns the string "InstancedMesh".
  16132. */
  16133. getClassName(): string;
  16134. /** Gets the list of lights affecting that mesh */
  16135. get lightSources(): Light[];
  16136. _resyncLightSources(): void;
  16137. _resyncLightSource(light: Light): void;
  16138. _removeLightSource(light: Light, dispose: boolean): void;
  16139. /**
  16140. * If the source mesh receives shadows
  16141. */
  16142. get receiveShadows(): boolean;
  16143. /**
  16144. * The material of the source mesh
  16145. */
  16146. get material(): Nullable<Material>;
  16147. /**
  16148. * Visibility of the source mesh
  16149. */
  16150. get visibility(): number;
  16151. /**
  16152. * Skeleton of the source mesh
  16153. */
  16154. get skeleton(): Nullable<Skeleton>;
  16155. /**
  16156. * Rendering ground id of the source mesh
  16157. */
  16158. get renderingGroupId(): number;
  16159. set renderingGroupId(value: number);
  16160. /**
  16161. * Returns the total number of vertices (integer).
  16162. */
  16163. getTotalVertices(): number;
  16164. /**
  16165. * Returns a positive integer : the total number of indices in this mesh geometry.
  16166. * @returns the numner of indices or zero if the mesh has no geometry.
  16167. */
  16168. getTotalIndices(): number;
  16169. /**
  16170. * The source mesh of the instance
  16171. */
  16172. get sourceMesh(): Mesh;
  16173. /**
  16174. * Creates a new InstancedMesh object from the mesh model.
  16175. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16176. * @param name defines the name of the new instance
  16177. * @returns a new InstancedMesh
  16178. */
  16179. createInstance(name: string): InstancedMesh;
  16180. /**
  16181. * Is this node ready to be used/rendered
  16182. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16183. * @return {boolean} is it ready
  16184. */
  16185. isReady(completeCheck?: boolean): boolean;
  16186. /**
  16187. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16188. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16189. * @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.
  16190. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16191. */
  16192. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16193. /**
  16194. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16195. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16196. * The `data` are either a numeric array either a Float32Array.
  16197. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16198. * 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).
  16199. * Note that a new underlying VertexBuffer object is created each call.
  16200. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16201. *
  16202. * Possible `kind` values :
  16203. * - VertexBuffer.PositionKind
  16204. * - VertexBuffer.UVKind
  16205. * - VertexBuffer.UV2Kind
  16206. * - VertexBuffer.UV3Kind
  16207. * - VertexBuffer.UV4Kind
  16208. * - VertexBuffer.UV5Kind
  16209. * - VertexBuffer.UV6Kind
  16210. * - VertexBuffer.ColorKind
  16211. * - VertexBuffer.MatricesIndicesKind
  16212. * - VertexBuffer.MatricesIndicesExtraKind
  16213. * - VertexBuffer.MatricesWeightsKind
  16214. * - VertexBuffer.MatricesWeightsExtraKind
  16215. *
  16216. * Returns the Mesh.
  16217. */
  16218. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16219. /**
  16220. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16221. * If the mesh has no geometry, it is simply returned as it is.
  16222. * The `data` are either a numeric array either a Float32Array.
  16223. * No new underlying VertexBuffer object is created.
  16224. * 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.
  16225. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16226. *
  16227. * Possible `kind` values :
  16228. * - VertexBuffer.PositionKind
  16229. * - VertexBuffer.UVKind
  16230. * - VertexBuffer.UV2Kind
  16231. * - VertexBuffer.UV3Kind
  16232. * - VertexBuffer.UV4Kind
  16233. * - VertexBuffer.UV5Kind
  16234. * - VertexBuffer.UV6Kind
  16235. * - VertexBuffer.ColorKind
  16236. * - VertexBuffer.MatricesIndicesKind
  16237. * - VertexBuffer.MatricesIndicesExtraKind
  16238. * - VertexBuffer.MatricesWeightsKind
  16239. * - VertexBuffer.MatricesWeightsExtraKind
  16240. *
  16241. * Returns the Mesh.
  16242. */
  16243. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16244. /**
  16245. * Sets the mesh indices.
  16246. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16247. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16248. * This method creates a new index buffer each call.
  16249. * Returns the Mesh.
  16250. */
  16251. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16252. /**
  16253. * Boolean : True if the mesh owns the requested kind of data.
  16254. */
  16255. isVerticesDataPresent(kind: string): boolean;
  16256. /**
  16257. * Returns an array of indices (IndicesArray).
  16258. */
  16259. getIndices(): Nullable<IndicesArray>;
  16260. get _positions(): Nullable<Vector3[]>;
  16261. /**
  16262. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16263. * This means the mesh underlying bounding box and sphere are recomputed.
  16264. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16265. * @returns the current mesh
  16266. */
  16267. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16268. /** @hidden */
  16269. _preActivate(): InstancedMesh;
  16270. /** @hidden */
  16271. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16272. /** @hidden */
  16273. _postActivate(): void;
  16274. getWorldMatrix(): Matrix;
  16275. get isAnInstance(): boolean;
  16276. /**
  16277. * Returns the current associated LOD AbstractMesh.
  16278. */
  16279. getLOD(camera: Camera): AbstractMesh;
  16280. /** @hidden */
  16281. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16282. /** @hidden */
  16283. _syncSubMeshes(): InstancedMesh;
  16284. /** @hidden */
  16285. _generatePointsArray(): boolean;
  16286. /**
  16287. * Creates a new InstancedMesh from the current mesh.
  16288. * - name (string) : the cloned mesh name
  16289. * - newParent (optional Node) : the optional Node to parent the clone to.
  16290. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16291. *
  16292. * Returns the clone.
  16293. */
  16294. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16295. /**
  16296. * Disposes the InstancedMesh.
  16297. * Returns nothing.
  16298. */
  16299. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16300. }
  16301. interface Mesh {
  16302. /**
  16303. * Register a custom buffer that will be instanced
  16304. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16305. * @param kind defines the buffer kind
  16306. * @param stride defines the stride in floats
  16307. */
  16308. registerInstancedBuffer(kind: string, stride: number): void;
  16309. /**
  16310. * true to use the edge renderer for all instances of this mesh
  16311. */
  16312. edgesShareWithInstances: boolean;
  16313. /** @hidden */
  16314. _userInstancedBuffersStorage: {
  16315. data: {
  16316. [key: string]: Float32Array;
  16317. };
  16318. sizes: {
  16319. [key: string]: number;
  16320. };
  16321. vertexBuffers: {
  16322. [key: string]: Nullable<VertexBuffer>;
  16323. };
  16324. strides: {
  16325. [key: string]: number;
  16326. };
  16327. };
  16328. }
  16329. interface AbstractMesh {
  16330. /**
  16331. * Object used to store instanced buffers defined by user
  16332. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16333. */
  16334. instancedBuffers: {
  16335. [key: string]: any;
  16336. };
  16337. }
  16338. }
  16339. declare module BABYLON {
  16340. /**
  16341. * Defines the options associated with the creation of a shader material.
  16342. */
  16343. export interface IShaderMaterialOptions {
  16344. /**
  16345. * Does the material work in alpha blend mode
  16346. */
  16347. needAlphaBlending: boolean;
  16348. /**
  16349. * Does the material work in alpha test mode
  16350. */
  16351. needAlphaTesting: boolean;
  16352. /**
  16353. * The list of attribute names used in the shader
  16354. */
  16355. attributes: string[];
  16356. /**
  16357. * The list of unifrom names used in the shader
  16358. */
  16359. uniforms: string[];
  16360. /**
  16361. * The list of UBO names used in the shader
  16362. */
  16363. uniformBuffers: string[];
  16364. /**
  16365. * The list of sampler names used in the shader
  16366. */
  16367. samplers: string[];
  16368. /**
  16369. * The list of defines used in the shader
  16370. */
  16371. defines: string[];
  16372. }
  16373. /**
  16374. * 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.
  16375. *
  16376. * This returned material effects how the mesh will look based on the code in the shaders.
  16377. *
  16378. * @see http://doc.babylonjs.com/how_to/shader_material
  16379. */
  16380. export class ShaderMaterial extends Material {
  16381. private _shaderPath;
  16382. private _options;
  16383. private _textures;
  16384. private _textureArrays;
  16385. private _floats;
  16386. private _ints;
  16387. private _floatsArrays;
  16388. private _colors3;
  16389. private _colors3Arrays;
  16390. private _colors4;
  16391. private _colors4Arrays;
  16392. private _vectors2;
  16393. private _vectors3;
  16394. private _vectors4;
  16395. private _matrices;
  16396. private _matrixArrays;
  16397. private _matrices3x3;
  16398. private _matrices2x2;
  16399. private _vectors2Arrays;
  16400. private _vectors3Arrays;
  16401. private _vectors4Arrays;
  16402. private _cachedWorldViewMatrix;
  16403. private _cachedWorldViewProjectionMatrix;
  16404. private _renderId;
  16405. private _multiview;
  16406. private _cachedDefines;
  16407. /** Define the Url to load snippets */
  16408. static SnippetUrl: string;
  16409. /** Snippet ID if the material was created from the snippet server */
  16410. snippetId: string;
  16411. /**
  16412. * Instantiate a new shader material.
  16413. * 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.
  16414. * This returned material effects how the mesh will look based on the code in the shaders.
  16415. * @see http://doc.babylonjs.com/how_to/shader_material
  16416. * @param name Define the name of the material in the scene
  16417. * @param scene Define the scene the material belongs to
  16418. * @param shaderPath Defines the route to the shader code in one of three ways:
  16419. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16420. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16421. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16422. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16423. * @param options Define the options used to create the shader
  16424. */
  16425. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16426. /**
  16427. * Gets the shader path used to define the shader code
  16428. * It can be modified to trigger a new compilation
  16429. */
  16430. get shaderPath(): any;
  16431. /**
  16432. * Sets the shader path used to define the shader code
  16433. * It can be modified to trigger a new compilation
  16434. */
  16435. set shaderPath(shaderPath: any);
  16436. /**
  16437. * Gets the options used to compile the shader.
  16438. * They can be modified to trigger a new compilation
  16439. */
  16440. get options(): IShaderMaterialOptions;
  16441. /**
  16442. * Gets the current class name of the material e.g. "ShaderMaterial"
  16443. * Mainly use in serialization.
  16444. * @returns the class name
  16445. */
  16446. getClassName(): string;
  16447. /**
  16448. * Specifies if the material will require alpha blending
  16449. * @returns a boolean specifying if alpha blending is needed
  16450. */
  16451. needAlphaBlending(): boolean;
  16452. /**
  16453. * Specifies if this material should be rendered in alpha test mode
  16454. * @returns a boolean specifying if an alpha test is needed.
  16455. */
  16456. needAlphaTesting(): boolean;
  16457. private _checkUniform;
  16458. /**
  16459. * Set a texture in the shader.
  16460. * @param name Define the name of the uniform samplers as defined in the shader
  16461. * @param texture Define the texture to bind to this sampler
  16462. * @return the material itself allowing "fluent" like uniform updates
  16463. */
  16464. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16465. /**
  16466. * Set a texture array in the shader.
  16467. * @param name Define the name of the uniform sampler array as defined in the shader
  16468. * @param textures Define the list of textures to bind to this sampler
  16469. * @return the material itself allowing "fluent" like uniform updates
  16470. */
  16471. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16472. /**
  16473. * Set a float in the shader.
  16474. * @param name Define the name of the uniform as defined in the shader
  16475. * @param value Define the value to give to the uniform
  16476. * @return the material itself allowing "fluent" like uniform updates
  16477. */
  16478. setFloat(name: string, value: number): ShaderMaterial;
  16479. /**
  16480. * Set a int in the shader.
  16481. * @param name Define the name of the uniform as defined in the shader
  16482. * @param value Define the value to give to the uniform
  16483. * @return the material itself allowing "fluent" like uniform updates
  16484. */
  16485. setInt(name: string, value: number): ShaderMaterial;
  16486. /**
  16487. * Set an array of floats in the shader.
  16488. * @param name Define the name of the uniform as defined in the shader
  16489. * @param value Define the value to give to the uniform
  16490. * @return the material itself allowing "fluent" like uniform updates
  16491. */
  16492. setFloats(name: string, value: number[]): ShaderMaterial;
  16493. /**
  16494. * Set a vec3 in the shader from a Color3.
  16495. * @param name Define the name of the uniform as defined in the shader
  16496. * @param value Define the value to give to the uniform
  16497. * @return the material itself allowing "fluent" like uniform updates
  16498. */
  16499. setColor3(name: string, value: Color3): ShaderMaterial;
  16500. /**
  16501. * Set a vec3 array in the shader from a Color3 array.
  16502. * @param name Define the name of the uniform as defined in the shader
  16503. * @param value Define the value to give to the uniform
  16504. * @return the material itself allowing "fluent" like uniform updates
  16505. */
  16506. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16507. /**
  16508. * Set a vec4 in the shader from a Color4.
  16509. * @param name Define the name of the uniform as defined in the shader
  16510. * @param value Define the value to give to the uniform
  16511. * @return the material itself allowing "fluent" like uniform updates
  16512. */
  16513. setColor4(name: string, value: Color4): ShaderMaterial;
  16514. /**
  16515. * Set a vec4 array in the shader from a Color4 array.
  16516. * @param name Define the name of the uniform as defined in the shader
  16517. * @param value Define the value to give to the uniform
  16518. * @return the material itself allowing "fluent" like uniform updates
  16519. */
  16520. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16521. /**
  16522. * Set a vec2 in the shader from a Vector2.
  16523. * @param name Define the name of the uniform as defined in the shader
  16524. * @param value Define the value to give to the uniform
  16525. * @return the material itself allowing "fluent" like uniform updates
  16526. */
  16527. setVector2(name: string, value: Vector2): ShaderMaterial;
  16528. /**
  16529. * Set a vec3 in the shader from a Vector3.
  16530. * @param name Define the name of the uniform as defined in the shader
  16531. * @param value Define the value to give to the uniform
  16532. * @return the material itself allowing "fluent" like uniform updates
  16533. */
  16534. setVector3(name: string, value: Vector3): ShaderMaterial;
  16535. /**
  16536. * Set a vec4 in the shader from a Vector4.
  16537. * @param name Define the name of the uniform as defined in the shader
  16538. * @param value Define the value to give to the uniform
  16539. * @return the material itself allowing "fluent" like uniform updates
  16540. */
  16541. setVector4(name: string, value: Vector4): ShaderMaterial;
  16542. /**
  16543. * Set a mat4 in the shader from a Matrix.
  16544. * @param name Define the name of the uniform as defined in the shader
  16545. * @param value Define the value to give to the uniform
  16546. * @return the material itself allowing "fluent" like uniform updates
  16547. */
  16548. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16549. /**
  16550. * Set a float32Array in the shader from a matrix array.
  16551. * @param name Define the name of the uniform as defined in the shader
  16552. * @param value Define the value to give to the uniform
  16553. * @return the material itself allowing "fluent" like uniform updates
  16554. */
  16555. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16556. /**
  16557. * Set a mat3 in the shader from a Float32Array.
  16558. * @param name Define the name of the uniform as defined in the shader
  16559. * @param value Define the value to give to the uniform
  16560. * @return the material itself allowing "fluent" like uniform updates
  16561. */
  16562. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16563. /**
  16564. * Set a mat2 in the shader from a Float32Array.
  16565. * @param name Define the name of the uniform as defined in the shader
  16566. * @param value Define the value to give to the uniform
  16567. * @return the material itself allowing "fluent" like uniform updates
  16568. */
  16569. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16570. /**
  16571. * Set a vec2 array in the shader from a number array.
  16572. * @param name Define the name of the uniform as defined in the shader
  16573. * @param value Define the value to give to the uniform
  16574. * @return the material itself allowing "fluent" like uniform updates
  16575. */
  16576. setArray2(name: string, value: number[]): ShaderMaterial;
  16577. /**
  16578. * Set a vec3 array in the shader from a number array.
  16579. * @param name Define the name of the uniform as defined in the shader
  16580. * @param value Define the value to give to the uniform
  16581. * @return the material itself allowing "fluent" like uniform updates
  16582. */
  16583. setArray3(name: string, value: number[]): ShaderMaterial;
  16584. /**
  16585. * Set a vec4 array in the shader from a number array.
  16586. * @param name Define the name of the uniform as defined in the shader
  16587. * @param value Define the value to give to the uniform
  16588. * @return the material itself allowing "fluent" like uniform updates
  16589. */
  16590. setArray4(name: string, value: number[]): ShaderMaterial;
  16591. private _checkCache;
  16592. /**
  16593. * Specifies that the submesh is ready to be used
  16594. * @param mesh defines the mesh to check
  16595. * @param subMesh defines which submesh to check
  16596. * @param useInstances specifies that instances should be used
  16597. * @returns a boolean indicating that the submesh is ready or not
  16598. */
  16599. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16600. /**
  16601. * Checks if the material is ready to render the requested mesh
  16602. * @param mesh Define the mesh to render
  16603. * @param useInstances Define whether or not the material is used with instances
  16604. * @returns true if ready, otherwise false
  16605. */
  16606. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16607. /**
  16608. * Binds the world matrix to the material
  16609. * @param world defines the world transformation matrix
  16610. * @param effectOverride - If provided, use this effect instead of internal effect
  16611. */
  16612. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16613. /**
  16614. * Binds the submesh to this material by preparing the effect and shader to draw
  16615. * @param world defines the world transformation matrix
  16616. * @param mesh defines the mesh containing the submesh
  16617. * @param subMesh defines the submesh to bind the material to
  16618. */
  16619. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16620. /**
  16621. * Binds the material to the mesh
  16622. * @param world defines the world transformation matrix
  16623. * @param mesh defines the mesh to bind the material to
  16624. * @param effectOverride - If provided, use this effect instead of internal effect
  16625. */
  16626. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16627. protected _afterBind(mesh?: Mesh): void;
  16628. /**
  16629. * Gets the active textures from the material
  16630. * @returns an array of textures
  16631. */
  16632. getActiveTextures(): BaseTexture[];
  16633. /**
  16634. * Specifies if the material uses a texture
  16635. * @param texture defines the texture to check against the material
  16636. * @returns a boolean specifying if the material uses the texture
  16637. */
  16638. hasTexture(texture: BaseTexture): boolean;
  16639. /**
  16640. * Makes a duplicate of the material, and gives it a new name
  16641. * @param name defines the new name for the duplicated material
  16642. * @returns the cloned material
  16643. */
  16644. clone(name: string): ShaderMaterial;
  16645. /**
  16646. * Disposes the material
  16647. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16648. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16649. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16650. */
  16651. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16652. /**
  16653. * Serializes this material in a JSON representation
  16654. * @returns the serialized material object
  16655. */
  16656. serialize(): any;
  16657. /**
  16658. * Creates a shader material from parsed shader material data
  16659. * @param source defines the JSON represnetation of the material
  16660. * @param scene defines the hosting scene
  16661. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16662. * @returns a new material
  16663. */
  16664. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16665. /**
  16666. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16667. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16668. * @param url defines the url to load from
  16669. * @param scene defines the hosting scene
  16670. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16671. * @returns a promise that will resolve to the new ShaderMaterial
  16672. */
  16673. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16674. /**
  16675. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16676. * @param snippetId defines the snippet to load
  16677. * @param scene defines the hosting scene
  16678. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16679. * @returns a promise that will resolve to the new ShaderMaterial
  16680. */
  16681. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16682. }
  16683. }
  16684. declare module BABYLON {
  16685. /** @hidden */
  16686. export var colorPixelShader: {
  16687. name: string;
  16688. shader: string;
  16689. };
  16690. }
  16691. declare module BABYLON {
  16692. /** @hidden */
  16693. export var colorVertexShader: {
  16694. name: string;
  16695. shader: string;
  16696. };
  16697. }
  16698. declare module BABYLON {
  16699. /**
  16700. * Line mesh
  16701. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16702. */
  16703. export class LinesMesh extends Mesh {
  16704. /**
  16705. * If vertex color should be applied to the mesh
  16706. */
  16707. readonly useVertexColor?: boolean | undefined;
  16708. /**
  16709. * If vertex alpha should be applied to the mesh
  16710. */
  16711. readonly useVertexAlpha?: boolean | undefined;
  16712. /**
  16713. * Color of the line (Default: White)
  16714. */
  16715. color: Color3;
  16716. /**
  16717. * Alpha of the line (Default: 1)
  16718. */
  16719. alpha: number;
  16720. /**
  16721. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16722. * This margin is expressed in world space coordinates, so its value may vary.
  16723. * Default value is 0.1
  16724. */
  16725. intersectionThreshold: number;
  16726. private _colorShader;
  16727. private color4;
  16728. /**
  16729. * Creates a new LinesMesh
  16730. * @param name defines the name
  16731. * @param scene defines the hosting scene
  16732. * @param parent defines the parent mesh if any
  16733. * @param source defines the optional source LinesMesh used to clone data from
  16734. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16735. * When false, achieved by calling a clone(), also passing False.
  16736. * This will make creation of children, recursive.
  16737. * @param useVertexColor defines if this LinesMesh supports vertex color
  16738. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16739. */
  16740. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16741. /**
  16742. * If vertex color should be applied to the mesh
  16743. */
  16744. useVertexColor?: boolean | undefined,
  16745. /**
  16746. * If vertex alpha should be applied to the mesh
  16747. */
  16748. useVertexAlpha?: boolean | undefined);
  16749. private _addClipPlaneDefine;
  16750. private _removeClipPlaneDefine;
  16751. isReady(): boolean;
  16752. /**
  16753. * Returns the string "LineMesh"
  16754. */
  16755. getClassName(): string;
  16756. /**
  16757. * @hidden
  16758. */
  16759. get material(): Material;
  16760. /**
  16761. * @hidden
  16762. */
  16763. set material(value: Material);
  16764. /**
  16765. * @hidden
  16766. */
  16767. get checkCollisions(): boolean;
  16768. /** @hidden */
  16769. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16770. /** @hidden */
  16771. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16772. /**
  16773. * Disposes of the line mesh
  16774. * @param doNotRecurse If children should be disposed
  16775. */
  16776. dispose(doNotRecurse?: boolean): void;
  16777. /**
  16778. * Returns a new LineMesh object cloned from the current one.
  16779. */
  16780. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16781. /**
  16782. * Creates a new InstancedLinesMesh object from the mesh model.
  16783. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16784. * @param name defines the name of the new instance
  16785. * @returns a new InstancedLinesMesh
  16786. */
  16787. createInstance(name: string): InstancedLinesMesh;
  16788. }
  16789. /**
  16790. * Creates an instance based on a source LinesMesh
  16791. */
  16792. export class InstancedLinesMesh extends InstancedMesh {
  16793. /**
  16794. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16795. * This margin is expressed in world space coordinates, so its value may vary.
  16796. * Initilized with the intersectionThreshold value of the source LinesMesh
  16797. */
  16798. intersectionThreshold: number;
  16799. constructor(name: string, source: LinesMesh);
  16800. /**
  16801. * Returns the string "InstancedLinesMesh".
  16802. */
  16803. getClassName(): string;
  16804. }
  16805. }
  16806. declare module BABYLON {
  16807. /** @hidden */
  16808. export var linePixelShader: {
  16809. name: string;
  16810. shader: string;
  16811. };
  16812. }
  16813. declare module BABYLON {
  16814. /** @hidden */
  16815. export var lineVertexShader: {
  16816. name: string;
  16817. shader: string;
  16818. };
  16819. }
  16820. declare module BABYLON {
  16821. interface Scene {
  16822. /** @hidden */
  16823. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16824. }
  16825. interface AbstractMesh {
  16826. /**
  16827. * Gets the edgesRenderer associated with the mesh
  16828. */
  16829. edgesRenderer: Nullable<EdgesRenderer>;
  16830. }
  16831. interface LinesMesh {
  16832. /**
  16833. * Enables the edge rendering mode on the mesh.
  16834. * This mode makes the mesh edges visible
  16835. * @param epsilon defines the maximal distance between two angles to detect a face
  16836. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16837. * @returns the currentAbstractMesh
  16838. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16839. */
  16840. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16841. }
  16842. interface InstancedLinesMesh {
  16843. /**
  16844. * Enables the edge rendering mode on the mesh.
  16845. * This mode makes the mesh edges visible
  16846. * @param epsilon defines the maximal distance between two angles to detect a face
  16847. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16848. * @returns the current InstancedLinesMesh
  16849. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16850. */
  16851. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16852. }
  16853. /**
  16854. * Defines the minimum contract an Edges renderer should follow.
  16855. */
  16856. export interface IEdgesRenderer extends IDisposable {
  16857. /**
  16858. * Gets or sets a boolean indicating if the edgesRenderer is active
  16859. */
  16860. isEnabled: boolean;
  16861. /**
  16862. * Renders the edges of the attached mesh,
  16863. */
  16864. render(): void;
  16865. /**
  16866. * Checks wether or not the edges renderer is ready to render.
  16867. * @return true if ready, otherwise false.
  16868. */
  16869. isReady(): boolean;
  16870. /**
  16871. * List of instances to render in case the source mesh has instances
  16872. */
  16873. customInstances: SmartArray<Matrix>;
  16874. }
  16875. /**
  16876. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16877. */
  16878. export class EdgesRenderer implements IEdgesRenderer {
  16879. /**
  16880. * Define the size of the edges with an orthographic camera
  16881. */
  16882. edgesWidthScalerForOrthographic: number;
  16883. /**
  16884. * Define the size of the edges with a perspective camera
  16885. */
  16886. edgesWidthScalerForPerspective: number;
  16887. protected _source: AbstractMesh;
  16888. protected _linesPositions: number[];
  16889. protected _linesNormals: number[];
  16890. protected _linesIndices: number[];
  16891. protected _epsilon: number;
  16892. protected _indicesCount: number;
  16893. protected _lineShader: ShaderMaterial;
  16894. protected _ib: DataBuffer;
  16895. protected _buffers: {
  16896. [key: string]: Nullable<VertexBuffer>;
  16897. };
  16898. protected _buffersForInstances: {
  16899. [key: string]: Nullable<VertexBuffer>;
  16900. };
  16901. protected _checkVerticesInsteadOfIndices: boolean;
  16902. private _meshRebuildObserver;
  16903. private _meshDisposeObserver;
  16904. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16905. isEnabled: boolean;
  16906. /**
  16907. * List of instances to render in case the source mesh has instances
  16908. */
  16909. customInstances: SmartArray<Matrix>;
  16910. private static GetShader;
  16911. /**
  16912. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16913. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16914. * @param source Mesh used to create edges
  16915. * @param epsilon sum of angles in adjacency to check for edge
  16916. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16917. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16918. */
  16919. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16920. protected _prepareRessources(): void;
  16921. /** @hidden */
  16922. _rebuild(): void;
  16923. /**
  16924. * Releases the required resources for the edges renderer
  16925. */
  16926. dispose(): void;
  16927. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16928. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16929. /**
  16930. * Checks if the pair of p0 and p1 is en edge
  16931. * @param faceIndex
  16932. * @param edge
  16933. * @param faceNormals
  16934. * @param p0
  16935. * @param p1
  16936. * @private
  16937. */
  16938. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16939. /**
  16940. * push line into the position, normal and index buffer
  16941. * @protected
  16942. */
  16943. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16944. /**
  16945. * Generates lines edges from adjacencjes
  16946. * @private
  16947. */
  16948. _generateEdgesLines(): void;
  16949. /**
  16950. * Checks wether or not the edges renderer is ready to render.
  16951. * @return true if ready, otherwise false.
  16952. */
  16953. isReady(): boolean;
  16954. /**
  16955. * Renders the edges of the attached mesh,
  16956. */
  16957. render(): void;
  16958. }
  16959. /**
  16960. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16961. */
  16962. export class LineEdgesRenderer extends EdgesRenderer {
  16963. /**
  16964. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16965. * @param source LineMesh used to generate edges
  16966. * @param epsilon not important (specified angle for edge detection)
  16967. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16968. */
  16969. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16970. /**
  16971. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16972. */
  16973. _generateEdgesLines(): void;
  16974. }
  16975. }
  16976. declare module BABYLON {
  16977. /**
  16978. * This represents the object necessary to create a rendering group.
  16979. * This is exclusively used and created by the rendering manager.
  16980. * To modify the behavior, you use the available helpers in your scene or meshes.
  16981. * @hidden
  16982. */
  16983. export class RenderingGroup {
  16984. index: number;
  16985. private static _zeroVector;
  16986. private _scene;
  16987. private _opaqueSubMeshes;
  16988. private _transparentSubMeshes;
  16989. private _alphaTestSubMeshes;
  16990. private _depthOnlySubMeshes;
  16991. private _particleSystems;
  16992. private _spriteManagers;
  16993. private _opaqueSortCompareFn;
  16994. private _alphaTestSortCompareFn;
  16995. private _transparentSortCompareFn;
  16996. private _renderOpaque;
  16997. private _renderAlphaTest;
  16998. private _renderTransparent;
  16999. /** @hidden */
  17000. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17001. onBeforeTransparentRendering: () => void;
  17002. /**
  17003. * Set the opaque sort comparison function.
  17004. * If null the sub meshes will be render in the order they were created
  17005. */
  17006. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17007. /**
  17008. * Set the alpha test sort comparison function.
  17009. * If null the sub meshes will be render in the order they were created
  17010. */
  17011. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17012. /**
  17013. * Set the transparent sort comparison function.
  17014. * If null the sub meshes will be render in the order they were created
  17015. */
  17016. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17017. /**
  17018. * Creates a new rendering group.
  17019. * @param index The rendering group index
  17020. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17021. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17022. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17023. */
  17024. 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>);
  17025. /**
  17026. * Render all the sub meshes contained in the group.
  17027. * @param customRenderFunction Used to override the default render behaviour of the group.
  17028. * @returns true if rendered some submeshes.
  17029. */
  17030. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17031. /**
  17032. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17033. * @param subMeshes The submeshes to render
  17034. */
  17035. private renderOpaqueSorted;
  17036. /**
  17037. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17038. * @param subMeshes The submeshes to render
  17039. */
  17040. private renderAlphaTestSorted;
  17041. /**
  17042. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17043. * @param subMeshes The submeshes to render
  17044. */
  17045. private renderTransparentSorted;
  17046. /**
  17047. * Renders the submeshes in a specified order.
  17048. * @param subMeshes The submeshes to sort before render
  17049. * @param sortCompareFn The comparison function use to sort
  17050. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17051. * @param transparent Specifies to activate blending if true
  17052. */
  17053. private static renderSorted;
  17054. /**
  17055. * Renders the submeshes in the order they were dispatched (no sort applied).
  17056. * @param subMeshes The submeshes to render
  17057. */
  17058. private static renderUnsorted;
  17059. /**
  17060. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17061. * are rendered back to front if in the same alpha index.
  17062. *
  17063. * @param a The first submesh
  17064. * @param b The second submesh
  17065. * @returns The result of the comparison
  17066. */
  17067. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17068. /**
  17069. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17070. * are rendered back to front.
  17071. *
  17072. * @param a The first submesh
  17073. * @param b The second submesh
  17074. * @returns The result of the comparison
  17075. */
  17076. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17077. /**
  17078. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17079. * are rendered front to back (prevent overdraw).
  17080. *
  17081. * @param a The first submesh
  17082. * @param b The second submesh
  17083. * @returns The result of the comparison
  17084. */
  17085. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17086. /**
  17087. * Resets the different lists of submeshes to prepare a new frame.
  17088. */
  17089. prepare(): void;
  17090. dispose(): void;
  17091. /**
  17092. * Inserts the submesh in its correct queue depending on its material.
  17093. * @param subMesh The submesh to dispatch
  17094. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17095. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17096. */
  17097. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17098. dispatchSprites(spriteManager: ISpriteManager): void;
  17099. dispatchParticles(particleSystem: IParticleSystem): void;
  17100. private _renderParticles;
  17101. private _renderSprites;
  17102. }
  17103. }
  17104. declare module BABYLON {
  17105. /**
  17106. * Interface describing the different options available in the rendering manager
  17107. * regarding Auto Clear between groups.
  17108. */
  17109. export interface IRenderingManagerAutoClearSetup {
  17110. /**
  17111. * Defines whether or not autoclear is enable.
  17112. */
  17113. autoClear: boolean;
  17114. /**
  17115. * Defines whether or not to autoclear the depth buffer.
  17116. */
  17117. depth: boolean;
  17118. /**
  17119. * Defines whether or not to autoclear the stencil buffer.
  17120. */
  17121. stencil: boolean;
  17122. }
  17123. /**
  17124. * This class is used by the onRenderingGroupObservable
  17125. */
  17126. export class RenderingGroupInfo {
  17127. /**
  17128. * The Scene that being rendered
  17129. */
  17130. scene: Scene;
  17131. /**
  17132. * The camera currently used for the rendering pass
  17133. */
  17134. camera: Nullable<Camera>;
  17135. /**
  17136. * The ID of the renderingGroup being processed
  17137. */
  17138. renderingGroupId: number;
  17139. }
  17140. /**
  17141. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17142. * It is enable to manage the different groups as well as the different necessary sort functions.
  17143. * This should not be used directly aside of the few static configurations
  17144. */
  17145. export class RenderingManager {
  17146. /**
  17147. * The max id used for rendering groups (not included)
  17148. */
  17149. static MAX_RENDERINGGROUPS: number;
  17150. /**
  17151. * The min id used for rendering groups (included)
  17152. */
  17153. static MIN_RENDERINGGROUPS: number;
  17154. /**
  17155. * Used to globally prevent autoclearing scenes.
  17156. */
  17157. static AUTOCLEAR: boolean;
  17158. /**
  17159. * @hidden
  17160. */
  17161. _useSceneAutoClearSetup: boolean;
  17162. private _scene;
  17163. private _renderingGroups;
  17164. private _depthStencilBufferAlreadyCleaned;
  17165. private _autoClearDepthStencil;
  17166. private _customOpaqueSortCompareFn;
  17167. private _customAlphaTestSortCompareFn;
  17168. private _customTransparentSortCompareFn;
  17169. private _renderingGroupInfo;
  17170. /**
  17171. * Instantiates a new rendering group for a particular scene
  17172. * @param scene Defines the scene the groups belongs to
  17173. */
  17174. constructor(scene: Scene);
  17175. private _clearDepthStencilBuffer;
  17176. /**
  17177. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17178. * @hidden
  17179. */
  17180. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17181. /**
  17182. * Resets the different information of the group to prepare a new frame
  17183. * @hidden
  17184. */
  17185. reset(): void;
  17186. /**
  17187. * Dispose and release the group and its associated resources.
  17188. * @hidden
  17189. */
  17190. dispose(): void;
  17191. /**
  17192. * Clear the info related to rendering groups preventing retention points during dispose.
  17193. */
  17194. freeRenderingGroups(): void;
  17195. private _prepareRenderingGroup;
  17196. /**
  17197. * Add a sprite manager to the rendering manager in order to render it this frame.
  17198. * @param spriteManager Define the sprite manager to render
  17199. */
  17200. dispatchSprites(spriteManager: ISpriteManager): void;
  17201. /**
  17202. * Add a particle system to the rendering manager in order to render it this frame.
  17203. * @param particleSystem Define the particle system to render
  17204. */
  17205. dispatchParticles(particleSystem: IParticleSystem): void;
  17206. /**
  17207. * Add a submesh to the manager in order to render it this frame
  17208. * @param subMesh The submesh to dispatch
  17209. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17210. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17211. */
  17212. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17213. /**
  17214. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17215. * This allowed control for front to back rendering or reversly depending of the special needs.
  17216. *
  17217. * @param renderingGroupId The rendering group id corresponding to its index
  17218. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17219. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17220. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17221. */
  17222. 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;
  17223. /**
  17224. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17225. *
  17226. * @param renderingGroupId The rendering group id corresponding to its index
  17227. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17228. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17229. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17230. */
  17231. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17232. /**
  17233. * Gets the current auto clear configuration for one rendering group of the rendering
  17234. * manager.
  17235. * @param index the rendering group index to get the information for
  17236. * @returns The auto clear setup for the requested rendering group
  17237. */
  17238. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17239. }
  17240. }
  17241. declare module BABYLON {
  17242. /**
  17243. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17244. */
  17245. export interface ICustomShaderOptions {
  17246. /**
  17247. * Gets or sets the custom shader name to use
  17248. */
  17249. shaderName: string;
  17250. /**
  17251. * The list of attribute names used in the shader
  17252. */
  17253. attributes?: string[];
  17254. /**
  17255. * The list of unifrom names used in the shader
  17256. */
  17257. uniforms?: string[];
  17258. /**
  17259. * The list of sampler names used in the shader
  17260. */
  17261. samplers?: string[];
  17262. /**
  17263. * The list of defines used in the shader
  17264. */
  17265. defines?: string[];
  17266. }
  17267. /**
  17268. * Interface to implement to create a shadow generator compatible with BJS.
  17269. */
  17270. export interface IShadowGenerator {
  17271. /**
  17272. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17273. * @returns The render target texture if present otherwise, null
  17274. */
  17275. getShadowMap(): Nullable<RenderTargetTexture>;
  17276. /**
  17277. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17278. * @param subMesh The submesh we want to render in the shadow map
  17279. * @param useInstances Defines wether will draw in the map using instances
  17280. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17281. * @returns true if ready otherwise, false
  17282. */
  17283. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17284. /**
  17285. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17286. * @param defines Defines of the material we want to update
  17287. * @param lightIndex Index of the light in the enabled light list of the material
  17288. */
  17289. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17290. /**
  17291. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17292. * defined in the generator but impacting the effect).
  17293. * It implies the unifroms available on the materials are the standard BJS ones.
  17294. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17295. * @param effect The effect we are binfing the information for
  17296. */
  17297. bindShadowLight(lightIndex: string, effect: Effect): void;
  17298. /**
  17299. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17300. * (eq to shadow prjection matrix * light transform matrix)
  17301. * @returns The transform matrix used to create the shadow map
  17302. */
  17303. getTransformMatrix(): Matrix;
  17304. /**
  17305. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17306. * Cube and 2D textures for instance.
  17307. */
  17308. recreateShadowMap(): void;
  17309. /**
  17310. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17311. * @param onCompiled Callback triggered at the and of the effects compilation
  17312. * @param options Sets of optional options forcing the compilation with different modes
  17313. */
  17314. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17315. useInstances: boolean;
  17316. }>): void;
  17317. /**
  17318. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17319. * @param options Sets of optional options forcing the compilation with different modes
  17320. * @returns A promise that resolves when the compilation completes
  17321. */
  17322. forceCompilationAsync(options?: Partial<{
  17323. useInstances: boolean;
  17324. }>): Promise<void>;
  17325. /**
  17326. * Serializes the shadow generator setup to a json object.
  17327. * @returns The serialized JSON object
  17328. */
  17329. serialize(): any;
  17330. /**
  17331. * Disposes the Shadow map and related Textures and effects.
  17332. */
  17333. dispose(): void;
  17334. }
  17335. /**
  17336. * Default implementation IShadowGenerator.
  17337. * This is the main object responsible of generating shadows in the framework.
  17338. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17339. */
  17340. export class ShadowGenerator implements IShadowGenerator {
  17341. /**
  17342. * Name of the shadow generator class
  17343. */
  17344. static CLASSNAME: string;
  17345. /**
  17346. * Shadow generator mode None: no filtering applied.
  17347. */
  17348. static readonly FILTER_NONE: number;
  17349. /**
  17350. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17351. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17352. */
  17353. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17354. /**
  17355. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17356. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17357. */
  17358. static readonly FILTER_POISSONSAMPLING: number;
  17359. /**
  17360. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17361. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17362. */
  17363. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17364. /**
  17365. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17366. * edge artifacts on steep falloff.
  17367. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17368. */
  17369. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17370. /**
  17371. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17372. * edge artifacts on steep falloff.
  17373. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17374. */
  17375. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17376. /**
  17377. * Shadow generator mode PCF: Percentage Closer Filtering
  17378. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17379. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17380. */
  17381. static readonly FILTER_PCF: number;
  17382. /**
  17383. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17384. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17385. * Contact Hardening
  17386. */
  17387. static readonly FILTER_PCSS: number;
  17388. /**
  17389. * Reserved for PCF and PCSS
  17390. * Highest Quality.
  17391. *
  17392. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17393. *
  17394. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17395. */
  17396. static readonly QUALITY_HIGH: number;
  17397. /**
  17398. * Reserved for PCF and PCSS
  17399. * Good tradeoff for quality/perf cross devices
  17400. *
  17401. * Execute PCF on a 3*3 kernel.
  17402. *
  17403. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17404. */
  17405. static readonly QUALITY_MEDIUM: number;
  17406. /**
  17407. * Reserved for PCF and PCSS
  17408. * The lowest quality but the fastest.
  17409. *
  17410. * Execute PCF on a 1*1 kernel.
  17411. *
  17412. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17413. */
  17414. static readonly QUALITY_LOW: number;
  17415. /** Gets or sets the custom shader name to use */
  17416. customShaderOptions: ICustomShaderOptions;
  17417. /**
  17418. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17419. */
  17420. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17421. /**
  17422. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17423. */
  17424. onAfterShadowMapRenderObservable: Observable<Effect>;
  17425. /**
  17426. * Observable triggered before a mesh is rendered in the shadow map.
  17427. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17428. */
  17429. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17430. /**
  17431. * Observable triggered after a mesh is rendered in the shadow map.
  17432. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17433. */
  17434. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17435. protected _bias: number;
  17436. /**
  17437. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17438. */
  17439. get bias(): number;
  17440. /**
  17441. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17442. */
  17443. set bias(bias: number);
  17444. protected _normalBias: number;
  17445. /**
  17446. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17447. */
  17448. get normalBias(): number;
  17449. /**
  17450. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17451. */
  17452. set normalBias(normalBias: number);
  17453. protected _blurBoxOffset: number;
  17454. /**
  17455. * Gets the blur box offset: offset applied during the blur pass.
  17456. * Only useful if useKernelBlur = false
  17457. */
  17458. get blurBoxOffset(): number;
  17459. /**
  17460. * Sets the blur box offset: offset applied during the blur pass.
  17461. * Only useful if useKernelBlur = false
  17462. */
  17463. set blurBoxOffset(value: number);
  17464. protected _blurScale: number;
  17465. /**
  17466. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17467. * 2 means half of the size.
  17468. */
  17469. get blurScale(): number;
  17470. /**
  17471. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17472. * 2 means half of the size.
  17473. */
  17474. set blurScale(value: number);
  17475. protected _blurKernel: number;
  17476. /**
  17477. * Gets the blur kernel: kernel size of the blur pass.
  17478. * Only useful if useKernelBlur = true
  17479. */
  17480. get blurKernel(): number;
  17481. /**
  17482. * Sets the blur kernel: kernel size of the blur pass.
  17483. * Only useful if useKernelBlur = true
  17484. */
  17485. set blurKernel(value: number);
  17486. protected _useKernelBlur: boolean;
  17487. /**
  17488. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17489. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17490. */
  17491. get useKernelBlur(): boolean;
  17492. /**
  17493. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17494. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17495. */
  17496. set useKernelBlur(value: boolean);
  17497. protected _depthScale: number;
  17498. /**
  17499. * Gets the depth scale used in ESM mode.
  17500. */
  17501. get depthScale(): number;
  17502. /**
  17503. * Sets the depth scale used in ESM mode.
  17504. * This can override the scale stored on the light.
  17505. */
  17506. set depthScale(value: number);
  17507. protected _validateFilter(filter: number): number;
  17508. protected _filter: number;
  17509. /**
  17510. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17511. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17512. */
  17513. get filter(): number;
  17514. /**
  17515. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17516. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17517. */
  17518. set filter(value: number);
  17519. /**
  17520. * Gets if the current filter is set to Poisson Sampling.
  17521. */
  17522. get usePoissonSampling(): boolean;
  17523. /**
  17524. * Sets the current filter to Poisson Sampling.
  17525. */
  17526. set usePoissonSampling(value: boolean);
  17527. /**
  17528. * Gets if the current filter is set to ESM.
  17529. */
  17530. get useExponentialShadowMap(): boolean;
  17531. /**
  17532. * Sets the current filter is to ESM.
  17533. */
  17534. set useExponentialShadowMap(value: boolean);
  17535. /**
  17536. * Gets if the current filter is set to filtered ESM.
  17537. */
  17538. get useBlurExponentialShadowMap(): boolean;
  17539. /**
  17540. * Gets if the current filter is set to filtered ESM.
  17541. */
  17542. set useBlurExponentialShadowMap(value: boolean);
  17543. /**
  17544. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17545. * exponential to prevent steep falloff artifacts).
  17546. */
  17547. get useCloseExponentialShadowMap(): boolean;
  17548. /**
  17549. * Sets the current filter to "close ESM" (using the inverse of the
  17550. * exponential to prevent steep falloff artifacts).
  17551. */
  17552. set useCloseExponentialShadowMap(value: boolean);
  17553. /**
  17554. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17555. * exponential to prevent steep falloff artifacts).
  17556. */
  17557. get useBlurCloseExponentialShadowMap(): boolean;
  17558. /**
  17559. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17560. * exponential to prevent steep falloff artifacts).
  17561. */
  17562. set useBlurCloseExponentialShadowMap(value: boolean);
  17563. /**
  17564. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17565. */
  17566. get usePercentageCloserFiltering(): boolean;
  17567. /**
  17568. * Sets the current filter to "PCF" (percentage closer filtering).
  17569. */
  17570. set usePercentageCloserFiltering(value: boolean);
  17571. protected _filteringQuality: number;
  17572. /**
  17573. * Gets the PCF or PCSS Quality.
  17574. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17575. */
  17576. get filteringQuality(): number;
  17577. /**
  17578. * Sets the PCF or PCSS Quality.
  17579. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17580. */
  17581. set filteringQuality(filteringQuality: number);
  17582. /**
  17583. * Gets if the current filter is set to "PCSS" (contact hardening).
  17584. */
  17585. get useContactHardeningShadow(): boolean;
  17586. /**
  17587. * Sets the current filter to "PCSS" (contact hardening).
  17588. */
  17589. set useContactHardeningShadow(value: boolean);
  17590. protected _contactHardeningLightSizeUVRatio: number;
  17591. /**
  17592. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17593. * Using a ratio helps keeping shape stability independently of the map size.
  17594. *
  17595. * It does not account for the light projection as it was having too much
  17596. * instability during the light setup or during light position changes.
  17597. *
  17598. * Only valid if useContactHardeningShadow is true.
  17599. */
  17600. get contactHardeningLightSizeUVRatio(): number;
  17601. /**
  17602. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17603. * Using a ratio helps keeping shape stability independently of the map size.
  17604. *
  17605. * It does not account for the light projection as it was having too much
  17606. * instability during the light setup or during light position changes.
  17607. *
  17608. * Only valid if useContactHardeningShadow is true.
  17609. */
  17610. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17611. protected _darkness: number;
  17612. /** Gets or sets the actual darkness of a shadow */
  17613. get darkness(): number;
  17614. set darkness(value: number);
  17615. /**
  17616. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17617. * 0 means strongest and 1 would means no shadow.
  17618. * @returns the darkness.
  17619. */
  17620. getDarkness(): number;
  17621. /**
  17622. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17623. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17624. * @returns the shadow generator allowing fluent coding.
  17625. */
  17626. setDarkness(darkness: number): ShadowGenerator;
  17627. protected _transparencyShadow: boolean;
  17628. /** Gets or sets the ability to have transparent shadow */
  17629. get transparencyShadow(): boolean;
  17630. set transparencyShadow(value: boolean);
  17631. /**
  17632. * Sets the ability to have transparent shadow (boolean).
  17633. * @param transparent True if transparent else False
  17634. * @returns the shadow generator allowing fluent coding
  17635. */
  17636. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17637. /**
  17638. * Enables or disables shadows with varying strength based on the transparency
  17639. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17640. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17641. * mesh.visibility * alphaTexture.a
  17642. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17643. */
  17644. enableSoftTransparentShadow: boolean;
  17645. protected _shadowMap: Nullable<RenderTargetTexture>;
  17646. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17647. /**
  17648. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17649. * @returns The render target texture if present otherwise, null
  17650. */
  17651. getShadowMap(): Nullable<RenderTargetTexture>;
  17652. /**
  17653. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17654. * @returns The render target texture if the shadow map is present otherwise, null
  17655. */
  17656. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17657. /**
  17658. * Gets the class name of that object
  17659. * @returns "ShadowGenerator"
  17660. */
  17661. getClassName(): string;
  17662. /**
  17663. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17664. * @param mesh Mesh to add
  17665. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17666. * @returns the Shadow Generator itself
  17667. */
  17668. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17669. /**
  17670. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17671. * @param mesh Mesh to remove
  17672. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17673. * @returns the Shadow Generator itself
  17674. */
  17675. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17676. /**
  17677. * Controls the extent to which the shadows fade out at the edge of the frustum
  17678. */
  17679. frustumEdgeFalloff: number;
  17680. protected _light: IShadowLight;
  17681. /**
  17682. * Returns the associated light object.
  17683. * @returns the light generating the shadow
  17684. */
  17685. getLight(): IShadowLight;
  17686. /**
  17687. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17688. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17689. * It might on the other hand introduce peter panning.
  17690. */
  17691. forceBackFacesOnly: boolean;
  17692. protected _scene: Scene;
  17693. protected _lightDirection: Vector3;
  17694. protected _effect: Effect;
  17695. protected _viewMatrix: Matrix;
  17696. protected _projectionMatrix: Matrix;
  17697. protected _transformMatrix: Matrix;
  17698. protected _cachedPosition: Vector3;
  17699. protected _cachedDirection: Vector3;
  17700. protected _cachedDefines: string;
  17701. protected _currentRenderID: number;
  17702. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17703. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17704. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17705. protected _blurPostProcesses: PostProcess[];
  17706. protected _mapSize: number;
  17707. protected _currentFaceIndex: number;
  17708. protected _currentFaceIndexCache: number;
  17709. protected _textureType: number;
  17710. protected _defaultTextureMatrix: Matrix;
  17711. protected _storedUniqueId: Nullable<number>;
  17712. /** @hidden */
  17713. static _SceneComponentInitialization: (scene: Scene) => void;
  17714. /**
  17715. * Creates a ShadowGenerator object.
  17716. * A ShadowGenerator is the required tool to use the shadows.
  17717. * Each light casting shadows needs to use its own ShadowGenerator.
  17718. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17719. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17720. * @param light The light object generating the shadows.
  17721. * @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.
  17722. */
  17723. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17724. protected _initializeGenerator(): void;
  17725. protected _createTargetRenderTexture(): void;
  17726. protected _initializeShadowMap(): void;
  17727. protected _initializeBlurRTTAndPostProcesses(): void;
  17728. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17729. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17730. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17731. protected _applyFilterValues(): void;
  17732. /**
  17733. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17734. * @param onCompiled Callback triggered at the and of the effects compilation
  17735. * @param options Sets of optional options forcing the compilation with different modes
  17736. */
  17737. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17738. useInstances: boolean;
  17739. }>): void;
  17740. /**
  17741. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17742. * @param options Sets of optional options forcing the compilation with different modes
  17743. * @returns A promise that resolves when the compilation completes
  17744. */
  17745. forceCompilationAsync(options?: Partial<{
  17746. useInstances: boolean;
  17747. }>): Promise<void>;
  17748. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17749. private _prepareShadowDefines;
  17750. /**
  17751. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17752. * @param subMesh The submesh we want to render in the shadow map
  17753. * @param useInstances Defines wether will draw in the map using instances
  17754. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17755. * @returns true if ready otherwise, false
  17756. */
  17757. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17758. /**
  17759. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17760. * @param defines Defines of the material we want to update
  17761. * @param lightIndex Index of the light in the enabled light list of the material
  17762. */
  17763. prepareDefines(defines: any, lightIndex: number): void;
  17764. /**
  17765. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17766. * defined in the generator but impacting the effect).
  17767. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17768. * @param effect The effect we are binfing the information for
  17769. */
  17770. bindShadowLight(lightIndex: string, effect: Effect): void;
  17771. /**
  17772. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17773. * (eq to shadow prjection matrix * light transform matrix)
  17774. * @returns The transform matrix used to create the shadow map
  17775. */
  17776. getTransformMatrix(): Matrix;
  17777. /**
  17778. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17779. * Cube and 2D textures for instance.
  17780. */
  17781. recreateShadowMap(): void;
  17782. protected _disposeBlurPostProcesses(): void;
  17783. protected _disposeRTTandPostProcesses(): void;
  17784. /**
  17785. * Disposes the ShadowGenerator.
  17786. * Returns nothing.
  17787. */
  17788. dispose(): void;
  17789. /**
  17790. * Serializes the shadow generator setup to a json object.
  17791. * @returns The serialized JSON object
  17792. */
  17793. serialize(): any;
  17794. /**
  17795. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17796. * @param parsedShadowGenerator The JSON object to parse
  17797. * @param scene The scene to create the shadow map for
  17798. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17799. * @returns The parsed shadow generator
  17800. */
  17801. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17802. }
  17803. }
  17804. declare module BABYLON {
  17805. /**
  17806. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17807. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17808. * 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.
  17809. */
  17810. export abstract class Light extends Node {
  17811. /**
  17812. * Falloff Default: light is falling off following the material specification:
  17813. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17814. */
  17815. static readonly FALLOFF_DEFAULT: number;
  17816. /**
  17817. * Falloff Physical: light is falling off following the inverse squared distance law.
  17818. */
  17819. static readonly FALLOFF_PHYSICAL: number;
  17820. /**
  17821. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17822. * to enhance interoperability with other engines.
  17823. */
  17824. static readonly FALLOFF_GLTF: number;
  17825. /**
  17826. * Falloff Standard: light is falling off like in the standard material
  17827. * to enhance interoperability with other materials.
  17828. */
  17829. static readonly FALLOFF_STANDARD: number;
  17830. /**
  17831. * If every light affecting the material is in this lightmapMode,
  17832. * material.lightmapTexture adds or multiplies
  17833. * (depends on material.useLightmapAsShadowmap)
  17834. * after every other light calculations.
  17835. */
  17836. static readonly LIGHTMAP_DEFAULT: number;
  17837. /**
  17838. * material.lightmapTexture as only diffuse lighting from this light
  17839. * adds only specular lighting from this light
  17840. * adds dynamic shadows
  17841. */
  17842. static readonly LIGHTMAP_SPECULAR: number;
  17843. /**
  17844. * material.lightmapTexture as only lighting
  17845. * no light calculation from this light
  17846. * only adds dynamic shadows from this light
  17847. */
  17848. static readonly LIGHTMAP_SHADOWSONLY: number;
  17849. /**
  17850. * Each light type uses the default quantity according to its type:
  17851. * point/spot lights use luminous intensity
  17852. * directional lights use illuminance
  17853. */
  17854. static readonly INTENSITYMODE_AUTOMATIC: number;
  17855. /**
  17856. * lumen (lm)
  17857. */
  17858. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17859. /**
  17860. * candela (lm/sr)
  17861. */
  17862. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17863. /**
  17864. * lux (lm/m^2)
  17865. */
  17866. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17867. /**
  17868. * nit (cd/m^2)
  17869. */
  17870. static readonly INTENSITYMODE_LUMINANCE: number;
  17871. /**
  17872. * Light type const id of the point light.
  17873. */
  17874. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17875. /**
  17876. * Light type const id of the directional light.
  17877. */
  17878. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17879. /**
  17880. * Light type const id of the spot light.
  17881. */
  17882. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17883. /**
  17884. * Light type const id of the hemispheric light.
  17885. */
  17886. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17887. /**
  17888. * Diffuse gives the basic color to an object.
  17889. */
  17890. diffuse: Color3;
  17891. /**
  17892. * Specular produces a highlight color on an object.
  17893. * Note: This is note affecting PBR materials.
  17894. */
  17895. specular: Color3;
  17896. /**
  17897. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17898. * falling off base on range or angle.
  17899. * This can be set to any values in Light.FALLOFF_x.
  17900. *
  17901. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17902. * other types of materials.
  17903. */
  17904. falloffType: number;
  17905. /**
  17906. * Strength of the light.
  17907. * Note: By default it is define in the framework own unit.
  17908. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17909. */
  17910. intensity: number;
  17911. private _range;
  17912. protected _inverseSquaredRange: number;
  17913. /**
  17914. * Defines how far from the source the light is impacting in scene units.
  17915. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17916. */
  17917. get range(): number;
  17918. /**
  17919. * Defines how far from the source the light is impacting in scene units.
  17920. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17921. */
  17922. set range(value: number);
  17923. /**
  17924. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17925. * of light.
  17926. */
  17927. private _photometricScale;
  17928. private _intensityMode;
  17929. /**
  17930. * Gets the photometric scale used to interpret the intensity.
  17931. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17932. */
  17933. get intensityMode(): number;
  17934. /**
  17935. * Sets the photometric scale used to interpret the intensity.
  17936. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17937. */
  17938. set intensityMode(value: number);
  17939. private _radius;
  17940. /**
  17941. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17942. */
  17943. get radius(): number;
  17944. /**
  17945. * sets the light radius used by PBR Materials to simulate soft area lights.
  17946. */
  17947. set radius(value: number);
  17948. private _renderPriority;
  17949. /**
  17950. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17951. * exceeding the number allowed of the materials.
  17952. */
  17953. renderPriority: number;
  17954. private _shadowEnabled;
  17955. /**
  17956. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17957. * the current shadow generator.
  17958. */
  17959. get shadowEnabled(): boolean;
  17960. /**
  17961. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17962. * the current shadow generator.
  17963. */
  17964. set shadowEnabled(value: boolean);
  17965. private _includedOnlyMeshes;
  17966. /**
  17967. * Gets the only meshes impacted by this light.
  17968. */
  17969. get includedOnlyMeshes(): AbstractMesh[];
  17970. /**
  17971. * Sets the only meshes impacted by this light.
  17972. */
  17973. set includedOnlyMeshes(value: AbstractMesh[]);
  17974. private _excludedMeshes;
  17975. /**
  17976. * Gets the meshes not impacted by this light.
  17977. */
  17978. get excludedMeshes(): AbstractMesh[];
  17979. /**
  17980. * Sets the meshes not impacted by this light.
  17981. */
  17982. set excludedMeshes(value: AbstractMesh[]);
  17983. private _excludeWithLayerMask;
  17984. /**
  17985. * Gets the layer id use to find what meshes are not impacted by the light.
  17986. * Inactive if 0
  17987. */
  17988. get excludeWithLayerMask(): number;
  17989. /**
  17990. * Sets the layer id use to find what meshes are not impacted by the light.
  17991. * Inactive if 0
  17992. */
  17993. set excludeWithLayerMask(value: number);
  17994. private _includeOnlyWithLayerMask;
  17995. /**
  17996. * Gets the layer id use to find what meshes are impacted by the light.
  17997. * Inactive if 0
  17998. */
  17999. get includeOnlyWithLayerMask(): number;
  18000. /**
  18001. * Sets the layer id use to find what meshes are impacted by the light.
  18002. * Inactive if 0
  18003. */
  18004. set includeOnlyWithLayerMask(value: number);
  18005. private _lightmapMode;
  18006. /**
  18007. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18008. */
  18009. get lightmapMode(): number;
  18010. /**
  18011. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18012. */
  18013. set lightmapMode(value: number);
  18014. /**
  18015. * Shadow generator associted to the light.
  18016. * @hidden Internal use only.
  18017. */
  18018. _shadowGenerator: Nullable<IShadowGenerator>;
  18019. /**
  18020. * @hidden Internal use only.
  18021. */
  18022. _excludedMeshesIds: string[];
  18023. /**
  18024. * @hidden Internal use only.
  18025. */
  18026. _includedOnlyMeshesIds: string[];
  18027. /**
  18028. * The current light unifom buffer.
  18029. * @hidden Internal use only.
  18030. */
  18031. _uniformBuffer: UniformBuffer;
  18032. /** @hidden */
  18033. _renderId: number;
  18034. /**
  18035. * Creates a Light object in the scene.
  18036. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18037. * @param name The firendly name of the light
  18038. * @param scene The scene the light belongs too
  18039. */
  18040. constructor(name: string, scene: Scene);
  18041. protected abstract _buildUniformLayout(): void;
  18042. /**
  18043. * Sets the passed Effect "effect" with the Light information.
  18044. * @param effect The effect to update
  18045. * @param lightIndex The index of the light in the effect to update
  18046. * @returns The light
  18047. */
  18048. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18049. /**
  18050. * Sets the passed Effect "effect" with the Light textures.
  18051. * @param effect The effect to update
  18052. * @param lightIndex The index of the light in the effect to update
  18053. * @returns The light
  18054. */
  18055. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18056. /**
  18057. * Binds the lights information from the scene to the effect for the given mesh.
  18058. * @param lightIndex Light index
  18059. * @param scene The scene where the light belongs to
  18060. * @param effect The effect we are binding the data to
  18061. * @param useSpecular Defines if specular is supported
  18062. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18063. */
  18064. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18065. /**
  18066. * Sets the passed Effect "effect" with the Light information.
  18067. * @param effect The effect to update
  18068. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18069. * @returns The light
  18070. */
  18071. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18072. /**
  18073. * Returns the string "Light".
  18074. * @returns the class name
  18075. */
  18076. getClassName(): string;
  18077. /** @hidden */
  18078. readonly _isLight: boolean;
  18079. /**
  18080. * Converts the light information to a readable string for debug purpose.
  18081. * @param fullDetails Supports for multiple levels of logging within scene loading
  18082. * @returns the human readable light info
  18083. */
  18084. toString(fullDetails?: boolean): string;
  18085. /** @hidden */
  18086. protected _syncParentEnabledState(): void;
  18087. /**
  18088. * Set the enabled state of this node.
  18089. * @param value - the new enabled state
  18090. */
  18091. setEnabled(value: boolean): void;
  18092. /**
  18093. * Returns the Light associated shadow generator if any.
  18094. * @return the associated shadow generator.
  18095. */
  18096. getShadowGenerator(): Nullable<IShadowGenerator>;
  18097. /**
  18098. * Returns a Vector3, the absolute light position in the World.
  18099. * @returns the world space position of the light
  18100. */
  18101. getAbsolutePosition(): Vector3;
  18102. /**
  18103. * Specifies if the light will affect the passed mesh.
  18104. * @param mesh The mesh to test against the light
  18105. * @return true the mesh is affected otherwise, false.
  18106. */
  18107. canAffectMesh(mesh: AbstractMesh): boolean;
  18108. /**
  18109. * Sort function to order lights for rendering.
  18110. * @param a First Light object to compare to second.
  18111. * @param b Second Light object to compare first.
  18112. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18113. */
  18114. static CompareLightsPriority(a: Light, b: Light): number;
  18115. /**
  18116. * Releases resources associated with this node.
  18117. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18118. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18119. */
  18120. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18121. /**
  18122. * Returns the light type ID (integer).
  18123. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18124. */
  18125. getTypeID(): number;
  18126. /**
  18127. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18128. * @returns the scaled intensity in intensity mode unit
  18129. */
  18130. getScaledIntensity(): number;
  18131. /**
  18132. * Returns a new Light object, named "name", from the current one.
  18133. * @param name The name of the cloned light
  18134. * @param newParent The parent of this light, if it has one
  18135. * @returns the new created light
  18136. */
  18137. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18138. /**
  18139. * Serializes the current light into a Serialization object.
  18140. * @returns the serialized object.
  18141. */
  18142. serialize(): any;
  18143. /**
  18144. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18145. * This new light is named "name" and added to the passed scene.
  18146. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18147. * @param name The friendly name of the light
  18148. * @param scene The scene the new light will belong to
  18149. * @returns the constructor function
  18150. */
  18151. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18152. /**
  18153. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18154. * @param parsedLight The JSON representation of the light
  18155. * @param scene The scene to create the parsed light in
  18156. * @returns the created light after parsing
  18157. */
  18158. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18159. private _hookArrayForExcluded;
  18160. private _hookArrayForIncludedOnly;
  18161. private _resyncMeshes;
  18162. /**
  18163. * Forces the meshes to update their light related information in their rendering used effects
  18164. * @hidden Internal Use Only
  18165. */
  18166. _markMeshesAsLightDirty(): void;
  18167. /**
  18168. * Recomputes the cached photometric scale if needed.
  18169. */
  18170. private _computePhotometricScale;
  18171. /**
  18172. * Returns the Photometric Scale according to the light type and intensity mode.
  18173. */
  18174. private _getPhotometricScale;
  18175. /**
  18176. * Reorder the light in the scene according to their defined priority.
  18177. * @hidden Internal Use Only
  18178. */
  18179. _reorderLightsInScene(): void;
  18180. /**
  18181. * Prepares the list of defines specific to the light type.
  18182. * @param defines the list of defines
  18183. * @param lightIndex defines the index of the light for the effect
  18184. */
  18185. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18186. }
  18187. }
  18188. declare module BABYLON {
  18189. /**
  18190. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18191. * This is the base of the follow, arc rotate cameras and Free camera
  18192. * @see http://doc.babylonjs.com/features/cameras
  18193. */
  18194. export class TargetCamera extends Camera {
  18195. private static _RigCamTransformMatrix;
  18196. private static _TargetTransformMatrix;
  18197. private static _TargetFocalPoint;
  18198. private _tmpUpVector;
  18199. private _tmpTargetVector;
  18200. /**
  18201. * Define the current direction the camera is moving to
  18202. */
  18203. cameraDirection: Vector3;
  18204. /**
  18205. * Define the current rotation the camera is rotating to
  18206. */
  18207. cameraRotation: Vector2;
  18208. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18209. ignoreParentScaling: boolean;
  18210. /**
  18211. * When set, the up vector of the camera will be updated by the rotation of the camera
  18212. */
  18213. updateUpVectorFromRotation: boolean;
  18214. private _tmpQuaternion;
  18215. /**
  18216. * Define the current rotation of the camera
  18217. */
  18218. rotation: Vector3;
  18219. /**
  18220. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18221. */
  18222. rotationQuaternion: Quaternion;
  18223. /**
  18224. * Define the current speed of the camera
  18225. */
  18226. speed: number;
  18227. /**
  18228. * Add constraint to the camera to prevent it to move freely in all directions and
  18229. * around all axis.
  18230. */
  18231. noRotationConstraint: boolean;
  18232. /**
  18233. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18234. * panning
  18235. */
  18236. invertRotation: boolean;
  18237. /**
  18238. * Speed multiplier for inverse camera panning
  18239. */
  18240. inverseRotationSpeed: number;
  18241. /**
  18242. * Define the current target of the camera as an object or a position.
  18243. */
  18244. lockedTarget: any;
  18245. /** @hidden */
  18246. _currentTarget: Vector3;
  18247. /** @hidden */
  18248. _initialFocalDistance: number;
  18249. /** @hidden */
  18250. _viewMatrix: Matrix;
  18251. /** @hidden */
  18252. _camMatrix: Matrix;
  18253. /** @hidden */
  18254. _cameraTransformMatrix: Matrix;
  18255. /** @hidden */
  18256. _cameraRotationMatrix: Matrix;
  18257. /** @hidden */
  18258. _referencePoint: Vector3;
  18259. /** @hidden */
  18260. _transformedReferencePoint: Vector3;
  18261. /** @hidden */
  18262. _reset: () => void;
  18263. private _defaultUp;
  18264. /**
  18265. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18266. * This is the base of the follow, arc rotate cameras and Free camera
  18267. * @see http://doc.babylonjs.com/features/cameras
  18268. * @param name Defines the name of the camera in the scene
  18269. * @param position Defines the start position of the camera in the scene
  18270. * @param scene Defines the scene the camera belongs to
  18271. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18272. */
  18273. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18274. /**
  18275. * Gets the position in front of the camera at a given distance.
  18276. * @param distance The distance from the camera we want the position to be
  18277. * @returns the position
  18278. */
  18279. getFrontPosition(distance: number): Vector3;
  18280. /** @hidden */
  18281. _getLockedTargetPosition(): Nullable<Vector3>;
  18282. private _storedPosition;
  18283. private _storedRotation;
  18284. private _storedRotationQuaternion;
  18285. /**
  18286. * Store current camera state of the camera (fov, position, rotation, etc..)
  18287. * @returns the camera
  18288. */
  18289. storeState(): Camera;
  18290. /**
  18291. * Restored camera state. You must call storeState() first
  18292. * @returns whether it was successful or not
  18293. * @hidden
  18294. */
  18295. _restoreStateValues(): boolean;
  18296. /** @hidden */
  18297. _initCache(): void;
  18298. /** @hidden */
  18299. _updateCache(ignoreParentClass?: boolean): void;
  18300. /** @hidden */
  18301. _isSynchronizedViewMatrix(): boolean;
  18302. /** @hidden */
  18303. _computeLocalCameraSpeed(): number;
  18304. /**
  18305. * Defines the target the camera should look at.
  18306. * @param target Defines the new target as a Vector or a mesh
  18307. */
  18308. setTarget(target: Vector3): void;
  18309. /**
  18310. * Return the current target position of the camera. This value is expressed in local space.
  18311. * @returns the target position
  18312. */
  18313. getTarget(): Vector3;
  18314. /** @hidden */
  18315. _decideIfNeedsToMove(): boolean;
  18316. /** @hidden */
  18317. _updatePosition(): void;
  18318. /** @hidden */
  18319. _checkInputs(): void;
  18320. protected _updateCameraRotationMatrix(): void;
  18321. /**
  18322. * 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)
  18323. * @returns the current camera
  18324. */
  18325. private _rotateUpVectorWithCameraRotationMatrix;
  18326. private _cachedRotationZ;
  18327. private _cachedQuaternionRotationZ;
  18328. /** @hidden */
  18329. _getViewMatrix(): Matrix;
  18330. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18331. /**
  18332. * @hidden
  18333. */
  18334. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18335. /**
  18336. * @hidden
  18337. */
  18338. _updateRigCameras(): void;
  18339. private _getRigCamPositionAndTarget;
  18340. /**
  18341. * Gets the current object class name.
  18342. * @return the class name
  18343. */
  18344. getClassName(): string;
  18345. }
  18346. }
  18347. declare module BABYLON {
  18348. /**
  18349. * Gather the list of keyboard event types as constants.
  18350. */
  18351. export class KeyboardEventTypes {
  18352. /**
  18353. * The keydown event is fired when a key becomes active (pressed).
  18354. */
  18355. static readonly KEYDOWN: number;
  18356. /**
  18357. * The keyup event is fired when a key has been released.
  18358. */
  18359. static readonly KEYUP: number;
  18360. }
  18361. /**
  18362. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18363. */
  18364. export class KeyboardInfo {
  18365. /**
  18366. * Defines the type of event (KeyboardEventTypes)
  18367. */
  18368. type: number;
  18369. /**
  18370. * Defines the related dom event
  18371. */
  18372. event: KeyboardEvent;
  18373. /**
  18374. * Instantiates a new keyboard info.
  18375. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18376. * @param type Defines the type of event (KeyboardEventTypes)
  18377. * @param event Defines the related dom event
  18378. */
  18379. constructor(
  18380. /**
  18381. * Defines the type of event (KeyboardEventTypes)
  18382. */
  18383. type: number,
  18384. /**
  18385. * Defines the related dom event
  18386. */
  18387. event: KeyboardEvent);
  18388. }
  18389. /**
  18390. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18391. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18392. */
  18393. export class KeyboardInfoPre extends KeyboardInfo {
  18394. /**
  18395. * Defines the type of event (KeyboardEventTypes)
  18396. */
  18397. type: number;
  18398. /**
  18399. * Defines the related dom event
  18400. */
  18401. event: KeyboardEvent;
  18402. /**
  18403. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18404. */
  18405. skipOnPointerObservable: boolean;
  18406. /**
  18407. * Instantiates a new keyboard pre info.
  18408. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18409. * @param type Defines the type of event (KeyboardEventTypes)
  18410. * @param event Defines the related dom event
  18411. */
  18412. constructor(
  18413. /**
  18414. * Defines the type of event (KeyboardEventTypes)
  18415. */
  18416. type: number,
  18417. /**
  18418. * Defines the related dom event
  18419. */
  18420. event: KeyboardEvent);
  18421. }
  18422. }
  18423. declare module BABYLON {
  18424. /**
  18425. * Manage the keyboard inputs to control the movement of a free camera.
  18426. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18427. */
  18428. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18429. /**
  18430. * Defines the camera the input is attached to.
  18431. */
  18432. camera: FreeCamera;
  18433. /**
  18434. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18435. */
  18436. keysUp: number[];
  18437. /**
  18438. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18439. */
  18440. keysUpward: number[];
  18441. /**
  18442. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18443. */
  18444. keysDown: number[];
  18445. /**
  18446. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18447. */
  18448. keysDownward: number[];
  18449. /**
  18450. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18451. */
  18452. keysLeft: number[];
  18453. /**
  18454. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18455. */
  18456. keysRight: number[];
  18457. private _keys;
  18458. private _onCanvasBlurObserver;
  18459. private _onKeyboardObserver;
  18460. private _engine;
  18461. private _scene;
  18462. /**
  18463. * Attach the input controls to a specific dom element to get the input from.
  18464. * @param element Defines the element the controls should be listened from
  18465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18466. */
  18467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18468. /**
  18469. * Detach the current controls from the specified dom element.
  18470. * @param element Defines the element to stop listening the inputs from
  18471. */
  18472. detachControl(element: Nullable<HTMLElement>): void;
  18473. /**
  18474. * Update the current camera state depending on the inputs that have been used this frame.
  18475. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18476. */
  18477. checkInputs(): void;
  18478. /**
  18479. * Gets the class name of the current intput.
  18480. * @returns the class name
  18481. */
  18482. getClassName(): string;
  18483. /** @hidden */
  18484. _onLostFocus(): void;
  18485. /**
  18486. * Get the friendly name associated with the input class.
  18487. * @returns the input friendly name
  18488. */
  18489. getSimpleName(): string;
  18490. }
  18491. }
  18492. declare module BABYLON {
  18493. /**
  18494. * Gather the list of pointer event types as constants.
  18495. */
  18496. export class PointerEventTypes {
  18497. /**
  18498. * 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.
  18499. */
  18500. static readonly POINTERDOWN: number;
  18501. /**
  18502. * The pointerup event is fired when a pointer is no longer active.
  18503. */
  18504. static readonly POINTERUP: number;
  18505. /**
  18506. * The pointermove event is fired when a pointer changes coordinates.
  18507. */
  18508. static readonly POINTERMOVE: number;
  18509. /**
  18510. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18511. */
  18512. static readonly POINTERWHEEL: number;
  18513. /**
  18514. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18515. */
  18516. static readonly POINTERPICK: number;
  18517. /**
  18518. * The pointertap event is fired when a the object has been touched and released without drag.
  18519. */
  18520. static readonly POINTERTAP: number;
  18521. /**
  18522. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18523. */
  18524. static readonly POINTERDOUBLETAP: number;
  18525. }
  18526. /**
  18527. * Base class of pointer info types.
  18528. */
  18529. export class PointerInfoBase {
  18530. /**
  18531. * Defines the type of event (PointerEventTypes)
  18532. */
  18533. type: number;
  18534. /**
  18535. * Defines the related dom event
  18536. */
  18537. event: PointerEvent | MouseWheelEvent;
  18538. /**
  18539. * Instantiates the base class of pointers info.
  18540. * @param type Defines the type of event (PointerEventTypes)
  18541. * @param event Defines the related dom event
  18542. */
  18543. constructor(
  18544. /**
  18545. * Defines the type of event (PointerEventTypes)
  18546. */
  18547. type: number,
  18548. /**
  18549. * Defines the related dom event
  18550. */
  18551. event: PointerEvent | MouseWheelEvent);
  18552. }
  18553. /**
  18554. * This class is used to store pointer related info for the onPrePointerObservable event.
  18555. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18556. */
  18557. export class PointerInfoPre extends PointerInfoBase {
  18558. /**
  18559. * Ray from a pointer if availible (eg. 6dof controller)
  18560. */
  18561. ray: Nullable<Ray>;
  18562. /**
  18563. * Defines the local position of the pointer on the canvas.
  18564. */
  18565. localPosition: Vector2;
  18566. /**
  18567. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18568. */
  18569. skipOnPointerObservable: boolean;
  18570. /**
  18571. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18572. * @param type Defines the type of event (PointerEventTypes)
  18573. * @param event Defines the related dom event
  18574. * @param localX Defines the local x coordinates of the pointer when the event occured
  18575. * @param localY Defines the local y coordinates of the pointer when the event occured
  18576. */
  18577. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18578. }
  18579. /**
  18580. * This type contains all the data related to a pointer event in Babylon.js.
  18581. * 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.
  18582. */
  18583. export class PointerInfo extends PointerInfoBase {
  18584. /**
  18585. * Defines the picking info associated to the info (if any)\
  18586. */
  18587. pickInfo: Nullable<PickingInfo>;
  18588. /**
  18589. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18590. * @param type Defines the type of event (PointerEventTypes)
  18591. * @param event Defines the related dom event
  18592. * @param pickInfo Defines the picking info associated to the info (if any)\
  18593. */
  18594. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18595. /**
  18596. * Defines the picking info associated to the info (if any)\
  18597. */
  18598. pickInfo: Nullable<PickingInfo>);
  18599. }
  18600. /**
  18601. * Data relating to a touch event on the screen.
  18602. */
  18603. export interface PointerTouch {
  18604. /**
  18605. * X coordinate of touch.
  18606. */
  18607. x: number;
  18608. /**
  18609. * Y coordinate of touch.
  18610. */
  18611. y: number;
  18612. /**
  18613. * Id of touch. Unique for each finger.
  18614. */
  18615. pointerId: number;
  18616. /**
  18617. * Event type passed from DOM.
  18618. */
  18619. type: any;
  18620. }
  18621. }
  18622. declare module BABYLON {
  18623. /**
  18624. * Manage the mouse inputs to control the movement of a free camera.
  18625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18626. */
  18627. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18628. /**
  18629. * Define if touch is enabled in the mouse input
  18630. */
  18631. touchEnabled: boolean;
  18632. /**
  18633. * Defines the camera the input is attached to.
  18634. */
  18635. camera: FreeCamera;
  18636. /**
  18637. * Defines the buttons associated with the input to handle camera move.
  18638. */
  18639. buttons: number[];
  18640. /**
  18641. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18642. */
  18643. angularSensibility: number;
  18644. private _pointerInput;
  18645. private _onMouseMove;
  18646. private _observer;
  18647. private previousPosition;
  18648. /**
  18649. * Observable for when a pointer move event occurs containing the move offset
  18650. */
  18651. onPointerMovedObservable: Observable<{
  18652. offsetX: number;
  18653. offsetY: number;
  18654. }>;
  18655. /**
  18656. * @hidden
  18657. * If the camera should be rotated automatically based on pointer movement
  18658. */
  18659. _allowCameraRotation: boolean;
  18660. /**
  18661. * Manage the mouse inputs to control the movement of a free camera.
  18662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18663. * @param touchEnabled Defines if touch is enabled or not
  18664. */
  18665. constructor(
  18666. /**
  18667. * Define if touch is enabled in the mouse input
  18668. */
  18669. touchEnabled?: boolean);
  18670. /**
  18671. * Attach the input controls to a specific dom element to get the input from.
  18672. * @param element Defines the element the controls should be listened from
  18673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18674. */
  18675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18676. /**
  18677. * Called on JS contextmenu event.
  18678. * Override this method to provide functionality.
  18679. */
  18680. protected onContextMenu(evt: PointerEvent): void;
  18681. /**
  18682. * Detach the current controls from the specified dom element.
  18683. * @param element Defines the element to stop listening the inputs from
  18684. */
  18685. detachControl(element: Nullable<HTMLElement>): void;
  18686. /**
  18687. * Gets the class name of the current intput.
  18688. * @returns the class name
  18689. */
  18690. getClassName(): string;
  18691. /**
  18692. * Get the friendly name associated with the input class.
  18693. * @returns the input friendly name
  18694. */
  18695. getSimpleName(): string;
  18696. }
  18697. }
  18698. declare module BABYLON {
  18699. /**
  18700. * Manage the touch inputs to control the movement of a free camera.
  18701. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18702. */
  18703. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18704. /**
  18705. * Defines the camera the input is attached to.
  18706. */
  18707. camera: FreeCamera;
  18708. /**
  18709. * Defines the touch sensibility for rotation.
  18710. * The higher the faster.
  18711. */
  18712. touchAngularSensibility: number;
  18713. /**
  18714. * Defines the touch sensibility for move.
  18715. * The higher the faster.
  18716. */
  18717. touchMoveSensibility: number;
  18718. private _offsetX;
  18719. private _offsetY;
  18720. private _pointerPressed;
  18721. private _pointerInput;
  18722. private _observer;
  18723. private _onLostFocus;
  18724. /**
  18725. * Attach the input controls to a specific dom element to get the input from.
  18726. * @param element Defines the element the controls should be listened from
  18727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18728. */
  18729. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18730. /**
  18731. * Detach the current controls from the specified dom element.
  18732. * @param element Defines the element to stop listening the inputs from
  18733. */
  18734. detachControl(element: Nullable<HTMLElement>): void;
  18735. /**
  18736. * Update the current camera state depending on the inputs that have been used this frame.
  18737. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18738. */
  18739. checkInputs(): void;
  18740. /**
  18741. * Gets the class name of the current intput.
  18742. * @returns the class name
  18743. */
  18744. getClassName(): string;
  18745. /**
  18746. * Get the friendly name associated with the input class.
  18747. * @returns the input friendly name
  18748. */
  18749. getSimpleName(): string;
  18750. }
  18751. }
  18752. declare module BABYLON {
  18753. /**
  18754. * Default Inputs manager for the FreeCamera.
  18755. * It groups all the default supported inputs for ease of use.
  18756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18757. */
  18758. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18759. /**
  18760. * @hidden
  18761. */
  18762. _mouseInput: Nullable<FreeCameraMouseInput>;
  18763. /**
  18764. * Instantiates a new FreeCameraInputsManager.
  18765. * @param camera Defines the camera the inputs belong to
  18766. */
  18767. constructor(camera: FreeCamera);
  18768. /**
  18769. * Add keyboard input support to the input manager.
  18770. * @returns the current input manager
  18771. */
  18772. addKeyboard(): FreeCameraInputsManager;
  18773. /**
  18774. * Add mouse input support to the input manager.
  18775. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18776. * @returns the current input manager
  18777. */
  18778. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18779. /**
  18780. * Removes the mouse input support from the manager
  18781. * @returns the current input manager
  18782. */
  18783. removeMouse(): FreeCameraInputsManager;
  18784. /**
  18785. * Add touch input support to the input manager.
  18786. * @returns the current input manager
  18787. */
  18788. addTouch(): FreeCameraInputsManager;
  18789. /**
  18790. * Remove all attached input methods from a camera
  18791. */
  18792. clear(): void;
  18793. }
  18794. }
  18795. declare module BABYLON {
  18796. /**
  18797. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18798. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18799. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18800. */
  18801. export class FreeCamera extends TargetCamera {
  18802. /**
  18803. * Define the collision ellipsoid of the camera.
  18804. * This is helpful to simulate a camera body like the player body around the camera
  18805. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18806. */
  18807. ellipsoid: Vector3;
  18808. /**
  18809. * Define an offset for the position of the ellipsoid around the camera.
  18810. * This can be helpful to determine the center of the body near the gravity center of the body
  18811. * instead of its head.
  18812. */
  18813. ellipsoidOffset: Vector3;
  18814. /**
  18815. * Enable or disable collisions of the camera with the rest of the scene objects.
  18816. */
  18817. checkCollisions: boolean;
  18818. /**
  18819. * Enable or disable gravity on the camera.
  18820. */
  18821. applyGravity: boolean;
  18822. /**
  18823. * Define the input manager associated to the camera.
  18824. */
  18825. inputs: FreeCameraInputsManager;
  18826. /**
  18827. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18828. * Higher values reduce sensitivity.
  18829. */
  18830. get angularSensibility(): number;
  18831. /**
  18832. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18833. * Higher values reduce sensitivity.
  18834. */
  18835. set angularSensibility(value: number);
  18836. /**
  18837. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18838. */
  18839. get keysUp(): number[];
  18840. set keysUp(value: number[]);
  18841. /**
  18842. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18843. */
  18844. get keysUpward(): number[];
  18845. set keysUpward(value: number[]);
  18846. /**
  18847. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18848. */
  18849. get keysDown(): number[];
  18850. set keysDown(value: number[]);
  18851. /**
  18852. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18853. */
  18854. get keysDownward(): number[];
  18855. set keysDownward(value: number[]);
  18856. /**
  18857. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18858. */
  18859. get keysLeft(): number[];
  18860. set keysLeft(value: number[]);
  18861. /**
  18862. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18863. */
  18864. get keysRight(): number[];
  18865. set keysRight(value: number[]);
  18866. /**
  18867. * Event raised when the camera collide with a mesh in the scene.
  18868. */
  18869. onCollide: (collidedMesh: AbstractMesh) => void;
  18870. private _collider;
  18871. private _needMoveForGravity;
  18872. private _oldPosition;
  18873. private _diffPosition;
  18874. private _newPosition;
  18875. /** @hidden */
  18876. _localDirection: Vector3;
  18877. /** @hidden */
  18878. _transformedDirection: Vector3;
  18879. /**
  18880. * Instantiates a Free Camera.
  18881. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18882. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18883. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18884. * @param name Define the name of the camera in the scene
  18885. * @param position Define the start position of the camera in the scene
  18886. * @param scene Define the scene the camera belongs to
  18887. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18888. */
  18889. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18890. /**
  18891. * Attached controls to the current camera.
  18892. * @param element Defines the element the controls should be listened from
  18893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18894. */
  18895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18896. /**
  18897. * Detach the current controls from the camera.
  18898. * The camera will stop reacting to inputs.
  18899. * @param element Defines the element to stop listening the inputs from
  18900. */
  18901. detachControl(element: HTMLElement): void;
  18902. private _collisionMask;
  18903. /**
  18904. * Define a collision mask to limit the list of object the camera can collide with
  18905. */
  18906. get collisionMask(): number;
  18907. set collisionMask(mask: number);
  18908. /** @hidden */
  18909. _collideWithWorld(displacement: Vector3): void;
  18910. private _onCollisionPositionChange;
  18911. /** @hidden */
  18912. _checkInputs(): void;
  18913. /** @hidden */
  18914. _decideIfNeedsToMove(): boolean;
  18915. /** @hidden */
  18916. _updatePosition(): void;
  18917. /**
  18918. * Destroy the camera and release the current resources hold by it.
  18919. */
  18920. dispose(): void;
  18921. /**
  18922. * Gets the current object class name.
  18923. * @return the class name
  18924. */
  18925. getClassName(): string;
  18926. }
  18927. }
  18928. declare module BABYLON {
  18929. /**
  18930. * Represents a gamepad control stick position
  18931. */
  18932. export class StickValues {
  18933. /**
  18934. * The x component of the control stick
  18935. */
  18936. x: number;
  18937. /**
  18938. * The y component of the control stick
  18939. */
  18940. y: number;
  18941. /**
  18942. * Initializes the gamepad x and y control stick values
  18943. * @param x The x component of the gamepad control stick value
  18944. * @param y The y component of the gamepad control stick value
  18945. */
  18946. constructor(
  18947. /**
  18948. * The x component of the control stick
  18949. */
  18950. x: number,
  18951. /**
  18952. * The y component of the control stick
  18953. */
  18954. y: number);
  18955. }
  18956. /**
  18957. * An interface which manages callbacks for gamepad button changes
  18958. */
  18959. export interface GamepadButtonChanges {
  18960. /**
  18961. * Called when a gamepad has been changed
  18962. */
  18963. changed: boolean;
  18964. /**
  18965. * Called when a gamepad press event has been triggered
  18966. */
  18967. pressChanged: boolean;
  18968. /**
  18969. * Called when a touch event has been triggered
  18970. */
  18971. touchChanged: boolean;
  18972. /**
  18973. * Called when a value has changed
  18974. */
  18975. valueChanged: boolean;
  18976. }
  18977. /**
  18978. * Represents a gamepad
  18979. */
  18980. export class Gamepad {
  18981. /**
  18982. * The id of the gamepad
  18983. */
  18984. id: string;
  18985. /**
  18986. * The index of the gamepad
  18987. */
  18988. index: number;
  18989. /**
  18990. * The browser gamepad
  18991. */
  18992. browserGamepad: any;
  18993. /**
  18994. * Specifies what type of gamepad this represents
  18995. */
  18996. type: number;
  18997. private _leftStick;
  18998. private _rightStick;
  18999. /** @hidden */
  19000. _isConnected: boolean;
  19001. private _leftStickAxisX;
  19002. private _leftStickAxisY;
  19003. private _rightStickAxisX;
  19004. private _rightStickAxisY;
  19005. /**
  19006. * Triggered when the left control stick has been changed
  19007. */
  19008. private _onleftstickchanged;
  19009. /**
  19010. * Triggered when the right control stick has been changed
  19011. */
  19012. private _onrightstickchanged;
  19013. /**
  19014. * Represents a gamepad controller
  19015. */
  19016. static GAMEPAD: number;
  19017. /**
  19018. * Represents a generic controller
  19019. */
  19020. static GENERIC: number;
  19021. /**
  19022. * Represents an XBox controller
  19023. */
  19024. static XBOX: number;
  19025. /**
  19026. * Represents a pose-enabled controller
  19027. */
  19028. static POSE_ENABLED: number;
  19029. /**
  19030. * Represents an Dual Shock controller
  19031. */
  19032. static DUALSHOCK: number;
  19033. /**
  19034. * Specifies whether the left control stick should be Y-inverted
  19035. */
  19036. protected _invertLeftStickY: boolean;
  19037. /**
  19038. * Specifies if the gamepad has been connected
  19039. */
  19040. get isConnected(): boolean;
  19041. /**
  19042. * Initializes the gamepad
  19043. * @param id The id of the gamepad
  19044. * @param index The index of the gamepad
  19045. * @param browserGamepad The browser gamepad
  19046. * @param leftStickX The x component of the left joystick
  19047. * @param leftStickY The y component of the left joystick
  19048. * @param rightStickX The x component of the right joystick
  19049. * @param rightStickY The y component of the right joystick
  19050. */
  19051. constructor(
  19052. /**
  19053. * The id of the gamepad
  19054. */
  19055. id: string,
  19056. /**
  19057. * The index of the gamepad
  19058. */
  19059. index: number,
  19060. /**
  19061. * The browser gamepad
  19062. */
  19063. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19064. /**
  19065. * Callback triggered when the left joystick has changed
  19066. * @param callback
  19067. */
  19068. onleftstickchanged(callback: (values: StickValues) => void): void;
  19069. /**
  19070. * Callback triggered when the right joystick has changed
  19071. * @param callback
  19072. */
  19073. onrightstickchanged(callback: (values: StickValues) => void): void;
  19074. /**
  19075. * Gets the left joystick
  19076. */
  19077. get leftStick(): StickValues;
  19078. /**
  19079. * Sets the left joystick values
  19080. */
  19081. set leftStick(newValues: StickValues);
  19082. /**
  19083. * Gets the right joystick
  19084. */
  19085. get rightStick(): StickValues;
  19086. /**
  19087. * Sets the right joystick value
  19088. */
  19089. set rightStick(newValues: StickValues);
  19090. /**
  19091. * Updates the gamepad joystick positions
  19092. */
  19093. update(): void;
  19094. /**
  19095. * Disposes the gamepad
  19096. */
  19097. dispose(): void;
  19098. }
  19099. /**
  19100. * Represents a generic gamepad
  19101. */
  19102. export class GenericPad extends Gamepad {
  19103. private _buttons;
  19104. private _onbuttondown;
  19105. private _onbuttonup;
  19106. /**
  19107. * Observable triggered when a button has been pressed
  19108. */
  19109. onButtonDownObservable: Observable<number>;
  19110. /**
  19111. * Observable triggered when a button has been released
  19112. */
  19113. onButtonUpObservable: Observable<number>;
  19114. /**
  19115. * Callback triggered when a button has been pressed
  19116. * @param callback Called when a button has been pressed
  19117. */
  19118. onbuttondown(callback: (buttonPressed: number) => void): void;
  19119. /**
  19120. * Callback triggered when a button has been released
  19121. * @param callback Called when a button has been released
  19122. */
  19123. onbuttonup(callback: (buttonReleased: number) => void): void;
  19124. /**
  19125. * Initializes the generic gamepad
  19126. * @param id The id of the generic gamepad
  19127. * @param index The index of the generic gamepad
  19128. * @param browserGamepad The browser gamepad
  19129. */
  19130. constructor(id: string, index: number, browserGamepad: any);
  19131. private _setButtonValue;
  19132. /**
  19133. * Updates the generic gamepad
  19134. */
  19135. update(): void;
  19136. /**
  19137. * Disposes the generic gamepad
  19138. */
  19139. dispose(): void;
  19140. }
  19141. }
  19142. declare module BABYLON {
  19143. /**
  19144. * Defines the types of pose enabled controllers that are supported
  19145. */
  19146. export enum PoseEnabledControllerType {
  19147. /**
  19148. * HTC Vive
  19149. */
  19150. VIVE = 0,
  19151. /**
  19152. * Oculus Rift
  19153. */
  19154. OCULUS = 1,
  19155. /**
  19156. * Windows mixed reality
  19157. */
  19158. WINDOWS = 2,
  19159. /**
  19160. * Samsung gear VR
  19161. */
  19162. GEAR_VR = 3,
  19163. /**
  19164. * Google Daydream
  19165. */
  19166. DAYDREAM = 4,
  19167. /**
  19168. * Generic
  19169. */
  19170. GENERIC = 5
  19171. }
  19172. /**
  19173. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19174. */
  19175. export interface MutableGamepadButton {
  19176. /**
  19177. * Value of the button/trigger
  19178. */
  19179. value: number;
  19180. /**
  19181. * If the button/trigger is currently touched
  19182. */
  19183. touched: boolean;
  19184. /**
  19185. * If the button/trigger is currently pressed
  19186. */
  19187. pressed: boolean;
  19188. }
  19189. /**
  19190. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19191. * @hidden
  19192. */
  19193. export interface ExtendedGamepadButton extends GamepadButton {
  19194. /**
  19195. * If the button/trigger is currently pressed
  19196. */
  19197. readonly pressed: boolean;
  19198. /**
  19199. * If the button/trigger is currently touched
  19200. */
  19201. readonly touched: boolean;
  19202. /**
  19203. * Value of the button/trigger
  19204. */
  19205. readonly value: number;
  19206. }
  19207. /** @hidden */
  19208. export interface _GamePadFactory {
  19209. /**
  19210. * Returns whether or not the current gamepad can be created for this type of controller.
  19211. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19212. * @returns true if it can be created, otherwise false
  19213. */
  19214. canCreate(gamepadInfo: any): boolean;
  19215. /**
  19216. * Creates a new instance of the Gamepad.
  19217. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19218. * @returns the new gamepad instance
  19219. */
  19220. create(gamepadInfo: any): Gamepad;
  19221. }
  19222. /**
  19223. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19224. */
  19225. export class PoseEnabledControllerHelper {
  19226. /** @hidden */
  19227. static _ControllerFactories: _GamePadFactory[];
  19228. /** @hidden */
  19229. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19230. /**
  19231. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19232. * @param vrGamepad the gamepad to initialized
  19233. * @returns a vr controller of the type the gamepad identified as
  19234. */
  19235. static InitiateController(vrGamepad: any): Gamepad;
  19236. }
  19237. /**
  19238. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19239. */
  19240. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19241. /**
  19242. * If the controller is used in a webXR session
  19243. */
  19244. isXR: boolean;
  19245. private _deviceRoomPosition;
  19246. private _deviceRoomRotationQuaternion;
  19247. /**
  19248. * The device position in babylon space
  19249. */
  19250. devicePosition: Vector3;
  19251. /**
  19252. * The device rotation in babylon space
  19253. */
  19254. deviceRotationQuaternion: Quaternion;
  19255. /**
  19256. * The scale factor of the device in babylon space
  19257. */
  19258. deviceScaleFactor: number;
  19259. /**
  19260. * (Likely devicePosition should be used instead) The device position in its room space
  19261. */
  19262. position: Vector3;
  19263. /**
  19264. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19265. */
  19266. rotationQuaternion: Quaternion;
  19267. /**
  19268. * The type of controller (Eg. Windows mixed reality)
  19269. */
  19270. controllerType: PoseEnabledControllerType;
  19271. protected _calculatedPosition: Vector3;
  19272. private _calculatedRotation;
  19273. /**
  19274. * The raw pose from the device
  19275. */
  19276. rawPose: DevicePose;
  19277. private _trackPosition;
  19278. private _maxRotationDistFromHeadset;
  19279. private _draggedRoomRotation;
  19280. /**
  19281. * @hidden
  19282. */
  19283. _disableTrackPosition(fixedPosition: Vector3): void;
  19284. /**
  19285. * Internal, the mesh attached to the controller
  19286. * @hidden
  19287. */
  19288. _mesh: Nullable<AbstractMesh>;
  19289. private _poseControlledCamera;
  19290. private _leftHandSystemQuaternion;
  19291. /**
  19292. * Internal, matrix used to convert room space to babylon space
  19293. * @hidden
  19294. */
  19295. _deviceToWorld: Matrix;
  19296. /**
  19297. * Node to be used when casting a ray from the controller
  19298. * @hidden
  19299. */
  19300. _pointingPoseNode: Nullable<TransformNode>;
  19301. /**
  19302. * Name of the child mesh that can be used to cast a ray from the controller
  19303. */
  19304. static readonly POINTING_POSE: string;
  19305. /**
  19306. * Creates a new PoseEnabledController from a gamepad
  19307. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19308. */
  19309. constructor(browserGamepad: any);
  19310. private _workingMatrix;
  19311. /**
  19312. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19313. */
  19314. update(): void;
  19315. /**
  19316. * Updates only the pose device and mesh without doing any button event checking
  19317. */
  19318. protected _updatePoseAndMesh(): void;
  19319. /**
  19320. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19321. * @param poseData raw pose fromthe device
  19322. */
  19323. updateFromDevice(poseData: DevicePose): void;
  19324. /**
  19325. * @hidden
  19326. */
  19327. _meshAttachedObservable: Observable<AbstractMesh>;
  19328. /**
  19329. * Attaches a mesh to the controller
  19330. * @param mesh the mesh to be attached
  19331. */
  19332. attachToMesh(mesh: AbstractMesh): void;
  19333. /**
  19334. * Attaches the controllers mesh to a camera
  19335. * @param camera the camera the mesh should be attached to
  19336. */
  19337. attachToPoseControlledCamera(camera: TargetCamera): void;
  19338. /**
  19339. * Disposes of the controller
  19340. */
  19341. dispose(): void;
  19342. /**
  19343. * The mesh that is attached to the controller
  19344. */
  19345. get mesh(): Nullable<AbstractMesh>;
  19346. /**
  19347. * Gets the ray of the controller in the direction the controller is pointing
  19348. * @param length the length the resulting ray should be
  19349. * @returns a ray in the direction the controller is pointing
  19350. */
  19351. getForwardRay(length?: number): Ray;
  19352. }
  19353. }
  19354. declare module BABYLON {
  19355. /**
  19356. * Defines the WebVRController object that represents controllers tracked in 3D space
  19357. */
  19358. export abstract class WebVRController extends PoseEnabledController {
  19359. /**
  19360. * Internal, the default controller model for the controller
  19361. */
  19362. protected _defaultModel: Nullable<AbstractMesh>;
  19363. /**
  19364. * Fired when the trigger state has changed
  19365. */
  19366. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19367. /**
  19368. * Fired when the main button state has changed
  19369. */
  19370. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19371. /**
  19372. * Fired when the secondary button state has changed
  19373. */
  19374. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19375. /**
  19376. * Fired when the pad state has changed
  19377. */
  19378. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19379. /**
  19380. * Fired when controllers stick values have changed
  19381. */
  19382. onPadValuesChangedObservable: Observable<StickValues>;
  19383. /**
  19384. * Array of button availible on the controller
  19385. */
  19386. protected _buttons: Array<MutableGamepadButton>;
  19387. private _onButtonStateChange;
  19388. /**
  19389. * Fired when a controller button's state has changed
  19390. * @param callback the callback containing the button that was modified
  19391. */
  19392. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19393. /**
  19394. * X and Y axis corresponding to the controllers joystick
  19395. */
  19396. pad: StickValues;
  19397. /**
  19398. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19399. */
  19400. hand: string;
  19401. /**
  19402. * The default controller model for the controller
  19403. */
  19404. get defaultModel(): Nullable<AbstractMesh>;
  19405. /**
  19406. * Creates a new WebVRController from a gamepad
  19407. * @param vrGamepad the gamepad that the WebVRController should be created from
  19408. */
  19409. constructor(vrGamepad: any);
  19410. /**
  19411. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19412. */
  19413. update(): void;
  19414. /**
  19415. * Function to be called when a button is modified
  19416. */
  19417. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19418. /**
  19419. * Loads a mesh and attaches it to the controller
  19420. * @param scene the scene the mesh should be added to
  19421. * @param meshLoaded callback for when the mesh has been loaded
  19422. */
  19423. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19424. private _setButtonValue;
  19425. private _changes;
  19426. private _checkChanges;
  19427. /**
  19428. * Disposes of th webVRCOntroller
  19429. */
  19430. dispose(): void;
  19431. }
  19432. }
  19433. declare module BABYLON {
  19434. /**
  19435. * The HemisphericLight simulates the ambient environment light,
  19436. * so the passed direction is the light reflection direction, not the incoming direction.
  19437. */
  19438. export class HemisphericLight extends Light {
  19439. /**
  19440. * The groundColor is the light in the opposite direction to the one specified during creation.
  19441. * 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.
  19442. */
  19443. groundColor: Color3;
  19444. /**
  19445. * The light reflection direction, not the incoming direction.
  19446. */
  19447. direction: Vector3;
  19448. /**
  19449. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19450. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19451. * The HemisphericLight can't cast shadows.
  19452. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19453. * @param name The friendly name of the light
  19454. * @param direction The direction of the light reflection
  19455. * @param scene The scene the light belongs to
  19456. */
  19457. constructor(name: string, direction: Vector3, scene: Scene);
  19458. protected _buildUniformLayout(): void;
  19459. /**
  19460. * Returns the string "HemisphericLight".
  19461. * @return The class name
  19462. */
  19463. getClassName(): string;
  19464. /**
  19465. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19466. * Returns the updated direction.
  19467. * @param target The target the direction should point to
  19468. * @return The computed direction
  19469. */
  19470. setDirectionToTarget(target: Vector3): Vector3;
  19471. /**
  19472. * Returns the shadow generator associated to the light.
  19473. * @returns Always null for hemispheric lights because it does not support shadows.
  19474. */
  19475. getShadowGenerator(): Nullable<IShadowGenerator>;
  19476. /**
  19477. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19478. * @param effect The effect to update
  19479. * @param lightIndex The index of the light in the effect to update
  19480. * @returns The hemispheric light
  19481. */
  19482. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19483. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19484. /**
  19485. * Computes the world matrix of the node
  19486. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19487. * @param useWasUpdatedFlag defines a reserved property
  19488. * @returns the world matrix
  19489. */
  19490. computeWorldMatrix(): Matrix;
  19491. /**
  19492. * Returns the integer 3.
  19493. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19494. */
  19495. getTypeID(): number;
  19496. /**
  19497. * Prepares the list of defines specific to the light type.
  19498. * @param defines the list of defines
  19499. * @param lightIndex defines the index of the light for the effect
  19500. */
  19501. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19502. }
  19503. }
  19504. declare module BABYLON {
  19505. /** @hidden */
  19506. export var vrMultiviewToSingleviewPixelShader: {
  19507. name: string;
  19508. shader: string;
  19509. };
  19510. }
  19511. declare module BABYLON {
  19512. /**
  19513. * Renders to multiple views with a single draw call
  19514. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19515. */
  19516. export class MultiviewRenderTarget extends RenderTargetTexture {
  19517. /**
  19518. * Creates a multiview render target
  19519. * @param scene scene used with the render target
  19520. * @param size the size of the render target (used for each view)
  19521. */
  19522. constructor(scene: Scene, size?: number | {
  19523. width: number;
  19524. height: number;
  19525. } | {
  19526. ratio: number;
  19527. });
  19528. /**
  19529. * @hidden
  19530. * @param faceIndex the face index, if its a cube texture
  19531. */
  19532. _bindFrameBuffer(faceIndex?: number): void;
  19533. /**
  19534. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19535. * @returns the view count
  19536. */
  19537. getViewCount(): number;
  19538. }
  19539. }
  19540. declare module BABYLON {
  19541. interface Engine {
  19542. /**
  19543. * Creates a new multiview render target
  19544. * @param width defines the width of the texture
  19545. * @param height defines the height of the texture
  19546. * @returns the created multiview texture
  19547. */
  19548. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19549. /**
  19550. * Binds a multiview framebuffer to be drawn to
  19551. * @param multiviewTexture texture to bind
  19552. */
  19553. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19554. }
  19555. interface Camera {
  19556. /**
  19557. * @hidden
  19558. * 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)
  19559. */
  19560. _useMultiviewToSingleView: boolean;
  19561. /**
  19562. * @hidden
  19563. * 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)
  19564. */
  19565. _multiviewTexture: Nullable<RenderTargetTexture>;
  19566. /**
  19567. * @hidden
  19568. * ensures the multiview texture of the camera exists and has the specified width/height
  19569. * @param width height to set on the multiview texture
  19570. * @param height width to set on the multiview texture
  19571. */
  19572. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19573. }
  19574. interface Scene {
  19575. /** @hidden */
  19576. _transformMatrixR: Matrix;
  19577. /** @hidden */
  19578. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19579. /** @hidden */
  19580. _createMultiviewUbo(): void;
  19581. /** @hidden */
  19582. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19583. /** @hidden */
  19584. _renderMultiviewToSingleView(camera: Camera): void;
  19585. }
  19586. }
  19587. declare module BABYLON {
  19588. /**
  19589. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19590. * This will not be used for webXR as it supports displaying texture arrays directly
  19591. */
  19592. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19593. /**
  19594. * Initializes a VRMultiviewToSingleview
  19595. * @param name name of the post process
  19596. * @param camera camera to be applied to
  19597. * @param scaleFactor scaling factor to the size of the output texture
  19598. */
  19599. constructor(name: string, camera: Camera, scaleFactor: number);
  19600. }
  19601. }
  19602. declare module BABYLON {
  19603. /**
  19604. * Interface used to define additional presentation attributes
  19605. */
  19606. export interface IVRPresentationAttributes {
  19607. /**
  19608. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19609. */
  19610. highRefreshRate: boolean;
  19611. /**
  19612. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19613. */
  19614. foveationLevel: number;
  19615. }
  19616. interface Engine {
  19617. /** @hidden */
  19618. _vrDisplay: any;
  19619. /** @hidden */
  19620. _vrSupported: boolean;
  19621. /** @hidden */
  19622. _oldSize: Size;
  19623. /** @hidden */
  19624. _oldHardwareScaleFactor: number;
  19625. /** @hidden */
  19626. _vrExclusivePointerMode: boolean;
  19627. /** @hidden */
  19628. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19629. /** @hidden */
  19630. _onVRDisplayPointerRestricted: () => void;
  19631. /** @hidden */
  19632. _onVRDisplayPointerUnrestricted: () => void;
  19633. /** @hidden */
  19634. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19635. /** @hidden */
  19636. _onVrDisplayDisconnect: Nullable<() => void>;
  19637. /** @hidden */
  19638. _onVrDisplayPresentChange: Nullable<() => void>;
  19639. /**
  19640. * Observable signaled when VR display mode changes
  19641. */
  19642. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19643. /**
  19644. * Observable signaled when VR request present is complete
  19645. */
  19646. onVRRequestPresentComplete: Observable<boolean>;
  19647. /**
  19648. * Observable signaled when VR request present starts
  19649. */
  19650. onVRRequestPresentStart: Observable<Engine>;
  19651. /**
  19652. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19653. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19654. */
  19655. isInVRExclusivePointerMode: boolean;
  19656. /**
  19657. * Gets a boolean indicating if a webVR device was detected
  19658. * @returns true if a webVR device was detected
  19659. */
  19660. isVRDevicePresent(): boolean;
  19661. /**
  19662. * Gets the current webVR device
  19663. * @returns the current webVR device (or null)
  19664. */
  19665. getVRDevice(): any;
  19666. /**
  19667. * Initializes a webVR display and starts listening to display change events
  19668. * The onVRDisplayChangedObservable will be notified upon these changes
  19669. * @returns A promise containing a VRDisplay and if vr is supported
  19670. */
  19671. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19672. /** @hidden */
  19673. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19674. /**
  19675. * Gets or sets the presentation attributes used to configure VR rendering
  19676. */
  19677. vrPresentationAttributes?: IVRPresentationAttributes;
  19678. /**
  19679. * Call this function to switch to webVR mode
  19680. * Will do nothing if webVR is not supported or if there is no webVR device
  19681. * @param options the webvr options provided to the camera. mainly used for multiview
  19682. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19683. */
  19684. enableVR(options: WebVROptions): void;
  19685. /** @hidden */
  19686. _onVRFullScreenTriggered(): void;
  19687. }
  19688. }
  19689. declare module BABYLON {
  19690. /**
  19691. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19692. * IMPORTANT!! The data is right-hand data.
  19693. * @export
  19694. * @interface DevicePose
  19695. */
  19696. export interface DevicePose {
  19697. /**
  19698. * The position of the device, values in array are [x,y,z].
  19699. */
  19700. readonly position: Nullable<Float32Array>;
  19701. /**
  19702. * The linearVelocity of the device, values in array are [x,y,z].
  19703. */
  19704. readonly linearVelocity: Nullable<Float32Array>;
  19705. /**
  19706. * The linearAcceleration of the device, values in array are [x,y,z].
  19707. */
  19708. readonly linearAcceleration: Nullable<Float32Array>;
  19709. /**
  19710. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19711. */
  19712. readonly orientation: Nullable<Float32Array>;
  19713. /**
  19714. * The angularVelocity of the device, values in array are [x,y,z].
  19715. */
  19716. readonly angularVelocity: Nullable<Float32Array>;
  19717. /**
  19718. * The angularAcceleration of the device, values in array are [x,y,z].
  19719. */
  19720. readonly angularAcceleration: Nullable<Float32Array>;
  19721. }
  19722. /**
  19723. * Interface representing a pose controlled object in Babylon.
  19724. * A pose controlled object has both regular pose values as well as pose values
  19725. * from an external device such as a VR head mounted display
  19726. */
  19727. export interface PoseControlled {
  19728. /**
  19729. * The position of the object in babylon space.
  19730. */
  19731. position: Vector3;
  19732. /**
  19733. * The rotation quaternion of the object in babylon space.
  19734. */
  19735. rotationQuaternion: Quaternion;
  19736. /**
  19737. * The position of the device in babylon space.
  19738. */
  19739. devicePosition?: Vector3;
  19740. /**
  19741. * The rotation quaternion of the device in babylon space.
  19742. */
  19743. deviceRotationQuaternion: Quaternion;
  19744. /**
  19745. * The raw pose coming from the device.
  19746. */
  19747. rawPose: Nullable<DevicePose>;
  19748. /**
  19749. * The scale of the device to be used when translating from device space to babylon space.
  19750. */
  19751. deviceScaleFactor: number;
  19752. /**
  19753. * Updates the poseControlled values based on the input device pose.
  19754. * @param poseData the pose data to update the object with
  19755. */
  19756. updateFromDevice(poseData: DevicePose): void;
  19757. }
  19758. /**
  19759. * Set of options to customize the webVRCamera
  19760. */
  19761. export interface WebVROptions {
  19762. /**
  19763. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19764. */
  19765. trackPosition?: boolean;
  19766. /**
  19767. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19768. */
  19769. positionScale?: number;
  19770. /**
  19771. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19772. */
  19773. displayName?: string;
  19774. /**
  19775. * Should the native controller meshes be initialized. (default: true)
  19776. */
  19777. controllerMeshes?: boolean;
  19778. /**
  19779. * Creating a default HemiLight only on controllers. (default: true)
  19780. */
  19781. defaultLightingOnControllers?: boolean;
  19782. /**
  19783. * If you don't want to use the default VR button of the helper. (default: false)
  19784. */
  19785. useCustomVRButton?: boolean;
  19786. /**
  19787. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19788. */
  19789. customVRButton?: HTMLButtonElement;
  19790. /**
  19791. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19792. */
  19793. rayLength?: number;
  19794. /**
  19795. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19796. */
  19797. defaultHeight?: number;
  19798. /**
  19799. * If multiview should be used if availible (default: false)
  19800. */
  19801. useMultiview?: boolean;
  19802. }
  19803. /**
  19804. * This represents a WebVR camera.
  19805. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19806. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19807. */
  19808. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19809. private webVROptions;
  19810. /**
  19811. * @hidden
  19812. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19813. */
  19814. _vrDevice: any;
  19815. /**
  19816. * The rawPose of the vrDevice.
  19817. */
  19818. rawPose: Nullable<DevicePose>;
  19819. private _onVREnabled;
  19820. private _specsVersion;
  19821. private _attached;
  19822. private _frameData;
  19823. protected _descendants: Array<Node>;
  19824. private _deviceRoomPosition;
  19825. /** @hidden */
  19826. _deviceRoomRotationQuaternion: Quaternion;
  19827. private _standingMatrix;
  19828. /**
  19829. * Represents device position in babylon space.
  19830. */
  19831. devicePosition: Vector3;
  19832. /**
  19833. * Represents device rotation in babylon space.
  19834. */
  19835. deviceRotationQuaternion: Quaternion;
  19836. /**
  19837. * The scale of the device to be used when translating from device space to babylon space.
  19838. */
  19839. deviceScaleFactor: number;
  19840. private _deviceToWorld;
  19841. private _worldToDevice;
  19842. /**
  19843. * References to the webVR controllers for the vrDevice.
  19844. */
  19845. controllers: Array<WebVRController>;
  19846. /**
  19847. * Emits an event when a controller is attached.
  19848. */
  19849. onControllersAttachedObservable: Observable<WebVRController[]>;
  19850. /**
  19851. * Emits an event when a controller's mesh has been loaded;
  19852. */
  19853. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19854. /**
  19855. * Emits an event when the HMD's pose has been updated.
  19856. */
  19857. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19858. private _poseSet;
  19859. /**
  19860. * If the rig cameras be used as parent instead of this camera.
  19861. */
  19862. rigParenting: boolean;
  19863. private _lightOnControllers;
  19864. private _defaultHeight?;
  19865. /**
  19866. * Instantiates a WebVRFreeCamera.
  19867. * @param name The name of the WebVRFreeCamera
  19868. * @param position The starting anchor position for the camera
  19869. * @param scene The scene the camera belongs to
  19870. * @param webVROptions a set of customizable options for the webVRCamera
  19871. */
  19872. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19873. /**
  19874. * Gets the device distance from the ground in meters.
  19875. * @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.
  19876. */
  19877. deviceDistanceToRoomGround(): number;
  19878. /**
  19879. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19880. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19881. */
  19882. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19883. /**
  19884. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19885. * @returns A promise with a boolean set to if the standing matrix is supported.
  19886. */
  19887. useStandingMatrixAsync(): Promise<boolean>;
  19888. /**
  19889. * Disposes the camera
  19890. */
  19891. dispose(): void;
  19892. /**
  19893. * Gets a vrController by name.
  19894. * @param name The name of the controller to retreive
  19895. * @returns the controller matching the name specified or null if not found
  19896. */
  19897. getControllerByName(name: string): Nullable<WebVRController>;
  19898. private _leftController;
  19899. /**
  19900. * The controller corresponding to the users left hand.
  19901. */
  19902. get leftController(): Nullable<WebVRController>;
  19903. private _rightController;
  19904. /**
  19905. * The controller corresponding to the users right hand.
  19906. */
  19907. get rightController(): Nullable<WebVRController>;
  19908. /**
  19909. * Casts a ray forward from the vrCamera's gaze.
  19910. * @param length Length of the ray (default: 100)
  19911. * @returns the ray corresponding to the gaze
  19912. */
  19913. getForwardRay(length?: number): Ray;
  19914. /**
  19915. * @hidden
  19916. * Updates the camera based on device's frame data
  19917. */
  19918. _checkInputs(): void;
  19919. /**
  19920. * Updates the poseControlled values based on the input device pose.
  19921. * @param poseData Pose coming from the device
  19922. */
  19923. updateFromDevice(poseData: DevicePose): void;
  19924. private _htmlElementAttached;
  19925. private _detachIfAttached;
  19926. /**
  19927. * WebVR's attach control will start broadcasting frames to the device.
  19928. * Note that in certain browsers (chrome for example) this function must be called
  19929. * within a user-interaction callback. Example:
  19930. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19931. *
  19932. * @param element html element to attach the vrDevice to
  19933. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19934. */
  19935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19936. /**
  19937. * Detaches the camera from the html element and disables VR
  19938. *
  19939. * @param element html element to detach from
  19940. */
  19941. detachControl(element: HTMLElement): void;
  19942. /**
  19943. * @returns the name of this class
  19944. */
  19945. getClassName(): string;
  19946. /**
  19947. * Calls resetPose on the vrDisplay
  19948. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19949. */
  19950. resetToCurrentRotation(): void;
  19951. /**
  19952. * @hidden
  19953. * Updates the rig cameras (left and right eye)
  19954. */
  19955. _updateRigCameras(): void;
  19956. private _workingVector;
  19957. private _oneVector;
  19958. private _workingMatrix;
  19959. private updateCacheCalled;
  19960. private _correctPositionIfNotTrackPosition;
  19961. /**
  19962. * @hidden
  19963. * Updates the cached values of the camera
  19964. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19965. */
  19966. _updateCache(ignoreParentClass?: boolean): void;
  19967. /**
  19968. * @hidden
  19969. * Get current device position in babylon world
  19970. */
  19971. _computeDevicePosition(): void;
  19972. /**
  19973. * Updates the current device position and rotation in the babylon world
  19974. */
  19975. update(): void;
  19976. /**
  19977. * @hidden
  19978. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19979. * @returns an identity matrix
  19980. */
  19981. _getViewMatrix(): Matrix;
  19982. private _tmpMatrix;
  19983. /**
  19984. * This function is called by the two RIG cameras.
  19985. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19986. * @hidden
  19987. */
  19988. _getWebVRViewMatrix(): Matrix;
  19989. /** @hidden */
  19990. _getWebVRProjectionMatrix(): Matrix;
  19991. private _onGamepadConnectedObserver;
  19992. private _onGamepadDisconnectedObserver;
  19993. private _updateCacheWhenTrackingDisabledObserver;
  19994. /**
  19995. * Initializes the controllers and their meshes
  19996. */
  19997. initControllers(): void;
  19998. }
  19999. }
  20000. declare module BABYLON {
  20001. /**
  20002. * "Static Class" containing the most commonly used helper while dealing with material for
  20003. * rendering purpose.
  20004. *
  20005. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20006. *
  20007. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20008. */
  20009. export class MaterialHelper {
  20010. /**
  20011. * Bind the current view position to an effect.
  20012. * @param effect The effect to be bound
  20013. * @param scene The scene the eyes position is used from
  20014. * @param variableName name of the shader variable that will hold the eye position
  20015. */
  20016. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20017. /**
  20018. * Helps preparing the defines values about the UVs in used in the effect.
  20019. * UVs are shared as much as we can accross channels in the shaders.
  20020. * @param texture The texture we are preparing the UVs for
  20021. * @param defines The defines to update
  20022. * @param key The channel key "diffuse", "specular"... used in the shader
  20023. */
  20024. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20025. /**
  20026. * Binds a texture matrix value to its corrsponding uniform
  20027. * @param texture The texture to bind the matrix for
  20028. * @param uniformBuffer The uniform buffer receivin the data
  20029. * @param key The channel key "diffuse", "specular"... used in the shader
  20030. */
  20031. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20032. /**
  20033. * Gets the current status of the fog (should it be enabled?)
  20034. * @param mesh defines the mesh to evaluate for fog support
  20035. * @param scene defines the hosting scene
  20036. * @returns true if fog must be enabled
  20037. */
  20038. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20039. /**
  20040. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20041. * @param mesh defines the current mesh
  20042. * @param scene defines the current scene
  20043. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20044. * @param pointsCloud defines if point cloud rendering has to be turned on
  20045. * @param fogEnabled defines if fog has to be turned on
  20046. * @param alphaTest defines if alpha testing has to be turned on
  20047. * @param defines defines the current list of defines
  20048. */
  20049. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20050. /**
  20051. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20052. * @param scene defines the current scene
  20053. * @param engine defines the current engine
  20054. * @param defines specifies the list of active defines
  20055. * @param useInstances defines if instances have to be turned on
  20056. * @param useClipPlane defines if clip plane have to be turned on
  20057. * @param useInstances defines if instances have to be turned on
  20058. * @param useThinInstances defines if thin instances have to be turned on
  20059. */
  20060. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20061. /**
  20062. * Prepares the defines for bones
  20063. * @param mesh The mesh containing the geometry data we will draw
  20064. * @param defines The defines to update
  20065. */
  20066. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20067. /**
  20068. * Prepares the defines for morph targets
  20069. * @param mesh The mesh containing the geometry data we will draw
  20070. * @param defines The defines to update
  20071. */
  20072. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20073. /**
  20074. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20075. * @param mesh The mesh containing the geometry data we will draw
  20076. * @param defines The defines to update
  20077. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20078. * @param useBones Precise whether bones should be used or not (override mesh info)
  20079. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20080. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20081. * @returns false if defines are considered not dirty and have not been checked
  20082. */
  20083. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20084. /**
  20085. * Prepares the defines related to multiview
  20086. * @param scene The scene we are intending to draw
  20087. * @param defines The defines to update
  20088. */
  20089. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20090. /**
  20091. * Prepares the defines related to the light information passed in parameter
  20092. * @param scene The scene we are intending to draw
  20093. * @param mesh The mesh the effect is compiling for
  20094. * @param light The light the effect is compiling for
  20095. * @param lightIndex The index of the light
  20096. * @param defines The defines to update
  20097. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20098. * @param state Defines the current state regarding what is needed (normals, etc...)
  20099. */
  20100. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20101. needNormals: boolean;
  20102. needRebuild: boolean;
  20103. shadowEnabled: boolean;
  20104. specularEnabled: boolean;
  20105. lightmapMode: boolean;
  20106. }): void;
  20107. /**
  20108. * Prepares the defines related to the light information passed in parameter
  20109. * @param scene The scene we are intending to draw
  20110. * @param mesh The mesh the effect is compiling for
  20111. * @param defines The defines to update
  20112. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20113. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20114. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20115. * @returns true if normals will be required for the rest of the effect
  20116. */
  20117. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20118. /**
  20119. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20120. * @param lightIndex defines the light index
  20121. * @param uniformsList The uniform list
  20122. * @param samplersList The sampler list
  20123. * @param projectedLightTexture defines if projected texture must be used
  20124. * @param uniformBuffersList defines an optional list of uniform buffers
  20125. */
  20126. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20127. /**
  20128. * Prepares the uniforms and samplers list to be used in the effect
  20129. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20130. * @param samplersList The sampler list
  20131. * @param defines The defines helping in the list generation
  20132. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20133. */
  20134. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20135. /**
  20136. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20137. * @param defines The defines to update while falling back
  20138. * @param fallbacks The authorized effect fallbacks
  20139. * @param maxSimultaneousLights The maximum number of lights allowed
  20140. * @param rank the current rank of the Effect
  20141. * @returns The newly affected rank
  20142. */
  20143. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20144. private static _TmpMorphInfluencers;
  20145. /**
  20146. * Prepares the list of attributes required for morph targets according to the effect defines.
  20147. * @param attribs The current list of supported attribs
  20148. * @param mesh The mesh to prepare the morph targets attributes for
  20149. * @param influencers The number of influencers
  20150. */
  20151. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20152. /**
  20153. * Prepares the list of attributes required for morph targets according to the effect defines.
  20154. * @param attribs The current list of supported attribs
  20155. * @param mesh The mesh to prepare the morph targets attributes for
  20156. * @param defines The current Defines of the effect
  20157. */
  20158. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20159. /**
  20160. * Prepares the list of attributes required for bones according to the effect defines.
  20161. * @param attribs The current list of supported attribs
  20162. * @param mesh The mesh to prepare the bones attributes for
  20163. * @param defines The current Defines of the effect
  20164. * @param fallbacks The current efffect fallback strategy
  20165. */
  20166. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20167. /**
  20168. * Check and prepare the list of attributes required for instances according to the effect defines.
  20169. * @param attribs The current list of supported attribs
  20170. * @param defines The current MaterialDefines of the effect
  20171. */
  20172. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20173. /**
  20174. * Add the list of attributes required for instances to the attribs array.
  20175. * @param attribs The current list of supported attribs
  20176. */
  20177. static PushAttributesForInstances(attribs: string[]): void;
  20178. /**
  20179. * Binds the light information to the effect.
  20180. * @param light The light containing the generator
  20181. * @param effect The effect we are binding the data to
  20182. * @param lightIndex The light index in the effect used to render
  20183. */
  20184. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20185. /**
  20186. * Binds the lights information from the scene to the effect for the given mesh.
  20187. * @param light Light to bind
  20188. * @param lightIndex Light index
  20189. * @param scene The scene where the light belongs to
  20190. * @param effect The effect we are binding the data to
  20191. * @param useSpecular Defines if specular is supported
  20192. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20193. */
  20194. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20195. /**
  20196. * Binds the lights information from the scene to the effect for the given mesh.
  20197. * @param scene The scene the lights belongs to
  20198. * @param mesh The mesh we are binding the information to render
  20199. * @param effect The effect we are binding the data to
  20200. * @param defines The generated defines for the effect
  20201. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20202. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20203. */
  20204. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20205. private static _tempFogColor;
  20206. /**
  20207. * Binds the fog information from the scene to the effect for the given mesh.
  20208. * @param scene The scene the lights belongs to
  20209. * @param mesh The mesh we are binding the information to render
  20210. * @param effect The effect we are binding the data to
  20211. * @param linearSpace Defines if the fog effect is applied in linear space
  20212. */
  20213. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20214. /**
  20215. * Binds the bones information from the mesh to the effect.
  20216. * @param mesh The mesh we are binding the information to render
  20217. * @param effect The effect we are binding the data to
  20218. */
  20219. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20220. /**
  20221. * Binds the morph targets information from the mesh to the effect.
  20222. * @param abstractMesh The mesh we are binding the information to render
  20223. * @param effect The effect we are binding the data to
  20224. */
  20225. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20226. /**
  20227. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20228. * @param defines The generated defines used in the effect
  20229. * @param effect The effect we are binding the data to
  20230. * @param scene The scene we are willing to render with logarithmic scale for
  20231. */
  20232. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20233. /**
  20234. * Binds the clip plane information from the scene to the effect.
  20235. * @param scene The scene the clip plane information are extracted from
  20236. * @param effect The effect we are binding the data to
  20237. */
  20238. static BindClipPlane(effect: Effect, scene: Scene): void;
  20239. }
  20240. }
  20241. declare module BABYLON {
  20242. /**
  20243. * Block used to expose an input value
  20244. */
  20245. export class InputBlock extends NodeMaterialBlock {
  20246. private _mode;
  20247. private _associatedVariableName;
  20248. private _storedValue;
  20249. private _valueCallback;
  20250. private _type;
  20251. private _animationType;
  20252. /** Gets or set a value used to limit the range of float values */
  20253. min: number;
  20254. /** Gets or set a value used to limit the range of float values */
  20255. max: number;
  20256. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20257. isBoolean: boolean;
  20258. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20259. matrixMode: number;
  20260. /** @hidden */
  20261. _systemValue: Nullable<NodeMaterialSystemValues>;
  20262. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20263. visibleInInspector: boolean;
  20264. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20265. isConstant: boolean;
  20266. /** Gets or sets the group to use to display this block in the Inspector */
  20267. groupInInspector: string;
  20268. /** Gets an observable raised when the value is changed */
  20269. onValueChangedObservable: Observable<InputBlock>;
  20270. /**
  20271. * Gets or sets the connection point type (default is float)
  20272. */
  20273. get type(): NodeMaterialBlockConnectionPointTypes;
  20274. /**
  20275. * Creates a new InputBlock
  20276. * @param name defines the block name
  20277. * @param target defines the target of that block (Vertex by default)
  20278. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20279. */
  20280. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20281. /**
  20282. * Gets the output component
  20283. */
  20284. get output(): NodeMaterialConnectionPoint;
  20285. /**
  20286. * Set the source of this connection point to a vertex attribute
  20287. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20288. * @returns the current connection point
  20289. */
  20290. setAsAttribute(attributeName?: string): InputBlock;
  20291. /**
  20292. * Set the source of this connection point to a system value
  20293. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20294. * @returns the current connection point
  20295. */
  20296. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20297. /**
  20298. * Gets or sets the value of that point.
  20299. * Please note that this value will be ignored if valueCallback is defined
  20300. */
  20301. get value(): any;
  20302. set value(value: any);
  20303. /**
  20304. * Gets or sets a callback used to get the value of that point.
  20305. * Please note that setting this value will force the connection point to ignore the value property
  20306. */
  20307. get valueCallback(): () => any;
  20308. set valueCallback(value: () => any);
  20309. /**
  20310. * Gets or sets the associated variable name in the shader
  20311. */
  20312. get associatedVariableName(): string;
  20313. set associatedVariableName(value: string);
  20314. /** Gets or sets the type of animation applied to the input */
  20315. get animationType(): AnimatedInputBlockTypes;
  20316. set animationType(value: AnimatedInputBlockTypes);
  20317. /**
  20318. * Gets a boolean indicating that this connection point not defined yet
  20319. */
  20320. get isUndefined(): boolean;
  20321. /**
  20322. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20323. * In this case the connection point name must be the name of the uniform to use.
  20324. * Can only be set on inputs
  20325. */
  20326. get isUniform(): boolean;
  20327. set isUniform(value: boolean);
  20328. /**
  20329. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20330. * In this case the connection point name must be the name of the attribute to use
  20331. * Can only be set on inputs
  20332. */
  20333. get isAttribute(): boolean;
  20334. set isAttribute(value: boolean);
  20335. /**
  20336. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20337. * Can only be set on exit points
  20338. */
  20339. get isVarying(): boolean;
  20340. set isVarying(value: boolean);
  20341. /**
  20342. * Gets a boolean indicating that the current connection point is a system value
  20343. */
  20344. get isSystemValue(): boolean;
  20345. /**
  20346. * Gets or sets the current well known value or null if not defined as a system value
  20347. */
  20348. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20349. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20350. /**
  20351. * Gets the current class name
  20352. * @returns the class name
  20353. */
  20354. getClassName(): string;
  20355. /**
  20356. * Animate the input if animationType !== None
  20357. * @param scene defines the rendering scene
  20358. */
  20359. animate(scene: Scene): void;
  20360. private _emitDefine;
  20361. initialize(state: NodeMaterialBuildState): void;
  20362. /**
  20363. * Set the input block to its default value (based on its type)
  20364. */
  20365. setDefaultValue(): void;
  20366. private _emitConstant;
  20367. /** @hidden */
  20368. get _noContextSwitch(): boolean;
  20369. private _emit;
  20370. /** @hidden */
  20371. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20372. /** @hidden */
  20373. _transmit(effect: Effect, scene: Scene): void;
  20374. protected _buildBlock(state: NodeMaterialBuildState): void;
  20375. protected _dumpPropertiesCode(): string;
  20376. dispose(): void;
  20377. serialize(): any;
  20378. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20379. }
  20380. }
  20381. declare module BABYLON {
  20382. /**
  20383. * Enum used to define the compatibility state between two connection points
  20384. */
  20385. export enum NodeMaterialConnectionPointCompatibilityStates {
  20386. /** Points are compatibles */
  20387. Compatible = 0,
  20388. /** Points are incompatible because of their types */
  20389. TypeIncompatible = 1,
  20390. /** Points are incompatible because of their targets (vertex vs fragment) */
  20391. TargetIncompatible = 2
  20392. }
  20393. /**
  20394. * Defines the direction of a connection point
  20395. */
  20396. export enum NodeMaterialConnectionPointDirection {
  20397. /** Input */
  20398. Input = 0,
  20399. /** Output */
  20400. Output = 1
  20401. }
  20402. /**
  20403. * Defines a connection point for a block
  20404. */
  20405. export class NodeMaterialConnectionPoint {
  20406. /** @hidden */
  20407. _ownerBlock: NodeMaterialBlock;
  20408. /** @hidden */
  20409. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20410. private _endpoints;
  20411. private _associatedVariableName;
  20412. private _direction;
  20413. /** @hidden */
  20414. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20415. /** @hidden */
  20416. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20417. private _type;
  20418. /** @hidden */
  20419. _enforceAssociatedVariableName: boolean;
  20420. /** Gets the direction of the point */
  20421. get direction(): NodeMaterialConnectionPointDirection;
  20422. /** Indicates that this connection point needs dual validation before being connected to another point */
  20423. needDualDirectionValidation: boolean;
  20424. /**
  20425. * Gets or sets the additional types supported by this connection point
  20426. */
  20427. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20428. /**
  20429. * Gets or sets the additional types excluded by this connection point
  20430. */
  20431. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20432. /**
  20433. * Observable triggered when this point is connected
  20434. */
  20435. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20436. /**
  20437. * Gets or sets the associated variable name in the shader
  20438. */
  20439. get associatedVariableName(): string;
  20440. set associatedVariableName(value: string);
  20441. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20442. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20443. /**
  20444. * Gets or sets the connection point type (default is float)
  20445. */
  20446. get type(): NodeMaterialBlockConnectionPointTypes;
  20447. set type(value: NodeMaterialBlockConnectionPointTypes);
  20448. /**
  20449. * Gets or sets the connection point name
  20450. */
  20451. name: string;
  20452. /**
  20453. * Gets or sets the connection point name
  20454. */
  20455. displayName: string;
  20456. /**
  20457. * Gets or sets a boolean indicating that this connection point can be omitted
  20458. */
  20459. isOptional: boolean;
  20460. /**
  20461. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20462. */
  20463. isExposedOnFrame: boolean;
  20464. /**
  20465. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20466. */
  20467. define: string;
  20468. /** @hidden */
  20469. _prioritizeVertex: boolean;
  20470. private _target;
  20471. /** Gets or sets the target of that connection point */
  20472. get target(): NodeMaterialBlockTargets;
  20473. set target(value: NodeMaterialBlockTargets);
  20474. /**
  20475. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20476. */
  20477. get isConnected(): boolean;
  20478. /**
  20479. * Gets a boolean indicating that the current point is connected to an input block
  20480. */
  20481. get isConnectedToInputBlock(): boolean;
  20482. /**
  20483. * Gets a the connected input block (if any)
  20484. */
  20485. get connectInputBlock(): Nullable<InputBlock>;
  20486. /** Get the other side of the connection (if any) */
  20487. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20488. /** Get the block that owns this connection point */
  20489. get ownerBlock(): NodeMaterialBlock;
  20490. /** Get the block connected on the other side of this connection (if any) */
  20491. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20492. /** Get the block connected on the endpoints of this connection (if any) */
  20493. get connectedBlocks(): Array<NodeMaterialBlock>;
  20494. /** Gets the list of connected endpoints */
  20495. get endpoints(): NodeMaterialConnectionPoint[];
  20496. /** Gets a boolean indicating if that output point is connected to at least one input */
  20497. get hasEndpoints(): boolean;
  20498. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20499. get isConnectedInVertexShader(): boolean;
  20500. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20501. get isConnectedInFragmentShader(): boolean;
  20502. /**
  20503. * Creates a block suitable to be used as an input for this input point.
  20504. * If null is returned, a block based on the point type will be created.
  20505. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  20506. */
  20507. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20508. /**
  20509. * Creates a new connection point
  20510. * @param name defines the connection point name
  20511. * @param ownerBlock defines the block hosting this connection point
  20512. * @param direction defines the direction of the connection point
  20513. */
  20514. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20515. /**
  20516. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20517. * @returns the class name
  20518. */
  20519. getClassName(): string;
  20520. /**
  20521. * Gets a boolean indicating if the current point can be connected to another point
  20522. * @param connectionPoint defines the other connection point
  20523. * @returns a boolean
  20524. */
  20525. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20526. /**
  20527. * Gets a number indicating if the current point can be connected to another point
  20528. * @param connectionPoint defines the other connection point
  20529. * @returns a number defining the compatibility state
  20530. */
  20531. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20532. /**
  20533. * Connect this point to another connection point
  20534. * @param connectionPoint defines the other connection point
  20535. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20536. * @returns the current connection point
  20537. */
  20538. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20539. /**
  20540. * Disconnect this point from one of his endpoint
  20541. * @param endpoint defines the other connection point
  20542. * @returns the current connection point
  20543. */
  20544. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20545. /**
  20546. * Serializes this point in a JSON representation
  20547. * @param isInput defines if the connection point is an input (default is true)
  20548. * @returns the serialized point object
  20549. */
  20550. serialize(isInput?: boolean): any;
  20551. /**
  20552. * Release resources
  20553. */
  20554. dispose(): void;
  20555. }
  20556. }
  20557. declare module BABYLON {
  20558. /**
  20559. * Enum used to define the material modes
  20560. */
  20561. export enum NodeMaterialModes {
  20562. /** Regular material */
  20563. Material = 0,
  20564. /** For post process */
  20565. PostProcess = 1,
  20566. /** For particle system */
  20567. Particle = 2
  20568. }
  20569. }
  20570. declare module BABYLON {
  20571. /**
  20572. * Block used to read a texture from a sampler
  20573. */
  20574. export class TextureBlock extends NodeMaterialBlock {
  20575. private _defineName;
  20576. private _linearDefineName;
  20577. private _gammaDefineName;
  20578. private _tempTextureRead;
  20579. private _samplerName;
  20580. private _transformedUVName;
  20581. private _textureTransformName;
  20582. private _textureInfoName;
  20583. private _mainUVName;
  20584. private _mainUVDefineName;
  20585. private _fragmentOnly;
  20586. /**
  20587. * Gets or sets the texture associated with the node
  20588. */
  20589. texture: Nullable<Texture>;
  20590. /**
  20591. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20592. */
  20593. convertToGammaSpace: boolean;
  20594. /**
  20595. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20596. */
  20597. convertToLinearSpace: boolean;
  20598. /**
  20599. * Create a new TextureBlock
  20600. * @param name defines the block name
  20601. */
  20602. constructor(name: string, fragmentOnly?: boolean);
  20603. /**
  20604. * Gets the current class name
  20605. * @returns the class name
  20606. */
  20607. getClassName(): string;
  20608. /**
  20609. * Gets the uv input component
  20610. */
  20611. get uv(): NodeMaterialConnectionPoint;
  20612. /**
  20613. * Gets the rgba output component
  20614. */
  20615. get rgba(): NodeMaterialConnectionPoint;
  20616. /**
  20617. * Gets the rgb output component
  20618. */
  20619. get rgb(): NodeMaterialConnectionPoint;
  20620. /**
  20621. * Gets the r output component
  20622. */
  20623. get r(): NodeMaterialConnectionPoint;
  20624. /**
  20625. * Gets the g output component
  20626. */
  20627. get g(): NodeMaterialConnectionPoint;
  20628. /**
  20629. * Gets the b output component
  20630. */
  20631. get b(): NodeMaterialConnectionPoint;
  20632. /**
  20633. * Gets the a output component
  20634. */
  20635. get a(): NodeMaterialConnectionPoint;
  20636. get target(): NodeMaterialBlockTargets;
  20637. autoConfigure(material: NodeMaterial): void;
  20638. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20639. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20640. isReady(): boolean;
  20641. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20642. private get _isMixed();
  20643. private _injectVertexCode;
  20644. private _writeTextureRead;
  20645. private _writeOutput;
  20646. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20647. protected _dumpPropertiesCode(): string;
  20648. serialize(): any;
  20649. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20650. }
  20651. }
  20652. declare module BABYLON {
  20653. /** @hidden */
  20654. export var reflectionFunction: {
  20655. name: string;
  20656. shader: string;
  20657. };
  20658. }
  20659. declare module BABYLON {
  20660. /**
  20661. * Base block used to read a reflection texture from a sampler
  20662. */
  20663. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20664. /** @hidden */
  20665. _define3DName: string;
  20666. /** @hidden */
  20667. _defineCubicName: string;
  20668. /** @hidden */
  20669. _defineExplicitName: string;
  20670. /** @hidden */
  20671. _defineProjectionName: string;
  20672. /** @hidden */
  20673. _defineLocalCubicName: string;
  20674. /** @hidden */
  20675. _defineSphericalName: string;
  20676. /** @hidden */
  20677. _definePlanarName: string;
  20678. /** @hidden */
  20679. _defineEquirectangularName: string;
  20680. /** @hidden */
  20681. _defineMirroredEquirectangularFixedName: string;
  20682. /** @hidden */
  20683. _defineEquirectangularFixedName: string;
  20684. /** @hidden */
  20685. _defineSkyboxName: string;
  20686. /** @hidden */
  20687. _defineOppositeZ: string;
  20688. /** @hidden */
  20689. _cubeSamplerName: string;
  20690. /** @hidden */
  20691. _2DSamplerName: string;
  20692. protected _positionUVWName: string;
  20693. protected _directionWName: string;
  20694. protected _reflectionVectorName: string;
  20695. /** @hidden */
  20696. _reflectionCoordsName: string;
  20697. /** @hidden */
  20698. _reflectionMatrixName: string;
  20699. protected _reflectionColorName: string;
  20700. /**
  20701. * Gets or sets the texture associated with the node
  20702. */
  20703. texture: Nullable<BaseTexture>;
  20704. /**
  20705. * Create a new ReflectionTextureBaseBlock
  20706. * @param name defines the block name
  20707. */
  20708. constructor(name: string);
  20709. /**
  20710. * Gets the current class name
  20711. * @returns the class name
  20712. */
  20713. getClassName(): string;
  20714. /**
  20715. * Gets the world position input component
  20716. */
  20717. abstract get position(): NodeMaterialConnectionPoint;
  20718. /**
  20719. * Gets the world position input component
  20720. */
  20721. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20722. /**
  20723. * Gets the world normal input component
  20724. */
  20725. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20726. /**
  20727. * Gets the world input component
  20728. */
  20729. abstract get world(): NodeMaterialConnectionPoint;
  20730. /**
  20731. * Gets the camera (or eye) position component
  20732. */
  20733. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20734. /**
  20735. * Gets the view input component
  20736. */
  20737. abstract get view(): NodeMaterialConnectionPoint;
  20738. protected _getTexture(): Nullable<BaseTexture>;
  20739. autoConfigure(material: NodeMaterial): void;
  20740. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20741. isReady(): boolean;
  20742. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20743. /**
  20744. * Gets the code to inject in the vertex shader
  20745. * @param state current state of the node material building
  20746. * @returns the shader code
  20747. */
  20748. handleVertexSide(state: NodeMaterialBuildState): string;
  20749. /**
  20750. * Handles the inits for the fragment code path
  20751. * @param state node material build state
  20752. */
  20753. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20754. /**
  20755. * Generates the reflection coords code for the fragment code path
  20756. * @param worldNormalVarName name of the world normal variable
  20757. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20758. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20759. * @returns the shader code
  20760. */
  20761. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20762. /**
  20763. * Generates the reflection color code for the fragment code path
  20764. * @param lodVarName name of the lod variable
  20765. * @param swizzleLookupTexture swizzle to use for the final color variable
  20766. * @returns the shader code
  20767. */
  20768. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20769. /**
  20770. * Generates the code corresponding to the connected output points
  20771. * @param state node material build state
  20772. * @param varName name of the variable to output
  20773. * @returns the shader code
  20774. */
  20775. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20776. protected _buildBlock(state: NodeMaterialBuildState): this;
  20777. protected _dumpPropertiesCode(): string;
  20778. serialize(): any;
  20779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20780. }
  20781. }
  20782. declare module BABYLON {
  20783. /**
  20784. * Defines a connection point to be used for points with a custom object type
  20785. */
  20786. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20787. private _blockType;
  20788. private _blockName;
  20789. private _nameForCheking?;
  20790. /**
  20791. * Creates a new connection point
  20792. * @param name defines the connection point name
  20793. * @param ownerBlock defines the block hosting this connection point
  20794. * @param direction defines the direction of the connection point
  20795. */
  20796. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20797. /**
  20798. * Gets a number indicating if the current point can be connected to another point
  20799. * @param connectionPoint defines the other connection point
  20800. * @returns a number defining the compatibility state
  20801. */
  20802. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20803. /**
  20804. * Creates a block suitable to be used as an input for this input point.
  20805. * If null is returned, a block based on the point type will be created.
  20806. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  20807. */
  20808. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20809. }
  20810. }
  20811. declare module BABYLON {
  20812. /**
  20813. * Enum defining the type of properties that can be edited in the property pages in the NME
  20814. */
  20815. export enum PropertyTypeForEdition {
  20816. /** property is a boolean */
  20817. Boolean = 0,
  20818. /** property is a float */
  20819. Float = 1,
  20820. /** property is a Vector2 */
  20821. Vector2 = 2,
  20822. /** property is a list of values */
  20823. List = 3
  20824. }
  20825. /**
  20826. * Interface that defines an option in a variable of type list
  20827. */
  20828. export interface IEditablePropertyListOption {
  20829. /** label of the option */
  20830. "label": string;
  20831. /** value of the option */
  20832. "value": number;
  20833. }
  20834. /**
  20835. * Interface that defines the options available for an editable property
  20836. */
  20837. export interface IEditablePropertyOption {
  20838. /** min value */
  20839. "min"?: number;
  20840. /** max value */
  20841. "max"?: number;
  20842. /** notifiers: indicates which actions to take when the property is changed */
  20843. "notifiers"?: {
  20844. /** the material should be rebuilt */
  20845. "rebuild"?: boolean;
  20846. /** the preview should be updated */
  20847. "update"?: boolean;
  20848. };
  20849. /** list of the options for a variable of type list */
  20850. "options"?: IEditablePropertyListOption[];
  20851. }
  20852. /**
  20853. * Interface that describes an editable property
  20854. */
  20855. export interface IPropertyDescriptionForEdition {
  20856. /** name of the property */
  20857. "propertyName": string;
  20858. /** display name of the property */
  20859. "displayName": string;
  20860. /** type of the property */
  20861. "type": PropertyTypeForEdition;
  20862. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20863. "groupName": string;
  20864. /** options for the property */
  20865. "options": IEditablePropertyOption;
  20866. }
  20867. /**
  20868. * Decorator that flags a property in a node material block as being editable
  20869. */
  20870. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20871. }
  20872. declare module BABYLON {
  20873. /**
  20874. * Block used to implement the refraction part of the sub surface module of the PBR material
  20875. */
  20876. export class RefractionBlock extends NodeMaterialBlock {
  20877. /** @hidden */
  20878. _define3DName: string;
  20879. /** @hidden */
  20880. _refractionMatrixName: string;
  20881. /** @hidden */
  20882. _defineLODRefractionAlpha: string;
  20883. /** @hidden */
  20884. _defineLinearSpecularRefraction: string;
  20885. /** @hidden */
  20886. _defineOppositeZ: string;
  20887. /** @hidden */
  20888. _cubeSamplerName: string;
  20889. /** @hidden */
  20890. _2DSamplerName: string;
  20891. /** @hidden */
  20892. _vRefractionMicrosurfaceInfosName: string;
  20893. /** @hidden */
  20894. _vRefractionInfosName: string;
  20895. private _scene;
  20896. /**
  20897. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20898. * Materials half opaque for instance using refraction could benefit from this control.
  20899. */
  20900. linkRefractionWithTransparency: boolean;
  20901. /**
  20902. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20903. */
  20904. invertRefractionY: boolean;
  20905. /**
  20906. * Gets or sets the texture associated with the node
  20907. */
  20908. texture: Nullable<BaseTexture>;
  20909. /**
  20910. * Create a new RefractionBlock
  20911. * @param name defines the block name
  20912. */
  20913. constructor(name: string);
  20914. /**
  20915. * Gets the current class name
  20916. * @returns the class name
  20917. */
  20918. getClassName(): string;
  20919. /**
  20920. * Gets the intensity input component
  20921. */
  20922. get intensity(): NodeMaterialConnectionPoint;
  20923. /**
  20924. * Gets the index of refraction input component
  20925. */
  20926. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20927. /**
  20928. * Gets the tint at distance input component
  20929. */
  20930. get tintAtDistance(): NodeMaterialConnectionPoint;
  20931. /**
  20932. * Gets the view input component
  20933. */
  20934. get view(): NodeMaterialConnectionPoint;
  20935. /**
  20936. * Gets the refraction object output component
  20937. */
  20938. get refraction(): NodeMaterialConnectionPoint;
  20939. /**
  20940. * Returns true if the block has a texture
  20941. */
  20942. get hasTexture(): boolean;
  20943. protected _getTexture(): Nullable<BaseTexture>;
  20944. autoConfigure(material: NodeMaterial): void;
  20945. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20946. isReady(): boolean;
  20947. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20948. /**
  20949. * Gets the main code of the block (fragment side)
  20950. * @param state current state of the node material building
  20951. * @returns the shader code
  20952. */
  20953. getCode(state: NodeMaterialBuildState): string;
  20954. protected _buildBlock(state: NodeMaterialBuildState): this;
  20955. protected _dumpPropertiesCode(): string;
  20956. serialize(): any;
  20957. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20958. }
  20959. }
  20960. declare module BABYLON {
  20961. /**
  20962. * Base block used as input for post process
  20963. */
  20964. export class CurrentScreenBlock extends NodeMaterialBlock {
  20965. private _samplerName;
  20966. private _linearDefineName;
  20967. private _gammaDefineName;
  20968. private _mainUVName;
  20969. private _tempTextureRead;
  20970. /**
  20971. * Gets or sets the texture associated with the node
  20972. */
  20973. texture: Nullable<BaseTexture>;
  20974. /**
  20975. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20976. */
  20977. convertToGammaSpace: boolean;
  20978. /**
  20979. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20980. */
  20981. convertToLinearSpace: boolean;
  20982. /**
  20983. * Create a new CurrentScreenBlock
  20984. * @param name defines the block name
  20985. */
  20986. constructor(name: string);
  20987. /**
  20988. * Gets the current class name
  20989. * @returns the class name
  20990. */
  20991. getClassName(): string;
  20992. /**
  20993. * Gets the uv input component
  20994. */
  20995. get uv(): NodeMaterialConnectionPoint;
  20996. /**
  20997. * Gets the rgba output component
  20998. */
  20999. get rgba(): NodeMaterialConnectionPoint;
  21000. /**
  21001. * Gets the rgb output component
  21002. */
  21003. get rgb(): NodeMaterialConnectionPoint;
  21004. /**
  21005. * Gets the r output component
  21006. */
  21007. get r(): NodeMaterialConnectionPoint;
  21008. /**
  21009. * Gets the g output component
  21010. */
  21011. get g(): NodeMaterialConnectionPoint;
  21012. /**
  21013. * Gets the b output component
  21014. */
  21015. get b(): NodeMaterialConnectionPoint;
  21016. /**
  21017. * Gets the a output component
  21018. */
  21019. get a(): NodeMaterialConnectionPoint;
  21020. /**
  21021. * Initialize the block and prepare the context for build
  21022. * @param state defines the state that will be used for the build
  21023. */
  21024. initialize(state: NodeMaterialBuildState): void;
  21025. get target(): NodeMaterialBlockTargets;
  21026. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21027. isReady(): boolean;
  21028. private _injectVertexCode;
  21029. private _writeTextureRead;
  21030. private _writeOutput;
  21031. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21032. serialize(): any;
  21033. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21034. }
  21035. }
  21036. declare module BABYLON {
  21037. /**
  21038. * Base block used for the particle texture
  21039. */
  21040. export class ParticleTextureBlock extends NodeMaterialBlock {
  21041. private _samplerName;
  21042. private _linearDefineName;
  21043. private _gammaDefineName;
  21044. private _tempTextureRead;
  21045. /**
  21046. * Gets or sets the texture associated with the node
  21047. */
  21048. texture: Nullable<BaseTexture>;
  21049. /**
  21050. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21051. */
  21052. convertToGammaSpace: boolean;
  21053. /**
  21054. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21055. */
  21056. convertToLinearSpace: boolean;
  21057. /**
  21058. * Create a new ParticleTextureBlock
  21059. * @param name defines the block name
  21060. */
  21061. constructor(name: string);
  21062. /**
  21063. * Gets the current class name
  21064. * @returns the class name
  21065. */
  21066. getClassName(): string;
  21067. /**
  21068. * Gets the uv input component
  21069. */
  21070. get uv(): NodeMaterialConnectionPoint;
  21071. /**
  21072. * Gets the rgba output component
  21073. */
  21074. get rgba(): NodeMaterialConnectionPoint;
  21075. /**
  21076. * Gets the rgb output component
  21077. */
  21078. get rgb(): NodeMaterialConnectionPoint;
  21079. /**
  21080. * Gets the r output component
  21081. */
  21082. get r(): NodeMaterialConnectionPoint;
  21083. /**
  21084. * Gets the g output component
  21085. */
  21086. get g(): NodeMaterialConnectionPoint;
  21087. /**
  21088. * Gets the b output component
  21089. */
  21090. get b(): NodeMaterialConnectionPoint;
  21091. /**
  21092. * Gets the a output component
  21093. */
  21094. get a(): NodeMaterialConnectionPoint;
  21095. /**
  21096. * Initialize the block and prepare the context for build
  21097. * @param state defines the state that will be used for the build
  21098. */
  21099. initialize(state: NodeMaterialBuildState): void;
  21100. autoConfigure(material: NodeMaterial): void;
  21101. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21102. isReady(): boolean;
  21103. private _writeOutput;
  21104. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21105. serialize(): any;
  21106. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21107. }
  21108. }
  21109. declare module BABYLON {
  21110. /**
  21111. * Class used to store shared data between 2 NodeMaterialBuildState
  21112. */
  21113. export class NodeMaterialBuildStateSharedData {
  21114. /**
  21115. * Gets the list of emitted varyings
  21116. */
  21117. temps: string[];
  21118. /**
  21119. * Gets the list of emitted varyings
  21120. */
  21121. varyings: string[];
  21122. /**
  21123. * Gets the varying declaration string
  21124. */
  21125. varyingDeclaration: string;
  21126. /**
  21127. * Input blocks
  21128. */
  21129. inputBlocks: InputBlock[];
  21130. /**
  21131. * Input blocks
  21132. */
  21133. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21134. /**
  21135. * Bindable blocks (Blocks that need to set data to the effect)
  21136. */
  21137. bindableBlocks: NodeMaterialBlock[];
  21138. /**
  21139. * List of blocks that can provide a compilation fallback
  21140. */
  21141. blocksWithFallbacks: NodeMaterialBlock[];
  21142. /**
  21143. * List of blocks that can provide a define update
  21144. */
  21145. blocksWithDefines: NodeMaterialBlock[];
  21146. /**
  21147. * List of blocks that can provide a repeatable content
  21148. */
  21149. repeatableContentBlocks: NodeMaterialBlock[];
  21150. /**
  21151. * List of blocks that can provide a dynamic list of uniforms
  21152. */
  21153. dynamicUniformBlocks: NodeMaterialBlock[];
  21154. /**
  21155. * List of blocks that can block the isReady function for the material
  21156. */
  21157. blockingBlocks: NodeMaterialBlock[];
  21158. /**
  21159. * Gets the list of animated inputs
  21160. */
  21161. animatedInputs: InputBlock[];
  21162. /**
  21163. * Build Id used to avoid multiple recompilations
  21164. */
  21165. buildId: number;
  21166. /** List of emitted variables */
  21167. variableNames: {
  21168. [key: string]: number;
  21169. };
  21170. /** List of emitted defines */
  21171. defineNames: {
  21172. [key: string]: number;
  21173. };
  21174. /** Should emit comments? */
  21175. emitComments: boolean;
  21176. /** Emit build activity */
  21177. verbose: boolean;
  21178. /** Gets or sets the hosting scene */
  21179. scene: Scene;
  21180. /**
  21181. * Gets the compilation hints emitted at compilation time
  21182. */
  21183. hints: {
  21184. needWorldViewMatrix: boolean;
  21185. needWorldViewProjectionMatrix: boolean;
  21186. needAlphaBlending: boolean;
  21187. needAlphaTesting: boolean;
  21188. };
  21189. /**
  21190. * List of compilation checks
  21191. */
  21192. checks: {
  21193. emitVertex: boolean;
  21194. emitFragment: boolean;
  21195. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21196. };
  21197. /**
  21198. * Is vertex program allowed to be empty?
  21199. */
  21200. allowEmptyVertexProgram: boolean;
  21201. /** Creates a new shared data */
  21202. constructor();
  21203. /**
  21204. * Emits console errors and exceptions if there is a failing check
  21205. */
  21206. emitErrors(): void;
  21207. }
  21208. }
  21209. declare module BABYLON {
  21210. /**
  21211. * Class used to store node based material build state
  21212. */
  21213. export class NodeMaterialBuildState {
  21214. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21215. supportUniformBuffers: boolean;
  21216. /**
  21217. * Gets the list of emitted attributes
  21218. */
  21219. attributes: string[];
  21220. /**
  21221. * Gets the list of emitted uniforms
  21222. */
  21223. uniforms: string[];
  21224. /**
  21225. * Gets the list of emitted constants
  21226. */
  21227. constants: string[];
  21228. /**
  21229. * Gets the list of emitted samplers
  21230. */
  21231. samplers: string[];
  21232. /**
  21233. * Gets the list of emitted functions
  21234. */
  21235. functions: {
  21236. [key: string]: string;
  21237. };
  21238. /**
  21239. * Gets the list of emitted extensions
  21240. */
  21241. extensions: {
  21242. [key: string]: string;
  21243. };
  21244. /**
  21245. * Gets the target of the compilation state
  21246. */
  21247. target: NodeMaterialBlockTargets;
  21248. /**
  21249. * Gets the list of emitted counters
  21250. */
  21251. counters: {
  21252. [key: string]: number;
  21253. };
  21254. /**
  21255. * Shared data between multiple NodeMaterialBuildState instances
  21256. */
  21257. sharedData: NodeMaterialBuildStateSharedData;
  21258. /** @hidden */
  21259. _vertexState: NodeMaterialBuildState;
  21260. /** @hidden */
  21261. _attributeDeclaration: string;
  21262. /** @hidden */
  21263. _uniformDeclaration: string;
  21264. /** @hidden */
  21265. _constantDeclaration: string;
  21266. /** @hidden */
  21267. _samplerDeclaration: string;
  21268. /** @hidden */
  21269. _varyingTransfer: string;
  21270. /** @hidden */
  21271. _injectAtEnd: string;
  21272. private _repeatableContentAnchorIndex;
  21273. /** @hidden */
  21274. _builtCompilationString: string;
  21275. /**
  21276. * Gets the emitted compilation strings
  21277. */
  21278. compilationString: string;
  21279. /**
  21280. * Finalize the compilation strings
  21281. * @param state defines the current compilation state
  21282. */
  21283. finalize(state: NodeMaterialBuildState): void;
  21284. /** @hidden */
  21285. get _repeatableContentAnchor(): string;
  21286. /** @hidden */
  21287. _getFreeVariableName(prefix: string): string;
  21288. /** @hidden */
  21289. _getFreeDefineName(prefix: string): string;
  21290. /** @hidden */
  21291. _excludeVariableName(name: string): void;
  21292. /** @hidden */
  21293. _emit2DSampler(name: string): void;
  21294. /** @hidden */
  21295. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21296. /** @hidden */
  21297. _emitExtension(name: string, extension: string, define?: string): void;
  21298. /** @hidden */
  21299. _emitFunction(name: string, code: string, comments: string): void;
  21300. /** @hidden */
  21301. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21302. replaceStrings?: {
  21303. search: RegExp;
  21304. replace: string;
  21305. }[];
  21306. repeatKey?: string;
  21307. }): string;
  21308. /** @hidden */
  21309. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21310. repeatKey?: string;
  21311. removeAttributes?: boolean;
  21312. removeUniforms?: boolean;
  21313. removeVaryings?: boolean;
  21314. removeIfDef?: boolean;
  21315. replaceStrings?: {
  21316. search: RegExp;
  21317. replace: string;
  21318. }[];
  21319. }, storeKey?: string): void;
  21320. /** @hidden */
  21321. _registerTempVariable(name: string): boolean;
  21322. /** @hidden */
  21323. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21324. /** @hidden */
  21325. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21326. /** @hidden */
  21327. _emitFloat(value: number): string;
  21328. }
  21329. }
  21330. declare module BABYLON {
  21331. /**
  21332. * Helper class used to generate session unique ID
  21333. */
  21334. export class UniqueIdGenerator {
  21335. private static _UniqueIdCounter;
  21336. /**
  21337. * Gets an unique (relatively to the current scene) Id
  21338. */
  21339. static get UniqueId(): number;
  21340. }
  21341. }
  21342. declare module BABYLON {
  21343. /**
  21344. * Defines a block that can be used inside a node based material
  21345. */
  21346. export class NodeMaterialBlock {
  21347. private _buildId;
  21348. private _buildTarget;
  21349. private _target;
  21350. private _isFinalMerger;
  21351. private _isInput;
  21352. protected _isUnique: boolean;
  21353. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21354. inputsAreExclusive: boolean;
  21355. /** @hidden */
  21356. _codeVariableName: string;
  21357. /** @hidden */
  21358. _inputs: NodeMaterialConnectionPoint[];
  21359. /** @hidden */
  21360. _outputs: NodeMaterialConnectionPoint[];
  21361. /** @hidden */
  21362. _preparationId: number;
  21363. /**
  21364. * Gets or sets the name of the block
  21365. */
  21366. name: string;
  21367. /**
  21368. * Gets or sets the unique id of the node
  21369. */
  21370. uniqueId: number;
  21371. /**
  21372. * Gets or sets the comments associated with this block
  21373. */
  21374. comments: string;
  21375. /**
  21376. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21377. */
  21378. get isUnique(): boolean;
  21379. /**
  21380. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21381. */
  21382. get isFinalMerger(): boolean;
  21383. /**
  21384. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21385. */
  21386. get isInput(): boolean;
  21387. /**
  21388. * Gets or sets the build Id
  21389. */
  21390. get buildId(): number;
  21391. set buildId(value: number);
  21392. /**
  21393. * Gets or sets the target of the block
  21394. */
  21395. get target(): NodeMaterialBlockTargets;
  21396. set target(value: NodeMaterialBlockTargets);
  21397. /**
  21398. * Gets the list of input points
  21399. */
  21400. get inputs(): NodeMaterialConnectionPoint[];
  21401. /** Gets the list of output points */
  21402. get outputs(): NodeMaterialConnectionPoint[];
  21403. /**
  21404. * Find an input by its name
  21405. * @param name defines the name of the input to look for
  21406. * @returns the input or null if not found
  21407. */
  21408. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21409. /**
  21410. * Find an output by its name
  21411. * @param name defines the name of the outputto look for
  21412. * @returns the output or null if not found
  21413. */
  21414. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21415. /**
  21416. * Creates a new NodeMaterialBlock
  21417. * @param name defines the block name
  21418. * @param target defines the target of that block (Vertex by default)
  21419. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21420. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21421. */
  21422. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21423. /**
  21424. * Initialize the block and prepare the context for build
  21425. * @param state defines the state that will be used for the build
  21426. */
  21427. initialize(state: NodeMaterialBuildState): void;
  21428. /**
  21429. * Bind data to effect. Will only be called for blocks with isBindable === true
  21430. * @param effect defines the effect to bind data to
  21431. * @param nodeMaterial defines the hosting NodeMaterial
  21432. * @param mesh defines the mesh that will be rendered
  21433. * @param subMesh defines the submesh that will be rendered
  21434. */
  21435. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21436. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21437. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21438. protected _writeFloat(value: number): string;
  21439. /**
  21440. * Gets the current class name e.g. "NodeMaterialBlock"
  21441. * @returns the class name
  21442. */
  21443. getClassName(): string;
  21444. /**
  21445. * Register a new input. Must be called inside a block constructor
  21446. * @param name defines the connection point name
  21447. * @param type defines the connection point type
  21448. * @param isOptional defines a boolean indicating that this input can be omitted
  21449. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21450. * @param point an already created connection point. If not provided, create a new one
  21451. * @returns the current block
  21452. */
  21453. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21454. /**
  21455. * Register a new output. Must be called inside a block constructor
  21456. * @param name defines the connection point name
  21457. * @param type defines the connection point type
  21458. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21459. * @param point an already created connection point. If not provided, create a new one
  21460. * @returns the current block
  21461. */
  21462. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21463. /**
  21464. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21465. * @param forOutput defines an optional connection point to check compatibility with
  21466. * @returns the first available input or null
  21467. */
  21468. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21469. /**
  21470. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21471. * @param forBlock defines an optional block to check compatibility with
  21472. * @returns the first available input or null
  21473. */
  21474. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21475. /**
  21476. * Gets the sibling of the given output
  21477. * @param current defines the current output
  21478. * @returns the next output in the list or null
  21479. */
  21480. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21481. /**
  21482. * Connect current block with another block
  21483. * @param other defines the block to connect with
  21484. * @param options define the various options to help pick the right connections
  21485. * @returns the current block
  21486. */
  21487. connectTo(other: NodeMaterialBlock, options?: {
  21488. input?: string;
  21489. output?: string;
  21490. outputSwizzle?: string;
  21491. }): this | undefined;
  21492. protected _buildBlock(state: NodeMaterialBuildState): void;
  21493. /**
  21494. * Add uniforms, samplers and uniform buffers at compilation time
  21495. * @param state defines the state to update
  21496. * @param nodeMaterial defines the node material requesting the update
  21497. * @param defines defines the material defines to update
  21498. * @param uniformBuffers defines the list of uniform buffer names
  21499. */
  21500. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21501. /**
  21502. * Add potential fallbacks if shader compilation fails
  21503. * @param mesh defines the mesh to be rendered
  21504. * @param fallbacks defines the current prioritized list of fallbacks
  21505. */
  21506. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21507. /**
  21508. * Initialize defines for shader compilation
  21509. * @param mesh defines the mesh to be rendered
  21510. * @param nodeMaterial defines the node material requesting the update
  21511. * @param defines defines the material defines to update
  21512. * @param useInstances specifies that instances should be used
  21513. */
  21514. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21515. /**
  21516. * Update defines for shader compilation
  21517. * @param mesh defines the mesh to be rendered
  21518. * @param nodeMaterial defines the node material requesting the update
  21519. * @param defines defines the material defines to update
  21520. * @param useInstances specifies that instances should be used
  21521. * @param subMesh defines which submesh to render
  21522. */
  21523. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21524. /**
  21525. * Lets the block try to connect some inputs automatically
  21526. * @param material defines the hosting NodeMaterial
  21527. */
  21528. autoConfigure(material: NodeMaterial): void;
  21529. /**
  21530. * Function called when a block is declared as repeatable content generator
  21531. * @param vertexShaderState defines the current compilation state for the vertex shader
  21532. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21533. * @param mesh defines the mesh to be rendered
  21534. * @param defines defines the material defines to update
  21535. */
  21536. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21537. /**
  21538. * Checks if the block is ready
  21539. * @param mesh defines the mesh to be rendered
  21540. * @param nodeMaterial defines the node material requesting the update
  21541. * @param defines defines the material defines to update
  21542. * @param useInstances specifies that instances should be used
  21543. * @returns true if the block is ready
  21544. */
  21545. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21546. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21547. private _processBuild;
  21548. /**
  21549. * Compile the current node and generate the shader code
  21550. * @param state defines the current compilation state (uniforms, samplers, current string)
  21551. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21552. * @returns true if already built
  21553. */
  21554. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21555. protected _inputRename(name: string): string;
  21556. protected _outputRename(name: string): string;
  21557. protected _dumpPropertiesCode(): string;
  21558. /** @hidden */
  21559. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21560. /** @hidden */
  21561. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21562. /**
  21563. * Clone the current block to a new identical block
  21564. * @param scene defines the hosting scene
  21565. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21566. * @returns a copy of the current block
  21567. */
  21568. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21569. /**
  21570. * Serializes this block in a JSON representation
  21571. * @returns the serialized block object
  21572. */
  21573. serialize(): any;
  21574. /** @hidden */
  21575. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21576. private _deserializePortDisplayNamesAndExposedOnFrame;
  21577. /**
  21578. * Release resources
  21579. */
  21580. dispose(): void;
  21581. }
  21582. }
  21583. declare module BABYLON {
  21584. /**
  21585. * Base class of materials working in push mode in babylon JS
  21586. * @hidden
  21587. */
  21588. export class PushMaterial extends Material {
  21589. protected _activeEffect: Effect;
  21590. protected _normalMatrix: Matrix;
  21591. constructor(name: string, scene: Scene);
  21592. getEffect(): Effect;
  21593. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21594. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21595. /**
  21596. * Binds the given world matrix to the active effect
  21597. *
  21598. * @param world the matrix to bind
  21599. */
  21600. bindOnlyWorldMatrix(world: Matrix): void;
  21601. /**
  21602. * Binds the given normal matrix to the active effect
  21603. *
  21604. * @param normalMatrix the matrix to bind
  21605. */
  21606. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21607. bind(world: Matrix, mesh?: Mesh): void;
  21608. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21609. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21610. }
  21611. }
  21612. declare module BABYLON {
  21613. /**
  21614. * Root class for all node material optimizers
  21615. */
  21616. export class NodeMaterialOptimizer {
  21617. /**
  21618. * Function used to optimize a NodeMaterial graph
  21619. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21620. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21621. */
  21622. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21623. }
  21624. }
  21625. declare module BABYLON {
  21626. /**
  21627. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21628. */
  21629. export class TransformBlock extends NodeMaterialBlock {
  21630. /**
  21631. * Defines the value to use to complement W value to transform it to a Vector4
  21632. */
  21633. complementW: number;
  21634. /**
  21635. * Defines the value to use to complement z value to transform it to a Vector4
  21636. */
  21637. complementZ: number;
  21638. /**
  21639. * Creates a new TransformBlock
  21640. * @param name defines the block name
  21641. */
  21642. constructor(name: string);
  21643. /**
  21644. * Gets the current class name
  21645. * @returns the class name
  21646. */
  21647. getClassName(): string;
  21648. /**
  21649. * Gets the vector input
  21650. */
  21651. get vector(): NodeMaterialConnectionPoint;
  21652. /**
  21653. * Gets the output component
  21654. */
  21655. get output(): NodeMaterialConnectionPoint;
  21656. /**
  21657. * Gets the xyz output component
  21658. */
  21659. get xyz(): NodeMaterialConnectionPoint;
  21660. /**
  21661. * Gets the matrix transform input
  21662. */
  21663. get transform(): NodeMaterialConnectionPoint;
  21664. protected _buildBlock(state: NodeMaterialBuildState): this;
  21665. /**
  21666. * Update defines for shader compilation
  21667. * @param mesh defines the mesh to be rendered
  21668. * @param nodeMaterial defines the node material requesting the update
  21669. * @param defines defines the material defines to update
  21670. * @param useInstances specifies that instances should be used
  21671. * @param subMesh defines which submesh to render
  21672. */
  21673. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21674. serialize(): any;
  21675. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21676. protected _dumpPropertiesCode(): string;
  21677. }
  21678. }
  21679. declare module BABYLON {
  21680. /**
  21681. * Block used to output the vertex position
  21682. */
  21683. export class VertexOutputBlock extends NodeMaterialBlock {
  21684. /**
  21685. * Creates a new VertexOutputBlock
  21686. * @param name defines the block name
  21687. */
  21688. constructor(name: string);
  21689. /**
  21690. * Gets the current class name
  21691. * @returns the class name
  21692. */
  21693. getClassName(): string;
  21694. /**
  21695. * Gets the vector input component
  21696. */
  21697. get vector(): NodeMaterialConnectionPoint;
  21698. protected _buildBlock(state: NodeMaterialBuildState): this;
  21699. }
  21700. }
  21701. declare module BABYLON {
  21702. /**
  21703. * Block used to output the final color
  21704. */
  21705. export class FragmentOutputBlock extends NodeMaterialBlock {
  21706. /**
  21707. * Create a new FragmentOutputBlock
  21708. * @param name defines the block name
  21709. */
  21710. constructor(name: string);
  21711. /**
  21712. * Gets the current class name
  21713. * @returns the class name
  21714. */
  21715. getClassName(): string;
  21716. /**
  21717. * Gets the rgba input component
  21718. */
  21719. get rgba(): NodeMaterialConnectionPoint;
  21720. /**
  21721. * Gets the rgb input component
  21722. */
  21723. get rgb(): NodeMaterialConnectionPoint;
  21724. /**
  21725. * Gets the a input component
  21726. */
  21727. get a(): NodeMaterialConnectionPoint;
  21728. protected _buildBlock(state: NodeMaterialBuildState): this;
  21729. }
  21730. }
  21731. declare module BABYLON {
  21732. /**
  21733. * Block used for the particle ramp gradient section
  21734. */
  21735. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21736. /**
  21737. * Create a new ParticleRampGradientBlock
  21738. * @param name defines the block name
  21739. */
  21740. constructor(name: string);
  21741. /**
  21742. * Gets the current class name
  21743. * @returns the class name
  21744. */
  21745. getClassName(): string;
  21746. /**
  21747. * Gets the color input component
  21748. */
  21749. get color(): NodeMaterialConnectionPoint;
  21750. /**
  21751. * Gets the rampColor output component
  21752. */
  21753. get rampColor(): NodeMaterialConnectionPoint;
  21754. /**
  21755. * Initialize the block and prepare the context for build
  21756. * @param state defines the state that will be used for the build
  21757. */
  21758. initialize(state: NodeMaterialBuildState): void;
  21759. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21760. }
  21761. }
  21762. declare module BABYLON {
  21763. /**
  21764. * Block used for the particle blend multiply section
  21765. */
  21766. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21767. /**
  21768. * Create a new ParticleBlendMultiplyBlock
  21769. * @param name defines the block name
  21770. */
  21771. constructor(name: string);
  21772. /**
  21773. * Gets the current class name
  21774. * @returns the class name
  21775. */
  21776. getClassName(): string;
  21777. /**
  21778. * Gets the color input component
  21779. */
  21780. get color(): NodeMaterialConnectionPoint;
  21781. /**
  21782. * Gets the alphaTexture input component
  21783. */
  21784. get alphaTexture(): NodeMaterialConnectionPoint;
  21785. /**
  21786. * Gets the alphaColor input component
  21787. */
  21788. get alphaColor(): NodeMaterialConnectionPoint;
  21789. /**
  21790. * Gets the blendColor output component
  21791. */
  21792. get blendColor(): NodeMaterialConnectionPoint;
  21793. /**
  21794. * Initialize the block and prepare the context for build
  21795. * @param state defines the state that will be used for the build
  21796. */
  21797. initialize(state: NodeMaterialBuildState): void;
  21798. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21799. }
  21800. }
  21801. declare module BABYLON {
  21802. /**
  21803. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21804. */
  21805. export class VectorMergerBlock extends NodeMaterialBlock {
  21806. /**
  21807. * Create a new VectorMergerBlock
  21808. * @param name defines the block name
  21809. */
  21810. constructor(name: string);
  21811. /**
  21812. * Gets the current class name
  21813. * @returns the class name
  21814. */
  21815. getClassName(): string;
  21816. /**
  21817. * Gets the xyz component (input)
  21818. */
  21819. get xyzIn(): NodeMaterialConnectionPoint;
  21820. /**
  21821. * Gets the xy component (input)
  21822. */
  21823. get xyIn(): NodeMaterialConnectionPoint;
  21824. /**
  21825. * Gets the x component (input)
  21826. */
  21827. get x(): NodeMaterialConnectionPoint;
  21828. /**
  21829. * Gets the y component (input)
  21830. */
  21831. get y(): NodeMaterialConnectionPoint;
  21832. /**
  21833. * Gets the z component (input)
  21834. */
  21835. get z(): NodeMaterialConnectionPoint;
  21836. /**
  21837. * Gets the w component (input)
  21838. */
  21839. get w(): NodeMaterialConnectionPoint;
  21840. /**
  21841. * Gets the xyzw component (output)
  21842. */
  21843. get xyzw(): NodeMaterialConnectionPoint;
  21844. /**
  21845. * Gets the xyz component (output)
  21846. */
  21847. get xyzOut(): NodeMaterialConnectionPoint;
  21848. /**
  21849. * Gets the xy component (output)
  21850. */
  21851. get xyOut(): NodeMaterialConnectionPoint;
  21852. /**
  21853. * Gets the xy component (output)
  21854. * @deprecated Please use xyOut instead.
  21855. */
  21856. get xy(): NodeMaterialConnectionPoint;
  21857. /**
  21858. * Gets the xyz component (output)
  21859. * @deprecated Please use xyzOut instead.
  21860. */
  21861. get xyz(): NodeMaterialConnectionPoint;
  21862. protected _buildBlock(state: NodeMaterialBuildState): this;
  21863. }
  21864. }
  21865. declare module BABYLON {
  21866. /**
  21867. * Block used to remap a float from a range to a new one
  21868. */
  21869. export class RemapBlock extends NodeMaterialBlock {
  21870. /**
  21871. * Gets or sets the source range
  21872. */
  21873. sourceRange: Vector2;
  21874. /**
  21875. * Gets or sets the target range
  21876. */
  21877. targetRange: Vector2;
  21878. /**
  21879. * Creates a new RemapBlock
  21880. * @param name defines the block name
  21881. */
  21882. constructor(name: string);
  21883. /**
  21884. * Gets the current class name
  21885. * @returns the class name
  21886. */
  21887. getClassName(): string;
  21888. /**
  21889. * Gets the input component
  21890. */
  21891. get input(): NodeMaterialConnectionPoint;
  21892. /**
  21893. * Gets the source min input component
  21894. */
  21895. get sourceMin(): NodeMaterialConnectionPoint;
  21896. /**
  21897. * Gets the source max input component
  21898. */
  21899. get sourceMax(): NodeMaterialConnectionPoint;
  21900. /**
  21901. * Gets the target min input component
  21902. */
  21903. get targetMin(): NodeMaterialConnectionPoint;
  21904. /**
  21905. * Gets the target max input component
  21906. */
  21907. get targetMax(): NodeMaterialConnectionPoint;
  21908. /**
  21909. * Gets the output component
  21910. */
  21911. get output(): NodeMaterialConnectionPoint;
  21912. protected _buildBlock(state: NodeMaterialBuildState): this;
  21913. protected _dumpPropertiesCode(): string;
  21914. serialize(): any;
  21915. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21916. }
  21917. }
  21918. declare module BABYLON {
  21919. /**
  21920. * Block used to multiply 2 values
  21921. */
  21922. export class MultiplyBlock extends NodeMaterialBlock {
  21923. /**
  21924. * Creates a new MultiplyBlock
  21925. * @param name defines the block name
  21926. */
  21927. constructor(name: string);
  21928. /**
  21929. * Gets the current class name
  21930. * @returns the class name
  21931. */
  21932. getClassName(): string;
  21933. /**
  21934. * Gets the left operand input component
  21935. */
  21936. get left(): NodeMaterialConnectionPoint;
  21937. /**
  21938. * Gets the right operand input component
  21939. */
  21940. get right(): NodeMaterialConnectionPoint;
  21941. /**
  21942. * Gets the output component
  21943. */
  21944. get output(): NodeMaterialConnectionPoint;
  21945. protected _buildBlock(state: NodeMaterialBuildState): this;
  21946. }
  21947. }
  21948. declare module BABYLON {
  21949. /**
  21950. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21951. */
  21952. export class ColorSplitterBlock extends NodeMaterialBlock {
  21953. /**
  21954. * Create a new ColorSplitterBlock
  21955. * @param name defines the block name
  21956. */
  21957. constructor(name: string);
  21958. /**
  21959. * Gets the current class name
  21960. * @returns the class name
  21961. */
  21962. getClassName(): string;
  21963. /**
  21964. * Gets the rgba component (input)
  21965. */
  21966. get rgba(): NodeMaterialConnectionPoint;
  21967. /**
  21968. * Gets the rgb component (input)
  21969. */
  21970. get rgbIn(): NodeMaterialConnectionPoint;
  21971. /**
  21972. * Gets the rgb component (output)
  21973. */
  21974. get rgbOut(): NodeMaterialConnectionPoint;
  21975. /**
  21976. * Gets the r component (output)
  21977. */
  21978. get r(): NodeMaterialConnectionPoint;
  21979. /**
  21980. * Gets the g component (output)
  21981. */
  21982. get g(): NodeMaterialConnectionPoint;
  21983. /**
  21984. * Gets the b component (output)
  21985. */
  21986. get b(): NodeMaterialConnectionPoint;
  21987. /**
  21988. * Gets the a component (output)
  21989. */
  21990. get a(): NodeMaterialConnectionPoint;
  21991. protected _inputRename(name: string): string;
  21992. protected _outputRename(name: string): string;
  21993. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21994. }
  21995. }
  21996. declare module BABYLON {
  21997. /**
  21998. * Interface used to configure the node material editor
  21999. */
  22000. export interface INodeMaterialEditorOptions {
  22001. /** Define the URl to load node editor script */
  22002. editorURL?: string;
  22003. }
  22004. /** @hidden */
  22005. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22006. NORMAL: boolean;
  22007. TANGENT: boolean;
  22008. UV1: boolean;
  22009. /** BONES */
  22010. NUM_BONE_INFLUENCERS: number;
  22011. BonesPerMesh: number;
  22012. BONETEXTURE: boolean;
  22013. /** MORPH TARGETS */
  22014. MORPHTARGETS: boolean;
  22015. MORPHTARGETS_NORMAL: boolean;
  22016. MORPHTARGETS_TANGENT: boolean;
  22017. MORPHTARGETS_UV: boolean;
  22018. NUM_MORPH_INFLUENCERS: number;
  22019. /** IMAGE PROCESSING */
  22020. IMAGEPROCESSING: boolean;
  22021. VIGNETTE: boolean;
  22022. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22023. VIGNETTEBLENDMODEOPAQUE: boolean;
  22024. TONEMAPPING: boolean;
  22025. TONEMAPPING_ACES: boolean;
  22026. CONTRAST: boolean;
  22027. EXPOSURE: boolean;
  22028. COLORCURVES: boolean;
  22029. COLORGRADING: boolean;
  22030. COLORGRADING3D: boolean;
  22031. SAMPLER3DGREENDEPTH: boolean;
  22032. SAMPLER3DBGRMAP: boolean;
  22033. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22034. /** MISC. */
  22035. BUMPDIRECTUV: number;
  22036. constructor();
  22037. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22038. }
  22039. /**
  22040. * Class used to configure NodeMaterial
  22041. */
  22042. export interface INodeMaterialOptions {
  22043. /**
  22044. * Defines if blocks should emit comments
  22045. */
  22046. emitComments: boolean;
  22047. }
  22048. /**
  22049. * Class used to create a node based material built by assembling shader blocks
  22050. */
  22051. export class NodeMaterial extends PushMaterial {
  22052. private static _BuildIdGenerator;
  22053. private _options;
  22054. private _vertexCompilationState;
  22055. private _fragmentCompilationState;
  22056. private _sharedData;
  22057. private _buildId;
  22058. private _buildWasSuccessful;
  22059. private _cachedWorldViewMatrix;
  22060. private _cachedWorldViewProjectionMatrix;
  22061. private _optimizers;
  22062. private _animationFrame;
  22063. /** Define the Url to load node editor script */
  22064. static EditorURL: string;
  22065. /** Define the Url to load snippets */
  22066. static SnippetUrl: string;
  22067. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22068. static IgnoreTexturesAtLoadTime: boolean;
  22069. private BJSNODEMATERIALEDITOR;
  22070. /** Get the inspector from bundle or global */
  22071. private _getGlobalNodeMaterialEditor;
  22072. /**
  22073. * Snippet ID if the material was created from the snippet server
  22074. */
  22075. snippetId: string;
  22076. /**
  22077. * Gets or sets data used by visual editor
  22078. * @see https://nme.babylonjs.com
  22079. */
  22080. editorData: any;
  22081. /**
  22082. * 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)
  22083. */
  22084. ignoreAlpha: boolean;
  22085. /**
  22086. * Defines the maximum number of lights that can be used in the material
  22087. */
  22088. maxSimultaneousLights: number;
  22089. /**
  22090. * Observable raised when the material is built
  22091. */
  22092. onBuildObservable: Observable<NodeMaterial>;
  22093. /**
  22094. * Gets or sets the root nodes of the material vertex shader
  22095. */
  22096. _vertexOutputNodes: NodeMaterialBlock[];
  22097. /**
  22098. * Gets or sets the root nodes of the material fragment (pixel) shader
  22099. */
  22100. _fragmentOutputNodes: NodeMaterialBlock[];
  22101. /** Gets or sets options to control the node material overall behavior */
  22102. get options(): INodeMaterialOptions;
  22103. set options(options: INodeMaterialOptions);
  22104. /**
  22105. * Default configuration related to image processing available in the standard Material.
  22106. */
  22107. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22108. /**
  22109. * Gets the image processing configuration used either in this material.
  22110. */
  22111. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22112. /**
  22113. * Sets the Default image processing configuration used either in the this material.
  22114. *
  22115. * If sets to null, the scene one is in use.
  22116. */
  22117. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22118. /**
  22119. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22120. */
  22121. attachedBlocks: NodeMaterialBlock[];
  22122. /**
  22123. * Specifies the mode of the node material
  22124. * @hidden
  22125. */
  22126. _mode: NodeMaterialModes;
  22127. /**
  22128. * Gets the mode property
  22129. */
  22130. get mode(): NodeMaterialModes;
  22131. /**
  22132. * Create a new node based material
  22133. * @param name defines the material name
  22134. * @param scene defines the hosting scene
  22135. * @param options defines creation option
  22136. */
  22137. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22138. /**
  22139. * Gets the current class name of the material e.g. "NodeMaterial"
  22140. * @returns the class name
  22141. */
  22142. getClassName(): string;
  22143. /**
  22144. * Keep track of the image processing observer to allow dispose and replace.
  22145. */
  22146. private _imageProcessingObserver;
  22147. /**
  22148. * Attaches a new image processing configuration to the Standard Material.
  22149. * @param configuration
  22150. */
  22151. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22152. /**
  22153. * Get a block by its name
  22154. * @param name defines the name of the block to retrieve
  22155. * @returns the required block or null if not found
  22156. */
  22157. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22158. /**
  22159. * Get a block by its name
  22160. * @param predicate defines the predicate used to find the good candidate
  22161. * @returns the required block or null if not found
  22162. */
  22163. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22164. /**
  22165. * Get an input block by its name
  22166. * @param predicate defines the predicate used to find the good candidate
  22167. * @returns the required input block or null if not found
  22168. */
  22169. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22170. /**
  22171. * Gets the list of input blocks attached to this material
  22172. * @returns an array of InputBlocks
  22173. */
  22174. getInputBlocks(): InputBlock[];
  22175. /**
  22176. * Adds a new optimizer to the list of optimizers
  22177. * @param optimizer defines the optimizers to add
  22178. * @returns the current material
  22179. */
  22180. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22181. /**
  22182. * Remove an optimizer from the list of optimizers
  22183. * @param optimizer defines the optimizers to remove
  22184. * @returns the current material
  22185. */
  22186. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22187. /**
  22188. * Add a new block to the list of output nodes
  22189. * @param node defines the node to add
  22190. * @returns the current material
  22191. */
  22192. addOutputNode(node: NodeMaterialBlock): this;
  22193. /**
  22194. * Remove a block from the list of root nodes
  22195. * @param node defines the node to remove
  22196. * @returns the current material
  22197. */
  22198. removeOutputNode(node: NodeMaterialBlock): this;
  22199. private _addVertexOutputNode;
  22200. private _removeVertexOutputNode;
  22201. private _addFragmentOutputNode;
  22202. private _removeFragmentOutputNode;
  22203. /**
  22204. * Specifies if the material will require alpha blending
  22205. * @returns a boolean specifying if alpha blending is needed
  22206. */
  22207. needAlphaBlending(): boolean;
  22208. /**
  22209. * Specifies if this material should be rendered in alpha test mode
  22210. * @returns a boolean specifying if an alpha test is needed.
  22211. */
  22212. needAlphaTesting(): boolean;
  22213. private _initializeBlock;
  22214. private _resetDualBlocks;
  22215. /**
  22216. * Remove a block from the current node material
  22217. * @param block defines the block to remove
  22218. */
  22219. removeBlock(block: NodeMaterialBlock): void;
  22220. /**
  22221. * Build the material and generates the inner effect
  22222. * @param verbose defines if the build should log activity
  22223. */
  22224. build(verbose?: boolean): void;
  22225. /**
  22226. * Runs an otpimization phase to try to improve the shader code
  22227. */
  22228. optimize(): void;
  22229. private _prepareDefinesForAttributes;
  22230. /**
  22231. * Create a post process from the material
  22232. * @param camera The camera to apply the render pass to.
  22233. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22235. * @param engine The engine which the post process will be applied. (default: current engine)
  22236. * @param reusable If the post process can be reused on the same frame. (default: false)
  22237. * @param textureType Type of textures used when performing the post process. (default: 0)
  22238. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22239. * @returns the post process created
  22240. */
  22241. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22242. /**
  22243. * Create the post process effect from the material
  22244. * @param postProcess The post process to create the effect for
  22245. */
  22246. createEffectForPostProcess(postProcess: PostProcess): void;
  22247. private _createEffectOrPostProcess;
  22248. private _createEffectForParticles;
  22249. /**
  22250. * Create the effect to be used as the custom effect for a particle system
  22251. * @param particleSystem Particle system to create the effect for
  22252. * @param onCompiled defines a function to call when the effect creation is successful
  22253. * @param onError defines a function to call when the effect creation has failed
  22254. */
  22255. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22256. private _processDefines;
  22257. /**
  22258. * Get if the submesh is ready to be used and all its information available.
  22259. * Child classes can use it to update shaders
  22260. * @param mesh defines the mesh to check
  22261. * @param subMesh defines which submesh to check
  22262. * @param useInstances specifies that instances should be used
  22263. * @returns a boolean indicating that the submesh is ready or not
  22264. */
  22265. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22266. /**
  22267. * Get a string representing the shaders built by the current node graph
  22268. */
  22269. get compiledShaders(): string;
  22270. /**
  22271. * Binds the world matrix to the material
  22272. * @param world defines the world transformation matrix
  22273. */
  22274. bindOnlyWorldMatrix(world: Matrix): void;
  22275. /**
  22276. * Binds the submesh to this material by preparing the effect and shader to draw
  22277. * @param world defines the world transformation matrix
  22278. * @param mesh defines the mesh containing the submesh
  22279. * @param subMesh defines the submesh to bind the material to
  22280. */
  22281. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22282. /**
  22283. * Gets the active textures from the material
  22284. * @returns an array of textures
  22285. */
  22286. getActiveTextures(): BaseTexture[];
  22287. /**
  22288. * Gets the list of texture blocks
  22289. * @returns an array of texture blocks
  22290. */
  22291. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22292. /**
  22293. * Specifies if the material uses a texture
  22294. * @param texture defines the texture to check against the material
  22295. * @returns a boolean specifying if the material uses the texture
  22296. */
  22297. hasTexture(texture: BaseTexture): boolean;
  22298. /**
  22299. * Disposes the material
  22300. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22301. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22302. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22303. */
  22304. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22305. /** Creates the node editor window. */
  22306. private _createNodeEditor;
  22307. /**
  22308. * Launch the node material editor
  22309. * @param config Define the configuration of the editor
  22310. * @return a promise fulfilled when the node editor is visible
  22311. */
  22312. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22313. /**
  22314. * Clear the current material
  22315. */
  22316. clear(): void;
  22317. /**
  22318. * Clear the current material and set it to a default state
  22319. */
  22320. setToDefault(): void;
  22321. /**
  22322. * Clear the current material and set it to a default state for post process
  22323. */
  22324. setToDefaultPostProcess(): void;
  22325. /**
  22326. * Clear the current material and set it to a default state for particle
  22327. */
  22328. setToDefaultParticle(): void;
  22329. /**
  22330. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22331. * @param url defines the url to load from
  22332. * @returns a promise that will fullfil when the material is fully loaded
  22333. */
  22334. loadAsync(url: string): Promise<void>;
  22335. private _gatherBlocks;
  22336. /**
  22337. * Generate a string containing the code declaration required to create an equivalent of this material
  22338. * @returns a string
  22339. */
  22340. generateCode(): string;
  22341. /**
  22342. * Serializes this material in a JSON representation
  22343. * @returns the serialized material object
  22344. */
  22345. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22346. private _restoreConnections;
  22347. /**
  22348. * Clear the current graph and load a new one from a serialization object
  22349. * @param source defines the JSON representation of the material
  22350. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22351. * @param merge defines whether or not the source must be merged or replace the current content
  22352. */
  22353. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22354. /**
  22355. * Makes a duplicate of the current material.
  22356. * @param name - name to use for the new material.
  22357. */
  22358. clone(name: string): NodeMaterial;
  22359. /**
  22360. * Creates a node material from parsed material data
  22361. * @param source defines the JSON representation of the material
  22362. * @param scene defines the hosting scene
  22363. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22364. * @returns a new node material
  22365. */
  22366. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22367. /**
  22368. * Creates a node material from a snippet saved in a remote file
  22369. * @param name defines the name of the material to create
  22370. * @param url defines the url to load from
  22371. * @param scene defines the hosting scene
  22372. * @returns a promise that will resolve to the new node material
  22373. */
  22374. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22375. /**
  22376. * Creates a node material from a snippet saved by the node material editor
  22377. * @param snippetId defines the snippet to load
  22378. * @param scene defines the hosting scene
  22379. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22380. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22381. * @returns a promise that will resolve to the new node material
  22382. */
  22383. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22384. /**
  22385. * Creates a new node material set to default basic configuration
  22386. * @param name defines the name of the material
  22387. * @param scene defines the hosting scene
  22388. * @returns a new NodeMaterial
  22389. */
  22390. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22391. }
  22392. }
  22393. declare module BABYLON {
  22394. /**
  22395. * Size options for a post process
  22396. */
  22397. export type PostProcessOptions = {
  22398. width: number;
  22399. height: number;
  22400. };
  22401. /**
  22402. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22403. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22404. */
  22405. export class PostProcess {
  22406. /** Name of the PostProcess. */
  22407. name: string;
  22408. /**
  22409. * Gets or sets the unique id of the post process
  22410. */
  22411. uniqueId: number;
  22412. /**
  22413. * Width of the texture to apply the post process on
  22414. */
  22415. width: number;
  22416. /**
  22417. * Height of the texture to apply the post process on
  22418. */
  22419. height: number;
  22420. /**
  22421. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22422. */
  22423. nodeMaterialSource: Nullable<NodeMaterial>;
  22424. /**
  22425. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22426. * @hidden
  22427. */
  22428. _outputTexture: Nullable<InternalTexture>;
  22429. /**
  22430. * Sampling mode used by the shader
  22431. * See https://doc.babylonjs.com/classes/3.1/texture
  22432. */
  22433. renderTargetSamplingMode: number;
  22434. /**
  22435. * Clear color to use when screen clearing
  22436. */
  22437. clearColor: Color4;
  22438. /**
  22439. * If the buffer needs to be cleared before applying the post process. (default: true)
  22440. * Should be set to false if shader will overwrite all previous pixels.
  22441. */
  22442. autoClear: boolean;
  22443. /**
  22444. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22445. */
  22446. alphaMode: number;
  22447. /**
  22448. * Sets the setAlphaBlendConstants of the babylon engine
  22449. */
  22450. alphaConstants: Color4;
  22451. /**
  22452. * Animations to be used for the post processing
  22453. */
  22454. animations: Animation[];
  22455. /**
  22456. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22457. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22458. */
  22459. enablePixelPerfectMode: boolean;
  22460. /**
  22461. * Force the postprocess to be applied without taking in account viewport
  22462. */
  22463. forceFullscreenViewport: boolean;
  22464. /**
  22465. * List of inspectable custom properties (used by the Inspector)
  22466. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22467. */
  22468. inspectableCustomProperties: IInspectable[];
  22469. /**
  22470. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22471. *
  22472. * | Value | Type | Description |
  22473. * | ----- | ----------------------------------- | ----------- |
  22474. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22475. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22476. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22477. *
  22478. */
  22479. scaleMode: number;
  22480. /**
  22481. * Force textures to be a power of two (default: false)
  22482. */
  22483. alwaysForcePOT: boolean;
  22484. private _samples;
  22485. /**
  22486. * Number of sample textures (default: 1)
  22487. */
  22488. get samples(): number;
  22489. set samples(n: number);
  22490. /**
  22491. * Modify the scale of the post process to be the same as the viewport (default: false)
  22492. */
  22493. adaptScaleToCurrentViewport: boolean;
  22494. private _camera;
  22495. private _scene;
  22496. private _engine;
  22497. private _options;
  22498. private _reusable;
  22499. private _textureType;
  22500. private _textureFormat;
  22501. /**
  22502. * Smart array of input and output textures for the post process.
  22503. * @hidden
  22504. */
  22505. _textures: SmartArray<InternalTexture>;
  22506. /**
  22507. * The index in _textures that corresponds to the output texture.
  22508. * @hidden
  22509. */
  22510. _currentRenderTextureInd: number;
  22511. private _effect;
  22512. private _samplers;
  22513. private _fragmentUrl;
  22514. private _vertexUrl;
  22515. private _parameters;
  22516. private _scaleRatio;
  22517. protected _indexParameters: any;
  22518. private _shareOutputWithPostProcess;
  22519. private _texelSize;
  22520. private _forcedOutputTexture;
  22521. /**
  22522. * Returns the fragment url or shader name used in the post process.
  22523. * @returns the fragment url or name in the shader store.
  22524. */
  22525. getEffectName(): string;
  22526. /**
  22527. * An event triggered when the postprocess is activated.
  22528. */
  22529. onActivateObservable: Observable<Camera>;
  22530. private _onActivateObserver;
  22531. /**
  22532. * A function that is added to the onActivateObservable
  22533. */
  22534. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22535. /**
  22536. * An event triggered when the postprocess changes its size.
  22537. */
  22538. onSizeChangedObservable: Observable<PostProcess>;
  22539. private _onSizeChangedObserver;
  22540. /**
  22541. * A function that is added to the onSizeChangedObservable
  22542. */
  22543. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22544. /**
  22545. * An event triggered when the postprocess applies its effect.
  22546. */
  22547. onApplyObservable: Observable<Effect>;
  22548. private _onApplyObserver;
  22549. /**
  22550. * A function that is added to the onApplyObservable
  22551. */
  22552. set onApply(callback: (effect: Effect) => void);
  22553. /**
  22554. * An event triggered before rendering the postprocess
  22555. */
  22556. onBeforeRenderObservable: Observable<Effect>;
  22557. private _onBeforeRenderObserver;
  22558. /**
  22559. * A function that is added to the onBeforeRenderObservable
  22560. */
  22561. set onBeforeRender(callback: (effect: Effect) => void);
  22562. /**
  22563. * An event triggered after rendering the postprocess
  22564. */
  22565. onAfterRenderObservable: Observable<Effect>;
  22566. private _onAfterRenderObserver;
  22567. /**
  22568. * A function that is added to the onAfterRenderObservable
  22569. */
  22570. set onAfterRender(callback: (efect: Effect) => void);
  22571. /**
  22572. * 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
  22573. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22574. */
  22575. get inputTexture(): InternalTexture;
  22576. set inputTexture(value: InternalTexture);
  22577. /**
  22578. * Gets the camera which post process is applied to.
  22579. * @returns The camera the post process is applied to.
  22580. */
  22581. getCamera(): Camera;
  22582. /**
  22583. * Gets the texel size of the postprocess.
  22584. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22585. */
  22586. get texelSize(): Vector2;
  22587. /**
  22588. * Creates a new instance PostProcess
  22589. * @param name The name of the PostProcess.
  22590. * @param fragmentUrl The url of the fragment shader to be used.
  22591. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22592. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22593. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22594. * @param camera The camera to apply the render pass to.
  22595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22596. * @param engine The engine which the post process will be applied. (default: current engine)
  22597. * @param reusable If the post process can be reused on the same frame. (default: false)
  22598. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22599. * @param textureType Type of textures used when performing the post process. (default: 0)
  22600. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22601. * @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
  22602. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22603. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22604. */
  22605. constructor(
  22606. /** Name of the PostProcess. */
  22607. 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);
  22608. /**
  22609. * Gets a string idenfifying the name of the class
  22610. * @returns "PostProcess" string
  22611. */
  22612. getClassName(): string;
  22613. /**
  22614. * Gets the engine which this post process belongs to.
  22615. * @returns The engine the post process was enabled with.
  22616. */
  22617. getEngine(): Engine;
  22618. /**
  22619. * The effect that is created when initializing the post process.
  22620. * @returns The created effect corresponding the the postprocess.
  22621. */
  22622. getEffect(): Effect;
  22623. /**
  22624. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22625. * @param postProcess The post process to share the output with.
  22626. * @returns This post process.
  22627. */
  22628. shareOutputWith(postProcess: PostProcess): PostProcess;
  22629. /**
  22630. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22631. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22632. */
  22633. useOwnOutput(): void;
  22634. /**
  22635. * Updates the effect with the current post process compile time values and recompiles the shader.
  22636. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22637. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22638. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22639. * @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
  22640. * @param onCompiled Called when the shader has been compiled.
  22641. * @param onError Called if there is an error when compiling a shader.
  22642. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22643. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22644. */
  22645. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  22646. /**
  22647. * The post process is reusable if it can be used multiple times within one frame.
  22648. * @returns If the post process is reusable
  22649. */
  22650. isReusable(): boolean;
  22651. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22652. markTextureDirty(): void;
  22653. /**
  22654. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22655. * 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.
  22656. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22657. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22658. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22659. * @returns The target texture that was bound to be written to.
  22660. */
  22661. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22662. /**
  22663. * If the post process is supported.
  22664. */
  22665. get isSupported(): boolean;
  22666. /**
  22667. * The aspect ratio of the output texture.
  22668. */
  22669. get aspectRatio(): number;
  22670. /**
  22671. * Get a value indicating if the post-process is ready to be used
  22672. * @returns true if the post-process is ready (shader is compiled)
  22673. */
  22674. isReady(): boolean;
  22675. /**
  22676. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22677. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22678. */
  22679. apply(): Nullable<Effect>;
  22680. private _disposeTextures;
  22681. /**
  22682. * Disposes the post process.
  22683. * @param camera The camera to dispose the post process on.
  22684. */
  22685. dispose(camera?: Camera): void;
  22686. }
  22687. }
  22688. declare module BABYLON {
  22689. /** @hidden */
  22690. export var kernelBlurVaryingDeclaration: {
  22691. name: string;
  22692. shader: string;
  22693. };
  22694. }
  22695. declare module BABYLON {
  22696. /** @hidden */
  22697. export var kernelBlurFragment: {
  22698. name: string;
  22699. shader: string;
  22700. };
  22701. }
  22702. declare module BABYLON {
  22703. /** @hidden */
  22704. export var kernelBlurFragment2: {
  22705. name: string;
  22706. shader: string;
  22707. };
  22708. }
  22709. declare module BABYLON {
  22710. /** @hidden */
  22711. export var kernelBlurPixelShader: {
  22712. name: string;
  22713. shader: string;
  22714. };
  22715. }
  22716. declare module BABYLON {
  22717. /** @hidden */
  22718. export var kernelBlurVertex: {
  22719. name: string;
  22720. shader: string;
  22721. };
  22722. }
  22723. declare module BABYLON {
  22724. /** @hidden */
  22725. export var kernelBlurVertexShader: {
  22726. name: string;
  22727. shader: string;
  22728. };
  22729. }
  22730. declare module BABYLON {
  22731. /**
  22732. * The Blur Post Process which blurs an image based on a kernel and direction.
  22733. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22734. */
  22735. export class BlurPostProcess extends PostProcess {
  22736. /** The direction in which to blur the image. */
  22737. direction: Vector2;
  22738. private blockCompilation;
  22739. protected _kernel: number;
  22740. protected _idealKernel: number;
  22741. protected _packedFloat: boolean;
  22742. private _staticDefines;
  22743. /**
  22744. * Sets the length in pixels of the blur sample region
  22745. */
  22746. set kernel(v: number);
  22747. /**
  22748. * Gets the length in pixels of the blur sample region
  22749. */
  22750. get kernel(): number;
  22751. /**
  22752. * Sets wether or not the blur needs to unpack/repack floats
  22753. */
  22754. set packedFloat(v: boolean);
  22755. /**
  22756. * Gets wether or not the blur is unpacking/repacking floats
  22757. */
  22758. get packedFloat(): boolean;
  22759. /**
  22760. * Creates a new instance BlurPostProcess
  22761. * @param name The name of the effect.
  22762. * @param direction The direction in which to blur the image.
  22763. * @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.
  22764. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22765. * @param camera The camera to apply the render pass to.
  22766. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22767. * @param engine The engine which the post process will be applied. (default: current engine)
  22768. * @param reusable If the post process can be reused on the same frame. (default: false)
  22769. * @param textureType Type of textures used when performing the post process. (default: 0)
  22770. * @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)
  22771. */
  22772. constructor(name: string,
  22773. /** The direction in which to blur the image. */
  22774. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22775. /**
  22776. * Updates the effect with the current post process compile time values and recompiles the shader.
  22777. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22778. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22779. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22780. * @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
  22781. * @param onCompiled Called when the shader has been compiled.
  22782. * @param onError Called if there is an error when compiling a shader.
  22783. */
  22784. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22785. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22786. /**
  22787. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22788. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22789. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22790. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22791. * The gaps between physical kernels are compensated for in the weighting of the samples
  22792. * @param idealKernel Ideal blur kernel.
  22793. * @return Nearest best kernel.
  22794. */
  22795. protected _nearestBestKernel(idealKernel: number): number;
  22796. /**
  22797. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22798. * @param x The point on the Gaussian distribution to sample.
  22799. * @return the value of the Gaussian function at x.
  22800. */
  22801. protected _gaussianWeight(x: number): number;
  22802. /**
  22803. * Generates a string that can be used as a floating point number in GLSL.
  22804. * @param x Value to print.
  22805. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22806. * @return GLSL float string.
  22807. */
  22808. protected _glslFloat(x: number, decimalFigures?: number): string;
  22809. }
  22810. }
  22811. declare module BABYLON {
  22812. /**
  22813. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22814. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22815. * You can then easily use it as a reflectionTexture on a flat surface.
  22816. * In case the surface is not a plane, please consider relying on reflection probes.
  22817. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22818. */
  22819. export class MirrorTexture extends RenderTargetTexture {
  22820. private scene;
  22821. /**
  22822. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22823. * 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.
  22824. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22825. */
  22826. mirrorPlane: Plane;
  22827. /**
  22828. * Define the blur ratio used to blur the reflection if needed.
  22829. */
  22830. set blurRatio(value: number);
  22831. get blurRatio(): number;
  22832. /**
  22833. * Define the adaptive blur kernel used to blur the reflection if needed.
  22834. * This will autocompute the closest best match for the `blurKernel`
  22835. */
  22836. set adaptiveBlurKernel(value: number);
  22837. /**
  22838. * Define the blur kernel used to blur the reflection if needed.
  22839. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22840. */
  22841. set blurKernel(value: number);
  22842. /**
  22843. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22844. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22845. */
  22846. set blurKernelX(value: number);
  22847. get blurKernelX(): number;
  22848. /**
  22849. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22850. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22851. */
  22852. set blurKernelY(value: number);
  22853. get blurKernelY(): number;
  22854. private _autoComputeBlurKernel;
  22855. protected _onRatioRescale(): void;
  22856. private _updateGammaSpace;
  22857. private _imageProcessingConfigChangeObserver;
  22858. private _transformMatrix;
  22859. private _mirrorMatrix;
  22860. private _savedViewMatrix;
  22861. private _blurX;
  22862. private _blurY;
  22863. private _adaptiveBlurKernel;
  22864. private _blurKernelX;
  22865. private _blurKernelY;
  22866. private _blurRatio;
  22867. /**
  22868. * Instantiates a Mirror Texture.
  22869. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22870. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22871. * You can then easily use it as a reflectionTexture on a flat surface.
  22872. * In case the surface is not a plane, please consider relying on reflection probes.
  22873. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22874. * @param name
  22875. * @param size
  22876. * @param scene
  22877. * @param generateMipMaps
  22878. * @param type
  22879. * @param samplingMode
  22880. * @param generateDepthBuffer
  22881. */
  22882. constructor(name: string, size: number | {
  22883. width: number;
  22884. height: number;
  22885. } | {
  22886. ratio: number;
  22887. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22888. private _preparePostProcesses;
  22889. /**
  22890. * Clone the mirror texture.
  22891. * @returns the cloned texture
  22892. */
  22893. clone(): MirrorTexture;
  22894. /**
  22895. * Serialize the texture to a JSON representation you could use in Parse later on
  22896. * @returns the serialized JSON representation
  22897. */
  22898. serialize(): any;
  22899. /**
  22900. * Dispose the texture and release its associated resources.
  22901. */
  22902. dispose(): void;
  22903. }
  22904. }
  22905. declare module BABYLON {
  22906. /**
  22907. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22908. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22909. */
  22910. export class Texture extends BaseTexture {
  22911. /**
  22912. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22913. */
  22914. static SerializeBuffers: boolean;
  22915. /** @hidden */
  22916. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22917. /** @hidden */
  22918. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22919. /** @hidden */
  22920. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22921. /** nearest is mag = nearest and min = nearest and mip = linear */
  22922. static readonly NEAREST_SAMPLINGMODE: number;
  22923. /** nearest is mag = nearest and min = nearest and mip = linear */
  22924. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22925. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22926. static readonly BILINEAR_SAMPLINGMODE: number;
  22927. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22928. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22929. /** Trilinear is mag = linear and min = linear and mip = linear */
  22930. static readonly TRILINEAR_SAMPLINGMODE: number;
  22931. /** Trilinear is mag = linear and min = linear and mip = linear */
  22932. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22933. /** mag = nearest and min = nearest and mip = nearest */
  22934. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22935. /** mag = nearest and min = linear and mip = nearest */
  22936. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22937. /** mag = nearest and min = linear and mip = linear */
  22938. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22939. /** mag = nearest and min = linear and mip = none */
  22940. static readonly NEAREST_LINEAR: number;
  22941. /** mag = nearest and min = nearest and mip = none */
  22942. static readonly NEAREST_NEAREST: number;
  22943. /** mag = linear and min = nearest and mip = nearest */
  22944. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22945. /** mag = linear and min = nearest and mip = linear */
  22946. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22947. /** mag = linear and min = linear and mip = none */
  22948. static readonly LINEAR_LINEAR: number;
  22949. /** mag = linear and min = nearest and mip = none */
  22950. static readonly LINEAR_NEAREST: number;
  22951. /** Explicit coordinates mode */
  22952. static readonly EXPLICIT_MODE: number;
  22953. /** Spherical coordinates mode */
  22954. static readonly SPHERICAL_MODE: number;
  22955. /** Planar coordinates mode */
  22956. static readonly PLANAR_MODE: number;
  22957. /** Cubic coordinates mode */
  22958. static readonly CUBIC_MODE: number;
  22959. /** Projection coordinates mode */
  22960. static readonly PROJECTION_MODE: number;
  22961. /** Inverse Cubic coordinates mode */
  22962. static readonly SKYBOX_MODE: number;
  22963. /** Inverse Cubic coordinates mode */
  22964. static readonly INVCUBIC_MODE: number;
  22965. /** Equirectangular coordinates mode */
  22966. static readonly EQUIRECTANGULAR_MODE: number;
  22967. /** Equirectangular Fixed coordinates mode */
  22968. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22969. /** Equirectangular Fixed Mirrored coordinates mode */
  22970. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22971. /** Texture is not repeating outside of 0..1 UVs */
  22972. static readonly CLAMP_ADDRESSMODE: number;
  22973. /** Texture is repeating outside of 0..1 UVs */
  22974. static readonly WRAP_ADDRESSMODE: number;
  22975. /** Texture is repeating and mirrored */
  22976. static readonly MIRROR_ADDRESSMODE: number;
  22977. /**
  22978. * 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
  22979. */
  22980. static UseSerializedUrlIfAny: boolean;
  22981. /**
  22982. * Define the url of the texture.
  22983. */
  22984. url: Nullable<string>;
  22985. /**
  22986. * Define an offset on the texture to offset the u coordinates of the UVs
  22987. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22988. */
  22989. uOffset: number;
  22990. /**
  22991. * Define an offset on the texture to offset the v coordinates of the UVs
  22992. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22993. */
  22994. vOffset: number;
  22995. /**
  22996. * Define an offset on the texture to scale the u coordinates of the UVs
  22997. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22998. */
  22999. uScale: number;
  23000. /**
  23001. * Define an offset on the texture to scale the v coordinates of the UVs
  23002. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23003. */
  23004. vScale: number;
  23005. /**
  23006. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23007. * @see http://doc.babylonjs.com/how_to/more_materials
  23008. */
  23009. uAng: number;
  23010. /**
  23011. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23012. * @see http://doc.babylonjs.com/how_to/more_materials
  23013. */
  23014. vAng: number;
  23015. /**
  23016. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23017. * @see http://doc.babylonjs.com/how_to/more_materials
  23018. */
  23019. wAng: number;
  23020. /**
  23021. * Defines the center of rotation (U)
  23022. */
  23023. uRotationCenter: number;
  23024. /**
  23025. * Defines the center of rotation (V)
  23026. */
  23027. vRotationCenter: number;
  23028. /**
  23029. * Defines the center of rotation (W)
  23030. */
  23031. wRotationCenter: number;
  23032. /**
  23033. * Are mip maps generated for this texture or not.
  23034. */
  23035. get noMipmap(): boolean;
  23036. /**
  23037. * List of inspectable custom properties (used by the Inspector)
  23038. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23039. */
  23040. inspectableCustomProperties: Nullable<IInspectable[]>;
  23041. private _noMipmap;
  23042. /** @hidden */
  23043. _invertY: boolean;
  23044. private _rowGenerationMatrix;
  23045. private _cachedTextureMatrix;
  23046. private _projectionModeMatrix;
  23047. private _t0;
  23048. private _t1;
  23049. private _t2;
  23050. private _cachedUOffset;
  23051. private _cachedVOffset;
  23052. private _cachedUScale;
  23053. private _cachedVScale;
  23054. private _cachedUAng;
  23055. private _cachedVAng;
  23056. private _cachedWAng;
  23057. private _cachedProjectionMatrixId;
  23058. private _cachedCoordinatesMode;
  23059. /** @hidden */
  23060. protected _initialSamplingMode: number;
  23061. /** @hidden */
  23062. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23063. private _deleteBuffer;
  23064. protected _format: Nullable<number>;
  23065. private _delayedOnLoad;
  23066. private _delayedOnError;
  23067. private _mimeType?;
  23068. /**
  23069. * Observable triggered once the texture has been loaded.
  23070. */
  23071. onLoadObservable: Observable<Texture>;
  23072. protected _isBlocking: boolean;
  23073. /**
  23074. * Is the texture preventing material to render while loading.
  23075. * If false, a default texture will be used instead of the loading one during the preparation step.
  23076. */
  23077. set isBlocking(value: boolean);
  23078. get isBlocking(): boolean;
  23079. /**
  23080. * Get the current sampling mode associated with the texture.
  23081. */
  23082. get samplingMode(): number;
  23083. /**
  23084. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23085. */
  23086. get invertY(): boolean;
  23087. /**
  23088. * Instantiates a new texture.
  23089. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23090. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23091. * @param url defines the url of the picture to load as a texture
  23092. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23093. * @param noMipmap defines if the texture will require mip maps or not
  23094. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23095. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23096. * @param onLoad defines a callback triggered when the texture has been loaded
  23097. * @param onError defines a callback triggered when an error occurred during the loading session
  23098. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23099. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23100. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23101. * @param mimeType defines an optional mime type information
  23102. */
  23103. 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);
  23104. /**
  23105. * Update the url (and optional buffer) of this texture if url was null during construction.
  23106. * @param url the url of the texture
  23107. * @param buffer the buffer of the texture (defaults to null)
  23108. * @param onLoad callback called when the texture is loaded (defaults to null)
  23109. */
  23110. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23111. /**
  23112. * Finish the loading sequence of a texture flagged as delayed load.
  23113. * @hidden
  23114. */
  23115. delayLoad(): void;
  23116. private _prepareRowForTextureGeneration;
  23117. /**
  23118. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23119. * @returns the transform matrix of the texture.
  23120. */
  23121. getTextureMatrix(uBase?: number): Matrix;
  23122. /**
  23123. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23124. * @returns The reflection texture transform
  23125. */
  23126. getReflectionTextureMatrix(): Matrix;
  23127. /**
  23128. * Clones the texture.
  23129. * @returns the cloned texture
  23130. */
  23131. clone(): Texture;
  23132. /**
  23133. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23134. * @returns The JSON representation of the texture
  23135. */
  23136. serialize(): any;
  23137. /**
  23138. * Get the current class name of the texture useful for serialization or dynamic coding.
  23139. * @returns "Texture"
  23140. */
  23141. getClassName(): string;
  23142. /**
  23143. * Dispose the texture and release its associated resources.
  23144. */
  23145. dispose(): void;
  23146. /**
  23147. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23148. * @param parsedTexture Define the JSON representation of the texture
  23149. * @param scene Define the scene the parsed texture should be instantiated in
  23150. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23151. * @returns The parsed texture if successful
  23152. */
  23153. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23154. /**
  23155. * Creates a texture from its base 64 representation.
  23156. * @param data Define the base64 payload without the data: prefix
  23157. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23158. * @param scene Define the scene the texture should belong to
  23159. * @param noMipmap Forces the texture to not create mip map information if true
  23160. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23161. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23162. * @param onLoad define a callback triggered when the texture has been loaded
  23163. * @param onError define a callback triggered when an error occurred during the loading session
  23164. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23165. * @returns the created texture
  23166. */
  23167. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23168. /**
  23169. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23170. * @param data Define the base64 payload without the data: prefix
  23171. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23172. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23173. * @param scene Define the scene the texture should belong to
  23174. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23175. * @param noMipmap Forces the texture to not create mip map information if true
  23176. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23177. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23178. * @param onLoad define a callback triggered when the texture has been loaded
  23179. * @param onError define a callback triggered when an error occurred during the loading session
  23180. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23181. * @returns the created texture
  23182. */
  23183. 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;
  23184. }
  23185. }
  23186. declare module BABYLON {
  23187. /**
  23188. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23189. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23190. */
  23191. export class PostProcessManager {
  23192. private _scene;
  23193. private _indexBuffer;
  23194. private _vertexBuffers;
  23195. /**
  23196. * Creates a new instance PostProcess
  23197. * @param scene The scene that the post process is associated with.
  23198. */
  23199. constructor(scene: Scene);
  23200. private _prepareBuffers;
  23201. private _buildIndexBuffer;
  23202. /**
  23203. * Rebuilds the vertex buffers of the manager.
  23204. * @hidden
  23205. */
  23206. _rebuild(): void;
  23207. /**
  23208. * Prepares a frame to be run through a post process.
  23209. * @param sourceTexture The input texture to the post procesess. (default: null)
  23210. * @param postProcesses An array of post processes to be run. (default: null)
  23211. * @returns True if the post processes were able to be run.
  23212. * @hidden
  23213. */
  23214. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23215. /**
  23216. * Manually render a set of post processes to a texture.
  23217. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23218. * @param postProcesses An array of post processes to be run.
  23219. * @param targetTexture The target texture to render to.
  23220. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23221. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23222. * @param lodLevel defines which lod of the texture to render to
  23223. */
  23224. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23225. /**
  23226. * Finalize the result of the output of the postprocesses.
  23227. * @param doNotPresent If true the result will not be displayed to the screen.
  23228. * @param targetTexture The target texture to render to.
  23229. * @param faceIndex The index of the face to bind the target texture to.
  23230. * @param postProcesses The array of post processes to render.
  23231. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23232. * @hidden
  23233. */
  23234. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23235. /**
  23236. * Disposes of the post process manager.
  23237. */
  23238. dispose(): void;
  23239. }
  23240. }
  23241. declare module BABYLON {
  23242. /**
  23243. * This Helps creating a texture that will be created from a camera in your scene.
  23244. * It is basically a dynamic texture that could be used to create special effects for instance.
  23245. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23246. */
  23247. export class RenderTargetTexture extends Texture {
  23248. isCube: boolean;
  23249. /**
  23250. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23251. */
  23252. static readonly REFRESHRATE_RENDER_ONCE: number;
  23253. /**
  23254. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23255. */
  23256. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23257. /**
  23258. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23259. * the central point of your effect and can save a lot of performances.
  23260. */
  23261. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23262. /**
  23263. * Use this predicate to dynamically define the list of mesh you want to render.
  23264. * If set, the renderList property will be overwritten.
  23265. */
  23266. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23267. private _renderList;
  23268. /**
  23269. * Use this list to define the list of mesh you want to render.
  23270. */
  23271. get renderList(): Nullable<Array<AbstractMesh>>;
  23272. set renderList(value: Nullable<Array<AbstractMesh>>);
  23273. /**
  23274. * Use this function to overload the renderList array at rendering time.
  23275. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23276. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23277. * the cube (if the RTT is a cube, else layerOrFace=0).
  23278. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23279. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23280. * hold dummy elements!
  23281. */
  23282. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23283. private _hookArray;
  23284. /**
  23285. * Define if particles should be rendered in your texture.
  23286. */
  23287. renderParticles: boolean;
  23288. /**
  23289. * Define if sprites should be rendered in your texture.
  23290. */
  23291. renderSprites: boolean;
  23292. /**
  23293. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23294. */
  23295. coordinatesMode: number;
  23296. /**
  23297. * Define the camera used to render the texture.
  23298. */
  23299. activeCamera: Nullable<Camera>;
  23300. /**
  23301. * Override the mesh isReady function with your own one.
  23302. */
  23303. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23304. /**
  23305. * Override the render function of the texture with your own one.
  23306. */
  23307. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23308. /**
  23309. * Define if camera post processes should be use while rendering the texture.
  23310. */
  23311. useCameraPostProcesses: boolean;
  23312. /**
  23313. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23314. */
  23315. ignoreCameraViewport: boolean;
  23316. private _postProcessManager;
  23317. private _postProcesses;
  23318. private _resizeObserver;
  23319. /**
  23320. * An event triggered when the texture is unbind.
  23321. */
  23322. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23323. /**
  23324. * An event triggered when the texture is unbind.
  23325. */
  23326. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23327. private _onAfterUnbindObserver;
  23328. /**
  23329. * Set a after unbind callback in the texture.
  23330. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23331. */
  23332. set onAfterUnbind(callback: () => void);
  23333. /**
  23334. * An event triggered before rendering the texture
  23335. */
  23336. onBeforeRenderObservable: Observable<number>;
  23337. private _onBeforeRenderObserver;
  23338. /**
  23339. * Set a before render callback in the texture.
  23340. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23341. */
  23342. set onBeforeRender(callback: (faceIndex: number) => void);
  23343. /**
  23344. * An event triggered after rendering the texture
  23345. */
  23346. onAfterRenderObservable: Observable<number>;
  23347. private _onAfterRenderObserver;
  23348. /**
  23349. * Set a after render callback in the texture.
  23350. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23351. */
  23352. set onAfterRender(callback: (faceIndex: number) => void);
  23353. /**
  23354. * An event triggered after the texture clear
  23355. */
  23356. onClearObservable: Observable<Engine>;
  23357. private _onClearObserver;
  23358. /**
  23359. * Set a clear callback in the texture.
  23360. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23361. */
  23362. set onClear(callback: (Engine: Engine) => void);
  23363. /**
  23364. * An event triggered when the texture is resized.
  23365. */
  23366. onResizeObservable: Observable<RenderTargetTexture>;
  23367. /**
  23368. * Define the clear color of the Render Target if it should be different from the scene.
  23369. */
  23370. clearColor: Color4;
  23371. protected _size: number | {
  23372. width: number;
  23373. height: number;
  23374. layers?: number;
  23375. };
  23376. protected _initialSizeParameter: number | {
  23377. width: number;
  23378. height: number;
  23379. } | {
  23380. ratio: number;
  23381. };
  23382. protected _sizeRatio: Nullable<number>;
  23383. /** @hidden */
  23384. _generateMipMaps: boolean;
  23385. protected _renderingManager: RenderingManager;
  23386. /** @hidden */
  23387. _waitingRenderList: string[];
  23388. protected _doNotChangeAspectRatio: boolean;
  23389. protected _currentRefreshId: number;
  23390. protected _refreshRate: number;
  23391. protected _textureMatrix: Matrix;
  23392. protected _samples: number;
  23393. protected _renderTargetOptions: RenderTargetCreationOptions;
  23394. /**
  23395. * Gets render target creation options that were used.
  23396. */
  23397. get renderTargetOptions(): RenderTargetCreationOptions;
  23398. protected _onRatioRescale(): void;
  23399. /**
  23400. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23401. * It must define where the camera used to render the texture is set
  23402. */
  23403. boundingBoxPosition: Vector3;
  23404. private _boundingBoxSize;
  23405. /**
  23406. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23407. * When defined, the cubemap will switch to local mode
  23408. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23409. * @example https://www.babylonjs-playground.com/#RNASML
  23410. */
  23411. set boundingBoxSize(value: Vector3);
  23412. get boundingBoxSize(): Vector3;
  23413. /**
  23414. * In case the RTT has been created with a depth texture, get the associated
  23415. * depth texture.
  23416. * Otherwise, return null.
  23417. */
  23418. get depthStencilTexture(): Nullable<InternalTexture>;
  23419. /**
  23420. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23421. * or used a shadow, depth texture...
  23422. * @param name The friendly name of the texture
  23423. * @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)
  23424. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23425. * @param generateMipMaps True if mip maps need to be generated after render.
  23426. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23427. * @param type The type of the buffer in the RTT (int, half float, float...)
  23428. * @param isCube True if a cube texture needs to be created
  23429. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23430. * @param generateDepthBuffer True to generate a depth buffer
  23431. * @param generateStencilBuffer True to generate a stencil buffer
  23432. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23433. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23434. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23435. */
  23436. constructor(name: string, size: number | {
  23437. width: number;
  23438. height: number;
  23439. layers?: number;
  23440. } | {
  23441. ratio: number;
  23442. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23443. /**
  23444. * Creates a depth stencil texture.
  23445. * This is only available in WebGL 2 or with the depth texture extension available.
  23446. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23447. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23448. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23449. */
  23450. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23451. private _processSizeParameter;
  23452. /**
  23453. * Define the number of samples to use in case of MSAA.
  23454. * It defaults to one meaning no MSAA has been enabled.
  23455. */
  23456. get samples(): number;
  23457. set samples(value: number);
  23458. /**
  23459. * Resets the refresh counter of the texture and start bak from scratch.
  23460. * Could be useful to regenerate the texture if it is setup to render only once.
  23461. */
  23462. resetRefreshCounter(): void;
  23463. /**
  23464. * Define the refresh rate of the texture or the rendering frequency.
  23465. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23466. */
  23467. get refreshRate(): number;
  23468. set refreshRate(value: number);
  23469. /**
  23470. * Adds a post process to the render target rendering passes.
  23471. * @param postProcess define the post process to add
  23472. */
  23473. addPostProcess(postProcess: PostProcess): void;
  23474. /**
  23475. * Clear all the post processes attached to the render target
  23476. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23477. */
  23478. clearPostProcesses(dispose?: boolean): void;
  23479. /**
  23480. * Remove one of the post process from the list of attached post processes to the texture
  23481. * @param postProcess define the post process to remove from the list
  23482. */
  23483. removePostProcess(postProcess: PostProcess): void;
  23484. /** @hidden */
  23485. _shouldRender(): boolean;
  23486. /**
  23487. * Gets the actual render size of the texture.
  23488. * @returns the width of the render size
  23489. */
  23490. getRenderSize(): number;
  23491. /**
  23492. * Gets the actual render width of the texture.
  23493. * @returns the width of the render size
  23494. */
  23495. getRenderWidth(): number;
  23496. /**
  23497. * Gets the actual render height of the texture.
  23498. * @returns the height of the render size
  23499. */
  23500. getRenderHeight(): number;
  23501. /**
  23502. * Gets the actual number of layers of the texture.
  23503. * @returns the number of layers
  23504. */
  23505. getRenderLayers(): number;
  23506. /**
  23507. * Get if the texture can be rescaled or not.
  23508. */
  23509. get canRescale(): boolean;
  23510. /**
  23511. * Resize the texture using a ratio.
  23512. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23513. */
  23514. scale(ratio: number): void;
  23515. /**
  23516. * Get the texture reflection matrix used to rotate/transform the reflection.
  23517. * @returns the reflection matrix
  23518. */
  23519. getReflectionTextureMatrix(): Matrix;
  23520. /**
  23521. * Resize the texture to a new desired size.
  23522. * Be carrefull as it will recreate all the data in the new texture.
  23523. * @param size Define the new size. It can be:
  23524. * - a number for squared texture,
  23525. * - an object containing { width: number, height: number }
  23526. * - or an object containing a ratio { ratio: number }
  23527. */
  23528. resize(size: number | {
  23529. width: number;
  23530. height: number;
  23531. } | {
  23532. ratio: number;
  23533. }): void;
  23534. private _defaultRenderListPrepared;
  23535. /**
  23536. * Renders all the objects from the render list into the texture.
  23537. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23538. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23539. */
  23540. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23541. private _bestReflectionRenderTargetDimension;
  23542. private _prepareRenderingManager;
  23543. /**
  23544. * @hidden
  23545. * @param faceIndex face index to bind to if this is a cubetexture
  23546. * @param layer defines the index of the texture to bind in the array
  23547. */
  23548. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23549. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23550. private renderToTarget;
  23551. /**
  23552. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23553. * This allowed control for front to back rendering or reversly depending of the special needs.
  23554. *
  23555. * @param renderingGroupId The rendering group id corresponding to its index
  23556. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23557. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23558. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23559. */
  23560. 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;
  23561. /**
  23562. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23563. *
  23564. * @param renderingGroupId The rendering group id corresponding to its index
  23565. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23566. */
  23567. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23568. /**
  23569. * Clones the texture.
  23570. * @returns the cloned texture
  23571. */
  23572. clone(): RenderTargetTexture;
  23573. /**
  23574. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23575. * @returns The JSON representation of the texture
  23576. */
  23577. serialize(): any;
  23578. /**
  23579. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23580. */
  23581. disposeFramebufferObjects(): void;
  23582. /**
  23583. * Dispose the texture and release its associated resources.
  23584. */
  23585. dispose(): void;
  23586. /** @hidden */
  23587. _rebuild(): void;
  23588. /**
  23589. * Clear the info related to rendering groups preventing retention point in material dispose.
  23590. */
  23591. freeRenderingGroups(): void;
  23592. /**
  23593. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23594. * @returns the view count
  23595. */
  23596. getViewCount(): number;
  23597. }
  23598. }
  23599. declare module BABYLON {
  23600. /**
  23601. * Class used to manipulate GUIDs
  23602. */
  23603. export class GUID {
  23604. /**
  23605. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23606. * Be aware Math.random() could cause collisions, but:
  23607. * "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"
  23608. * @returns a pseudo random id
  23609. */
  23610. static RandomId(): string;
  23611. }
  23612. }
  23613. declare module BABYLON {
  23614. /**
  23615. * Options to be used when creating a shadow depth material
  23616. */
  23617. export interface IIOptionShadowDepthMaterial {
  23618. /** Variables in the vertex shader code that need to have their names remapped.
  23619. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23620. * "var_name" should be either: worldPos or vNormalW
  23621. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23622. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23623. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23624. */
  23625. remappedVariables?: string[];
  23626. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23627. standalone?: boolean;
  23628. }
  23629. /**
  23630. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23631. */
  23632. export class ShadowDepthWrapper {
  23633. private _scene;
  23634. private _options?;
  23635. private _baseMaterial;
  23636. private _onEffectCreatedObserver;
  23637. private _subMeshToEffect;
  23638. private _subMeshToDepthEffect;
  23639. private _meshes;
  23640. /** @hidden */
  23641. _matriceNames: any;
  23642. /** Gets the standalone status of the wrapper */
  23643. get standalone(): boolean;
  23644. /** Gets the base material the wrapper is built upon */
  23645. get baseMaterial(): Material;
  23646. /**
  23647. * Instantiate a new shadow depth wrapper.
  23648. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23649. * generate the shadow depth map. For more information, please refer to the documentation:
  23650. * https://doc.babylonjs.com/babylon101/shadows
  23651. * @param baseMaterial Material to wrap
  23652. * @param scene Define the scene the material belongs to
  23653. * @param options Options used to create the wrapper
  23654. */
  23655. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23656. /**
  23657. * Gets the effect to use to generate the depth map
  23658. * @param subMesh subMesh to get the effect for
  23659. * @param shadowGenerator shadow generator to get the effect for
  23660. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23661. */
  23662. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23663. /**
  23664. * Specifies that the submesh is ready to be used for depth rendering
  23665. * @param subMesh submesh to check
  23666. * @param defines the list of defines to take into account when checking the effect
  23667. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23668. * @param useInstances specifies that instances should be used
  23669. * @returns a boolean indicating that the submesh is ready or not
  23670. */
  23671. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23672. /**
  23673. * Disposes the resources
  23674. */
  23675. dispose(): void;
  23676. private _makeEffect;
  23677. }
  23678. }
  23679. declare module BABYLON {
  23680. /**
  23681. * Options for compiling materials.
  23682. */
  23683. export interface IMaterialCompilationOptions {
  23684. /**
  23685. * Defines whether clip planes are enabled.
  23686. */
  23687. clipPlane: boolean;
  23688. /**
  23689. * Defines whether instances are enabled.
  23690. */
  23691. useInstances: boolean;
  23692. }
  23693. /**
  23694. * Options passed when calling customShaderNameResolve
  23695. */
  23696. export interface ICustomShaderNameResolveOptions {
  23697. /**
  23698. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  23699. */
  23700. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23701. }
  23702. /**
  23703. * Base class for the main features of a material in Babylon.js
  23704. */
  23705. export class Material implements IAnimatable {
  23706. /**
  23707. * Returns the triangle fill mode
  23708. */
  23709. static readonly TriangleFillMode: number;
  23710. /**
  23711. * Returns the wireframe mode
  23712. */
  23713. static readonly WireFrameFillMode: number;
  23714. /**
  23715. * Returns the point fill mode
  23716. */
  23717. static readonly PointFillMode: number;
  23718. /**
  23719. * Returns the point list draw mode
  23720. */
  23721. static readonly PointListDrawMode: number;
  23722. /**
  23723. * Returns the line list draw mode
  23724. */
  23725. static readonly LineListDrawMode: number;
  23726. /**
  23727. * Returns the line loop draw mode
  23728. */
  23729. static readonly LineLoopDrawMode: number;
  23730. /**
  23731. * Returns the line strip draw mode
  23732. */
  23733. static readonly LineStripDrawMode: number;
  23734. /**
  23735. * Returns the triangle strip draw mode
  23736. */
  23737. static readonly TriangleStripDrawMode: number;
  23738. /**
  23739. * Returns the triangle fan draw mode
  23740. */
  23741. static readonly TriangleFanDrawMode: number;
  23742. /**
  23743. * Stores the clock-wise side orientation
  23744. */
  23745. static readonly ClockWiseSideOrientation: number;
  23746. /**
  23747. * Stores the counter clock-wise side orientation
  23748. */
  23749. static readonly CounterClockWiseSideOrientation: number;
  23750. /**
  23751. * The dirty texture flag value
  23752. */
  23753. static readonly TextureDirtyFlag: number;
  23754. /**
  23755. * The dirty light flag value
  23756. */
  23757. static readonly LightDirtyFlag: number;
  23758. /**
  23759. * The dirty fresnel flag value
  23760. */
  23761. static readonly FresnelDirtyFlag: number;
  23762. /**
  23763. * The dirty attribute flag value
  23764. */
  23765. static readonly AttributesDirtyFlag: number;
  23766. /**
  23767. * The dirty misc flag value
  23768. */
  23769. static readonly MiscDirtyFlag: number;
  23770. /**
  23771. * The all dirty flag value
  23772. */
  23773. static readonly AllDirtyFlag: number;
  23774. /**
  23775. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23776. */
  23777. static readonly MATERIAL_OPAQUE: number;
  23778. /**
  23779. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23780. */
  23781. static readonly MATERIAL_ALPHATEST: number;
  23782. /**
  23783. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23784. */
  23785. static readonly MATERIAL_ALPHABLEND: number;
  23786. /**
  23787. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23788. * They are also discarded below the alpha cutoff threshold to improve performances.
  23789. */
  23790. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23791. /**
  23792. * The Whiteout method is used to blend normals.
  23793. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23794. */
  23795. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  23796. /**
  23797. * The Reoriented Normal Mapping method is used to blend normals.
  23798. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23799. */
  23800. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  23801. /**
  23802. * Custom callback helping to override the default shader used in the material.
  23803. */
  23804. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23805. /**
  23806. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23807. */
  23808. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23809. /**
  23810. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  23811. * This means that the material can keep using a previous shader while a new one is being compiled.
  23812. * This is mostly used when shader parallel compilation is supported (true by default)
  23813. */
  23814. allowShaderHotSwapping: boolean;
  23815. /**
  23816. * The ID of the material
  23817. */
  23818. id: string;
  23819. /**
  23820. * Gets or sets the unique id of the material
  23821. */
  23822. uniqueId: number;
  23823. /**
  23824. * The name of the material
  23825. */
  23826. name: string;
  23827. /**
  23828. * Gets or sets user defined metadata
  23829. */
  23830. metadata: any;
  23831. /**
  23832. * For internal use only. Please do not use.
  23833. */
  23834. reservedDataStore: any;
  23835. /**
  23836. * Specifies if the ready state should be checked on each call
  23837. */
  23838. checkReadyOnEveryCall: boolean;
  23839. /**
  23840. * Specifies if the ready state should be checked once
  23841. */
  23842. checkReadyOnlyOnce: boolean;
  23843. /**
  23844. * The state of the material
  23845. */
  23846. state: string;
  23847. /**
  23848. * The alpha value of the material
  23849. */
  23850. protected _alpha: number;
  23851. /**
  23852. * List of inspectable custom properties (used by the Inspector)
  23853. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23854. */
  23855. inspectableCustomProperties: IInspectable[];
  23856. /**
  23857. * Sets the alpha value of the material
  23858. */
  23859. set alpha(value: number);
  23860. /**
  23861. * Gets the alpha value of the material
  23862. */
  23863. get alpha(): number;
  23864. /**
  23865. * Specifies if back face culling is enabled
  23866. */
  23867. protected _backFaceCulling: boolean;
  23868. /**
  23869. * Sets the back-face culling state
  23870. */
  23871. set backFaceCulling(value: boolean);
  23872. /**
  23873. * Gets the back-face culling state
  23874. */
  23875. get backFaceCulling(): boolean;
  23876. /**
  23877. * Stores the value for side orientation
  23878. */
  23879. sideOrientation: number;
  23880. /**
  23881. * Callback triggered when the material is compiled
  23882. */
  23883. onCompiled: Nullable<(effect: Effect) => void>;
  23884. /**
  23885. * Callback triggered when an error occurs
  23886. */
  23887. onError: Nullable<(effect: Effect, errors: string) => void>;
  23888. /**
  23889. * Callback triggered to get the render target textures
  23890. */
  23891. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23892. /**
  23893. * Gets a boolean indicating that current material needs to register RTT
  23894. */
  23895. get hasRenderTargetTextures(): boolean;
  23896. /**
  23897. * Specifies if the material should be serialized
  23898. */
  23899. doNotSerialize: boolean;
  23900. /**
  23901. * @hidden
  23902. */
  23903. _storeEffectOnSubMeshes: boolean;
  23904. /**
  23905. * Stores the animations for the material
  23906. */
  23907. animations: Nullable<Array<Animation>>;
  23908. /**
  23909. * An event triggered when the material is disposed
  23910. */
  23911. onDisposeObservable: Observable<Material>;
  23912. /**
  23913. * An observer which watches for dispose events
  23914. */
  23915. private _onDisposeObserver;
  23916. private _onUnBindObservable;
  23917. /**
  23918. * Called during a dispose event
  23919. */
  23920. set onDispose(callback: () => void);
  23921. private _onBindObservable;
  23922. /**
  23923. * An event triggered when the material is bound
  23924. */
  23925. get onBindObservable(): Observable<AbstractMesh>;
  23926. /**
  23927. * An observer which watches for bind events
  23928. */
  23929. private _onBindObserver;
  23930. /**
  23931. * Called during a bind event
  23932. */
  23933. set onBind(callback: (Mesh: AbstractMesh) => void);
  23934. /**
  23935. * An event triggered when the material is unbound
  23936. */
  23937. get onUnBindObservable(): Observable<Material>;
  23938. protected _onEffectCreatedObservable: Nullable<Observable<{
  23939. effect: Effect;
  23940. subMesh: Nullable<SubMesh>;
  23941. }>>;
  23942. /**
  23943. * An event triggered when the effect is (re)created
  23944. */
  23945. get onEffectCreatedObservable(): Observable<{
  23946. effect: Effect;
  23947. subMesh: Nullable<SubMesh>;
  23948. }>;
  23949. /**
  23950. * Stores the value of the alpha mode
  23951. */
  23952. private _alphaMode;
  23953. /**
  23954. * Sets the value of the alpha mode.
  23955. *
  23956. * | Value | Type | Description |
  23957. * | --- | --- | --- |
  23958. * | 0 | ALPHA_DISABLE | |
  23959. * | 1 | ALPHA_ADD | |
  23960. * | 2 | ALPHA_COMBINE | |
  23961. * | 3 | ALPHA_SUBTRACT | |
  23962. * | 4 | ALPHA_MULTIPLY | |
  23963. * | 5 | ALPHA_MAXIMIZED | |
  23964. * | 6 | ALPHA_ONEONE | |
  23965. * | 7 | ALPHA_PREMULTIPLIED | |
  23966. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23967. * | 9 | ALPHA_INTERPOLATE | |
  23968. * | 10 | ALPHA_SCREENMODE | |
  23969. *
  23970. */
  23971. set alphaMode(value: number);
  23972. /**
  23973. * Gets the value of the alpha mode
  23974. */
  23975. get alphaMode(): number;
  23976. /**
  23977. * Stores the state of the need depth pre-pass value
  23978. */
  23979. private _needDepthPrePass;
  23980. /**
  23981. * Sets the need depth pre-pass value
  23982. */
  23983. set needDepthPrePass(value: boolean);
  23984. /**
  23985. * Gets the depth pre-pass value
  23986. */
  23987. get needDepthPrePass(): boolean;
  23988. /**
  23989. * Specifies if depth writing should be disabled
  23990. */
  23991. disableDepthWrite: boolean;
  23992. /**
  23993. * Specifies if color writing should be disabled
  23994. */
  23995. disableColorWrite: boolean;
  23996. /**
  23997. * Specifies if depth writing should be forced
  23998. */
  23999. forceDepthWrite: boolean;
  24000. /**
  24001. * Specifies the depth function that should be used. 0 means the default engine function
  24002. */
  24003. depthFunction: number;
  24004. /**
  24005. * Specifies if there should be a separate pass for culling
  24006. */
  24007. separateCullingPass: boolean;
  24008. /**
  24009. * Stores the state specifing if fog should be enabled
  24010. */
  24011. private _fogEnabled;
  24012. /**
  24013. * Sets the state for enabling fog
  24014. */
  24015. set fogEnabled(value: boolean);
  24016. /**
  24017. * Gets the value of the fog enabled state
  24018. */
  24019. get fogEnabled(): boolean;
  24020. /**
  24021. * Stores the size of points
  24022. */
  24023. pointSize: number;
  24024. /**
  24025. * Stores the z offset value
  24026. */
  24027. zOffset: number;
  24028. get wireframe(): boolean;
  24029. /**
  24030. * Sets the state of wireframe mode
  24031. */
  24032. set wireframe(value: boolean);
  24033. /**
  24034. * Gets the value specifying if point clouds are enabled
  24035. */
  24036. get pointsCloud(): boolean;
  24037. /**
  24038. * Sets the state of point cloud mode
  24039. */
  24040. set pointsCloud(value: boolean);
  24041. /**
  24042. * Gets the material fill mode
  24043. */
  24044. get fillMode(): number;
  24045. /**
  24046. * Sets the material fill mode
  24047. */
  24048. set fillMode(value: number);
  24049. /**
  24050. * @hidden
  24051. * Stores the effects for the material
  24052. */
  24053. _effect: Nullable<Effect>;
  24054. /**
  24055. * Specifies if uniform buffers should be used
  24056. */
  24057. private _useUBO;
  24058. /**
  24059. * Stores a reference to the scene
  24060. */
  24061. private _scene;
  24062. /**
  24063. * Stores the fill mode state
  24064. */
  24065. private _fillMode;
  24066. /**
  24067. * Specifies if the depth write state should be cached
  24068. */
  24069. private _cachedDepthWriteState;
  24070. /**
  24071. * Specifies if the color write state should be cached
  24072. */
  24073. private _cachedColorWriteState;
  24074. /**
  24075. * Specifies if the depth function state should be cached
  24076. */
  24077. private _cachedDepthFunctionState;
  24078. /**
  24079. * Stores the uniform buffer
  24080. */
  24081. protected _uniformBuffer: UniformBuffer;
  24082. /** @hidden */
  24083. _indexInSceneMaterialArray: number;
  24084. /** @hidden */
  24085. meshMap: Nullable<{
  24086. [id: string]: AbstractMesh | undefined;
  24087. }>;
  24088. /**
  24089. * Creates a material instance
  24090. * @param name defines the name of the material
  24091. * @param scene defines the scene to reference
  24092. * @param doNotAdd specifies if the material should be added to the scene
  24093. */
  24094. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24095. /**
  24096. * Returns a string representation of the current material
  24097. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24098. * @returns a string with material information
  24099. */
  24100. toString(fullDetails?: boolean): string;
  24101. /**
  24102. * Gets the class name of the material
  24103. * @returns a string with the class name of the material
  24104. */
  24105. getClassName(): string;
  24106. /**
  24107. * Specifies if updates for the material been locked
  24108. */
  24109. get isFrozen(): boolean;
  24110. /**
  24111. * Locks updates for the material
  24112. */
  24113. freeze(): void;
  24114. /**
  24115. * Unlocks updates for the material
  24116. */
  24117. unfreeze(): void;
  24118. /**
  24119. * Specifies if the material is ready to be used
  24120. * @param mesh defines the mesh to check
  24121. * @param useInstances specifies if instances should be used
  24122. * @returns a boolean indicating if the material is ready to be used
  24123. */
  24124. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24125. /**
  24126. * Specifies that the submesh is ready to be used
  24127. * @param mesh defines the mesh to check
  24128. * @param subMesh defines which submesh to check
  24129. * @param useInstances specifies that instances should be used
  24130. * @returns a boolean indicating that the submesh is ready or not
  24131. */
  24132. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24133. /**
  24134. * Returns the material effect
  24135. * @returns the effect associated with the material
  24136. */
  24137. getEffect(): Nullable<Effect>;
  24138. /**
  24139. * Returns the current scene
  24140. * @returns a Scene
  24141. */
  24142. getScene(): Scene;
  24143. /**
  24144. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24145. */
  24146. protected _forceAlphaTest: boolean;
  24147. /**
  24148. * The transparency mode of the material.
  24149. */
  24150. protected _transparencyMode: Nullable<number>;
  24151. /**
  24152. * Gets the current transparency mode.
  24153. */
  24154. get transparencyMode(): Nullable<number>;
  24155. /**
  24156. * Sets the transparency mode of the material.
  24157. *
  24158. * | Value | Type | Description |
  24159. * | ----- | ----------------------------------- | ----------- |
  24160. * | 0 | OPAQUE | |
  24161. * | 1 | ALPHATEST | |
  24162. * | 2 | ALPHABLEND | |
  24163. * | 3 | ALPHATESTANDBLEND | |
  24164. *
  24165. */
  24166. set transparencyMode(value: Nullable<number>);
  24167. /**
  24168. * Returns true if alpha blending should be disabled.
  24169. */
  24170. protected get _disableAlphaBlending(): boolean;
  24171. /**
  24172. * Specifies whether or not this material should be rendered in alpha blend mode.
  24173. * @returns a boolean specifying if alpha blending is needed
  24174. */
  24175. needAlphaBlending(): boolean;
  24176. /**
  24177. * Specifies if the mesh will require alpha blending
  24178. * @param mesh defines the mesh to check
  24179. * @returns a boolean specifying if alpha blending is needed for the mesh
  24180. */
  24181. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24182. /**
  24183. * Specifies whether or not this material should be rendered in alpha test mode.
  24184. * @returns a boolean specifying if an alpha test is needed.
  24185. */
  24186. needAlphaTesting(): boolean;
  24187. /**
  24188. * Specifies if material alpha testing should be turned on for the mesh
  24189. * @param mesh defines the mesh to check
  24190. */
  24191. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24192. /**
  24193. * Gets the texture used for the alpha test
  24194. * @returns the texture to use for alpha testing
  24195. */
  24196. getAlphaTestTexture(): Nullable<BaseTexture>;
  24197. /**
  24198. * Marks the material to indicate that it needs to be re-calculated
  24199. */
  24200. markDirty(): void;
  24201. /** @hidden */
  24202. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24203. /**
  24204. * Binds the material to the mesh
  24205. * @param world defines the world transformation matrix
  24206. * @param mesh defines the mesh to bind the material to
  24207. */
  24208. bind(world: Matrix, mesh?: Mesh): void;
  24209. /**
  24210. * Binds the submesh to the material
  24211. * @param world defines the world transformation matrix
  24212. * @param mesh defines the mesh containing the submesh
  24213. * @param subMesh defines the submesh to bind the material to
  24214. */
  24215. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24216. /**
  24217. * Binds the world matrix to the material
  24218. * @param world defines the world transformation matrix
  24219. */
  24220. bindOnlyWorldMatrix(world: Matrix): void;
  24221. /**
  24222. * Binds the scene's uniform buffer to the effect.
  24223. * @param effect defines the effect to bind to the scene uniform buffer
  24224. * @param sceneUbo defines the uniform buffer storing scene data
  24225. */
  24226. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24227. /**
  24228. * Binds the view matrix to the effect
  24229. * @param effect defines the effect to bind the view matrix to
  24230. */
  24231. bindView(effect: Effect): void;
  24232. /**
  24233. * Binds the view projection matrix to the effect
  24234. * @param effect defines the effect to bind the view projection matrix to
  24235. */
  24236. bindViewProjection(effect: Effect): void;
  24237. /**
  24238. * Processes to execute after binding the material to a mesh
  24239. * @param mesh defines the rendered mesh
  24240. */
  24241. protected _afterBind(mesh?: Mesh): void;
  24242. /**
  24243. * Unbinds the material from the mesh
  24244. */
  24245. unbind(): void;
  24246. /**
  24247. * Gets the active textures from the material
  24248. * @returns an array of textures
  24249. */
  24250. getActiveTextures(): BaseTexture[];
  24251. /**
  24252. * Specifies if the material uses a texture
  24253. * @param texture defines the texture to check against the material
  24254. * @returns a boolean specifying if the material uses the texture
  24255. */
  24256. hasTexture(texture: BaseTexture): boolean;
  24257. /**
  24258. * Makes a duplicate of the material, and gives it a new name
  24259. * @param name defines the new name for the duplicated material
  24260. * @returns the cloned material
  24261. */
  24262. clone(name: string): Nullable<Material>;
  24263. /**
  24264. * Gets the meshes bound to the material
  24265. * @returns an array of meshes bound to the material
  24266. */
  24267. getBindedMeshes(): AbstractMesh[];
  24268. /**
  24269. * Force shader compilation
  24270. * @param mesh defines the mesh associated with this material
  24271. * @param onCompiled defines a function to execute once the material is compiled
  24272. * @param options defines the options to configure the compilation
  24273. * @param onError defines a function to execute if the material fails compiling
  24274. */
  24275. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24276. /**
  24277. * Force shader compilation
  24278. * @param mesh defines the mesh that will use this material
  24279. * @param options defines additional options for compiling the shaders
  24280. * @returns a promise that resolves when the compilation completes
  24281. */
  24282. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24283. private static readonly _AllDirtyCallBack;
  24284. private static readonly _ImageProcessingDirtyCallBack;
  24285. private static readonly _TextureDirtyCallBack;
  24286. private static readonly _FresnelDirtyCallBack;
  24287. private static readonly _MiscDirtyCallBack;
  24288. private static readonly _LightsDirtyCallBack;
  24289. private static readonly _AttributeDirtyCallBack;
  24290. private static _FresnelAndMiscDirtyCallBack;
  24291. private static _TextureAndMiscDirtyCallBack;
  24292. private static readonly _DirtyCallbackArray;
  24293. private static readonly _RunDirtyCallBacks;
  24294. /**
  24295. * Marks a define in the material to indicate that it needs to be re-computed
  24296. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24297. */
  24298. markAsDirty(flag: number): void;
  24299. /**
  24300. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24301. * @param func defines a function which checks material defines against the submeshes
  24302. */
  24303. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24304. /**
  24305. * Indicates that we need to re-calculated for all submeshes
  24306. */
  24307. protected _markAllSubMeshesAsAllDirty(): void;
  24308. /**
  24309. * Indicates that image processing needs to be re-calculated for all submeshes
  24310. */
  24311. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24312. /**
  24313. * Indicates that textures need to be re-calculated for all submeshes
  24314. */
  24315. protected _markAllSubMeshesAsTexturesDirty(): void;
  24316. /**
  24317. * Indicates that fresnel needs to be re-calculated for all submeshes
  24318. */
  24319. protected _markAllSubMeshesAsFresnelDirty(): void;
  24320. /**
  24321. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24322. */
  24323. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24324. /**
  24325. * Indicates that lights need to be re-calculated for all submeshes
  24326. */
  24327. protected _markAllSubMeshesAsLightsDirty(): void;
  24328. /**
  24329. * Indicates that attributes need to be re-calculated for all submeshes
  24330. */
  24331. protected _markAllSubMeshesAsAttributesDirty(): void;
  24332. /**
  24333. * Indicates that misc needs to be re-calculated for all submeshes
  24334. */
  24335. protected _markAllSubMeshesAsMiscDirty(): void;
  24336. /**
  24337. * Indicates that textures and misc need to be re-calculated for all submeshes
  24338. */
  24339. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24340. /**
  24341. * Disposes the material
  24342. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24343. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24344. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24345. */
  24346. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24347. /** @hidden */
  24348. private releaseVertexArrayObject;
  24349. /**
  24350. * Serializes this material
  24351. * @returns the serialized material object
  24352. */
  24353. serialize(): any;
  24354. /**
  24355. * Creates a material from parsed material data
  24356. * @param parsedMaterial defines parsed material data
  24357. * @param scene defines the hosting scene
  24358. * @param rootUrl defines the root URL to use to load textures
  24359. * @returns a new material
  24360. */
  24361. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24362. }
  24363. }
  24364. declare module BABYLON {
  24365. /**
  24366. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24367. * separate meshes. This can be use to improve performances.
  24368. * @see http://doc.babylonjs.com/how_to/multi_materials
  24369. */
  24370. export class MultiMaterial extends Material {
  24371. private _subMaterials;
  24372. /**
  24373. * Gets or Sets the list of Materials used within the multi material.
  24374. * They need to be ordered according to the submeshes order in the associated mesh
  24375. */
  24376. get subMaterials(): Nullable<Material>[];
  24377. set subMaterials(value: Nullable<Material>[]);
  24378. /**
  24379. * Function used to align with Node.getChildren()
  24380. * @returns the list of Materials used within the multi material
  24381. */
  24382. getChildren(): Nullable<Material>[];
  24383. /**
  24384. * Instantiates a new Multi Material
  24385. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24386. * separate meshes. This can be use to improve performances.
  24387. * @see http://doc.babylonjs.com/how_to/multi_materials
  24388. * @param name Define the name in the scene
  24389. * @param scene Define the scene the material belongs to
  24390. */
  24391. constructor(name: string, scene: Scene);
  24392. private _hookArray;
  24393. /**
  24394. * Get one of the submaterial by its index in the submaterials array
  24395. * @param index The index to look the sub material at
  24396. * @returns The Material if the index has been defined
  24397. */
  24398. getSubMaterial(index: number): Nullable<Material>;
  24399. /**
  24400. * Get the list of active textures for the whole sub materials list.
  24401. * @returns All the textures that will be used during the rendering
  24402. */
  24403. getActiveTextures(): BaseTexture[];
  24404. /**
  24405. * Gets the current class name of the material e.g. "MultiMaterial"
  24406. * Mainly use in serialization.
  24407. * @returns the class name
  24408. */
  24409. getClassName(): string;
  24410. /**
  24411. * Checks if the material is ready to render the requested sub mesh
  24412. * @param mesh Define the mesh the submesh belongs to
  24413. * @param subMesh Define the sub mesh to look readyness for
  24414. * @param useInstances Define whether or not the material is used with instances
  24415. * @returns true if ready, otherwise false
  24416. */
  24417. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24418. /**
  24419. * Clones the current material and its related sub materials
  24420. * @param name Define the name of the newly cloned material
  24421. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24422. * @returns the cloned material
  24423. */
  24424. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24425. /**
  24426. * Serializes the materials into a JSON representation.
  24427. * @returns the JSON representation
  24428. */
  24429. serialize(): any;
  24430. /**
  24431. * Dispose the material and release its associated resources
  24432. * @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)
  24433. * @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)
  24434. * @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)
  24435. */
  24436. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24437. /**
  24438. * Creates a MultiMaterial from parsed MultiMaterial data.
  24439. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24440. * @param scene defines the hosting scene
  24441. * @returns a new MultiMaterial
  24442. */
  24443. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24444. }
  24445. }
  24446. declare module BABYLON {
  24447. /**
  24448. * Defines a subdivision inside a mesh
  24449. */
  24450. export class SubMesh implements ICullable {
  24451. /** the material index to use */
  24452. materialIndex: number;
  24453. /** vertex index start */
  24454. verticesStart: number;
  24455. /** vertices count */
  24456. verticesCount: number;
  24457. /** index start */
  24458. indexStart: number;
  24459. /** indices count */
  24460. indexCount: number;
  24461. /** @hidden */
  24462. _materialDefines: Nullable<MaterialDefines>;
  24463. /** @hidden */
  24464. _materialEffect: Nullable<Effect>;
  24465. /** @hidden */
  24466. _effectOverride: Nullable<Effect>;
  24467. /**
  24468. * Gets material defines used by the effect associated to the sub mesh
  24469. */
  24470. get materialDefines(): Nullable<MaterialDefines>;
  24471. /**
  24472. * Sets material defines used by the effect associated to the sub mesh
  24473. */
  24474. set materialDefines(defines: Nullable<MaterialDefines>);
  24475. /**
  24476. * Gets associated effect
  24477. */
  24478. get effect(): Nullable<Effect>;
  24479. /**
  24480. * Sets associated effect (effect used to render this submesh)
  24481. * @param effect defines the effect to associate with
  24482. * @param defines defines the set of defines used to compile this effect
  24483. */
  24484. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24485. /** @hidden */
  24486. _linesIndexCount: number;
  24487. private _mesh;
  24488. private _renderingMesh;
  24489. private _boundingInfo;
  24490. private _linesIndexBuffer;
  24491. /** @hidden */
  24492. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24493. /** @hidden */
  24494. _trianglePlanes: Plane[];
  24495. /** @hidden */
  24496. _lastColliderTransformMatrix: Nullable<Matrix>;
  24497. /** @hidden */
  24498. _renderId: number;
  24499. /** @hidden */
  24500. _alphaIndex: number;
  24501. /** @hidden */
  24502. _distanceToCamera: number;
  24503. /** @hidden */
  24504. _id: number;
  24505. private _currentMaterial;
  24506. /**
  24507. * Add a new submesh to a mesh
  24508. * @param materialIndex defines the material index to use
  24509. * @param verticesStart defines vertex index start
  24510. * @param verticesCount defines vertices count
  24511. * @param indexStart defines index start
  24512. * @param indexCount defines indices count
  24513. * @param mesh defines the parent mesh
  24514. * @param renderingMesh defines an optional rendering mesh
  24515. * @param createBoundingBox defines if bounding box should be created for this submesh
  24516. * @returns the new submesh
  24517. */
  24518. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24519. /**
  24520. * Creates a new submesh
  24521. * @param materialIndex defines the material index to use
  24522. * @param verticesStart defines vertex index start
  24523. * @param verticesCount defines vertices count
  24524. * @param indexStart defines index start
  24525. * @param indexCount defines indices count
  24526. * @param mesh defines the parent mesh
  24527. * @param renderingMesh defines an optional rendering mesh
  24528. * @param createBoundingBox defines if bounding box should be created for this submesh
  24529. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  24530. */
  24531. constructor(
  24532. /** the material index to use */
  24533. materialIndex: number,
  24534. /** vertex index start */
  24535. verticesStart: number,
  24536. /** vertices count */
  24537. verticesCount: number,
  24538. /** index start */
  24539. indexStart: number,
  24540. /** indices count */
  24541. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  24542. /**
  24543. * Returns true if this submesh covers the entire parent mesh
  24544. * @ignorenaming
  24545. */
  24546. get IsGlobal(): boolean;
  24547. /**
  24548. * Returns the submesh BoudingInfo object
  24549. * @returns current bounding info (or mesh's one if the submesh is global)
  24550. */
  24551. getBoundingInfo(): BoundingInfo;
  24552. /**
  24553. * Sets the submesh BoundingInfo
  24554. * @param boundingInfo defines the new bounding info to use
  24555. * @returns the SubMesh
  24556. */
  24557. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24558. /**
  24559. * Returns the mesh of the current submesh
  24560. * @return the parent mesh
  24561. */
  24562. getMesh(): AbstractMesh;
  24563. /**
  24564. * Returns the rendering mesh of the submesh
  24565. * @returns the rendering mesh (could be different from parent mesh)
  24566. */
  24567. getRenderingMesh(): Mesh;
  24568. /**
  24569. * Returns the replacement mesh of the submesh
  24570. * @returns the replacement mesh (could be different from parent mesh)
  24571. */
  24572. getReplacementMesh(): Nullable<AbstractMesh>;
  24573. /**
  24574. * Returns the effective mesh of the submesh
  24575. * @returns the effective mesh (could be different from parent mesh)
  24576. */
  24577. getEffectiveMesh(): AbstractMesh;
  24578. /**
  24579. * Returns the submesh material
  24580. * @returns null or the current material
  24581. */
  24582. getMaterial(): Nullable<Material>;
  24583. private _IsMultiMaterial;
  24584. /**
  24585. * Sets a new updated BoundingInfo object to the submesh
  24586. * @param data defines an optional position array to use to determine the bounding info
  24587. * @returns the SubMesh
  24588. */
  24589. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24590. /** @hidden */
  24591. _checkCollision(collider: Collider): boolean;
  24592. /**
  24593. * Updates the submesh BoundingInfo
  24594. * @param world defines the world matrix to use to update the bounding info
  24595. * @returns the submesh
  24596. */
  24597. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24598. /**
  24599. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24600. * @param frustumPlanes defines the frustum planes
  24601. * @returns true if the submesh is intersecting with the frustum
  24602. */
  24603. isInFrustum(frustumPlanes: Plane[]): boolean;
  24604. /**
  24605. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24606. * @param frustumPlanes defines the frustum planes
  24607. * @returns true if the submesh is inside the frustum
  24608. */
  24609. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24610. /**
  24611. * Renders the submesh
  24612. * @param enableAlphaMode defines if alpha needs to be used
  24613. * @returns the submesh
  24614. */
  24615. render(enableAlphaMode: boolean): SubMesh;
  24616. /**
  24617. * @hidden
  24618. */
  24619. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24620. /**
  24621. * Checks if the submesh intersects with a ray
  24622. * @param ray defines the ray to test
  24623. * @returns true is the passed ray intersects the submesh bounding box
  24624. */
  24625. canIntersects(ray: Ray): boolean;
  24626. /**
  24627. * Intersects current submesh with a ray
  24628. * @param ray defines the ray to test
  24629. * @param positions defines mesh's positions array
  24630. * @param indices defines mesh's indices array
  24631. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24632. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24633. * @returns intersection info or null if no intersection
  24634. */
  24635. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24636. /** @hidden */
  24637. private _intersectLines;
  24638. /** @hidden */
  24639. private _intersectUnIndexedLines;
  24640. /** @hidden */
  24641. private _intersectTriangles;
  24642. /** @hidden */
  24643. private _intersectUnIndexedTriangles;
  24644. /** @hidden */
  24645. _rebuild(): void;
  24646. /**
  24647. * Creates a new submesh from the passed mesh
  24648. * @param newMesh defines the new hosting mesh
  24649. * @param newRenderingMesh defines an optional rendering mesh
  24650. * @returns the new submesh
  24651. */
  24652. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24653. /**
  24654. * Release associated resources
  24655. */
  24656. dispose(): void;
  24657. /**
  24658. * Gets the class name
  24659. * @returns the string "SubMesh".
  24660. */
  24661. getClassName(): string;
  24662. /**
  24663. * Creates a new submesh from indices data
  24664. * @param materialIndex the index of the main mesh material
  24665. * @param startIndex the index where to start the copy in the mesh indices array
  24666. * @param indexCount the number of indices to copy then from the startIndex
  24667. * @param mesh the main mesh to create the submesh from
  24668. * @param renderingMesh the optional rendering mesh
  24669. * @returns a new submesh
  24670. */
  24671. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24672. }
  24673. }
  24674. declare module BABYLON {
  24675. /**
  24676. * Class used to represent data loading progression
  24677. */
  24678. export class SceneLoaderFlags {
  24679. private static _ForceFullSceneLoadingForIncremental;
  24680. private static _ShowLoadingScreen;
  24681. private static _CleanBoneMatrixWeights;
  24682. private static _loggingLevel;
  24683. /**
  24684. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24685. */
  24686. static get ForceFullSceneLoadingForIncremental(): boolean;
  24687. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24688. /**
  24689. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24690. */
  24691. static get ShowLoadingScreen(): boolean;
  24692. static set ShowLoadingScreen(value: boolean);
  24693. /**
  24694. * Defines the current logging level (while loading the scene)
  24695. * @ignorenaming
  24696. */
  24697. static get loggingLevel(): number;
  24698. static set loggingLevel(value: number);
  24699. /**
  24700. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24701. */
  24702. static get CleanBoneMatrixWeights(): boolean;
  24703. static set CleanBoneMatrixWeights(value: boolean);
  24704. }
  24705. }
  24706. declare module BABYLON {
  24707. /**
  24708. * Class used to store geometry data (vertex buffers + index buffer)
  24709. */
  24710. export class Geometry implements IGetSetVerticesData {
  24711. /**
  24712. * Gets or sets the ID of the geometry
  24713. */
  24714. id: string;
  24715. /**
  24716. * Gets or sets the unique ID of the geometry
  24717. */
  24718. uniqueId: number;
  24719. /**
  24720. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24721. */
  24722. delayLoadState: number;
  24723. /**
  24724. * Gets the file containing the data to load when running in delay load state
  24725. */
  24726. delayLoadingFile: Nullable<string>;
  24727. /**
  24728. * Callback called when the geometry is updated
  24729. */
  24730. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24731. private _scene;
  24732. private _engine;
  24733. private _meshes;
  24734. private _totalVertices;
  24735. /** @hidden */
  24736. _indices: IndicesArray;
  24737. /** @hidden */
  24738. _vertexBuffers: {
  24739. [key: string]: VertexBuffer;
  24740. };
  24741. private _isDisposed;
  24742. private _extend;
  24743. private _boundingBias;
  24744. /** @hidden */
  24745. _delayInfo: Array<string>;
  24746. private _indexBuffer;
  24747. private _indexBufferIsUpdatable;
  24748. /** @hidden */
  24749. _boundingInfo: Nullable<BoundingInfo>;
  24750. /** @hidden */
  24751. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24752. /** @hidden */
  24753. _softwareSkinningFrameId: number;
  24754. private _vertexArrayObjects;
  24755. private _updatable;
  24756. /** @hidden */
  24757. _positions: Nullable<Vector3[]>;
  24758. /**
  24759. * 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
  24760. */
  24761. get boundingBias(): Vector2;
  24762. /**
  24763. * 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
  24764. */
  24765. set boundingBias(value: Vector2);
  24766. /**
  24767. * Static function used to attach a new empty geometry to a mesh
  24768. * @param mesh defines the mesh to attach the geometry to
  24769. * @returns the new Geometry
  24770. */
  24771. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24772. /** Get the list of meshes using this geometry */
  24773. get meshes(): Mesh[];
  24774. /**
  24775. * Creates a new geometry
  24776. * @param id defines the unique ID
  24777. * @param scene defines the hosting scene
  24778. * @param vertexData defines the VertexData used to get geometry data
  24779. * @param updatable defines if geometry must be updatable (false by default)
  24780. * @param mesh defines the mesh that will be associated with the geometry
  24781. */
  24782. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24783. /**
  24784. * Gets the current extend of the geometry
  24785. */
  24786. get extend(): {
  24787. minimum: Vector3;
  24788. maximum: Vector3;
  24789. };
  24790. /**
  24791. * Gets the hosting scene
  24792. * @returns the hosting Scene
  24793. */
  24794. getScene(): Scene;
  24795. /**
  24796. * Gets the hosting engine
  24797. * @returns the hosting Engine
  24798. */
  24799. getEngine(): Engine;
  24800. /**
  24801. * Defines if the geometry is ready to use
  24802. * @returns true if the geometry is ready to be used
  24803. */
  24804. isReady(): boolean;
  24805. /**
  24806. * Gets a value indicating that the geometry should not be serialized
  24807. */
  24808. get doNotSerialize(): boolean;
  24809. /** @hidden */
  24810. _rebuild(): void;
  24811. /**
  24812. * Affects all geometry data in one call
  24813. * @param vertexData defines the geometry data
  24814. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24815. */
  24816. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24817. /**
  24818. * Set specific vertex data
  24819. * @param kind defines the data kind (Position, normal, etc...)
  24820. * @param data defines the vertex data to use
  24821. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24822. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24823. */
  24824. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24825. /**
  24826. * Removes a specific vertex data
  24827. * @param kind defines the data kind (Position, normal, etc...)
  24828. */
  24829. removeVerticesData(kind: string): void;
  24830. /**
  24831. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24832. * @param buffer defines the vertex buffer to use
  24833. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24834. */
  24835. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24836. /**
  24837. * Update a specific vertex buffer
  24838. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24839. * It will do nothing if the buffer is not updatable
  24840. * @param kind defines the data kind (Position, normal, etc...)
  24841. * @param data defines the data to use
  24842. * @param offset defines the offset in the target buffer where to store the data
  24843. * @param useBytes set to true if the offset is in bytes
  24844. */
  24845. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24846. /**
  24847. * Update a specific vertex buffer
  24848. * This function will create a new buffer if the current one is not updatable
  24849. * @param kind defines the data kind (Position, normal, etc...)
  24850. * @param data defines the data to use
  24851. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24852. */
  24853. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24854. private _updateBoundingInfo;
  24855. /** @hidden */
  24856. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24857. /**
  24858. * Gets total number of vertices
  24859. * @returns the total number of vertices
  24860. */
  24861. getTotalVertices(): number;
  24862. /**
  24863. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24864. * @param kind defines the data kind (Position, normal, etc...)
  24865. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24866. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24867. * @returns a float array containing vertex data
  24868. */
  24869. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24870. /**
  24871. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24872. * @param kind defines the data kind (Position, normal, etc...)
  24873. * @returns true if the vertex buffer with the specified kind is updatable
  24874. */
  24875. isVertexBufferUpdatable(kind: string): boolean;
  24876. /**
  24877. * Gets a specific vertex buffer
  24878. * @param kind defines the data kind (Position, normal, etc...)
  24879. * @returns a VertexBuffer
  24880. */
  24881. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24882. /**
  24883. * Returns all vertex buffers
  24884. * @return an object holding all vertex buffers indexed by kind
  24885. */
  24886. getVertexBuffers(): Nullable<{
  24887. [key: string]: VertexBuffer;
  24888. }>;
  24889. /**
  24890. * Gets a boolean indicating if specific vertex buffer is present
  24891. * @param kind defines the data kind (Position, normal, etc...)
  24892. * @returns true if data is present
  24893. */
  24894. isVerticesDataPresent(kind: string): boolean;
  24895. /**
  24896. * Gets a list of all attached data kinds (Position, normal, etc...)
  24897. * @returns a list of string containing all kinds
  24898. */
  24899. getVerticesDataKinds(): string[];
  24900. /**
  24901. * Update index buffer
  24902. * @param indices defines the indices to store in the index buffer
  24903. * @param offset defines the offset in the target buffer where to store the data
  24904. * @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)
  24905. */
  24906. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24907. /**
  24908. * Creates a new index buffer
  24909. * @param indices defines the indices to store in the index buffer
  24910. * @param totalVertices defines the total number of vertices (could be null)
  24911. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24912. */
  24913. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24914. /**
  24915. * Return the total number of indices
  24916. * @returns the total number of indices
  24917. */
  24918. getTotalIndices(): number;
  24919. /**
  24920. * Gets the index buffer array
  24921. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24922. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24923. * @returns the index buffer array
  24924. */
  24925. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24926. /**
  24927. * Gets the index buffer
  24928. * @return the index buffer
  24929. */
  24930. getIndexBuffer(): Nullable<DataBuffer>;
  24931. /** @hidden */
  24932. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24933. /**
  24934. * Release the associated resources for a specific mesh
  24935. * @param mesh defines the source mesh
  24936. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24937. */
  24938. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24939. /**
  24940. * Apply current geometry to a given mesh
  24941. * @param mesh defines the mesh to apply geometry to
  24942. */
  24943. applyToMesh(mesh: Mesh): void;
  24944. private _updateExtend;
  24945. private _applyToMesh;
  24946. private notifyUpdate;
  24947. /**
  24948. * Load the geometry if it was flagged as delay loaded
  24949. * @param scene defines the hosting scene
  24950. * @param onLoaded defines a callback called when the geometry is loaded
  24951. */
  24952. load(scene: Scene, onLoaded?: () => void): void;
  24953. private _queueLoad;
  24954. /**
  24955. * Invert the geometry to move from a right handed system to a left handed one.
  24956. */
  24957. toLeftHanded(): void;
  24958. /** @hidden */
  24959. _resetPointsArrayCache(): void;
  24960. /** @hidden */
  24961. _generatePointsArray(): boolean;
  24962. /**
  24963. * Gets a value indicating if the geometry is disposed
  24964. * @returns true if the geometry was disposed
  24965. */
  24966. isDisposed(): boolean;
  24967. private _disposeVertexArrayObjects;
  24968. /**
  24969. * Free all associated resources
  24970. */
  24971. dispose(): void;
  24972. /**
  24973. * Clone the current geometry into a new geometry
  24974. * @param id defines the unique ID of the new geometry
  24975. * @returns a new geometry object
  24976. */
  24977. copy(id: string): Geometry;
  24978. /**
  24979. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24980. * @return a JSON representation of the current geometry data (without the vertices data)
  24981. */
  24982. serialize(): any;
  24983. private toNumberArray;
  24984. /**
  24985. * Serialize all vertices data into a JSON oject
  24986. * @returns a JSON representation of the current geometry data
  24987. */
  24988. serializeVerticeData(): any;
  24989. /**
  24990. * Extracts a clone of a mesh geometry
  24991. * @param mesh defines the source mesh
  24992. * @param id defines the unique ID of the new geometry object
  24993. * @returns the new geometry object
  24994. */
  24995. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24996. /**
  24997. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24998. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24999. * Be aware Math.random() could cause collisions, but:
  25000. * "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"
  25001. * @returns a string containing a new GUID
  25002. */
  25003. static RandomId(): string;
  25004. /** @hidden */
  25005. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25006. private static _CleanMatricesWeights;
  25007. /**
  25008. * Create a new geometry from persisted data (Using .babylon file format)
  25009. * @param parsedVertexData defines the persisted data
  25010. * @param scene defines the hosting scene
  25011. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25012. * @returns the new geometry object
  25013. */
  25014. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25015. }
  25016. }
  25017. declare module BABYLON {
  25018. /**
  25019. * Define an interface for all classes that will get and set the data on vertices
  25020. */
  25021. export interface IGetSetVerticesData {
  25022. /**
  25023. * Gets a boolean indicating if specific vertex data is present
  25024. * @param kind defines the vertex data kind to use
  25025. * @returns true is data kind is present
  25026. */
  25027. isVerticesDataPresent(kind: string): boolean;
  25028. /**
  25029. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25030. * @param kind defines the data kind (Position, normal, etc...)
  25031. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25032. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25033. * @returns a float array containing vertex data
  25034. */
  25035. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25036. /**
  25037. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25038. * @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.
  25039. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25040. * @returns the indices array or an empty array if the mesh has no geometry
  25041. */
  25042. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25043. /**
  25044. * Set specific vertex data
  25045. * @param kind defines the data kind (Position, normal, etc...)
  25046. * @param data defines the vertex data to use
  25047. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25048. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25049. */
  25050. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25051. /**
  25052. * Update a specific associated vertex buffer
  25053. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25054. * - VertexBuffer.PositionKind
  25055. * - VertexBuffer.UVKind
  25056. * - VertexBuffer.UV2Kind
  25057. * - VertexBuffer.UV3Kind
  25058. * - VertexBuffer.UV4Kind
  25059. * - VertexBuffer.UV5Kind
  25060. * - VertexBuffer.UV6Kind
  25061. * - VertexBuffer.ColorKind
  25062. * - VertexBuffer.MatricesIndicesKind
  25063. * - VertexBuffer.MatricesIndicesExtraKind
  25064. * - VertexBuffer.MatricesWeightsKind
  25065. * - VertexBuffer.MatricesWeightsExtraKind
  25066. * @param data defines the data source
  25067. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25068. * @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)
  25069. */
  25070. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25071. /**
  25072. * Creates a new index buffer
  25073. * @param indices defines the indices to store in the index buffer
  25074. * @param totalVertices defines the total number of vertices (could be null)
  25075. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25076. */
  25077. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25078. }
  25079. /**
  25080. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25081. */
  25082. export class VertexData {
  25083. /**
  25084. * Mesh side orientation : usually the external or front surface
  25085. */
  25086. static readonly FRONTSIDE: number;
  25087. /**
  25088. * Mesh side orientation : usually the internal or back surface
  25089. */
  25090. static readonly BACKSIDE: number;
  25091. /**
  25092. * Mesh side orientation : both internal and external or front and back surfaces
  25093. */
  25094. static readonly DOUBLESIDE: number;
  25095. /**
  25096. * Mesh side orientation : by default, `FRONTSIDE`
  25097. */
  25098. static readonly DEFAULTSIDE: number;
  25099. /**
  25100. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25101. */
  25102. positions: Nullable<FloatArray>;
  25103. /**
  25104. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25105. */
  25106. normals: Nullable<FloatArray>;
  25107. /**
  25108. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25109. */
  25110. tangents: Nullable<FloatArray>;
  25111. /**
  25112. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25113. */
  25114. uvs: Nullable<FloatArray>;
  25115. /**
  25116. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25117. */
  25118. uvs2: Nullable<FloatArray>;
  25119. /**
  25120. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25121. */
  25122. uvs3: Nullable<FloatArray>;
  25123. /**
  25124. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25125. */
  25126. uvs4: Nullable<FloatArray>;
  25127. /**
  25128. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25129. */
  25130. uvs5: Nullable<FloatArray>;
  25131. /**
  25132. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25133. */
  25134. uvs6: Nullable<FloatArray>;
  25135. /**
  25136. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25137. */
  25138. colors: Nullable<FloatArray>;
  25139. /**
  25140. * 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).
  25141. */
  25142. matricesIndices: Nullable<FloatArray>;
  25143. /**
  25144. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25145. */
  25146. matricesWeights: Nullable<FloatArray>;
  25147. /**
  25148. * An array extending the number of possible indices
  25149. */
  25150. matricesIndicesExtra: Nullable<FloatArray>;
  25151. /**
  25152. * An array extending the number of possible weights when the number of indices is extended
  25153. */
  25154. matricesWeightsExtra: Nullable<FloatArray>;
  25155. /**
  25156. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25157. */
  25158. indices: Nullable<IndicesArray>;
  25159. /**
  25160. * Uses the passed data array to set the set the values for the specified kind of data
  25161. * @param data a linear array of floating numbers
  25162. * @param kind the type of data that is being set, eg positions, colors etc
  25163. */
  25164. set(data: FloatArray, kind: string): void;
  25165. /**
  25166. * Associates the vertexData to the passed Mesh.
  25167. * Sets it as updatable or not (default `false`)
  25168. * @param mesh the mesh the vertexData is applied to
  25169. * @param updatable when used and having the value true allows new data to update the vertexData
  25170. * @returns the VertexData
  25171. */
  25172. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25173. /**
  25174. * Associates the vertexData to the passed Geometry.
  25175. * Sets it as updatable or not (default `false`)
  25176. * @param geometry the geometry the vertexData is applied to
  25177. * @param updatable when used and having the value true allows new data to update the vertexData
  25178. * @returns VertexData
  25179. */
  25180. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25181. /**
  25182. * Updates the associated mesh
  25183. * @param mesh the mesh to be updated
  25184. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25185. * @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
  25186. * @returns VertexData
  25187. */
  25188. updateMesh(mesh: Mesh): VertexData;
  25189. /**
  25190. * Updates the associated geometry
  25191. * @param geometry the geometry to be updated
  25192. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25193. * @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
  25194. * @returns VertexData.
  25195. */
  25196. updateGeometry(geometry: Geometry): VertexData;
  25197. private _applyTo;
  25198. private _update;
  25199. /**
  25200. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25201. * @param matrix the transforming matrix
  25202. * @returns the VertexData
  25203. */
  25204. transform(matrix: Matrix): VertexData;
  25205. /**
  25206. * Merges the passed VertexData into the current one
  25207. * @param other the VertexData to be merged into the current one
  25208. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25209. * @returns the modified VertexData
  25210. */
  25211. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25212. private _mergeElement;
  25213. private _validate;
  25214. /**
  25215. * Serializes the VertexData
  25216. * @returns a serialized object
  25217. */
  25218. serialize(): any;
  25219. /**
  25220. * Extracts the vertexData from a mesh
  25221. * @param mesh the mesh from which to extract the VertexData
  25222. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25223. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25224. * @returns the object VertexData associated to the passed mesh
  25225. */
  25226. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25227. /**
  25228. * Extracts the vertexData from the geometry
  25229. * @param geometry the geometry from which to extract the VertexData
  25230. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25231. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25232. * @returns the object VertexData associated to the passed mesh
  25233. */
  25234. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25235. private static _ExtractFrom;
  25236. /**
  25237. * Creates the VertexData for a Ribbon
  25238. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25239. * * pathArray array of paths, each of which an array of successive Vector3
  25240. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25241. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25242. * * 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
  25243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25244. * * 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)
  25245. * * 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)
  25246. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25247. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25248. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25249. * @returns the VertexData of the ribbon
  25250. */
  25251. static CreateRibbon(options: {
  25252. pathArray: Vector3[][];
  25253. closeArray?: boolean;
  25254. closePath?: boolean;
  25255. offset?: number;
  25256. sideOrientation?: number;
  25257. frontUVs?: Vector4;
  25258. backUVs?: Vector4;
  25259. invertUV?: boolean;
  25260. uvs?: Vector2[];
  25261. colors?: Color4[];
  25262. }): VertexData;
  25263. /**
  25264. * Creates the VertexData for a box
  25265. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25266. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25267. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25268. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25269. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25270. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25271. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25272. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25273. * * 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)
  25274. * * 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)
  25275. * @returns the VertexData of the box
  25276. */
  25277. static CreateBox(options: {
  25278. size?: number;
  25279. width?: number;
  25280. height?: number;
  25281. depth?: number;
  25282. faceUV?: Vector4[];
  25283. faceColors?: Color4[];
  25284. sideOrientation?: number;
  25285. frontUVs?: Vector4;
  25286. backUVs?: Vector4;
  25287. }): VertexData;
  25288. /**
  25289. * Creates the VertexData for a tiled box
  25290. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25291. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25292. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25293. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25294. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25295. * @returns the VertexData of the box
  25296. */
  25297. static CreateTiledBox(options: {
  25298. pattern?: number;
  25299. width?: number;
  25300. height?: number;
  25301. depth?: number;
  25302. tileSize?: number;
  25303. tileWidth?: number;
  25304. tileHeight?: number;
  25305. alignHorizontal?: number;
  25306. alignVertical?: number;
  25307. faceUV?: Vector4[];
  25308. faceColors?: Color4[];
  25309. sideOrientation?: number;
  25310. }): VertexData;
  25311. /**
  25312. * Creates the VertexData for a tiled plane
  25313. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25314. * * pattern a limited pattern arrangement depending on the number
  25315. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25316. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25317. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25318. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25319. * * 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)
  25320. * * 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)
  25321. * @returns the VertexData of the tiled plane
  25322. */
  25323. static CreateTiledPlane(options: {
  25324. pattern?: number;
  25325. tileSize?: number;
  25326. tileWidth?: number;
  25327. tileHeight?: number;
  25328. size?: number;
  25329. width?: number;
  25330. height?: number;
  25331. alignHorizontal?: number;
  25332. alignVertical?: number;
  25333. sideOrientation?: number;
  25334. frontUVs?: Vector4;
  25335. backUVs?: Vector4;
  25336. }): VertexData;
  25337. /**
  25338. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25339. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25340. * * segments sets the number of horizontal strips optional, default 32
  25341. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25342. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25343. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25344. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25345. * * 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
  25346. * * 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
  25347. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25348. * * 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)
  25349. * * 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)
  25350. * @returns the VertexData of the ellipsoid
  25351. */
  25352. static CreateSphere(options: {
  25353. segments?: number;
  25354. diameter?: number;
  25355. diameterX?: number;
  25356. diameterY?: number;
  25357. diameterZ?: number;
  25358. arc?: number;
  25359. slice?: number;
  25360. sideOrientation?: number;
  25361. frontUVs?: Vector4;
  25362. backUVs?: Vector4;
  25363. }): VertexData;
  25364. /**
  25365. * Creates the VertexData for a cylinder, cone or prism
  25366. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25367. * * height sets the height (y direction) of the cylinder, optional, default 2
  25368. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25369. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25370. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25371. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25372. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25373. * * 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
  25374. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25375. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25376. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25377. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25378. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25379. * * 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)
  25380. * * 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)
  25381. * @returns the VertexData of the cylinder, cone or prism
  25382. */
  25383. static CreateCylinder(options: {
  25384. height?: number;
  25385. diameterTop?: number;
  25386. diameterBottom?: number;
  25387. diameter?: number;
  25388. tessellation?: number;
  25389. subdivisions?: number;
  25390. arc?: number;
  25391. faceColors?: Color4[];
  25392. faceUV?: Vector4[];
  25393. hasRings?: boolean;
  25394. enclose?: boolean;
  25395. sideOrientation?: number;
  25396. frontUVs?: Vector4;
  25397. backUVs?: Vector4;
  25398. }): VertexData;
  25399. /**
  25400. * Creates the VertexData for a torus
  25401. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25402. * * diameter the diameter of the torus, optional default 1
  25403. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25404. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25405. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25406. * * 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)
  25407. * * 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)
  25408. * @returns the VertexData of the torus
  25409. */
  25410. static CreateTorus(options: {
  25411. diameter?: number;
  25412. thickness?: number;
  25413. tessellation?: number;
  25414. sideOrientation?: number;
  25415. frontUVs?: Vector4;
  25416. backUVs?: Vector4;
  25417. }): VertexData;
  25418. /**
  25419. * Creates the VertexData of the LineSystem
  25420. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25421. * - lines an array of lines, each line being an array of successive Vector3
  25422. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25423. * @returns the VertexData of the LineSystem
  25424. */
  25425. static CreateLineSystem(options: {
  25426. lines: Vector3[][];
  25427. colors?: Nullable<Color4[][]>;
  25428. }): VertexData;
  25429. /**
  25430. * Create the VertexData for a DashedLines
  25431. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25432. * - points an array successive Vector3
  25433. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25434. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25435. * - dashNb the intended total number of dashes, optional, default 200
  25436. * @returns the VertexData for the DashedLines
  25437. */
  25438. static CreateDashedLines(options: {
  25439. points: Vector3[];
  25440. dashSize?: number;
  25441. gapSize?: number;
  25442. dashNb?: number;
  25443. }): VertexData;
  25444. /**
  25445. * Creates the VertexData for a Ground
  25446. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25447. * - width the width (x direction) of the ground, optional, default 1
  25448. * - height the height (z direction) of the ground, optional, default 1
  25449. * - subdivisions the number of subdivisions per side, optional, default 1
  25450. * @returns the VertexData of the Ground
  25451. */
  25452. static CreateGround(options: {
  25453. width?: number;
  25454. height?: number;
  25455. subdivisions?: number;
  25456. subdivisionsX?: number;
  25457. subdivisionsY?: number;
  25458. }): VertexData;
  25459. /**
  25460. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25461. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25462. * * xmin the ground minimum X coordinate, optional, default -1
  25463. * * zmin the ground minimum Z coordinate, optional, default -1
  25464. * * xmax the ground maximum X coordinate, optional, default 1
  25465. * * zmax the ground maximum Z coordinate, optional, default 1
  25466. * * 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}
  25467. * * 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}
  25468. * @returns the VertexData of the TiledGround
  25469. */
  25470. static CreateTiledGround(options: {
  25471. xmin: number;
  25472. zmin: number;
  25473. xmax: number;
  25474. zmax: number;
  25475. subdivisions?: {
  25476. w: number;
  25477. h: number;
  25478. };
  25479. precision?: {
  25480. w: number;
  25481. h: number;
  25482. };
  25483. }): VertexData;
  25484. /**
  25485. * Creates the VertexData of the Ground designed from a heightmap
  25486. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25487. * * width the width (x direction) of the ground
  25488. * * height the height (z direction) of the ground
  25489. * * subdivisions the number of subdivisions per side
  25490. * * minHeight the minimum altitude on the ground, optional, default 0
  25491. * * maxHeight the maximum altitude on the ground, optional default 1
  25492. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25493. * * buffer the array holding the image color data
  25494. * * bufferWidth the width of image
  25495. * * bufferHeight the height of image
  25496. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25497. * @returns the VertexData of the Ground designed from a heightmap
  25498. */
  25499. static CreateGroundFromHeightMap(options: {
  25500. width: number;
  25501. height: number;
  25502. subdivisions: number;
  25503. minHeight: number;
  25504. maxHeight: number;
  25505. colorFilter: Color3;
  25506. buffer: Uint8Array;
  25507. bufferWidth: number;
  25508. bufferHeight: number;
  25509. alphaFilter: number;
  25510. }): VertexData;
  25511. /**
  25512. * Creates the VertexData for a Plane
  25513. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25514. * * size sets the width and height of the plane to the value of size, optional default 1
  25515. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25516. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25517. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25518. * * 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)
  25519. * * 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)
  25520. * @returns the VertexData of the box
  25521. */
  25522. static CreatePlane(options: {
  25523. size?: number;
  25524. width?: number;
  25525. height?: number;
  25526. sideOrientation?: number;
  25527. frontUVs?: Vector4;
  25528. backUVs?: Vector4;
  25529. }): VertexData;
  25530. /**
  25531. * Creates the VertexData of the Disc or regular Polygon
  25532. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25533. * * radius the radius of the disc, optional default 0.5
  25534. * * tessellation the number of polygon sides, optional, default 64
  25535. * * 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
  25536. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25537. * * 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)
  25538. * * 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)
  25539. * @returns the VertexData of the box
  25540. */
  25541. static CreateDisc(options: {
  25542. radius?: number;
  25543. tessellation?: number;
  25544. arc?: number;
  25545. sideOrientation?: number;
  25546. frontUVs?: Vector4;
  25547. backUVs?: Vector4;
  25548. }): VertexData;
  25549. /**
  25550. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25551. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25552. * @param polygon a mesh built from polygonTriangulation.build()
  25553. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25554. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25555. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25556. * @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)
  25557. * @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)
  25558. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25559. * @returns the VertexData of the Polygon
  25560. */
  25561. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25562. /**
  25563. * Creates the VertexData of the IcoSphere
  25564. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25565. * * radius the radius of the IcoSphere, optional default 1
  25566. * * radiusX allows stretching in the x direction, optional, default radius
  25567. * * radiusY allows stretching in the y direction, optional, default radius
  25568. * * radiusZ allows stretching in the z direction, optional, default radius
  25569. * * flat when true creates a flat shaded mesh, optional, default true
  25570. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25571. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25572. * * 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)
  25573. * * 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)
  25574. * @returns the VertexData of the IcoSphere
  25575. */
  25576. static CreateIcoSphere(options: {
  25577. radius?: number;
  25578. radiusX?: number;
  25579. radiusY?: number;
  25580. radiusZ?: number;
  25581. flat?: boolean;
  25582. subdivisions?: number;
  25583. sideOrientation?: number;
  25584. frontUVs?: Vector4;
  25585. backUVs?: Vector4;
  25586. }): VertexData;
  25587. /**
  25588. * Creates the VertexData for a Polyhedron
  25589. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25590. * * type provided types are:
  25591. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25592. * * 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)
  25593. * * size the size of the IcoSphere, optional default 1
  25594. * * sizeX allows stretching in the x direction, optional, default size
  25595. * * sizeY allows stretching in the y direction, optional, default size
  25596. * * sizeZ allows stretching in the z direction, optional, default size
  25597. * * 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
  25598. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25599. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25600. * * flat when true creates a flat shaded mesh, optional, default true
  25601. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25602. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25603. * * 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)
  25604. * * 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)
  25605. * @returns the VertexData of the Polyhedron
  25606. */
  25607. static CreatePolyhedron(options: {
  25608. type?: number;
  25609. size?: number;
  25610. sizeX?: number;
  25611. sizeY?: number;
  25612. sizeZ?: number;
  25613. custom?: any;
  25614. faceUV?: Vector4[];
  25615. faceColors?: Color4[];
  25616. flat?: boolean;
  25617. sideOrientation?: number;
  25618. frontUVs?: Vector4;
  25619. backUVs?: Vector4;
  25620. }): VertexData;
  25621. /**
  25622. * Creates the VertexData for a TorusKnot
  25623. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25624. * * radius the radius of the torus knot, optional, default 2
  25625. * * tube the thickness of the tube, optional, default 0.5
  25626. * * radialSegments the number of sides on each tube segments, optional, default 32
  25627. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25628. * * p the number of windings around the z axis, optional, default 2
  25629. * * q the number of windings around the x axis, optional, default 3
  25630. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25631. * * 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)
  25632. * * 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)
  25633. * @returns the VertexData of the Torus Knot
  25634. */
  25635. static CreateTorusKnot(options: {
  25636. radius?: number;
  25637. tube?: number;
  25638. radialSegments?: number;
  25639. tubularSegments?: number;
  25640. p?: number;
  25641. q?: number;
  25642. sideOrientation?: number;
  25643. frontUVs?: Vector4;
  25644. backUVs?: Vector4;
  25645. }): VertexData;
  25646. /**
  25647. * Compute normals for given positions and indices
  25648. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25649. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25650. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25651. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25652. * * facetNormals : optional array of facet normals (vector3)
  25653. * * facetPositions : optional array of facet positions (vector3)
  25654. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25655. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25656. * * bInfo : optional bounding info, required for facetPartitioning computation
  25657. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25658. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25659. * * useRightHandedSystem: optional boolean to for right handed system computation
  25660. * * depthSort : optional boolean to enable the facet depth sort computation
  25661. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25662. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25663. */
  25664. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25665. facetNormals?: any;
  25666. facetPositions?: any;
  25667. facetPartitioning?: any;
  25668. ratio?: number;
  25669. bInfo?: any;
  25670. bbSize?: Vector3;
  25671. subDiv?: any;
  25672. useRightHandedSystem?: boolean;
  25673. depthSort?: boolean;
  25674. distanceTo?: Vector3;
  25675. depthSortedFacets?: any;
  25676. }): void;
  25677. /** @hidden */
  25678. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25679. /**
  25680. * Applies VertexData created from the imported parameters to the geometry
  25681. * @param parsedVertexData the parsed data from an imported file
  25682. * @param geometry the geometry to apply the VertexData to
  25683. */
  25684. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25685. }
  25686. }
  25687. declare module BABYLON {
  25688. /**
  25689. * Defines a target to use with MorphTargetManager
  25690. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25691. */
  25692. export class MorphTarget implements IAnimatable {
  25693. /** defines the name of the target */
  25694. name: string;
  25695. /**
  25696. * Gets or sets the list of animations
  25697. */
  25698. animations: Animation[];
  25699. private _scene;
  25700. private _positions;
  25701. private _normals;
  25702. private _tangents;
  25703. private _uvs;
  25704. private _influence;
  25705. private _uniqueId;
  25706. /**
  25707. * Observable raised when the influence changes
  25708. */
  25709. onInfluenceChanged: Observable<boolean>;
  25710. /** @hidden */
  25711. _onDataLayoutChanged: Observable<void>;
  25712. /**
  25713. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25714. */
  25715. get influence(): number;
  25716. set influence(influence: number);
  25717. /**
  25718. * Gets or sets the id of the morph Target
  25719. */
  25720. id: string;
  25721. private _animationPropertiesOverride;
  25722. /**
  25723. * Gets or sets the animation properties override
  25724. */
  25725. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25726. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25727. /**
  25728. * Creates a new MorphTarget
  25729. * @param name defines the name of the target
  25730. * @param influence defines the influence to use
  25731. * @param scene defines the scene the morphtarget belongs to
  25732. */
  25733. constructor(
  25734. /** defines the name of the target */
  25735. name: string, influence?: number, scene?: Nullable<Scene>);
  25736. /**
  25737. * Gets the unique ID of this manager
  25738. */
  25739. get uniqueId(): number;
  25740. /**
  25741. * Gets a boolean defining if the target contains position data
  25742. */
  25743. get hasPositions(): boolean;
  25744. /**
  25745. * Gets a boolean defining if the target contains normal data
  25746. */
  25747. get hasNormals(): boolean;
  25748. /**
  25749. * Gets a boolean defining if the target contains tangent data
  25750. */
  25751. get hasTangents(): boolean;
  25752. /**
  25753. * Gets a boolean defining if the target contains texture coordinates data
  25754. */
  25755. get hasUVs(): boolean;
  25756. /**
  25757. * Affects position data to this target
  25758. * @param data defines the position data to use
  25759. */
  25760. setPositions(data: Nullable<FloatArray>): void;
  25761. /**
  25762. * Gets the position data stored in this target
  25763. * @returns a FloatArray containing the position data (or null if not present)
  25764. */
  25765. getPositions(): Nullable<FloatArray>;
  25766. /**
  25767. * Affects normal data to this target
  25768. * @param data defines the normal data to use
  25769. */
  25770. setNormals(data: Nullable<FloatArray>): void;
  25771. /**
  25772. * Gets the normal data stored in this target
  25773. * @returns a FloatArray containing the normal data (or null if not present)
  25774. */
  25775. getNormals(): Nullable<FloatArray>;
  25776. /**
  25777. * Affects tangent data to this target
  25778. * @param data defines the tangent data to use
  25779. */
  25780. setTangents(data: Nullable<FloatArray>): void;
  25781. /**
  25782. * Gets the tangent data stored in this target
  25783. * @returns a FloatArray containing the tangent data (or null if not present)
  25784. */
  25785. getTangents(): Nullable<FloatArray>;
  25786. /**
  25787. * Affects texture coordinates data to this target
  25788. * @param data defines the texture coordinates data to use
  25789. */
  25790. setUVs(data: Nullable<FloatArray>): void;
  25791. /**
  25792. * Gets the texture coordinates data stored in this target
  25793. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25794. */
  25795. getUVs(): Nullable<FloatArray>;
  25796. /**
  25797. * Clone the current target
  25798. * @returns a new MorphTarget
  25799. */
  25800. clone(): MorphTarget;
  25801. /**
  25802. * Serializes the current target into a Serialization object
  25803. * @returns the serialized object
  25804. */
  25805. serialize(): any;
  25806. /**
  25807. * Returns the string "MorphTarget"
  25808. * @returns "MorphTarget"
  25809. */
  25810. getClassName(): string;
  25811. /**
  25812. * Creates a new target from serialized data
  25813. * @param serializationObject defines the serialized data to use
  25814. * @returns a new MorphTarget
  25815. */
  25816. static Parse(serializationObject: any): MorphTarget;
  25817. /**
  25818. * Creates a MorphTarget from mesh data
  25819. * @param mesh defines the source mesh
  25820. * @param name defines the name to use for the new target
  25821. * @param influence defines the influence to attach to the target
  25822. * @returns a new MorphTarget
  25823. */
  25824. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25825. }
  25826. }
  25827. declare module BABYLON {
  25828. /**
  25829. * This class is used to deform meshes using morphing between different targets
  25830. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25831. */
  25832. export class MorphTargetManager {
  25833. private _targets;
  25834. private _targetInfluenceChangedObservers;
  25835. private _targetDataLayoutChangedObservers;
  25836. private _activeTargets;
  25837. private _scene;
  25838. private _influences;
  25839. private _supportsNormals;
  25840. private _supportsTangents;
  25841. private _supportsUVs;
  25842. private _vertexCount;
  25843. private _uniqueId;
  25844. private _tempInfluences;
  25845. /**
  25846. * Gets or sets a boolean indicating if normals must be morphed
  25847. */
  25848. enableNormalMorphing: boolean;
  25849. /**
  25850. * Gets or sets a boolean indicating if tangents must be morphed
  25851. */
  25852. enableTangentMorphing: boolean;
  25853. /**
  25854. * Gets or sets a boolean indicating if UV must be morphed
  25855. */
  25856. enableUVMorphing: boolean;
  25857. /**
  25858. * Creates a new MorphTargetManager
  25859. * @param scene defines the current scene
  25860. */
  25861. constructor(scene?: Nullable<Scene>);
  25862. /**
  25863. * Gets the unique ID of this manager
  25864. */
  25865. get uniqueId(): number;
  25866. /**
  25867. * Gets the number of vertices handled by this manager
  25868. */
  25869. get vertexCount(): number;
  25870. /**
  25871. * Gets a boolean indicating if this manager supports morphing of normals
  25872. */
  25873. get supportsNormals(): boolean;
  25874. /**
  25875. * Gets a boolean indicating if this manager supports morphing of tangents
  25876. */
  25877. get supportsTangents(): boolean;
  25878. /**
  25879. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25880. */
  25881. get supportsUVs(): boolean;
  25882. /**
  25883. * Gets the number of targets stored in this manager
  25884. */
  25885. get numTargets(): number;
  25886. /**
  25887. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25888. */
  25889. get numInfluencers(): number;
  25890. /**
  25891. * Gets the list of influences (one per target)
  25892. */
  25893. get influences(): Float32Array;
  25894. /**
  25895. * Gets the active target at specified index. An active target is a target with an influence > 0
  25896. * @param index defines the index to check
  25897. * @returns the requested target
  25898. */
  25899. getActiveTarget(index: number): MorphTarget;
  25900. /**
  25901. * Gets the target at specified index
  25902. * @param index defines the index to check
  25903. * @returns the requested target
  25904. */
  25905. getTarget(index: number): MorphTarget;
  25906. /**
  25907. * Add a new target to this manager
  25908. * @param target defines the target to add
  25909. */
  25910. addTarget(target: MorphTarget): void;
  25911. /**
  25912. * Removes a target from the manager
  25913. * @param target defines the target to remove
  25914. */
  25915. removeTarget(target: MorphTarget): void;
  25916. /**
  25917. * Clone the current manager
  25918. * @returns a new MorphTargetManager
  25919. */
  25920. clone(): MorphTargetManager;
  25921. /**
  25922. * Serializes the current manager into a Serialization object
  25923. * @returns the serialized object
  25924. */
  25925. serialize(): any;
  25926. private _syncActiveTargets;
  25927. /**
  25928. * Syncrhonize the targets with all the meshes using this morph target manager
  25929. */
  25930. synchronize(): void;
  25931. /**
  25932. * Creates a new MorphTargetManager from serialized data
  25933. * @param serializationObject defines the serialized data
  25934. * @param scene defines the hosting scene
  25935. * @returns the new MorphTargetManager
  25936. */
  25937. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25938. }
  25939. }
  25940. declare module BABYLON {
  25941. /**
  25942. * Class used to represent a specific level of detail of a mesh
  25943. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25944. */
  25945. export class MeshLODLevel {
  25946. /** Defines the distance where this level should start being displayed */
  25947. distance: number;
  25948. /** Defines the mesh to use to render this level */
  25949. mesh: Nullable<Mesh>;
  25950. /**
  25951. * Creates a new LOD level
  25952. * @param distance defines the distance where this level should star being displayed
  25953. * @param mesh defines the mesh to use to render this level
  25954. */
  25955. constructor(
  25956. /** Defines the distance where this level should start being displayed */
  25957. distance: number,
  25958. /** Defines the mesh to use to render this level */
  25959. mesh: Nullable<Mesh>);
  25960. }
  25961. }
  25962. declare module BABYLON {
  25963. /**
  25964. * Mesh representing the gorund
  25965. */
  25966. export class GroundMesh extends Mesh {
  25967. /** If octree should be generated */
  25968. generateOctree: boolean;
  25969. private _heightQuads;
  25970. /** @hidden */
  25971. _subdivisionsX: number;
  25972. /** @hidden */
  25973. _subdivisionsY: number;
  25974. /** @hidden */
  25975. _width: number;
  25976. /** @hidden */
  25977. _height: number;
  25978. /** @hidden */
  25979. _minX: number;
  25980. /** @hidden */
  25981. _maxX: number;
  25982. /** @hidden */
  25983. _minZ: number;
  25984. /** @hidden */
  25985. _maxZ: number;
  25986. constructor(name: string, scene: Scene);
  25987. /**
  25988. * "GroundMesh"
  25989. * @returns "GroundMesh"
  25990. */
  25991. getClassName(): string;
  25992. /**
  25993. * The minimum of x and y subdivisions
  25994. */
  25995. get subdivisions(): number;
  25996. /**
  25997. * X subdivisions
  25998. */
  25999. get subdivisionsX(): number;
  26000. /**
  26001. * Y subdivisions
  26002. */
  26003. get subdivisionsY(): number;
  26004. /**
  26005. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26006. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26007. * @param chunksCount the number of subdivisions for x and y
  26008. * @param octreeBlocksSize (Default: 32)
  26009. */
  26010. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26011. /**
  26012. * Returns a height (y) value in the Worl system :
  26013. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26014. * @param x x coordinate
  26015. * @param z z coordinate
  26016. * @returns the ground y position if (x, z) are outside the ground surface.
  26017. */
  26018. getHeightAtCoordinates(x: number, z: number): number;
  26019. /**
  26020. * Returns a normalized vector (Vector3) orthogonal to the ground
  26021. * at the ground coordinates (x, z) expressed in the World system.
  26022. * @param x x coordinate
  26023. * @param z z coordinate
  26024. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26025. */
  26026. getNormalAtCoordinates(x: number, z: number): Vector3;
  26027. /**
  26028. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26029. * at the ground coordinates (x, z) expressed in the World system.
  26030. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26031. * @param x x coordinate
  26032. * @param z z coordinate
  26033. * @param ref vector to store the result
  26034. * @returns the GroundMesh.
  26035. */
  26036. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26037. /**
  26038. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26039. * if the ground has been updated.
  26040. * This can be used in the render loop.
  26041. * @returns the GroundMesh.
  26042. */
  26043. updateCoordinateHeights(): GroundMesh;
  26044. private _getFacetAt;
  26045. private _initHeightQuads;
  26046. private _computeHeightQuads;
  26047. /**
  26048. * Serializes this ground mesh
  26049. * @param serializationObject object to write serialization to
  26050. */
  26051. serialize(serializationObject: any): void;
  26052. /**
  26053. * Parses a serialized ground mesh
  26054. * @param parsedMesh the serialized mesh
  26055. * @param scene the scene to create the ground mesh in
  26056. * @returns the created ground mesh
  26057. */
  26058. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26059. }
  26060. }
  26061. declare module BABYLON {
  26062. /**
  26063. * Interface for Physics-Joint data
  26064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26065. */
  26066. export interface PhysicsJointData {
  26067. /**
  26068. * The main pivot of the joint
  26069. */
  26070. mainPivot?: Vector3;
  26071. /**
  26072. * The connected pivot of the joint
  26073. */
  26074. connectedPivot?: Vector3;
  26075. /**
  26076. * The main axis of the joint
  26077. */
  26078. mainAxis?: Vector3;
  26079. /**
  26080. * The connected axis of the joint
  26081. */
  26082. connectedAxis?: Vector3;
  26083. /**
  26084. * The collision of the joint
  26085. */
  26086. collision?: boolean;
  26087. /**
  26088. * Native Oimo/Cannon/Energy data
  26089. */
  26090. nativeParams?: any;
  26091. }
  26092. /**
  26093. * This is a holder class for the physics joint created by the physics plugin
  26094. * It holds a set of functions to control the underlying joint
  26095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26096. */
  26097. export class PhysicsJoint {
  26098. /**
  26099. * The type of the physics joint
  26100. */
  26101. type: number;
  26102. /**
  26103. * The data for the physics joint
  26104. */
  26105. jointData: PhysicsJointData;
  26106. private _physicsJoint;
  26107. protected _physicsPlugin: IPhysicsEnginePlugin;
  26108. /**
  26109. * Initializes the physics joint
  26110. * @param type The type of the physics joint
  26111. * @param jointData The data for the physics joint
  26112. */
  26113. constructor(
  26114. /**
  26115. * The type of the physics joint
  26116. */
  26117. type: number,
  26118. /**
  26119. * The data for the physics joint
  26120. */
  26121. jointData: PhysicsJointData);
  26122. /**
  26123. * Gets the physics joint
  26124. */
  26125. get physicsJoint(): any;
  26126. /**
  26127. * Sets the physics joint
  26128. */
  26129. set physicsJoint(newJoint: any);
  26130. /**
  26131. * Sets the physics plugin
  26132. */
  26133. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26134. /**
  26135. * Execute a function that is physics-plugin specific.
  26136. * @param {Function} func the function that will be executed.
  26137. * It accepts two parameters: the physics world and the physics joint
  26138. */
  26139. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26140. /**
  26141. * Distance-Joint type
  26142. */
  26143. static DistanceJoint: number;
  26144. /**
  26145. * Hinge-Joint type
  26146. */
  26147. static HingeJoint: number;
  26148. /**
  26149. * Ball-and-Socket joint type
  26150. */
  26151. static BallAndSocketJoint: number;
  26152. /**
  26153. * Wheel-Joint type
  26154. */
  26155. static WheelJoint: number;
  26156. /**
  26157. * Slider-Joint type
  26158. */
  26159. static SliderJoint: number;
  26160. /**
  26161. * Prismatic-Joint type
  26162. */
  26163. static PrismaticJoint: number;
  26164. /**
  26165. * Universal-Joint type
  26166. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26167. */
  26168. static UniversalJoint: number;
  26169. /**
  26170. * Hinge-Joint 2 type
  26171. */
  26172. static Hinge2Joint: number;
  26173. /**
  26174. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26175. */
  26176. static PointToPointJoint: number;
  26177. /**
  26178. * Spring-Joint type
  26179. */
  26180. static SpringJoint: number;
  26181. /**
  26182. * Lock-Joint type
  26183. */
  26184. static LockJoint: number;
  26185. }
  26186. /**
  26187. * A class representing a physics distance joint
  26188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26189. */
  26190. export class DistanceJoint extends PhysicsJoint {
  26191. /**
  26192. *
  26193. * @param jointData The data for the Distance-Joint
  26194. */
  26195. constructor(jointData: DistanceJointData);
  26196. /**
  26197. * Update the predefined distance.
  26198. * @param maxDistance The maximum preferred distance
  26199. * @param minDistance The minimum preferred distance
  26200. */
  26201. updateDistance(maxDistance: number, minDistance?: number): void;
  26202. }
  26203. /**
  26204. * Represents a Motor-Enabled Joint
  26205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26206. */
  26207. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26208. /**
  26209. * Initializes the Motor-Enabled Joint
  26210. * @param type The type of the joint
  26211. * @param jointData The physica joint data for the joint
  26212. */
  26213. constructor(type: number, jointData: PhysicsJointData);
  26214. /**
  26215. * Set the motor values.
  26216. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26217. * @param force the force to apply
  26218. * @param maxForce max force for this motor.
  26219. */
  26220. setMotor(force?: number, maxForce?: number): void;
  26221. /**
  26222. * Set the motor's limits.
  26223. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26224. * @param upperLimit The upper limit of the motor
  26225. * @param lowerLimit The lower limit of the motor
  26226. */
  26227. setLimit(upperLimit: number, lowerLimit?: number): void;
  26228. }
  26229. /**
  26230. * This class represents a single physics Hinge-Joint
  26231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26232. */
  26233. export class HingeJoint extends MotorEnabledJoint {
  26234. /**
  26235. * Initializes the Hinge-Joint
  26236. * @param jointData The joint data for the Hinge-Joint
  26237. */
  26238. constructor(jointData: PhysicsJointData);
  26239. /**
  26240. * Set the motor values.
  26241. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26242. * @param {number} force the force to apply
  26243. * @param {number} maxForce max force for this motor.
  26244. */
  26245. setMotor(force?: number, maxForce?: number): void;
  26246. /**
  26247. * Set the motor's limits.
  26248. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26249. * @param upperLimit The upper limit of the motor
  26250. * @param lowerLimit The lower limit of the motor
  26251. */
  26252. setLimit(upperLimit: number, lowerLimit?: number): void;
  26253. }
  26254. /**
  26255. * This class represents a dual hinge physics joint (same as wheel joint)
  26256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26257. */
  26258. export class Hinge2Joint extends MotorEnabledJoint {
  26259. /**
  26260. * Initializes the Hinge2-Joint
  26261. * @param jointData The joint data for the Hinge2-Joint
  26262. */
  26263. constructor(jointData: PhysicsJointData);
  26264. /**
  26265. * Set the motor values.
  26266. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26267. * @param {number} targetSpeed the speed the motor is to reach
  26268. * @param {number} maxForce max force for this motor.
  26269. * @param {motorIndex} the motor's index, 0 or 1.
  26270. */
  26271. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26272. /**
  26273. * Set the motor limits.
  26274. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26275. * @param {number} upperLimit the upper limit
  26276. * @param {number} lowerLimit lower limit
  26277. * @param {motorIndex} the motor's index, 0 or 1.
  26278. */
  26279. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26280. }
  26281. /**
  26282. * Interface for a motor enabled joint
  26283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26284. */
  26285. export interface IMotorEnabledJoint {
  26286. /**
  26287. * Physics joint
  26288. */
  26289. physicsJoint: any;
  26290. /**
  26291. * Sets the motor of the motor-enabled joint
  26292. * @param force The force of the motor
  26293. * @param maxForce The maximum force of the motor
  26294. * @param motorIndex The index of the motor
  26295. */
  26296. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26297. /**
  26298. * Sets the limit of the motor
  26299. * @param upperLimit The upper limit of the motor
  26300. * @param lowerLimit The lower limit of the motor
  26301. * @param motorIndex The index of the motor
  26302. */
  26303. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26304. }
  26305. /**
  26306. * Joint data for a Distance-Joint
  26307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26308. */
  26309. export interface DistanceJointData extends PhysicsJointData {
  26310. /**
  26311. * Max distance the 2 joint objects can be apart
  26312. */
  26313. maxDistance: number;
  26314. }
  26315. /**
  26316. * Joint data from a spring joint
  26317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26318. */
  26319. export interface SpringJointData extends PhysicsJointData {
  26320. /**
  26321. * Length of the spring
  26322. */
  26323. length: number;
  26324. /**
  26325. * Stiffness of the spring
  26326. */
  26327. stiffness: number;
  26328. /**
  26329. * Damping of the spring
  26330. */
  26331. damping: number;
  26332. /** this callback will be called when applying the force to the impostors. */
  26333. forceApplicationCallback: () => void;
  26334. }
  26335. }
  26336. declare module BABYLON {
  26337. /**
  26338. * Holds the data for the raycast result
  26339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26340. */
  26341. export class PhysicsRaycastResult {
  26342. private _hasHit;
  26343. private _hitDistance;
  26344. private _hitNormalWorld;
  26345. private _hitPointWorld;
  26346. private _rayFromWorld;
  26347. private _rayToWorld;
  26348. /**
  26349. * Gets if there was a hit
  26350. */
  26351. get hasHit(): boolean;
  26352. /**
  26353. * Gets the distance from the hit
  26354. */
  26355. get hitDistance(): number;
  26356. /**
  26357. * Gets the hit normal/direction in the world
  26358. */
  26359. get hitNormalWorld(): Vector3;
  26360. /**
  26361. * Gets the hit point in the world
  26362. */
  26363. get hitPointWorld(): Vector3;
  26364. /**
  26365. * Gets the ray "start point" of the ray in the world
  26366. */
  26367. get rayFromWorld(): Vector3;
  26368. /**
  26369. * Gets the ray "end point" of the ray in the world
  26370. */
  26371. get rayToWorld(): Vector3;
  26372. /**
  26373. * Sets the hit data (normal & point in world space)
  26374. * @param hitNormalWorld defines the normal in world space
  26375. * @param hitPointWorld defines the point in world space
  26376. */
  26377. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26378. /**
  26379. * Sets the distance from the start point to the hit point
  26380. * @param distance
  26381. */
  26382. setHitDistance(distance: number): void;
  26383. /**
  26384. * Calculates the distance manually
  26385. */
  26386. calculateHitDistance(): void;
  26387. /**
  26388. * Resets all the values to default
  26389. * @param from The from point on world space
  26390. * @param to The to point on world space
  26391. */
  26392. reset(from?: Vector3, to?: Vector3): void;
  26393. }
  26394. /**
  26395. * Interface for the size containing width and height
  26396. */
  26397. interface IXYZ {
  26398. /**
  26399. * X
  26400. */
  26401. x: number;
  26402. /**
  26403. * Y
  26404. */
  26405. y: number;
  26406. /**
  26407. * Z
  26408. */
  26409. z: number;
  26410. }
  26411. }
  26412. declare module BABYLON {
  26413. /**
  26414. * Interface used to describe a physics joint
  26415. */
  26416. export interface PhysicsImpostorJoint {
  26417. /** Defines the main impostor to which the joint is linked */
  26418. mainImpostor: PhysicsImpostor;
  26419. /** Defines the impostor that is connected to the main impostor using this joint */
  26420. connectedImpostor: PhysicsImpostor;
  26421. /** Defines the joint itself */
  26422. joint: PhysicsJoint;
  26423. }
  26424. /** @hidden */
  26425. export interface IPhysicsEnginePlugin {
  26426. world: any;
  26427. name: string;
  26428. setGravity(gravity: Vector3): void;
  26429. setTimeStep(timeStep: number): void;
  26430. getTimeStep(): number;
  26431. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26432. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26433. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26434. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26435. removePhysicsBody(impostor: PhysicsImpostor): void;
  26436. generateJoint(joint: PhysicsImpostorJoint): void;
  26437. removeJoint(joint: PhysicsImpostorJoint): void;
  26438. isSupported(): boolean;
  26439. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26440. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26441. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26442. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26443. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26444. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26445. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26446. getBodyMass(impostor: PhysicsImpostor): number;
  26447. getBodyFriction(impostor: PhysicsImpostor): number;
  26448. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26449. getBodyRestitution(impostor: PhysicsImpostor): number;
  26450. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26451. getBodyPressure?(impostor: PhysicsImpostor): number;
  26452. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26453. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26454. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26455. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26456. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26457. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26458. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26459. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26460. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26461. sleepBody(impostor: PhysicsImpostor): void;
  26462. wakeUpBody(impostor: PhysicsImpostor): void;
  26463. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26464. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26465. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26466. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26467. getRadius(impostor: PhysicsImpostor): number;
  26468. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26469. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26470. dispose(): void;
  26471. }
  26472. /**
  26473. * Interface used to define a physics engine
  26474. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26475. */
  26476. export interface IPhysicsEngine {
  26477. /**
  26478. * Gets the gravity vector used by the simulation
  26479. */
  26480. gravity: Vector3;
  26481. /**
  26482. * Sets the gravity vector used by the simulation
  26483. * @param gravity defines the gravity vector to use
  26484. */
  26485. setGravity(gravity: Vector3): void;
  26486. /**
  26487. * Set the time step of the physics engine.
  26488. * Default is 1/60.
  26489. * To slow it down, enter 1/600 for example.
  26490. * To speed it up, 1/30
  26491. * @param newTimeStep the new timestep to apply to this world.
  26492. */
  26493. setTimeStep(newTimeStep: number): void;
  26494. /**
  26495. * Get the time step of the physics engine.
  26496. * @returns the current time step
  26497. */
  26498. getTimeStep(): number;
  26499. /**
  26500. * Set the sub time step of the physics engine.
  26501. * Default is 0 meaning there is no sub steps
  26502. * To increase physics resolution precision, set a small value (like 1 ms)
  26503. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26504. */
  26505. setSubTimeStep(subTimeStep: number): void;
  26506. /**
  26507. * Get the sub time step of the physics engine.
  26508. * @returns the current sub time step
  26509. */
  26510. getSubTimeStep(): number;
  26511. /**
  26512. * Release all resources
  26513. */
  26514. dispose(): void;
  26515. /**
  26516. * Gets the name of the current physics plugin
  26517. * @returns the name of the plugin
  26518. */
  26519. getPhysicsPluginName(): string;
  26520. /**
  26521. * Adding a new impostor for the impostor tracking.
  26522. * This will be done by the impostor itself.
  26523. * @param impostor the impostor to add
  26524. */
  26525. addImpostor(impostor: PhysicsImpostor): void;
  26526. /**
  26527. * Remove an impostor from the engine.
  26528. * This impostor and its mesh will not longer be updated by the physics engine.
  26529. * @param impostor the impostor to remove
  26530. */
  26531. removeImpostor(impostor: PhysicsImpostor): void;
  26532. /**
  26533. * Add a joint to the physics engine
  26534. * @param mainImpostor defines the main impostor to which the joint is added.
  26535. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26536. * @param joint defines the joint that will connect both impostors.
  26537. */
  26538. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26539. /**
  26540. * Removes a joint from the simulation
  26541. * @param mainImpostor defines the impostor used with the joint
  26542. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26543. * @param joint defines the joint to remove
  26544. */
  26545. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26546. /**
  26547. * Gets the current plugin used to run the simulation
  26548. * @returns current plugin
  26549. */
  26550. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26551. /**
  26552. * Gets the list of physic impostors
  26553. * @returns an array of PhysicsImpostor
  26554. */
  26555. getImpostors(): Array<PhysicsImpostor>;
  26556. /**
  26557. * Gets the impostor for a physics enabled object
  26558. * @param object defines the object impersonated by the impostor
  26559. * @returns the PhysicsImpostor or null if not found
  26560. */
  26561. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26562. /**
  26563. * Gets the impostor for a physics body object
  26564. * @param body defines physics body used by the impostor
  26565. * @returns the PhysicsImpostor or null if not found
  26566. */
  26567. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26568. /**
  26569. * Does a raycast in the physics world
  26570. * @param from when should the ray start?
  26571. * @param to when should the ray end?
  26572. * @returns PhysicsRaycastResult
  26573. */
  26574. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26575. /**
  26576. * Called by the scene. No need to call it.
  26577. * @param delta defines the timespam between frames
  26578. */
  26579. _step(delta: number): void;
  26580. }
  26581. }
  26582. declare module BABYLON {
  26583. /**
  26584. * The interface for the physics imposter parameters
  26585. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26586. */
  26587. export interface PhysicsImpostorParameters {
  26588. /**
  26589. * The mass of the physics imposter
  26590. */
  26591. mass: number;
  26592. /**
  26593. * The friction of the physics imposter
  26594. */
  26595. friction?: number;
  26596. /**
  26597. * The coefficient of restitution of the physics imposter
  26598. */
  26599. restitution?: number;
  26600. /**
  26601. * The native options of the physics imposter
  26602. */
  26603. nativeOptions?: any;
  26604. /**
  26605. * Specifies if the parent should be ignored
  26606. */
  26607. ignoreParent?: boolean;
  26608. /**
  26609. * Specifies if bi-directional transformations should be disabled
  26610. */
  26611. disableBidirectionalTransformation?: boolean;
  26612. /**
  26613. * The pressure inside the physics imposter, soft object only
  26614. */
  26615. pressure?: number;
  26616. /**
  26617. * The stiffness the physics imposter, soft object only
  26618. */
  26619. stiffness?: number;
  26620. /**
  26621. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26622. */
  26623. velocityIterations?: number;
  26624. /**
  26625. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26626. */
  26627. positionIterations?: number;
  26628. /**
  26629. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26630. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26631. * Add to fix multiple points
  26632. */
  26633. fixedPoints?: number;
  26634. /**
  26635. * The collision margin around a soft object
  26636. */
  26637. margin?: number;
  26638. /**
  26639. * The collision margin around a soft object
  26640. */
  26641. damping?: number;
  26642. /**
  26643. * The path for a rope based on an extrusion
  26644. */
  26645. path?: any;
  26646. /**
  26647. * The shape of an extrusion used for a rope based on an extrusion
  26648. */
  26649. shape?: any;
  26650. }
  26651. /**
  26652. * Interface for a physics-enabled object
  26653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26654. */
  26655. export interface IPhysicsEnabledObject {
  26656. /**
  26657. * The position of the physics-enabled object
  26658. */
  26659. position: Vector3;
  26660. /**
  26661. * The rotation of the physics-enabled object
  26662. */
  26663. rotationQuaternion: Nullable<Quaternion>;
  26664. /**
  26665. * The scale of the physics-enabled object
  26666. */
  26667. scaling: Vector3;
  26668. /**
  26669. * The rotation of the physics-enabled object
  26670. */
  26671. rotation?: Vector3;
  26672. /**
  26673. * The parent of the physics-enabled object
  26674. */
  26675. parent?: any;
  26676. /**
  26677. * The bounding info of the physics-enabled object
  26678. * @returns The bounding info of the physics-enabled object
  26679. */
  26680. getBoundingInfo(): BoundingInfo;
  26681. /**
  26682. * Computes the world matrix
  26683. * @param force Specifies if the world matrix should be computed by force
  26684. * @returns A world matrix
  26685. */
  26686. computeWorldMatrix(force: boolean): Matrix;
  26687. /**
  26688. * Gets the world matrix
  26689. * @returns A world matrix
  26690. */
  26691. getWorldMatrix?(): Matrix;
  26692. /**
  26693. * Gets the child meshes
  26694. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26695. * @returns An array of abstract meshes
  26696. */
  26697. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26698. /**
  26699. * Gets the vertex data
  26700. * @param kind The type of vertex data
  26701. * @returns A nullable array of numbers, or a float32 array
  26702. */
  26703. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26704. /**
  26705. * Gets the indices from the mesh
  26706. * @returns A nullable array of index arrays
  26707. */
  26708. getIndices?(): Nullable<IndicesArray>;
  26709. /**
  26710. * Gets the scene from the mesh
  26711. * @returns the indices array or null
  26712. */
  26713. getScene?(): Scene;
  26714. /**
  26715. * Gets the absolute position from the mesh
  26716. * @returns the absolute position
  26717. */
  26718. getAbsolutePosition(): Vector3;
  26719. /**
  26720. * Gets the absolute pivot point from the mesh
  26721. * @returns the absolute pivot point
  26722. */
  26723. getAbsolutePivotPoint(): Vector3;
  26724. /**
  26725. * Rotates the mesh
  26726. * @param axis The axis of rotation
  26727. * @param amount The amount of rotation
  26728. * @param space The space of the rotation
  26729. * @returns The rotation transform node
  26730. */
  26731. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26732. /**
  26733. * Translates the mesh
  26734. * @param axis The axis of translation
  26735. * @param distance The distance of translation
  26736. * @param space The space of the translation
  26737. * @returns The transform node
  26738. */
  26739. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26740. /**
  26741. * Sets the absolute position of the mesh
  26742. * @param absolutePosition The absolute position of the mesh
  26743. * @returns The transform node
  26744. */
  26745. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26746. /**
  26747. * Gets the class name of the mesh
  26748. * @returns The class name
  26749. */
  26750. getClassName(): string;
  26751. }
  26752. /**
  26753. * Represents a physics imposter
  26754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26755. */
  26756. export class PhysicsImpostor {
  26757. /**
  26758. * The physics-enabled object used as the physics imposter
  26759. */
  26760. object: IPhysicsEnabledObject;
  26761. /**
  26762. * The type of the physics imposter
  26763. */
  26764. type: number;
  26765. private _options;
  26766. private _scene?;
  26767. /**
  26768. * The default object size of the imposter
  26769. */
  26770. static DEFAULT_OBJECT_SIZE: Vector3;
  26771. /**
  26772. * The identity quaternion of the imposter
  26773. */
  26774. static IDENTITY_QUATERNION: Quaternion;
  26775. /** @hidden */
  26776. _pluginData: any;
  26777. private _physicsEngine;
  26778. private _physicsBody;
  26779. private _bodyUpdateRequired;
  26780. private _onBeforePhysicsStepCallbacks;
  26781. private _onAfterPhysicsStepCallbacks;
  26782. /** @hidden */
  26783. _onPhysicsCollideCallbacks: Array<{
  26784. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26785. otherImpostors: Array<PhysicsImpostor>;
  26786. }>;
  26787. private _deltaPosition;
  26788. private _deltaRotation;
  26789. private _deltaRotationConjugated;
  26790. /** @hidden */
  26791. _isFromLine: boolean;
  26792. private _parent;
  26793. private _isDisposed;
  26794. private static _tmpVecs;
  26795. private static _tmpQuat;
  26796. /**
  26797. * Specifies if the physics imposter is disposed
  26798. */
  26799. get isDisposed(): boolean;
  26800. /**
  26801. * Gets the mass of the physics imposter
  26802. */
  26803. get mass(): number;
  26804. set mass(value: number);
  26805. /**
  26806. * Gets the coefficient of friction
  26807. */
  26808. get friction(): number;
  26809. /**
  26810. * Sets the coefficient of friction
  26811. */
  26812. set friction(value: number);
  26813. /**
  26814. * Gets the coefficient of restitution
  26815. */
  26816. get restitution(): number;
  26817. /**
  26818. * Sets the coefficient of restitution
  26819. */
  26820. set restitution(value: number);
  26821. /**
  26822. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26823. */
  26824. get pressure(): number;
  26825. /**
  26826. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26827. */
  26828. set pressure(value: number);
  26829. /**
  26830. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26831. */
  26832. get stiffness(): number;
  26833. /**
  26834. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26835. */
  26836. set stiffness(value: number);
  26837. /**
  26838. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26839. */
  26840. get velocityIterations(): number;
  26841. /**
  26842. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26843. */
  26844. set velocityIterations(value: number);
  26845. /**
  26846. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26847. */
  26848. get positionIterations(): number;
  26849. /**
  26850. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26851. */
  26852. set positionIterations(value: number);
  26853. /**
  26854. * The unique id of the physics imposter
  26855. * set by the physics engine when adding this impostor to the array
  26856. */
  26857. uniqueId: number;
  26858. /**
  26859. * @hidden
  26860. */
  26861. soft: boolean;
  26862. /**
  26863. * @hidden
  26864. */
  26865. segments: number;
  26866. private _joints;
  26867. /**
  26868. * Initializes the physics imposter
  26869. * @param object The physics-enabled object used as the physics imposter
  26870. * @param type The type of the physics imposter
  26871. * @param _options The options for the physics imposter
  26872. * @param _scene The Babylon scene
  26873. */
  26874. constructor(
  26875. /**
  26876. * The physics-enabled object used as the physics imposter
  26877. */
  26878. object: IPhysicsEnabledObject,
  26879. /**
  26880. * The type of the physics imposter
  26881. */
  26882. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26883. /**
  26884. * This function will completly initialize this impostor.
  26885. * It will create a new body - but only if this mesh has no parent.
  26886. * If it has, this impostor will not be used other than to define the impostor
  26887. * of the child mesh.
  26888. * @hidden
  26889. */
  26890. _init(): void;
  26891. private _getPhysicsParent;
  26892. /**
  26893. * Should a new body be generated.
  26894. * @returns boolean specifying if body initialization is required
  26895. */
  26896. isBodyInitRequired(): boolean;
  26897. /**
  26898. * Sets the updated scaling
  26899. * @param updated Specifies if the scaling is updated
  26900. */
  26901. setScalingUpdated(): void;
  26902. /**
  26903. * Force a regeneration of this or the parent's impostor's body.
  26904. * Use under cautious - This will remove all joints already implemented.
  26905. */
  26906. forceUpdate(): void;
  26907. /**
  26908. * Gets the body that holds this impostor. Either its own, or its parent.
  26909. */
  26910. get physicsBody(): any;
  26911. /**
  26912. * Get the parent of the physics imposter
  26913. * @returns Physics imposter or null
  26914. */
  26915. get parent(): Nullable<PhysicsImpostor>;
  26916. /**
  26917. * Sets the parent of the physics imposter
  26918. */
  26919. set parent(value: Nullable<PhysicsImpostor>);
  26920. /**
  26921. * Set the physics body. Used mainly by the physics engine/plugin
  26922. */
  26923. set physicsBody(physicsBody: any);
  26924. /**
  26925. * Resets the update flags
  26926. */
  26927. resetUpdateFlags(): void;
  26928. /**
  26929. * Gets the object extend size
  26930. * @returns the object extend size
  26931. */
  26932. getObjectExtendSize(): Vector3;
  26933. /**
  26934. * Gets the object center
  26935. * @returns The object center
  26936. */
  26937. getObjectCenter(): Vector3;
  26938. /**
  26939. * Get a specific parameter from the options parameters
  26940. * @param paramName The object parameter name
  26941. * @returns The object parameter
  26942. */
  26943. getParam(paramName: string): any;
  26944. /**
  26945. * Sets a specific parameter in the options given to the physics plugin
  26946. * @param paramName The parameter name
  26947. * @param value The value of the parameter
  26948. */
  26949. setParam(paramName: string, value: number): void;
  26950. /**
  26951. * Specifically change the body's mass option. Won't recreate the physics body object
  26952. * @param mass The mass of the physics imposter
  26953. */
  26954. setMass(mass: number): void;
  26955. /**
  26956. * Gets the linear velocity
  26957. * @returns linear velocity or null
  26958. */
  26959. getLinearVelocity(): Nullable<Vector3>;
  26960. /**
  26961. * Sets the linear velocity
  26962. * @param velocity linear velocity or null
  26963. */
  26964. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26965. /**
  26966. * Gets the angular velocity
  26967. * @returns angular velocity or null
  26968. */
  26969. getAngularVelocity(): Nullable<Vector3>;
  26970. /**
  26971. * Sets the angular velocity
  26972. * @param velocity The velocity or null
  26973. */
  26974. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26975. /**
  26976. * Execute a function with the physics plugin native code
  26977. * Provide a function the will have two variables - the world object and the physics body object
  26978. * @param func The function to execute with the physics plugin native code
  26979. */
  26980. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26981. /**
  26982. * Register a function that will be executed before the physics world is stepping forward
  26983. * @param func The function to execute before the physics world is stepped forward
  26984. */
  26985. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26986. /**
  26987. * Unregister a function that will be executed before the physics world is stepping forward
  26988. * @param func The function to execute before the physics world is stepped forward
  26989. */
  26990. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26991. /**
  26992. * Register a function that will be executed after the physics step
  26993. * @param func The function to execute after physics step
  26994. */
  26995. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26996. /**
  26997. * Unregisters a function that will be executed after the physics step
  26998. * @param func The function to execute after physics step
  26999. */
  27000. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27001. /**
  27002. * register a function that will be executed when this impostor collides against a different body
  27003. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27004. * @param func Callback that is executed on collision
  27005. */
  27006. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27007. /**
  27008. * Unregisters the physics imposter on contact
  27009. * @param collideAgainst The physics object to collide against
  27010. * @param func Callback to execute on collision
  27011. */
  27012. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27013. private _tmpQuat;
  27014. private _tmpQuat2;
  27015. /**
  27016. * Get the parent rotation
  27017. * @returns The parent rotation
  27018. */
  27019. getParentsRotation(): Quaternion;
  27020. /**
  27021. * this function is executed by the physics engine.
  27022. */
  27023. beforeStep: () => void;
  27024. /**
  27025. * this function is executed by the physics engine
  27026. */
  27027. afterStep: () => void;
  27028. /**
  27029. * Legacy collision detection event support
  27030. */
  27031. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27032. /**
  27033. * event and body object due to cannon's event-based architecture.
  27034. */
  27035. onCollide: (e: {
  27036. body: any;
  27037. }) => void;
  27038. /**
  27039. * Apply a force
  27040. * @param force The force to apply
  27041. * @param contactPoint The contact point for the force
  27042. * @returns The physics imposter
  27043. */
  27044. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27045. /**
  27046. * Apply an impulse
  27047. * @param force The impulse force
  27048. * @param contactPoint The contact point for the impulse force
  27049. * @returns The physics imposter
  27050. */
  27051. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27052. /**
  27053. * A help function to create a joint
  27054. * @param otherImpostor A physics imposter used to create a joint
  27055. * @param jointType The type of joint
  27056. * @param jointData The data for the joint
  27057. * @returns The physics imposter
  27058. */
  27059. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27060. /**
  27061. * Add a joint to this impostor with a different impostor
  27062. * @param otherImpostor A physics imposter used to add a joint
  27063. * @param joint The joint to add
  27064. * @returns The physics imposter
  27065. */
  27066. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27067. /**
  27068. * Add an anchor to a cloth impostor
  27069. * @param otherImpostor rigid impostor to anchor to
  27070. * @param width ratio across width from 0 to 1
  27071. * @param height ratio up height from 0 to 1
  27072. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27073. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27074. * @returns impostor the soft imposter
  27075. */
  27076. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27077. /**
  27078. * Add a hook to a rope impostor
  27079. * @param otherImpostor rigid impostor to anchor to
  27080. * @param length ratio across rope from 0 to 1
  27081. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27082. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27083. * @returns impostor the rope imposter
  27084. */
  27085. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27086. /**
  27087. * Will keep this body still, in a sleep mode.
  27088. * @returns the physics imposter
  27089. */
  27090. sleep(): PhysicsImpostor;
  27091. /**
  27092. * Wake the body up.
  27093. * @returns The physics imposter
  27094. */
  27095. wakeUp(): PhysicsImpostor;
  27096. /**
  27097. * Clones the physics imposter
  27098. * @param newObject The physics imposter clones to this physics-enabled object
  27099. * @returns A nullable physics imposter
  27100. */
  27101. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27102. /**
  27103. * Disposes the physics imposter
  27104. */
  27105. dispose(): void;
  27106. /**
  27107. * Sets the delta position
  27108. * @param position The delta position amount
  27109. */
  27110. setDeltaPosition(position: Vector3): void;
  27111. /**
  27112. * Sets the delta rotation
  27113. * @param rotation The delta rotation amount
  27114. */
  27115. setDeltaRotation(rotation: Quaternion): void;
  27116. /**
  27117. * Gets the box size of the physics imposter and stores the result in the input parameter
  27118. * @param result Stores the box size
  27119. * @returns The physics imposter
  27120. */
  27121. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27122. /**
  27123. * Gets the radius of the physics imposter
  27124. * @returns Radius of the physics imposter
  27125. */
  27126. getRadius(): number;
  27127. /**
  27128. * Sync a bone with this impostor
  27129. * @param bone The bone to sync to the impostor.
  27130. * @param boneMesh The mesh that the bone is influencing.
  27131. * @param jointPivot The pivot of the joint / bone in local space.
  27132. * @param distToJoint Optional distance from the impostor to the joint.
  27133. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27134. */
  27135. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27136. /**
  27137. * Sync impostor to a bone
  27138. * @param bone The bone that the impostor will be synced to.
  27139. * @param boneMesh The mesh that the bone is influencing.
  27140. * @param jointPivot The pivot of the joint / bone in local space.
  27141. * @param distToJoint Optional distance from the impostor to the joint.
  27142. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27143. * @param boneAxis Optional vector3 axis the bone is aligned with
  27144. */
  27145. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27146. /**
  27147. * No-Imposter type
  27148. */
  27149. static NoImpostor: number;
  27150. /**
  27151. * Sphere-Imposter type
  27152. */
  27153. static SphereImpostor: number;
  27154. /**
  27155. * Box-Imposter type
  27156. */
  27157. static BoxImpostor: number;
  27158. /**
  27159. * Plane-Imposter type
  27160. */
  27161. static PlaneImpostor: number;
  27162. /**
  27163. * Mesh-imposter type
  27164. */
  27165. static MeshImpostor: number;
  27166. /**
  27167. * Capsule-Impostor type (Ammo.js plugin only)
  27168. */
  27169. static CapsuleImpostor: number;
  27170. /**
  27171. * Cylinder-Imposter type
  27172. */
  27173. static CylinderImpostor: number;
  27174. /**
  27175. * Particle-Imposter type
  27176. */
  27177. static ParticleImpostor: number;
  27178. /**
  27179. * Heightmap-Imposter type
  27180. */
  27181. static HeightmapImpostor: number;
  27182. /**
  27183. * ConvexHull-Impostor type (Ammo.js plugin only)
  27184. */
  27185. static ConvexHullImpostor: number;
  27186. /**
  27187. * Custom-Imposter type (Ammo.js plugin only)
  27188. */
  27189. static CustomImpostor: number;
  27190. /**
  27191. * Rope-Imposter type
  27192. */
  27193. static RopeImpostor: number;
  27194. /**
  27195. * Cloth-Imposter type
  27196. */
  27197. static ClothImpostor: number;
  27198. /**
  27199. * Softbody-Imposter type
  27200. */
  27201. static SoftbodyImpostor: number;
  27202. }
  27203. }
  27204. declare module BABYLON {
  27205. /**
  27206. * @hidden
  27207. **/
  27208. export class _CreationDataStorage {
  27209. closePath?: boolean;
  27210. closeArray?: boolean;
  27211. idx: number[];
  27212. dashSize: number;
  27213. gapSize: number;
  27214. path3D: Path3D;
  27215. pathArray: Vector3[][];
  27216. arc: number;
  27217. radius: number;
  27218. cap: number;
  27219. tessellation: number;
  27220. }
  27221. /**
  27222. * @hidden
  27223. **/
  27224. class _InstanceDataStorage {
  27225. visibleInstances: any;
  27226. batchCache: _InstancesBatch;
  27227. instancesBufferSize: number;
  27228. instancesBuffer: Nullable<Buffer>;
  27229. instancesData: Float32Array;
  27230. overridenInstanceCount: number;
  27231. isFrozen: boolean;
  27232. previousBatch: Nullable<_InstancesBatch>;
  27233. hardwareInstancedRendering: boolean;
  27234. sideOrientation: number;
  27235. manualUpdate: boolean;
  27236. }
  27237. /**
  27238. * @hidden
  27239. **/
  27240. export class _InstancesBatch {
  27241. mustReturn: boolean;
  27242. visibleInstances: Nullable<InstancedMesh[]>[];
  27243. renderSelf: boolean[];
  27244. hardwareInstancedRendering: boolean[];
  27245. }
  27246. /**
  27247. * @hidden
  27248. **/
  27249. class _ThinInstanceDataStorage {
  27250. instancesCount: number;
  27251. matrixBuffer: Nullable<Buffer>;
  27252. matrixBufferSize: number;
  27253. matrixData: Nullable<Float32Array>;
  27254. boundingVectors: Array<Vector3>;
  27255. }
  27256. /**
  27257. * Class used to represent renderable models
  27258. */
  27259. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27260. /**
  27261. * Mesh side orientation : usually the external or front surface
  27262. */
  27263. static readonly FRONTSIDE: number;
  27264. /**
  27265. * Mesh side orientation : usually the internal or back surface
  27266. */
  27267. static readonly BACKSIDE: number;
  27268. /**
  27269. * Mesh side orientation : both internal and external or front and back surfaces
  27270. */
  27271. static readonly DOUBLESIDE: number;
  27272. /**
  27273. * Mesh side orientation : by default, `FRONTSIDE`
  27274. */
  27275. static readonly DEFAULTSIDE: number;
  27276. /**
  27277. * Mesh cap setting : no cap
  27278. */
  27279. static readonly NO_CAP: number;
  27280. /**
  27281. * Mesh cap setting : one cap at the beginning of the mesh
  27282. */
  27283. static readonly CAP_START: number;
  27284. /**
  27285. * Mesh cap setting : one cap at the end of the mesh
  27286. */
  27287. static readonly CAP_END: number;
  27288. /**
  27289. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27290. */
  27291. static readonly CAP_ALL: number;
  27292. /**
  27293. * Mesh pattern setting : no flip or rotate
  27294. */
  27295. static readonly NO_FLIP: number;
  27296. /**
  27297. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27298. */
  27299. static readonly FLIP_TILE: number;
  27300. /**
  27301. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27302. */
  27303. static readonly ROTATE_TILE: number;
  27304. /**
  27305. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27306. */
  27307. static readonly FLIP_ROW: number;
  27308. /**
  27309. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27310. */
  27311. static readonly ROTATE_ROW: number;
  27312. /**
  27313. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27314. */
  27315. static readonly FLIP_N_ROTATE_TILE: number;
  27316. /**
  27317. * Mesh pattern setting : rotate pattern and rotate
  27318. */
  27319. static readonly FLIP_N_ROTATE_ROW: number;
  27320. /**
  27321. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27322. */
  27323. static readonly CENTER: number;
  27324. /**
  27325. * Mesh tile positioning : part tiles on left
  27326. */
  27327. static readonly LEFT: number;
  27328. /**
  27329. * Mesh tile positioning : part tiles on right
  27330. */
  27331. static readonly RIGHT: number;
  27332. /**
  27333. * Mesh tile positioning : part tiles on top
  27334. */
  27335. static readonly TOP: number;
  27336. /**
  27337. * Mesh tile positioning : part tiles on bottom
  27338. */
  27339. static readonly BOTTOM: number;
  27340. /**
  27341. * Gets the default side orientation.
  27342. * @param orientation the orientation to value to attempt to get
  27343. * @returns the default orientation
  27344. * @hidden
  27345. */
  27346. static _GetDefaultSideOrientation(orientation?: number): number;
  27347. private _internalMeshDataInfo;
  27348. /**
  27349. * An event triggered before rendering the mesh
  27350. */
  27351. get onBeforeRenderObservable(): Observable<Mesh>;
  27352. /**
  27353. * An event triggered before binding the mesh
  27354. */
  27355. get onBeforeBindObservable(): Observable<Mesh>;
  27356. /**
  27357. * An event triggered after rendering the mesh
  27358. */
  27359. get onAfterRenderObservable(): Observable<Mesh>;
  27360. /**
  27361. * An event triggered before drawing the mesh
  27362. */
  27363. get onBeforeDrawObservable(): Observable<Mesh>;
  27364. private _onBeforeDrawObserver;
  27365. /**
  27366. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27367. */
  27368. set onBeforeDraw(callback: () => void);
  27369. get hasInstances(): boolean;
  27370. get hasThinInstances(): boolean;
  27371. /**
  27372. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27373. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27374. */
  27375. delayLoadState: number;
  27376. /**
  27377. * Gets the list of instances created from this mesh
  27378. * it is not supposed to be modified manually.
  27379. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27380. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27381. */
  27382. instances: InstancedMesh[];
  27383. /**
  27384. * Gets the file containing delay loading data for this mesh
  27385. */
  27386. delayLoadingFile: string;
  27387. /** @hidden */
  27388. _binaryInfo: any;
  27389. /**
  27390. * User defined function used to change how LOD level selection is done
  27391. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27392. */
  27393. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27394. /**
  27395. * Gets or sets the morph target manager
  27396. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27397. */
  27398. get morphTargetManager(): Nullable<MorphTargetManager>;
  27399. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27400. /** @hidden */
  27401. _creationDataStorage: Nullable<_CreationDataStorage>;
  27402. /** @hidden */
  27403. _geometry: Nullable<Geometry>;
  27404. /** @hidden */
  27405. _delayInfo: Array<string>;
  27406. /** @hidden */
  27407. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27408. /** @hidden */
  27409. _instanceDataStorage: _InstanceDataStorage;
  27410. /** @hidden */
  27411. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27412. private _effectiveMaterial;
  27413. /** @hidden */
  27414. _shouldGenerateFlatShading: boolean;
  27415. /** @hidden */
  27416. _originalBuilderSideOrientation: number;
  27417. /**
  27418. * Use this property to change the original side orientation defined at construction time
  27419. */
  27420. overrideMaterialSideOrientation: Nullable<number>;
  27421. /**
  27422. * Gets the source mesh (the one used to clone this one from)
  27423. */
  27424. get source(): Nullable<Mesh>;
  27425. /**
  27426. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27427. */
  27428. get isUnIndexed(): boolean;
  27429. set isUnIndexed(value: boolean);
  27430. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27431. get worldMatrixInstancedBuffer(): Float32Array;
  27432. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27433. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27434. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27435. /**
  27436. * @constructor
  27437. * @param name The value used by scene.getMeshByName() to do a lookup.
  27438. * @param scene The scene to add this mesh to.
  27439. * @param parent The parent of this mesh, if it has one
  27440. * @param source An optional Mesh from which geometry is shared, cloned.
  27441. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27442. * When false, achieved by calling a clone(), also passing False.
  27443. * This will make creation of children, recursive.
  27444. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27445. */
  27446. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27447. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27448. doNotInstantiate: boolean;
  27449. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27450. /**
  27451. * Gets the class name
  27452. * @returns the string "Mesh".
  27453. */
  27454. getClassName(): string;
  27455. /** @hidden */
  27456. get _isMesh(): boolean;
  27457. /**
  27458. * Returns a description of this mesh
  27459. * @param fullDetails define if full details about this mesh must be used
  27460. * @returns a descriptive string representing this mesh
  27461. */
  27462. toString(fullDetails?: boolean): string;
  27463. /** @hidden */
  27464. _unBindEffect(): void;
  27465. /**
  27466. * Gets a boolean indicating if this mesh has LOD
  27467. */
  27468. get hasLODLevels(): boolean;
  27469. /**
  27470. * Gets the list of MeshLODLevel associated with the current mesh
  27471. * @returns an array of MeshLODLevel
  27472. */
  27473. getLODLevels(): MeshLODLevel[];
  27474. private _sortLODLevels;
  27475. /**
  27476. * Add a mesh as LOD level triggered at the given distance.
  27477. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27478. * @param distance The distance from the center of the object to show this level
  27479. * @param mesh The mesh to be added as LOD level (can be null)
  27480. * @return This mesh (for chaining)
  27481. */
  27482. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27483. /**
  27484. * Returns the LOD level mesh at the passed distance or null if not found.
  27485. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27486. * @param distance The distance from the center of the object to show this level
  27487. * @returns a Mesh or `null`
  27488. */
  27489. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27490. /**
  27491. * Remove a mesh from the LOD array
  27492. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27493. * @param mesh defines the mesh to be removed
  27494. * @return This mesh (for chaining)
  27495. */
  27496. removeLODLevel(mesh: Mesh): Mesh;
  27497. /**
  27498. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27499. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27500. * @param camera defines the camera to use to compute distance
  27501. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27502. * @return This mesh (for chaining)
  27503. */
  27504. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27505. /**
  27506. * Gets the mesh internal Geometry object
  27507. */
  27508. get geometry(): Nullable<Geometry>;
  27509. /**
  27510. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27511. * @returns the total number of vertices
  27512. */
  27513. getTotalVertices(): number;
  27514. /**
  27515. * Returns the content of an associated vertex buffer
  27516. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27517. * - VertexBuffer.PositionKind
  27518. * - VertexBuffer.UVKind
  27519. * - VertexBuffer.UV2Kind
  27520. * - VertexBuffer.UV3Kind
  27521. * - VertexBuffer.UV4Kind
  27522. * - VertexBuffer.UV5Kind
  27523. * - VertexBuffer.UV6Kind
  27524. * - VertexBuffer.ColorKind
  27525. * - VertexBuffer.MatricesIndicesKind
  27526. * - VertexBuffer.MatricesIndicesExtraKind
  27527. * - VertexBuffer.MatricesWeightsKind
  27528. * - VertexBuffer.MatricesWeightsExtraKind
  27529. * @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
  27530. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27531. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27532. */
  27533. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27534. /**
  27535. * Returns the mesh VertexBuffer object from the requested `kind`
  27536. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27537. * - VertexBuffer.PositionKind
  27538. * - VertexBuffer.NormalKind
  27539. * - VertexBuffer.UVKind
  27540. * - VertexBuffer.UV2Kind
  27541. * - VertexBuffer.UV3Kind
  27542. * - VertexBuffer.UV4Kind
  27543. * - VertexBuffer.UV5Kind
  27544. * - VertexBuffer.UV6Kind
  27545. * - VertexBuffer.ColorKind
  27546. * - VertexBuffer.MatricesIndicesKind
  27547. * - VertexBuffer.MatricesIndicesExtraKind
  27548. * - VertexBuffer.MatricesWeightsKind
  27549. * - VertexBuffer.MatricesWeightsExtraKind
  27550. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27551. */
  27552. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27553. /**
  27554. * Tests if a specific vertex buffer is associated with this mesh
  27555. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27556. * - VertexBuffer.PositionKind
  27557. * - VertexBuffer.NormalKind
  27558. * - VertexBuffer.UVKind
  27559. * - VertexBuffer.UV2Kind
  27560. * - VertexBuffer.UV3Kind
  27561. * - VertexBuffer.UV4Kind
  27562. * - VertexBuffer.UV5Kind
  27563. * - VertexBuffer.UV6Kind
  27564. * - VertexBuffer.ColorKind
  27565. * - VertexBuffer.MatricesIndicesKind
  27566. * - VertexBuffer.MatricesIndicesExtraKind
  27567. * - VertexBuffer.MatricesWeightsKind
  27568. * - VertexBuffer.MatricesWeightsExtraKind
  27569. * @returns a boolean
  27570. */
  27571. isVerticesDataPresent(kind: string): boolean;
  27572. /**
  27573. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27574. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27575. * - VertexBuffer.PositionKind
  27576. * - VertexBuffer.UVKind
  27577. * - VertexBuffer.UV2Kind
  27578. * - VertexBuffer.UV3Kind
  27579. * - VertexBuffer.UV4Kind
  27580. * - VertexBuffer.UV5Kind
  27581. * - VertexBuffer.UV6Kind
  27582. * - VertexBuffer.ColorKind
  27583. * - VertexBuffer.MatricesIndicesKind
  27584. * - VertexBuffer.MatricesIndicesExtraKind
  27585. * - VertexBuffer.MatricesWeightsKind
  27586. * - VertexBuffer.MatricesWeightsExtraKind
  27587. * @returns a boolean
  27588. */
  27589. isVertexBufferUpdatable(kind: string): boolean;
  27590. /**
  27591. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27592. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27593. * - VertexBuffer.PositionKind
  27594. * - VertexBuffer.NormalKind
  27595. * - VertexBuffer.UVKind
  27596. * - VertexBuffer.UV2Kind
  27597. * - VertexBuffer.UV3Kind
  27598. * - VertexBuffer.UV4Kind
  27599. * - VertexBuffer.UV5Kind
  27600. * - VertexBuffer.UV6Kind
  27601. * - VertexBuffer.ColorKind
  27602. * - VertexBuffer.MatricesIndicesKind
  27603. * - VertexBuffer.MatricesIndicesExtraKind
  27604. * - VertexBuffer.MatricesWeightsKind
  27605. * - VertexBuffer.MatricesWeightsExtraKind
  27606. * @returns an array of strings
  27607. */
  27608. getVerticesDataKinds(): string[];
  27609. /**
  27610. * Returns a positive integer : the total number of indices in this mesh geometry.
  27611. * @returns the numner of indices or zero if the mesh has no geometry.
  27612. */
  27613. getTotalIndices(): number;
  27614. /**
  27615. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27616. * @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.
  27617. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27618. * @returns the indices array or an empty array if the mesh has no geometry
  27619. */
  27620. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27621. get isBlocked(): boolean;
  27622. /**
  27623. * Determine if the current mesh is ready to be rendered
  27624. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27625. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27626. * @returns true if all associated assets are ready (material, textures, shaders)
  27627. */
  27628. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27629. /**
  27630. * 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.
  27631. */
  27632. get areNormalsFrozen(): boolean;
  27633. /**
  27634. * 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.
  27635. * @returns the current mesh
  27636. */
  27637. freezeNormals(): Mesh;
  27638. /**
  27639. * 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
  27640. * @returns the current mesh
  27641. */
  27642. unfreezeNormals(): Mesh;
  27643. /**
  27644. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27645. */
  27646. set overridenInstanceCount(count: number);
  27647. /** @hidden */
  27648. _preActivate(): Mesh;
  27649. /** @hidden */
  27650. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27651. /** @hidden */
  27652. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27653. protected _afterComputeWorldMatrix(): void;
  27654. /** @hidden */
  27655. _postActivate(): void;
  27656. /**
  27657. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27658. * This means the mesh underlying bounding box and sphere are recomputed.
  27659. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27660. * @returns the current mesh
  27661. */
  27662. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27663. /** @hidden */
  27664. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27665. /**
  27666. * This function will subdivide the mesh into multiple submeshes
  27667. * @param count defines the expected number of submeshes
  27668. */
  27669. subdivide(count: number): void;
  27670. /**
  27671. * Copy a FloatArray into a specific associated vertex buffer
  27672. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27673. * - VertexBuffer.PositionKind
  27674. * - VertexBuffer.UVKind
  27675. * - VertexBuffer.UV2Kind
  27676. * - VertexBuffer.UV3Kind
  27677. * - VertexBuffer.UV4Kind
  27678. * - VertexBuffer.UV5Kind
  27679. * - VertexBuffer.UV6Kind
  27680. * - VertexBuffer.ColorKind
  27681. * - VertexBuffer.MatricesIndicesKind
  27682. * - VertexBuffer.MatricesIndicesExtraKind
  27683. * - VertexBuffer.MatricesWeightsKind
  27684. * - VertexBuffer.MatricesWeightsExtraKind
  27685. * @param data defines the data source
  27686. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27687. * @param stride defines the data stride size (can be null)
  27688. * @returns the current mesh
  27689. */
  27690. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27691. /**
  27692. * Delete a vertex buffer associated with this mesh
  27693. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27694. * - VertexBuffer.PositionKind
  27695. * - VertexBuffer.UVKind
  27696. * - VertexBuffer.UV2Kind
  27697. * - VertexBuffer.UV3Kind
  27698. * - VertexBuffer.UV4Kind
  27699. * - VertexBuffer.UV5Kind
  27700. * - VertexBuffer.UV6Kind
  27701. * - VertexBuffer.ColorKind
  27702. * - VertexBuffer.MatricesIndicesKind
  27703. * - VertexBuffer.MatricesIndicesExtraKind
  27704. * - VertexBuffer.MatricesWeightsKind
  27705. * - VertexBuffer.MatricesWeightsExtraKind
  27706. */
  27707. removeVerticesData(kind: string): void;
  27708. /**
  27709. * Flags an associated vertex buffer as updatable
  27710. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27711. * - VertexBuffer.PositionKind
  27712. * - VertexBuffer.UVKind
  27713. * - VertexBuffer.UV2Kind
  27714. * - VertexBuffer.UV3Kind
  27715. * - VertexBuffer.UV4Kind
  27716. * - VertexBuffer.UV5Kind
  27717. * - VertexBuffer.UV6Kind
  27718. * - VertexBuffer.ColorKind
  27719. * - VertexBuffer.MatricesIndicesKind
  27720. * - VertexBuffer.MatricesIndicesExtraKind
  27721. * - VertexBuffer.MatricesWeightsKind
  27722. * - VertexBuffer.MatricesWeightsExtraKind
  27723. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27724. */
  27725. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27726. /**
  27727. * Sets the mesh global Vertex Buffer
  27728. * @param buffer defines the buffer to use
  27729. * @returns the current mesh
  27730. */
  27731. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27732. /**
  27733. * Update a specific associated vertex buffer
  27734. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27735. * - VertexBuffer.PositionKind
  27736. * - VertexBuffer.UVKind
  27737. * - VertexBuffer.UV2Kind
  27738. * - VertexBuffer.UV3Kind
  27739. * - VertexBuffer.UV4Kind
  27740. * - VertexBuffer.UV5Kind
  27741. * - VertexBuffer.UV6Kind
  27742. * - VertexBuffer.ColorKind
  27743. * - VertexBuffer.MatricesIndicesKind
  27744. * - VertexBuffer.MatricesIndicesExtraKind
  27745. * - VertexBuffer.MatricesWeightsKind
  27746. * - VertexBuffer.MatricesWeightsExtraKind
  27747. * @param data defines the data source
  27748. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27749. * @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)
  27750. * @returns the current mesh
  27751. */
  27752. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27753. /**
  27754. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27755. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27756. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27757. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27758. * @returns the current mesh
  27759. */
  27760. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27761. /**
  27762. * Creates a un-shared specific occurence of the geometry for the mesh.
  27763. * @returns the current mesh
  27764. */
  27765. makeGeometryUnique(): Mesh;
  27766. /**
  27767. * Set the index buffer of this mesh
  27768. * @param indices defines the source data
  27769. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27770. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27771. * @returns the current mesh
  27772. */
  27773. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27774. /**
  27775. * Update the current index buffer
  27776. * @param indices defines the source data
  27777. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27778. * @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)
  27779. * @returns the current mesh
  27780. */
  27781. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27782. /**
  27783. * Invert the geometry to move from a right handed system to a left handed one.
  27784. * @returns the current mesh
  27785. */
  27786. toLeftHanded(): Mesh;
  27787. /** @hidden */
  27788. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27789. /** @hidden */
  27790. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27791. /**
  27792. * Registers for this mesh a javascript function called just before the rendering process
  27793. * @param func defines the function to call before rendering this mesh
  27794. * @returns the current mesh
  27795. */
  27796. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27797. /**
  27798. * Disposes a previously registered javascript function called before the rendering
  27799. * @param func defines the function to remove
  27800. * @returns the current mesh
  27801. */
  27802. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27803. /**
  27804. * Registers for this mesh a javascript function called just after the rendering is complete
  27805. * @param func defines the function to call after rendering this mesh
  27806. * @returns the current mesh
  27807. */
  27808. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27809. /**
  27810. * Disposes a previously registered javascript function called after the rendering.
  27811. * @param func defines the function to remove
  27812. * @returns the current mesh
  27813. */
  27814. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27815. /** @hidden */
  27816. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27817. /** @hidden */
  27818. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27819. /** @hidden */
  27820. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27821. /** @hidden */
  27822. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27823. /** @hidden */
  27824. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27825. /** @hidden */
  27826. _rebuild(): void;
  27827. /** @hidden */
  27828. _freeze(): void;
  27829. /** @hidden */
  27830. _unFreeze(): void;
  27831. /**
  27832. * 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
  27833. * @param subMesh defines the subMesh to render
  27834. * @param enableAlphaMode defines if alpha mode can be changed
  27835. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27836. * @returns the current mesh
  27837. */
  27838. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27839. private _onBeforeDraw;
  27840. /**
  27841. * Renormalize the mesh and patch it up if there are no weights
  27842. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27843. * However in the case of zero weights then we set just a single influence to 1.
  27844. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27845. */
  27846. cleanMatrixWeights(): void;
  27847. private normalizeSkinFourWeights;
  27848. private normalizeSkinWeightsAndExtra;
  27849. /**
  27850. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27851. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27852. * the user know there was an issue with importing the mesh
  27853. * @returns a validation object with skinned, valid and report string
  27854. */
  27855. validateSkinning(): {
  27856. skinned: boolean;
  27857. valid: boolean;
  27858. report: string;
  27859. };
  27860. /** @hidden */
  27861. _checkDelayState(): Mesh;
  27862. private _queueLoad;
  27863. /**
  27864. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27865. * A mesh is in the frustum if its bounding box intersects the frustum
  27866. * @param frustumPlanes defines the frustum to test
  27867. * @returns true if the mesh is in the frustum planes
  27868. */
  27869. isInFrustum(frustumPlanes: Plane[]): boolean;
  27870. /**
  27871. * Sets the mesh material by the material or multiMaterial `id` property
  27872. * @param id is a string identifying the material or the multiMaterial
  27873. * @returns the current mesh
  27874. */
  27875. setMaterialByID(id: string): Mesh;
  27876. /**
  27877. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27878. * @returns an array of IAnimatable
  27879. */
  27880. getAnimatables(): IAnimatable[];
  27881. /**
  27882. * Modifies the mesh geometry according to the passed transformation matrix.
  27883. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27884. * The mesh normals are modified using the same transformation.
  27885. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27886. * @param transform defines the transform matrix to use
  27887. * @see http://doc.babylonjs.com/resources/baking_transformations
  27888. * @returns the current mesh
  27889. */
  27890. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27891. /**
  27892. * Modifies the mesh geometry according to its own current World Matrix.
  27893. * The mesh World Matrix is then reset.
  27894. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27895. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27896. * @see http://doc.babylonjs.com/resources/baking_transformations
  27897. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27898. * @returns the current mesh
  27899. */
  27900. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27901. /** @hidden */
  27902. get _positions(): Nullable<Vector3[]>;
  27903. /** @hidden */
  27904. _resetPointsArrayCache(): Mesh;
  27905. /** @hidden */
  27906. _generatePointsArray(): boolean;
  27907. /**
  27908. * Returns a new Mesh object generated from the current mesh properties.
  27909. * This method must not get confused with createInstance()
  27910. * @param name is a string, the name given to the new mesh
  27911. * @param newParent can be any Node object (default `null`)
  27912. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27913. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27914. * @returns a new mesh
  27915. */
  27916. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27917. /**
  27918. * Releases resources associated with this mesh.
  27919. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27920. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27921. */
  27922. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27923. /** @hidden */
  27924. _disposeInstanceSpecificData(): void;
  27925. /** @hidden */
  27926. _disposeThinInstanceSpecificData(): void;
  27927. /**
  27928. * Modifies the mesh geometry according to a displacement map.
  27929. * 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.
  27930. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27931. * @param url is a string, the URL from the image file is to be downloaded.
  27932. * @param minHeight is the lower limit of the displacement.
  27933. * @param maxHeight is the upper limit of the displacement.
  27934. * @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.
  27935. * @param uvOffset is an optional vector2 used to offset UV.
  27936. * @param uvScale is an optional vector2 used to scale UV.
  27937. * @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.
  27938. * @returns the Mesh.
  27939. */
  27940. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27941. /**
  27942. * Modifies the mesh geometry according to a displacementMap buffer.
  27943. * 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.
  27944. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27945. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27946. * @param heightMapWidth is the width of the buffer image.
  27947. * @param heightMapHeight is the height of the buffer image.
  27948. * @param minHeight is the lower limit of the displacement.
  27949. * @param maxHeight is the upper limit of the displacement.
  27950. * @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.
  27951. * @param uvOffset is an optional vector2 used to offset UV.
  27952. * @param uvScale is an optional vector2 used to scale UV.
  27953. * @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.
  27954. * @returns the Mesh.
  27955. */
  27956. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27957. /**
  27958. * Modify the mesh to get a flat shading rendering.
  27959. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27960. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27961. * @returns current mesh
  27962. */
  27963. convertToFlatShadedMesh(): Mesh;
  27964. /**
  27965. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27966. * In other words, more vertices, no more indices and a single bigger VBO.
  27967. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27968. * @returns current mesh
  27969. */
  27970. convertToUnIndexedMesh(): Mesh;
  27971. /**
  27972. * Inverses facet orientations.
  27973. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27974. * @param flipNormals will also inverts the normals
  27975. * @returns current mesh
  27976. */
  27977. flipFaces(flipNormals?: boolean): Mesh;
  27978. /**
  27979. * Increase the number of facets and hence vertices in a mesh
  27980. * Vertex normals are interpolated from existing vertex normals
  27981. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27982. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27983. */
  27984. increaseVertices(numberPerEdge: number): void;
  27985. /**
  27986. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27987. * This will undo any application of covertToFlatShadedMesh
  27988. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27989. */
  27990. forceSharedVertices(): void;
  27991. /** @hidden */
  27992. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27993. /** @hidden */
  27994. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27995. /**
  27996. * Creates a new InstancedMesh object from the mesh model.
  27997. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27998. * @param name defines the name of the new instance
  27999. * @returns a new InstancedMesh
  28000. */
  28001. createInstance(name: string): InstancedMesh;
  28002. /**
  28003. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28004. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28005. * @returns the current mesh
  28006. */
  28007. synchronizeInstances(): Mesh;
  28008. /**
  28009. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28010. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28011. * This should be used together with the simplification to avoid disappearing triangles.
  28012. * @param successCallback an optional success callback to be called after the optimization finished.
  28013. * @returns the current mesh
  28014. */
  28015. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28016. /**
  28017. * Serialize current mesh
  28018. * @param serializationObject defines the object which will receive the serialization data
  28019. */
  28020. serialize(serializationObject: any): void;
  28021. /** @hidden */
  28022. _syncGeometryWithMorphTargetManager(): void;
  28023. /** @hidden */
  28024. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28025. /**
  28026. * Returns a new Mesh object parsed from the source provided.
  28027. * @param parsedMesh is the source
  28028. * @param scene defines the hosting scene
  28029. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28030. * @returns a new Mesh
  28031. */
  28032. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28033. /**
  28034. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28035. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28036. * @param name defines the name of the mesh to create
  28037. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28038. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28039. * @param closePath creates a seam between the first and the last points of each path of the path array
  28040. * @param offset is taken in account only if the `pathArray` is containing a single path
  28041. * @param scene defines the hosting scene
  28042. * @param updatable defines if the mesh must be flagged as updatable
  28043. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28044. * @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)
  28045. * @returns a new Mesh
  28046. */
  28047. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28048. /**
  28049. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28050. * @param name defines the name of the mesh to create
  28051. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28052. * @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
  28053. * @param scene defines the hosting scene
  28054. * @param updatable defines if the mesh must be flagged as updatable
  28055. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28056. * @returns a new Mesh
  28057. */
  28058. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28059. /**
  28060. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28061. * @param name defines the name of the mesh to create
  28062. * @param size sets the size (float) of each box side (default 1)
  28063. * @param scene defines the hosting scene
  28064. * @param updatable defines if the mesh must be flagged as updatable
  28065. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28066. * @returns a new Mesh
  28067. */
  28068. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28069. /**
  28070. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28071. * @param name defines the name of the mesh to create
  28072. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28073. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28074. * @param scene defines the hosting scene
  28075. * @param updatable defines if the mesh must be flagged as updatable
  28076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28077. * @returns a new Mesh
  28078. */
  28079. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28080. /**
  28081. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28082. * @param name defines the name of the mesh to create
  28083. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28084. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28085. * @param scene defines the hosting scene
  28086. * @returns a new Mesh
  28087. */
  28088. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28089. /**
  28090. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28091. * @param name defines the name of the mesh to create
  28092. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28093. * @param diameterTop set the top cap diameter (floats, default 1)
  28094. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28095. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28096. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28097. * @param scene defines the hosting scene
  28098. * @param updatable defines if the mesh must be flagged as updatable
  28099. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28100. * @returns a new Mesh
  28101. */
  28102. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28103. /**
  28104. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28105. * @param name defines the name of the mesh to create
  28106. * @param diameter sets the diameter size (float) of the torus (default 1)
  28107. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28108. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28109. * @param scene defines the hosting scene
  28110. * @param updatable defines if the mesh must be flagged as updatable
  28111. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28112. * @returns a new Mesh
  28113. */
  28114. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28115. /**
  28116. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28117. * @param name defines the name of the mesh to create
  28118. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28119. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28120. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28121. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28122. * @param p the number of windings on X axis (positive integers, default 2)
  28123. * @param q the number of windings on Y axis (positive integers, default 3)
  28124. * @param scene defines the hosting scene
  28125. * @param updatable defines if the mesh must be flagged as updatable
  28126. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28127. * @returns a new Mesh
  28128. */
  28129. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28130. /**
  28131. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28132. * @param name defines the name of the mesh to create
  28133. * @param points is an array successive Vector3
  28134. * @param scene defines the hosting scene
  28135. * @param updatable defines if the mesh must be flagged as updatable
  28136. * @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).
  28137. * @returns a new Mesh
  28138. */
  28139. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28140. /**
  28141. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28142. * @param name defines the name of the mesh to create
  28143. * @param points is an array successive Vector3
  28144. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28145. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28146. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28147. * @param scene defines the hosting scene
  28148. * @param updatable defines if the mesh must be flagged as updatable
  28149. * @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)
  28150. * @returns a new Mesh
  28151. */
  28152. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28153. /**
  28154. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28155. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28156. * 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.
  28157. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28158. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28159. * Remember you can only change the shape positions, not their number when updating a polygon.
  28160. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28161. * @param name defines the name of the mesh to create
  28162. * @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
  28163. * @param scene defines the hosting scene
  28164. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28165. * @param updatable defines if the mesh must be flagged as updatable
  28166. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28167. * @param earcutInjection can be used to inject your own earcut reference
  28168. * @returns a new Mesh
  28169. */
  28170. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28171. /**
  28172. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28173. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28174. * @param name defines the name of the mesh to create
  28175. * @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
  28176. * @param depth defines the height of extrusion
  28177. * @param scene defines the hosting scene
  28178. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28179. * @param updatable defines if the mesh must be flagged as updatable
  28180. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28181. * @param earcutInjection can be used to inject your own earcut reference
  28182. * @returns a new Mesh
  28183. */
  28184. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28185. /**
  28186. * Creates an extruded shape mesh.
  28187. * 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
  28188. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28189. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28190. * @param name defines the name of the mesh to create
  28191. * @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
  28192. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28193. * @param scale is the value to scale the shape
  28194. * @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
  28195. * @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
  28196. * @param scene defines the hosting scene
  28197. * @param updatable defines if the mesh must be flagged as updatable
  28198. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28199. * @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)
  28200. * @returns a new Mesh
  28201. */
  28202. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28203. /**
  28204. * Creates an custom extruded shape mesh.
  28205. * The custom extrusion is a parametric shape.
  28206. * It has no predefined shape. Its final shape will depend on the input parameters.
  28207. * Please consider using the same method from the MeshBuilder class instead
  28208. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28209. * @param name defines the name of the mesh to create
  28210. * @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
  28211. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28212. * @param scaleFunction is a custom Javascript function called on each path point
  28213. * @param rotationFunction is a custom Javascript function called on each path point
  28214. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28215. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28216. * @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
  28217. * @param scene defines the hosting scene
  28218. * @param updatable defines if the mesh must be flagged as updatable
  28219. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28220. * @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)
  28221. * @returns a new Mesh
  28222. */
  28223. 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;
  28224. /**
  28225. * Creates lathe mesh.
  28226. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28227. * Please consider using the same method from the MeshBuilder class instead
  28228. * @param name defines the name of the mesh to create
  28229. * @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
  28230. * @param radius is the radius value of the lathe
  28231. * @param tessellation is the side number of the lathe.
  28232. * @param scene defines the hosting scene
  28233. * @param updatable defines if the mesh must be flagged as updatable
  28234. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28235. * @returns a new Mesh
  28236. */
  28237. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28238. /**
  28239. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28240. * @param name defines the name of the mesh to create
  28241. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28242. * @param scene defines the hosting scene
  28243. * @param updatable defines if the mesh must be flagged as updatable
  28244. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28245. * @returns a new Mesh
  28246. */
  28247. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28248. /**
  28249. * Creates a ground mesh.
  28250. * Please consider using the same method from the MeshBuilder class instead
  28251. * @param name defines the name of the mesh to create
  28252. * @param width set the width of the ground
  28253. * @param height set the height of the ground
  28254. * @param subdivisions sets the number of subdivisions per side
  28255. * @param scene defines the hosting scene
  28256. * @param updatable defines if the mesh must be flagged as updatable
  28257. * @returns a new Mesh
  28258. */
  28259. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28260. /**
  28261. * Creates a tiled ground mesh.
  28262. * Please consider using the same method from the MeshBuilder class instead
  28263. * @param name defines the name of the mesh to create
  28264. * @param xmin set the ground minimum X coordinate
  28265. * @param zmin set the ground minimum Y coordinate
  28266. * @param xmax set the ground maximum X coordinate
  28267. * @param zmax set the ground maximum Z coordinate
  28268. * @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
  28269. * @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
  28270. * @param scene defines the hosting scene
  28271. * @param updatable defines if the mesh must be flagged as updatable
  28272. * @returns a new Mesh
  28273. */
  28274. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28275. w: number;
  28276. h: number;
  28277. }, precision: {
  28278. w: number;
  28279. h: number;
  28280. }, scene: Scene, updatable?: boolean): Mesh;
  28281. /**
  28282. * Creates a ground mesh from a height map.
  28283. * Please consider using the same method from the MeshBuilder class instead
  28284. * @see http://doc.babylonjs.com/babylon101/height_map
  28285. * @param name defines the name of the mesh to create
  28286. * @param url sets the URL of the height map image resource
  28287. * @param width set the ground width size
  28288. * @param height set the ground height size
  28289. * @param subdivisions sets the number of subdivision per side
  28290. * @param minHeight is the minimum altitude on the ground
  28291. * @param maxHeight is the maximum altitude on the ground
  28292. * @param scene defines the hosting scene
  28293. * @param updatable defines if the mesh must be flagged as updatable
  28294. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28295. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28296. * @returns a new Mesh
  28297. */
  28298. 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;
  28299. /**
  28300. * Creates a tube mesh.
  28301. * The tube is a parametric shape.
  28302. * It has no predefined shape. Its final shape will depend on the input parameters.
  28303. * Please consider using the same method from the MeshBuilder class instead
  28304. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28305. * @param name defines the name of the mesh to create
  28306. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28307. * @param radius sets the tube radius size
  28308. * @param tessellation is the number of sides on the tubular surface
  28309. * @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
  28310. * @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
  28311. * @param scene defines the hosting scene
  28312. * @param updatable defines if the mesh must be flagged as updatable
  28313. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28314. * @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)
  28315. * @returns a new Mesh
  28316. */
  28317. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28318. (i: number, distance: number): number;
  28319. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28320. /**
  28321. * Creates a polyhedron mesh.
  28322. * Please consider using the same method from the MeshBuilder class instead.
  28323. * * 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
  28324. * * The parameter `size` (positive float, default 1) sets the polygon size
  28325. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28326. * * 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`
  28327. * * 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
  28328. * * 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)`)
  28329. * * 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
  28330. * * 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
  28331. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28332. * * 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
  28333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28334. * @param name defines the name of the mesh to create
  28335. * @param options defines the options used to create the mesh
  28336. * @param scene defines the hosting scene
  28337. * @returns a new Mesh
  28338. */
  28339. static CreatePolyhedron(name: string, options: {
  28340. type?: number;
  28341. size?: number;
  28342. sizeX?: number;
  28343. sizeY?: number;
  28344. sizeZ?: number;
  28345. custom?: any;
  28346. faceUV?: Vector4[];
  28347. faceColors?: Color4[];
  28348. updatable?: boolean;
  28349. sideOrientation?: number;
  28350. }, scene: Scene): Mesh;
  28351. /**
  28352. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28353. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28354. * * 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`)
  28355. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28356. * * 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
  28357. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28358. * * 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
  28359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28360. * @param name defines the name of the mesh
  28361. * @param options defines the options used to create the mesh
  28362. * @param scene defines the hosting scene
  28363. * @returns a new Mesh
  28364. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28365. */
  28366. static CreateIcoSphere(name: string, options: {
  28367. radius?: number;
  28368. flat?: boolean;
  28369. subdivisions?: number;
  28370. sideOrientation?: number;
  28371. updatable?: boolean;
  28372. }, scene: Scene): Mesh;
  28373. /**
  28374. * Creates a decal mesh.
  28375. * Please consider using the same method from the MeshBuilder class instead.
  28376. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28377. * @param name defines the name of the mesh
  28378. * @param sourceMesh defines the mesh receiving the decal
  28379. * @param position sets the position of the decal in world coordinates
  28380. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28381. * @param size sets the decal scaling
  28382. * @param angle sets the angle to rotate the decal
  28383. * @returns a new Mesh
  28384. */
  28385. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28386. /**
  28387. * Prepare internal position array for software CPU skinning
  28388. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28389. */
  28390. setPositionsForCPUSkinning(): Float32Array;
  28391. /**
  28392. * Prepare internal normal array for software CPU skinning
  28393. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28394. */
  28395. setNormalsForCPUSkinning(): Float32Array;
  28396. /**
  28397. * Updates the vertex buffer by applying transformation from the bones
  28398. * @param skeleton defines the skeleton to apply to current mesh
  28399. * @returns the current mesh
  28400. */
  28401. applySkeleton(skeleton: Skeleton): Mesh;
  28402. /**
  28403. * 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
  28404. * @param meshes defines the list of meshes to scan
  28405. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28406. */
  28407. static MinMax(meshes: AbstractMesh[]): {
  28408. min: Vector3;
  28409. max: Vector3;
  28410. };
  28411. /**
  28412. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28413. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28414. * @returns a vector3
  28415. */
  28416. static Center(meshesOrMinMaxVector: {
  28417. min: Vector3;
  28418. max: Vector3;
  28419. } | AbstractMesh[]): Vector3;
  28420. /**
  28421. * Merge the array of meshes into a single mesh for performance reasons.
  28422. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28423. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28424. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28425. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28426. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28427. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28428. * @returns a new mesh
  28429. */
  28430. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28431. /** @hidden */
  28432. addInstance(instance: InstancedMesh): void;
  28433. /** @hidden */
  28434. removeInstance(instance: InstancedMesh): void;
  28435. }
  28436. }
  28437. declare module BABYLON {
  28438. /**
  28439. * This is the base class of all the camera used in the application.
  28440. * @see http://doc.babylonjs.com/features/cameras
  28441. */
  28442. export class Camera extends Node {
  28443. /** @hidden */
  28444. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28445. /**
  28446. * This is the default projection mode used by the cameras.
  28447. * It helps recreating a feeling of perspective and better appreciate depth.
  28448. * This is the best way to simulate real life cameras.
  28449. */
  28450. static readonly PERSPECTIVE_CAMERA: number;
  28451. /**
  28452. * This helps creating camera with an orthographic mode.
  28453. * 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.
  28454. */
  28455. static readonly ORTHOGRAPHIC_CAMERA: number;
  28456. /**
  28457. * This is the default FOV mode for perspective cameras.
  28458. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28459. */
  28460. static readonly FOVMODE_VERTICAL_FIXED: number;
  28461. /**
  28462. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28463. */
  28464. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28465. /**
  28466. * This specifies ther is no need for a camera rig.
  28467. * Basically only one eye is rendered corresponding to the camera.
  28468. */
  28469. static readonly RIG_MODE_NONE: number;
  28470. /**
  28471. * Simulates a camera Rig with one blue eye and one red eye.
  28472. * This can be use with 3d blue and red glasses.
  28473. */
  28474. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28475. /**
  28476. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28477. */
  28478. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28479. /**
  28480. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28481. */
  28482. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28483. /**
  28484. * Defines that both eyes of the camera will be rendered over under each other.
  28485. */
  28486. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28487. /**
  28488. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28489. */
  28490. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28491. /**
  28492. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28493. */
  28494. static readonly RIG_MODE_VR: number;
  28495. /**
  28496. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28497. */
  28498. static readonly RIG_MODE_WEBVR: number;
  28499. /**
  28500. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28501. */
  28502. static readonly RIG_MODE_CUSTOM: number;
  28503. /**
  28504. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28505. */
  28506. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28507. /**
  28508. * Define the input manager associated with the camera.
  28509. */
  28510. inputs: CameraInputsManager<Camera>;
  28511. /** @hidden */
  28512. _position: Vector3;
  28513. /**
  28514. * Define the current local position of the camera in the scene
  28515. */
  28516. get position(): Vector3;
  28517. set position(newPosition: Vector3);
  28518. /**
  28519. * The vector the camera should consider as up.
  28520. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28521. */
  28522. upVector: Vector3;
  28523. /**
  28524. * Define the current limit on the left side for an orthographic camera
  28525. * In scene unit
  28526. */
  28527. orthoLeft: Nullable<number>;
  28528. /**
  28529. * Define the current limit on the right side for an orthographic camera
  28530. * In scene unit
  28531. */
  28532. orthoRight: Nullable<number>;
  28533. /**
  28534. * Define the current limit on the bottom side for an orthographic camera
  28535. * In scene unit
  28536. */
  28537. orthoBottom: Nullable<number>;
  28538. /**
  28539. * Define the current limit on the top side for an orthographic camera
  28540. * In scene unit
  28541. */
  28542. orthoTop: Nullable<number>;
  28543. /**
  28544. * Field Of View is set in Radians. (default is 0.8)
  28545. */
  28546. fov: number;
  28547. /**
  28548. * Define the minimum distance the camera can see from.
  28549. * This is important to note that the depth buffer are not infinite and the closer it starts
  28550. * the more your scene might encounter depth fighting issue.
  28551. */
  28552. minZ: number;
  28553. /**
  28554. * Define the maximum distance the camera can see to.
  28555. * This is important to note that the depth buffer are not infinite and the further it end
  28556. * the more your scene might encounter depth fighting issue.
  28557. */
  28558. maxZ: number;
  28559. /**
  28560. * Define the default inertia of the camera.
  28561. * This helps giving a smooth feeling to the camera movement.
  28562. */
  28563. inertia: number;
  28564. /**
  28565. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28566. */
  28567. mode: number;
  28568. /**
  28569. * Define whether the camera is intermediate.
  28570. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28571. */
  28572. isIntermediate: boolean;
  28573. /**
  28574. * Define the viewport of the camera.
  28575. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28576. */
  28577. viewport: Viewport;
  28578. /**
  28579. * Restricts the camera to viewing objects with the same layerMask.
  28580. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28581. */
  28582. layerMask: number;
  28583. /**
  28584. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28585. */
  28586. fovMode: number;
  28587. /**
  28588. * Rig mode of the camera.
  28589. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28590. * This is normally controlled byt the camera themselves as internal use.
  28591. */
  28592. cameraRigMode: number;
  28593. /**
  28594. * Defines the distance between both "eyes" in case of a RIG
  28595. */
  28596. interaxialDistance: number;
  28597. /**
  28598. * Defines if stereoscopic rendering is done side by side or over under.
  28599. */
  28600. isStereoscopicSideBySide: boolean;
  28601. /**
  28602. * 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
  28603. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28604. * else in the scene. (Eg. security camera)
  28605. *
  28606. * 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)
  28607. */
  28608. customRenderTargets: RenderTargetTexture[];
  28609. /**
  28610. * When set, the camera will render to this render target instead of the default canvas
  28611. *
  28612. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28613. */
  28614. outputRenderTarget: Nullable<RenderTargetTexture>;
  28615. /**
  28616. * Observable triggered when the camera view matrix has changed.
  28617. */
  28618. onViewMatrixChangedObservable: Observable<Camera>;
  28619. /**
  28620. * Observable triggered when the camera Projection matrix has changed.
  28621. */
  28622. onProjectionMatrixChangedObservable: Observable<Camera>;
  28623. /**
  28624. * Observable triggered when the inputs have been processed.
  28625. */
  28626. onAfterCheckInputsObservable: Observable<Camera>;
  28627. /**
  28628. * Observable triggered when reset has been called and applied to the camera.
  28629. */
  28630. onRestoreStateObservable: Observable<Camera>;
  28631. /**
  28632. * Is this camera a part of a rig system?
  28633. */
  28634. isRigCamera: boolean;
  28635. /**
  28636. * If isRigCamera set to true this will be set with the parent camera.
  28637. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28638. */
  28639. rigParent?: Camera;
  28640. /** @hidden */
  28641. _cameraRigParams: any;
  28642. /** @hidden */
  28643. _rigCameras: Camera[];
  28644. /** @hidden */
  28645. _rigPostProcess: Nullable<PostProcess>;
  28646. protected _webvrViewMatrix: Matrix;
  28647. /** @hidden */
  28648. _skipRendering: boolean;
  28649. /** @hidden */
  28650. _projectionMatrix: Matrix;
  28651. /** @hidden */
  28652. _postProcesses: Nullable<PostProcess>[];
  28653. /** @hidden */
  28654. _activeMeshes: SmartArray<AbstractMesh>;
  28655. protected _globalPosition: Vector3;
  28656. /** @hidden */
  28657. _computedViewMatrix: Matrix;
  28658. private _doNotComputeProjectionMatrix;
  28659. private _transformMatrix;
  28660. private _frustumPlanes;
  28661. private _refreshFrustumPlanes;
  28662. private _storedFov;
  28663. private _stateStored;
  28664. /**
  28665. * Instantiates a new camera object.
  28666. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28667. * @see http://doc.babylonjs.com/features/cameras
  28668. * @param name Defines the name of the camera in the scene
  28669. * @param position Defines the position of the camera
  28670. * @param scene Defines the scene the camera belongs too
  28671. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28672. */
  28673. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28674. /**
  28675. * Store current camera state (fov, position, etc..)
  28676. * @returns the camera
  28677. */
  28678. storeState(): Camera;
  28679. /**
  28680. * Restores the camera state values if it has been stored. You must call storeState() first
  28681. */
  28682. protected _restoreStateValues(): boolean;
  28683. /**
  28684. * Restored camera state. You must call storeState() first.
  28685. * @returns true if restored and false otherwise
  28686. */
  28687. restoreState(): boolean;
  28688. /**
  28689. * Gets the class name of the camera.
  28690. * @returns the class name
  28691. */
  28692. getClassName(): string;
  28693. /** @hidden */
  28694. readonly _isCamera: boolean;
  28695. /**
  28696. * Gets a string representation of the camera useful for debug purpose.
  28697. * @param fullDetails Defines that a more verboe level of logging is required
  28698. * @returns the string representation
  28699. */
  28700. toString(fullDetails?: boolean): string;
  28701. /**
  28702. * Gets the current world space position of the camera.
  28703. */
  28704. get globalPosition(): Vector3;
  28705. /**
  28706. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28707. * @returns the active meshe list
  28708. */
  28709. getActiveMeshes(): SmartArray<AbstractMesh>;
  28710. /**
  28711. * Check whether a mesh is part of the current active mesh list of the camera
  28712. * @param mesh Defines the mesh to check
  28713. * @returns true if active, false otherwise
  28714. */
  28715. isActiveMesh(mesh: Mesh): boolean;
  28716. /**
  28717. * Is this camera ready to be used/rendered
  28718. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28719. * @return true if the camera is ready
  28720. */
  28721. isReady(completeCheck?: boolean): boolean;
  28722. /** @hidden */
  28723. _initCache(): void;
  28724. /** @hidden */
  28725. _updateCache(ignoreParentClass?: boolean): void;
  28726. /** @hidden */
  28727. _isSynchronized(): boolean;
  28728. /** @hidden */
  28729. _isSynchronizedViewMatrix(): boolean;
  28730. /** @hidden */
  28731. _isSynchronizedProjectionMatrix(): boolean;
  28732. /**
  28733. * Attach the input controls to a specific dom element to get the input from.
  28734. * @param element Defines the element the controls should be listened from
  28735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28736. */
  28737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28738. /**
  28739. * Detach the current controls from the specified dom element.
  28740. * @param element Defines the element to stop listening the inputs from
  28741. */
  28742. detachControl(element: HTMLElement): void;
  28743. /**
  28744. * Update the camera state according to the different inputs gathered during the frame.
  28745. */
  28746. update(): void;
  28747. /** @hidden */
  28748. _checkInputs(): void;
  28749. /** @hidden */
  28750. get rigCameras(): Camera[];
  28751. /**
  28752. * Gets the post process used by the rig cameras
  28753. */
  28754. get rigPostProcess(): Nullable<PostProcess>;
  28755. /**
  28756. * Internal, gets the first post proces.
  28757. * @returns the first post process to be run on this camera.
  28758. */
  28759. _getFirstPostProcess(): Nullable<PostProcess>;
  28760. private _cascadePostProcessesToRigCams;
  28761. /**
  28762. * Attach a post process to the camera.
  28763. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28764. * @param postProcess The post process to attach to the camera
  28765. * @param insertAt The position of the post process in case several of them are in use in the scene
  28766. * @returns the position the post process has been inserted at
  28767. */
  28768. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28769. /**
  28770. * Detach a post process to the camera.
  28771. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28772. * @param postProcess The post process to detach from the camera
  28773. */
  28774. detachPostProcess(postProcess: PostProcess): void;
  28775. /**
  28776. * Gets the current world matrix of the camera
  28777. */
  28778. getWorldMatrix(): Matrix;
  28779. /** @hidden */
  28780. _getViewMatrix(): Matrix;
  28781. /**
  28782. * Gets the current view matrix of the camera.
  28783. * @param force forces the camera to recompute the matrix without looking at the cached state
  28784. * @returns the view matrix
  28785. */
  28786. getViewMatrix(force?: boolean): Matrix;
  28787. /**
  28788. * Freeze the projection matrix.
  28789. * It will prevent the cache check of the camera projection compute and can speed up perf
  28790. * if no parameter of the camera are meant to change
  28791. * @param projection Defines manually a projection if necessary
  28792. */
  28793. freezeProjectionMatrix(projection?: Matrix): void;
  28794. /**
  28795. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28796. */
  28797. unfreezeProjectionMatrix(): void;
  28798. /**
  28799. * Gets the current projection matrix of the camera.
  28800. * @param force forces the camera to recompute the matrix without looking at the cached state
  28801. * @returns the projection matrix
  28802. */
  28803. getProjectionMatrix(force?: boolean): Matrix;
  28804. /**
  28805. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28806. * @returns a Matrix
  28807. */
  28808. getTransformationMatrix(): Matrix;
  28809. private _updateFrustumPlanes;
  28810. /**
  28811. * Checks if a cullable object (mesh...) is in the camera frustum
  28812. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28813. * @param target The object to check
  28814. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28815. * @returns true if the object is in frustum otherwise false
  28816. */
  28817. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28818. /**
  28819. * Checks if a cullable object (mesh...) is in the camera frustum
  28820. * Unlike isInFrustum this cheks the full bounding box
  28821. * @param target The object to check
  28822. * @returns true if the object is in frustum otherwise false
  28823. */
  28824. isCompletelyInFrustum(target: ICullable): boolean;
  28825. /**
  28826. * Gets a ray in the forward direction from the camera.
  28827. * @param length Defines the length of the ray to create
  28828. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28829. * @param origin Defines the start point of the ray which defaults to the camera position
  28830. * @returns the forward ray
  28831. */
  28832. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28833. /**
  28834. * Releases resources associated with this node.
  28835. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28836. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28837. */
  28838. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28839. /** @hidden */
  28840. _isLeftCamera: boolean;
  28841. /**
  28842. * Gets the left camera of a rig setup in case of Rigged Camera
  28843. */
  28844. get isLeftCamera(): boolean;
  28845. /** @hidden */
  28846. _isRightCamera: boolean;
  28847. /**
  28848. * Gets the right camera of a rig setup in case of Rigged Camera
  28849. */
  28850. get isRightCamera(): boolean;
  28851. /**
  28852. * Gets the left camera of a rig setup in case of Rigged Camera
  28853. */
  28854. get leftCamera(): Nullable<FreeCamera>;
  28855. /**
  28856. * Gets the right camera of a rig setup in case of Rigged Camera
  28857. */
  28858. get rightCamera(): Nullable<FreeCamera>;
  28859. /**
  28860. * Gets the left camera target of a rig setup in case of Rigged Camera
  28861. * @returns the target position
  28862. */
  28863. getLeftTarget(): Nullable<Vector3>;
  28864. /**
  28865. * Gets the right camera target of a rig setup in case of Rigged Camera
  28866. * @returns the target position
  28867. */
  28868. getRightTarget(): Nullable<Vector3>;
  28869. /**
  28870. * @hidden
  28871. */
  28872. setCameraRigMode(mode: number, rigParams: any): void;
  28873. /** @hidden */
  28874. static _setStereoscopicRigMode(camera: Camera): void;
  28875. /** @hidden */
  28876. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28877. /** @hidden */
  28878. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28879. /** @hidden */
  28880. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28881. /** @hidden */
  28882. _getVRProjectionMatrix(): Matrix;
  28883. protected _updateCameraRotationMatrix(): void;
  28884. protected _updateWebVRCameraRotationMatrix(): void;
  28885. /**
  28886. * This function MUST be overwritten by the different WebVR cameras available.
  28887. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28888. * @hidden
  28889. */
  28890. _getWebVRProjectionMatrix(): Matrix;
  28891. /**
  28892. * This function MUST be overwritten by the different WebVR cameras available.
  28893. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28894. * @hidden
  28895. */
  28896. _getWebVRViewMatrix(): Matrix;
  28897. /** @hidden */
  28898. setCameraRigParameter(name: string, value: any): void;
  28899. /**
  28900. * needs to be overridden by children so sub has required properties to be copied
  28901. * @hidden
  28902. */
  28903. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28904. /**
  28905. * May need to be overridden by children
  28906. * @hidden
  28907. */
  28908. _updateRigCameras(): void;
  28909. /** @hidden */
  28910. _setupInputs(): void;
  28911. /**
  28912. * Serialiaze the camera setup to a json represention
  28913. * @returns the JSON representation
  28914. */
  28915. serialize(): any;
  28916. /**
  28917. * Clones the current camera.
  28918. * @param name The cloned camera name
  28919. * @returns the cloned camera
  28920. */
  28921. clone(name: string): Camera;
  28922. /**
  28923. * Gets the direction of the camera relative to a given local axis.
  28924. * @param localAxis Defines the reference axis to provide a relative direction.
  28925. * @return the direction
  28926. */
  28927. getDirection(localAxis: Vector3): Vector3;
  28928. /**
  28929. * Returns the current camera absolute rotation
  28930. */
  28931. get absoluteRotation(): Quaternion;
  28932. /**
  28933. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28934. * @param localAxis Defines the reference axis to provide a relative direction.
  28935. * @param result Defines the vector to store the result in
  28936. */
  28937. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28938. /**
  28939. * Gets a camera constructor for a given camera type
  28940. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28941. * @param name The name of the camera the result will be able to instantiate
  28942. * @param scene The scene the result will construct the camera in
  28943. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28944. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28945. * @returns a factory method to construc the camera
  28946. */
  28947. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28948. /**
  28949. * Compute the world matrix of the camera.
  28950. * @returns the camera world matrix
  28951. */
  28952. computeWorldMatrix(): Matrix;
  28953. /**
  28954. * Parse a JSON and creates the camera from the parsed information
  28955. * @param parsedCamera The JSON to parse
  28956. * @param scene The scene to instantiate the camera in
  28957. * @returns the newly constructed camera
  28958. */
  28959. static Parse(parsedCamera: any, scene: Scene): Camera;
  28960. }
  28961. }
  28962. declare module BABYLON {
  28963. /**
  28964. * Class containing static functions to help procedurally build meshes
  28965. */
  28966. export class DiscBuilder {
  28967. /**
  28968. * Creates a plane polygonal mesh. By default, this is a disc
  28969. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28970. * * 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
  28971. * * 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
  28972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28973. * * 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
  28974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28975. * @param name defines the name of the mesh
  28976. * @param options defines the options used to create the mesh
  28977. * @param scene defines the hosting scene
  28978. * @returns the plane polygonal mesh
  28979. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28980. */
  28981. static CreateDisc(name: string, options: {
  28982. radius?: number;
  28983. tessellation?: number;
  28984. arc?: number;
  28985. updatable?: boolean;
  28986. sideOrientation?: number;
  28987. frontUVs?: Vector4;
  28988. backUVs?: Vector4;
  28989. }, scene?: Nullable<Scene>): Mesh;
  28990. }
  28991. }
  28992. declare module BABYLON {
  28993. /**
  28994. * Options to be used when creating a FresnelParameters.
  28995. */
  28996. export type IFresnelParametersCreationOptions = {
  28997. /**
  28998. * Define the color used on edges (grazing angle)
  28999. */
  29000. leftColor?: Color3;
  29001. /**
  29002. * Define the color used on center
  29003. */
  29004. rightColor?: Color3;
  29005. /**
  29006. * Define bias applied to computed fresnel term
  29007. */
  29008. bias?: number;
  29009. /**
  29010. * Defined the power exponent applied to fresnel term
  29011. */
  29012. power?: number;
  29013. /**
  29014. * Define if the fresnel effect is enable or not.
  29015. */
  29016. isEnabled?: boolean;
  29017. };
  29018. /**
  29019. * Serialized format for FresnelParameters.
  29020. */
  29021. export type IFresnelParametersSerialized = {
  29022. /**
  29023. * Define the color used on edges (grazing angle) [as an array]
  29024. */
  29025. leftColor: number[];
  29026. /**
  29027. * Define the color used on center [as an array]
  29028. */
  29029. rightColor: number[];
  29030. /**
  29031. * Define bias applied to computed fresnel term
  29032. */
  29033. bias: number;
  29034. /**
  29035. * Defined the power exponent applied to fresnel term
  29036. */
  29037. power?: number;
  29038. /**
  29039. * Define if the fresnel effect is enable or not.
  29040. */
  29041. isEnabled: boolean;
  29042. };
  29043. /**
  29044. * This represents all the required information to add a fresnel effect on a material:
  29045. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29046. */
  29047. export class FresnelParameters {
  29048. private _isEnabled;
  29049. /**
  29050. * Define if the fresnel effect is enable or not.
  29051. */
  29052. get isEnabled(): boolean;
  29053. set isEnabled(value: boolean);
  29054. /**
  29055. * Define the color used on edges (grazing angle)
  29056. */
  29057. leftColor: Color3;
  29058. /**
  29059. * Define the color used on center
  29060. */
  29061. rightColor: Color3;
  29062. /**
  29063. * Define bias applied to computed fresnel term
  29064. */
  29065. bias: number;
  29066. /**
  29067. * Defined the power exponent applied to fresnel term
  29068. */
  29069. power: number;
  29070. /**
  29071. * Creates a new FresnelParameters object.
  29072. *
  29073. * @param options provide your own settings to optionally to override defaults
  29074. */
  29075. constructor(options?: IFresnelParametersCreationOptions);
  29076. /**
  29077. * Clones the current fresnel and its valuues
  29078. * @returns a clone fresnel configuration
  29079. */
  29080. clone(): FresnelParameters;
  29081. /**
  29082. * Determines equality between FresnelParameters objects
  29083. * @param otherFresnelParameters defines the second operand
  29084. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29085. */
  29086. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29087. /**
  29088. * Serializes the current fresnel parameters to a JSON representation.
  29089. * @return the JSON serialization
  29090. */
  29091. serialize(): IFresnelParametersSerialized;
  29092. /**
  29093. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29094. * @param parsedFresnelParameters Define the JSON representation
  29095. * @returns the parsed parameters
  29096. */
  29097. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29098. }
  29099. }
  29100. declare module BABYLON {
  29101. /**
  29102. * This groups all the flags used to control the materials channel.
  29103. */
  29104. export class MaterialFlags {
  29105. private static _DiffuseTextureEnabled;
  29106. /**
  29107. * Are diffuse textures enabled in the application.
  29108. */
  29109. static get DiffuseTextureEnabled(): boolean;
  29110. static set DiffuseTextureEnabled(value: boolean);
  29111. private static _DetailTextureEnabled;
  29112. /**
  29113. * Are detail textures enabled in the application.
  29114. */
  29115. static get DetailTextureEnabled(): boolean;
  29116. static set DetailTextureEnabled(value: boolean);
  29117. private static _AmbientTextureEnabled;
  29118. /**
  29119. * Are ambient textures enabled in the application.
  29120. */
  29121. static get AmbientTextureEnabled(): boolean;
  29122. static set AmbientTextureEnabled(value: boolean);
  29123. private static _OpacityTextureEnabled;
  29124. /**
  29125. * Are opacity textures enabled in the application.
  29126. */
  29127. static get OpacityTextureEnabled(): boolean;
  29128. static set OpacityTextureEnabled(value: boolean);
  29129. private static _ReflectionTextureEnabled;
  29130. /**
  29131. * Are reflection textures enabled in the application.
  29132. */
  29133. static get ReflectionTextureEnabled(): boolean;
  29134. static set ReflectionTextureEnabled(value: boolean);
  29135. private static _EmissiveTextureEnabled;
  29136. /**
  29137. * Are emissive textures enabled in the application.
  29138. */
  29139. static get EmissiveTextureEnabled(): boolean;
  29140. static set EmissiveTextureEnabled(value: boolean);
  29141. private static _SpecularTextureEnabled;
  29142. /**
  29143. * Are specular textures enabled in the application.
  29144. */
  29145. static get SpecularTextureEnabled(): boolean;
  29146. static set SpecularTextureEnabled(value: boolean);
  29147. private static _BumpTextureEnabled;
  29148. /**
  29149. * Are bump textures enabled in the application.
  29150. */
  29151. static get BumpTextureEnabled(): boolean;
  29152. static set BumpTextureEnabled(value: boolean);
  29153. private static _LightmapTextureEnabled;
  29154. /**
  29155. * Are lightmap textures enabled in the application.
  29156. */
  29157. static get LightmapTextureEnabled(): boolean;
  29158. static set LightmapTextureEnabled(value: boolean);
  29159. private static _RefractionTextureEnabled;
  29160. /**
  29161. * Are refraction textures enabled in the application.
  29162. */
  29163. static get RefractionTextureEnabled(): boolean;
  29164. static set RefractionTextureEnabled(value: boolean);
  29165. private static _ColorGradingTextureEnabled;
  29166. /**
  29167. * Are color grading textures enabled in the application.
  29168. */
  29169. static get ColorGradingTextureEnabled(): boolean;
  29170. static set ColorGradingTextureEnabled(value: boolean);
  29171. private static _FresnelEnabled;
  29172. /**
  29173. * Are fresnels enabled in the application.
  29174. */
  29175. static get FresnelEnabled(): boolean;
  29176. static set FresnelEnabled(value: boolean);
  29177. private static _ClearCoatTextureEnabled;
  29178. /**
  29179. * Are clear coat textures enabled in the application.
  29180. */
  29181. static get ClearCoatTextureEnabled(): boolean;
  29182. static set ClearCoatTextureEnabled(value: boolean);
  29183. private static _ClearCoatBumpTextureEnabled;
  29184. /**
  29185. * Are clear coat bump textures enabled in the application.
  29186. */
  29187. static get ClearCoatBumpTextureEnabled(): boolean;
  29188. static set ClearCoatBumpTextureEnabled(value: boolean);
  29189. private static _ClearCoatTintTextureEnabled;
  29190. /**
  29191. * Are clear coat tint textures enabled in the application.
  29192. */
  29193. static get ClearCoatTintTextureEnabled(): boolean;
  29194. static set ClearCoatTintTextureEnabled(value: boolean);
  29195. private static _SheenTextureEnabled;
  29196. /**
  29197. * Are sheen textures enabled in the application.
  29198. */
  29199. static get SheenTextureEnabled(): boolean;
  29200. static set SheenTextureEnabled(value: boolean);
  29201. private static _AnisotropicTextureEnabled;
  29202. /**
  29203. * Are anisotropic textures enabled in the application.
  29204. */
  29205. static get AnisotropicTextureEnabled(): boolean;
  29206. static set AnisotropicTextureEnabled(value: boolean);
  29207. private static _ThicknessTextureEnabled;
  29208. /**
  29209. * Are thickness textures enabled in the application.
  29210. */
  29211. static get ThicknessTextureEnabled(): boolean;
  29212. static set ThicknessTextureEnabled(value: boolean);
  29213. }
  29214. }
  29215. declare module BABYLON {
  29216. /** @hidden */
  29217. export var defaultFragmentDeclaration: {
  29218. name: string;
  29219. shader: string;
  29220. };
  29221. }
  29222. declare module BABYLON {
  29223. /** @hidden */
  29224. export var defaultUboDeclaration: {
  29225. name: string;
  29226. shader: string;
  29227. };
  29228. }
  29229. declare module BABYLON {
  29230. /** @hidden */
  29231. export var lightFragmentDeclaration: {
  29232. name: string;
  29233. shader: string;
  29234. };
  29235. }
  29236. declare module BABYLON {
  29237. /** @hidden */
  29238. export var lightUboDeclaration: {
  29239. name: string;
  29240. shader: string;
  29241. };
  29242. }
  29243. declare module BABYLON {
  29244. /** @hidden */
  29245. export var lightsFragmentFunctions: {
  29246. name: string;
  29247. shader: string;
  29248. };
  29249. }
  29250. declare module BABYLON {
  29251. /** @hidden */
  29252. export var shadowsFragmentFunctions: {
  29253. name: string;
  29254. shader: string;
  29255. };
  29256. }
  29257. declare module BABYLON {
  29258. /** @hidden */
  29259. export var fresnelFunction: {
  29260. name: string;
  29261. shader: string;
  29262. };
  29263. }
  29264. declare module BABYLON {
  29265. /** @hidden */
  29266. export var bumpFragmentMainFunctions: {
  29267. name: string;
  29268. shader: string;
  29269. };
  29270. }
  29271. declare module BABYLON {
  29272. /** @hidden */
  29273. export var bumpFragmentFunctions: {
  29274. name: string;
  29275. shader: string;
  29276. };
  29277. }
  29278. declare module BABYLON {
  29279. /** @hidden */
  29280. export var logDepthDeclaration: {
  29281. name: string;
  29282. shader: string;
  29283. };
  29284. }
  29285. declare module BABYLON {
  29286. /** @hidden */
  29287. export var bumpFragment: {
  29288. name: string;
  29289. shader: string;
  29290. };
  29291. }
  29292. declare module BABYLON {
  29293. /** @hidden */
  29294. export var depthPrePass: {
  29295. name: string;
  29296. shader: string;
  29297. };
  29298. }
  29299. declare module BABYLON {
  29300. /** @hidden */
  29301. export var lightFragment: {
  29302. name: string;
  29303. shader: string;
  29304. };
  29305. }
  29306. declare module BABYLON {
  29307. /** @hidden */
  29308. export var logDepthFragment: {
  29309. name: string;
  29310. shader: string;
  29311. };
  29312. }
  29313. declare module BABYLON {
  29314. /** @hidden */
  29315. export var defaultPixelShader: {
  29316. name: string;
  29317. shader: string;
  29318. };
  29319. }
  29320. declare module BABYLON {
  29321. /** @hidden */
  29322. export var defaultVertexDeclaration: {
  29323. name: string;
  29324. shader: string;
  29325. };
  29326. }
  29327. declare module BABYLON {
  29328. /** @hidden */
  29329. export var bumpVertexDeclaration: {
  29330. name: string;
  29331. shader: string;
  29332. };
  29333. }
  29334. declare module BABYLON {
  29335. /** @hidden */
  29336. export var bumpVertex: {
  29337. name: string;
  29338. shader: string;
  29339. };
  29340. }
  29341. declare module BABYLON {
  29342. /** @hidden */
  29343. export var fogVertex: {
  29344. name: string;
  29345. shader: string;
  29346. };
  29347. }
  29348. declare module BABYLON {
  29349. /** @hidden */
  29350. export var shadowsVertex: {
  29351. name: string;
  29352. shader: string;
  29353. };
  29354. }
  29355. declare module BABYLON {
  29356. /** @hidden */
  29357. export var pointCloudVertex: {
  29358. name: string;
  29359. shader: string;
  29360. };
  29361. }
  29362. declare module BABYLON {
  29363. /** @hidden */
  29364. export var logDepthVertex: {
  29365. name: string;
  29366. shader: string;
  29367. };
  29368. }
  29369. declare module BABYLON {
  29370. /** @hidden */
  29371. export var defaultVertexShader: {
  29372. name: string;
  29373. shader: string;
  29374. };
  29375. }
  29376. declare module BABYLON {
  29377. /**
  29378. * @hidden
  29379. */
  29380. export interface IMaterialDetailMapDefines {
  29381. DETAIL: boolean;
  29382. DETAILDIRECTUV: number;
  29383. DETAIL_NORMALBLENDMETHOD: number;
  29384. /** @hidden */
  29385. _areTexturesDirty: boolean;
  29386. }
  29387. /**
  29388. * Define the code related to the detail map parameters of a material
  29389. *
  29390. * Inspired from:
  29391. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  29392. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  29393. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  29394. */
  29395. export class DetailMapConfiguration {
  29396. private _texture;
  29397. /**
  29398. * The detail texture of the material.
  29399. */
  29400. texture: Nullable<BaseTexture>;
  29401. /**
  29402. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  29403. * Bigger values mean stronger blending
  29404. */
  29405. diffuseBlendLevel: number;
  29406. /**
  29407. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  29408. * Bigger values mean stronger blending. Only used with PBR materials
  29409. */
  29410. roughnessBlendLevel: number;
  29411. /**
  29412. * Defines how strong the bump effect from the detail map is
  29413. * Bigger values mean stronger effect
  29414. */
  29415. bumpLevel: number;
  29416. private _normalBlendMethod;
  29417. /**
  29418. * The method used to blend the bump and detail normals together
  29419. */
  29420. normalBlendMethod: number;
  29421. private _isEnabled;
  29422. /**
  29423. * Enable or disable the detail map on this material
  29424. */
  29425. isEnabled: boolean;
  29426. /** @hidden */
  29427. private _internalMarkAllSubMeshesAsTexturesDirty;
  29428. /** @hidden */
  29429. _markAllSubMeshesAsTexturesDirty(): void;
  29430. /**
  29431. * Instantiate a new detail map
  29432. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  29433. */
  29434. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  29435. /**
  29436. * Gets whether the submesh is ready to be used or not.
  29437. * @param defines the list of "defines" to update.
  29438. * @param scene defines the scene the material belongs to.
  29439. * @returns - boolean indicating that the submesh is ready or not.
  29440. */
  29441. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  29442. /**
  29443. * Update the defines for detail map usage
  29444. * @param defines the list of "defines" to update.
  29445. * @param scene defines the scene the material belongs to.
  29446. */
  29447. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  29448. /**
  29449. * Binds the material data.
  29450. * @param uniformBuffer defines the Uniform buffer to fill in.
  29451. * @param scene defines the scene the material belongs to.
  29452. * @param isFrozen defines whether the material is frozen or not.
  29453. */
  29454. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  29455. /**
  29456. * Checks to see if a texture is used in the material.
  29457. * @param texture - Base texture to use.
  29458. * @returns - Boolean specifying if a texture is used in the material.
  29459. */
  29460. hasTexture(texture: BaseTexture): boolean;
  29461. /**
  29462. * Returns an array of the actively used textures.
  29463. * @param activeTextures Array of BaseTextures
  29464. */
  29465. getActiveTextures(activeTextures: BaseTexture[]): void;
  29466. /**
  29467. * Returns the animatable textures.
  29468. * @param animatables Array of animatable textures.
  29469. */
  29470. getAnimatables(animatables: IAnimatable[]): void;
  29471. /**
  29472. * Disposes the resources of the material.
  29473. * @param forceDisposeTextures - Forces the disposal of all textures.
  29474. */
  29475. dispose(forceDisposeTextures?: boolean): void;
  29476. /**
  29477. * Get the current class name useful for serialization or dynamic coding.
  29478. * @returns "DetailMap"
  29479. */
  29480. getClassName(): string;
  29481. /**
  29482. * Add the required uniforms to the current list.
  29483. * @param uniforms defines the current uniform list.
  29484. */
  29485. static AddUniforms(uniforms: string[]): void;
  29486. /**
  29487. * Add the required samplers to the current list.
  29488. * @param samplers defines the current sampler list.
  29489. */
  29490. static AddSamplers(samplers: string[]): void;
  29491. /**
  29492. * Add the required uniforms to the current buffer.
  29493. * @param uniformBuffer defines the current uniform buffer.
  29494. */
  29495. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  29496. /**
  29497. * Makes a duplicate of the current instance into another one.
  29498. * @param detailMap define the instance where to copy the info
  29499. */
  29500. copyTo(detailMap: DetailMapConfiguration): void;
  29501. /**
  29502. * Serializes this detail map instance
  29503. * @returns - An object with the serialized instance.
  29504. */
  29505. serialize(): any;
  29506. /**
  29507. * Parses a detail map setting from a serialized object.
  29508. * @param source - Serialized object.
  29509. * @param scene Defines the scene we are parsing for
  29510. * @param rootUrl Defines the rootUrl to load from
  29511. */
  29512. parse(source: any, scene: Scene, rootUrl: string): void;
  29513. }
  29514. }
  29515. declare module BABYLON {
  29516. /** @hidden */
  29517. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  29518. MAINUV1: boolean;
  29519. MAINUV2: boolean;
  29520. DIFFUSE: boolean;
  29521. DIFFUSEDIRECTUV: number;
  29522. DETAIL: boolean;
  29523. DETAILDIRECTUV: number;
  29524. DETAIL_NORMALBLENDMETHOD: number;
  29525. AMBIENT: boolean;
  29526. AMBIENTDIRECTUV: number;
  29527. OPACITY: boolean;
  29528. OPACITYDIRECTUV: number;
  29529. OPACITYRGB: boolean;
  29530. REFLECTION: boolean;
  29531. EMISSIVE: boolean;
  29532. EMISSIVEDIRECTUV: number;
  29533. SPECULAR: boolean;
  29534. SPECULARDIRECTUV: number;
  29535. BUMP: boolean;
  29536. BUMPDIRECTUV: number;
  29537. PARALLAX: boolean;
  29538. PARALLAXOCCLUSION: boolean;
  29539. SPECULAROVERALPHA: boolean;
  29540. CLIPPLANE: boolean;
  29541. CLIPPLANE2: boolean;
  29542. CLIPPLANE3: boolean;
  29543. CLIPPLANE4: boolean;
  29544. CLIPPLANE5: boolean;
  29545. CLIPPLANE6: boolean;
  29546. ALPHATEST: boolean;
  29547. DEPTHPREPASS: boolean;
  29548. ALPHAFROMDIFFUSE: boolean;
  29549. POINTSIZE: boolean;
  29550. FOG: boolean;
  29551. SPECULARTERM: boolean;
  29552. DIFFUSEFRESNEL: boolean;
  29553. OPACITYFRESNEL: boolean;
  29554. REFLECTIONFRESNEL: boolean;
  29555. REFRACTIONFRESNEL: boolean;
  29556. EMISSIVEFRESNEL: boolean;
  29557. FRESNEL: boolean;
  29558. NORMAL: boolean;
  29559. UV1: boolean;
  29560. UV2: boolean;
  29561. VERTEXCOLOR: boolean;
  29562. VERTEXALPHA: boolean;
  29563. NUM_BONE_INFLUENCERS: number;
  29564. BonesPerMesh: number;
  29565. BONETEXTURE: boolean;
  29566. INSTANCES: boolean;
  29567. THIN_INSTANCES: boolean;
  29568. GLOSSINESS: boolean;
  29569. ROUGHNESS: boolean;
  29570. EMISSIVEASILLUMINATION: boolean;
  29571. LINKEMISSIVEWITHDIFFUSE: boolean;
  29572. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29573. LIGHTMAP: boolean;
  29574. LIGHTMAPDIRECTUV: number;
  29575. OBJECTSPACE_NORMALMAP: boolean;
  29576. USELIGHTMAPASSHADOWMAP: boolean;
  29577. REFLECTIONMAP_3D: boolean;
  29578. REFLECTIONMAP_SPHERICAL: boolean;
  29579. REFLECTIONMAP_PLANAR: boolean;
  29580. REFLECTIONMAP_CUBIC: boolean;
  29581. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29582. REFLECTIONMAP_PROJECTION: boolean;
  29583. REFLECTIONMAP_SKYBOX: boolean;
  29584. REFLECTIONMAP_EXPLICIT: boolean;
  29585. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29586. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29587. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29588. INVERTCUBICMAP: boolean;
  29589. LOGARITHMICDEPTH: boolean;
  29590. REFRACTION: boolean;
  29591. REFRACTIONMAP_3D: boolean;
  29592. REFLECTIONOVERALPHA: boolean;
  29593. TWOSIDEDLIGHTING: boolean;
  29594. SHADOWFLOAT: boolean;
  29595. MORPHTARGETS: boolean;
  29596. MORPHTARGETS_NORMAL: boolean;
  29597. MORPHTARGETS_TANGENT: boolean;
  29598. MORPHTARGETS_UV: boolean;
  29599. NUM_MORPH_INFLUENCERS: number;
  29600. NONUNIFORMSCALING: boolean;
  29601. PREMULTIPLYALPHA: boolean;
  29602. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29603. ALPHABLEND: boolean;
  29604. RGBDLIGHTMAP: boolean;
  29605. RGBDREFLECTION: boolean;
  29606. RGBDREFRACTION: boolean;
  29607. IMAGEPROCESSING: boolean;
  29608. VIGNETTE: boolean;
  29609. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29610. VIGNETTEBLENDMODEOPAQUE: boolean;
  29611. TONEMAPPING: boolean;
  29612. TONEMAPPING_ACES: boolean;
  29613. CONTRAST: boolean;
  29614. COLORCURVES: boolean;
  29615. COLORGRADING: boolean;
  29616. COLORGRADING3D: boolean;
  29617. SAMPLER3DGREENDEPTH: boolean;
  29618. SAMPLER3DBGRMAP: boolean;
  29619. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29620. MULTIVIEW: boolean;
  29621. /**
  29622. * If the reflection texture on this material is in linear color space
  29623. * @hidden
  29624. */
  29625. IS_REFLECTION_LINEAR: boolean;
  29626. /**
  29627. * If the refraction texture on this material is in linear color space
  29628. * @hidden
  29629. */
  29630. IS_REFRACTION_LINEAR: boolean;
  29631. EXPOSURE: boolean;
  29632. constructor();
  29633. setReflectionMode(modeToEnable: string): void;
  29634. }
  29635. /**
  29636. * This is the default material used in Babylon. It is the best trade off between quality
  29637. * and performances.
  29638. * @see http://doc.babylonjs.com/babylon101/materials
  29639. */
  29640. export class StandardMaterial extends PushMaterial {
  29641. private _diffuseTexture;
  29642. /**
  29643. * The basic texture of the material as viewed under a light.
  29644. */
  29645. diffuseTexture: Nullable<BaseTexture>;
  29646. private _ambientTexture;
  29647. /**
  29648. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29649. */
  29650. ambientTexture: Nullable<BaseTexture>;
  29651. private _opacityTexture;
  29652. /**
  29653. * Define the transparency of the material from a texture.
  29654. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29655. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29656. */
  29657. opacityTexture: Nullable<BaseTexture>;
  29658. private _reflectionTexture;
  29659. /**
  29660. * Define the texture used to display the reflection.
  29661. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29662. */
  29663. reflectionTexture: Nullable<BaseTexture>;
  29664. private _emissiveTexture;
  29665. /**
  29666. * Define texture of the material as if self lit.
  29667. * This will be mixed in the final result even in the absence of light.
  29668. */
  29669. emissiveTexture: Nullable<BaseTexture>;
  29670. private _specularTexture;
  29671. /**
  29672. * Define how the color and intensity of the highlight given by the light in the material.
  29673. */
  29674. specularTexture: Nullable<BaseTexture>;
  29675. private _bumpTexture;
  29676. /**
  29677. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29678. * 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.
  29679. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29680. */
  29681. bumpTexture: Nullable<BaseTexture>;
  29682. private _lightmapTexture;
  29683. /**
  29684. * Complex lighting can be computationally expensive to compute at runtime.
  29685. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29686. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29687. */
  29688. lightmapTexture: Nullable<BaseTexture>;
  29689. private _refractionTexture;
  29690. /**
  29691. * Define the texture used to display the refraction.
  29692. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29693. */
  29694. refractionTexture: Nullable<BaseTexture>;
  29695. /**
  29696. * The color of the material lit by the environmental background lighting.
  29697. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29698. */
  29699. ambientColor: Color3;
  29700. /**
  29701. * The basic color of the material as viewed under a light.
  29702. */
  29703. diffuseColor: Color3;
  29704. /**
  29705. * Define how the color and intensity of the highlight given by the light in the material.
  29706. */
  29707. specularColor: Color3;
  29708. /**
  29709. * Define the color of the material as if self lit.
  29710. * This will be mixed in the final result even in the absence of light.
  29711. */
  29712. emissiveColor: Color3;
  29713. /**
  29714. * Defines how sharp are the highlights in the material.
  29715. * The bigger the value the sharper giving a more glossy feeling to the result.
  29716. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29717. */
  29718. specularPower: number;
  29719. private _useAlphaFromDiffuseTexture;
  29720. /**
  29721. * Does the transparency come from the diffuse texture alpha channel.
  29722. */
  29723. useAlphaFromDiffuseTexture: boolean;
  29724. private _useEmissiveAsIllumination;
  29725. /**
  29726. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29727. */
  29728. useEmissiveAsIllumination: boolean;
  29729. private _linkEmissiveWithDiffuse;
  29730. /**
  29731. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29732. * the emissive level when the final color is close to one.
  29733. */
  29734. linkEmissiveWithDiffuse: boolean;
  29735. private _useSpecularOverAlpha;
  29736. /**
  29737. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29738. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29739. */
  29740. useSpecularOverAlpha: boolean;
  29741. private _useReflectionOverAlpha;
  29742. /**
  29743. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29744. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29745. */
  29746. useReflectionOverAlpha: boolean;
  29747. private _disableLighting;
  29748. /**
  29749. * Does lights from the scene impacts this material.
  29750. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29751. */
  29752. disableLighting: boolean;
  29753. private _useObjectSpaceNormalMap;
  29754. /**
  29755. * Allows using an object space normal map (instead of tangent space).
  29756. */
  29757. useObjectSpaceNormalMap: boolean;
  29758. private _useParallax;
  29759. /**
  29760. * Is parallax enabled or not.
  29761. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29762. */
  29763. useParallax: boolean;
  29764. private _useParallaxOcclusion;
  29765. /**
  29766. * Is parallax occlusion enabled or not.
  29767. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29768. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29769. */
  29770. useParallaxOcclusion: boolean;
  29771. /**
  29772. * 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.
  29773. */
  29774. parallaxScaleBias: number;
  29775. private _roughness;
  29776. /**
  29777. * Helps to define how blurry the reflections should appears in the material.
  29778. */
  29779. roughness: number;
  29780. /**
  29781. * In case of refraction, define the value of the index of refraction.
  29782. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29783. */
  29784. indexOfRefraction: number;
  29785. /**
  29786. * Invert the refraction texture alongside the y axis.
  29787. * It can be useful with procedural textures or probe for instance.
  29788. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29789. */
  29790. invertRefractionY: boolean;
  29791. /**
  29792. * Defines the alpha limits in alpha test mode.
  29793. */
  29794. alphaCutOff: number;
  29795. private _useLightmapAsShadowmap;
  29796. /**
  29797. * In case of light mapping, define whether the map contains light or shadow informations.
  29798. */
  29799. useLightmapAsShadowmap: boolean;
  29800. private _diffuseFresnelParameters;
  29801. /**
  29802. * Define the diffuse fresnel parameters of the material.
  29803. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29804. */
  29805. diffuseFresnelParameters: FresnelParameters;
  29806. private _opacityFresnelParameters;
  29807. /**
  29808. * Define the opacity fresnel parameters of the material.
  29809. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29810. */
  29811. opacityFresnelParameters: FresnelParameters;
  29812. private _reflectionFresnelParameters;
  29813. /**
  29814. * Define the reflection fresnel parameters of the material.
  29815. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29816. */
  29817. reflectionFresnelParameters: FresnelParameters;
  29818. private _refractionFresnelParameters;
  29819. /**
  29820. * Define the refraction fresnel parameters of the material.
  29821. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29822. */
  29823. refractionFresnelParameters: FresnelParameters;
  29824. private _emissiveFresnelParameters;
  29825. /**
  29826. * Define the emissive fresnel parameters of the material.
  29827. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29828. */
  29829. emissiveFresnelParameters: FresnelParameters;
  29830. private _useReflectionFresnelFromSpecular;
  29831. /**
  29832. * If true automatically deducts the fresnels values from the material specularity.
  29833. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29834. */
  29835. useReflectionFresnelFromSpecular: boolean;
  29836. private _useGlossinessFromSpecularMapAlpha;
  29837. /**
  29838. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29839. */
  29840. useGlossinessFromSpecularMapAlpha: boolean;
  29841. private _maxSimultaneousLights;
  29842. /**
  29843. * Defines the maximum number of lights that can be used in the material
  29844. */
  29845. maxSimultaneousLights: number;
  29846. private _invertNormalMapX;
  29847. /**
  29848. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29849. */
  29850. invertNormalMapX: boolean;
  29851. private _invertNormalMapY;
  29852. /**
  29853. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29854. */
  29855. invertNormalMapY: boolean;
  29856. private _twoSidedLighting;
  29857. /**
  29858. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29859. */
  29860. twoSidedLighting: boolean;
  29861. /**
  29862. * Default configuration related to image processing available in the standard Material.
  29863. */
  29864. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29865. /**
  29866. * Gets the image processing configuration used either in this material.
  29867. */
  29868. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29869. /**
  29870. * Sets the Default image processing configuration used either in the this material.
  29871. *
  29872. * If sets to null, the scene one is in use.
  29873. */
  29874. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29875. /**
  29876. * Keep track of the image processing observer to allow dispose and replace.
  29877. */
  29878. private _imageProcessingObserver;
  29879. /**
  29880. * Attaches a new image processing configuration to the Standard Material.
  29881. * @param configuration
  29882. */
  29883. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29884. /**
  29885. * Gets wether the color curves effect is enabled.
  29886. */
  29887. get cameraColorCurvesEnabled(): boolean;
  29888. /**
  29889. * Sets wether the color curves effect is enabled.
  29890. */
  29891. set cameraColorCurvesEnabled(value: boolean);
  29892. /**
  29893. * Gets wether the color grading effect is enabled.
  29894. */
  29895. get cameraColorGradingEnabled(): boolean;
  29896. /**
  29897. * Gets wether the color grading effect is enabled.
  29898. */
  29899. set cameraColorGradingEnabled(value: boolean);
  29900. /**
  29901. * Gets wether tonemapping is enabled or not.
  29902. */
  29903. get cameraToneMappingEnabled(): boolean;
  29904. /**
  29905. * Sets wether tonemapping is enabled or not
  29906. */
  29907. set cameraToneMappingEnabled(value: boolean);
  29908. /**
  29909. * The camera exposure used on this material.
  29910. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29911. * This corresponds to a photographic exposure.
  29912. */
  29913. get cameraExposure(): number;
  29914. /**
  29915. * The camera exposure used on this material.
  29916. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29917. * This corresponds to a photographic exposure.
  29918. */
  29919. set cameraExposure(value: number);
  29920. /**
  29921. * Gets The camera contrast used on this material.
  29922. */
  29923. get cameraContrast(): number;
  29924. /**
  29925. * Sets The camera contrast used on this material.
  29926. */
  29927. set cameraContrast(value: number);
  29928. /**
  29929. * Gets the Color Grading 2D Lookup Texture.
  29930. */
  29931. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29932. /**
  29933. * Sets the Color Grading 2D Lookup Texture.
  29934. */
  29935. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29936. /**
  29937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29939. * 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;
  29940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29941. */
  29942. get cameraColorCurves(): Nullable<ColorCurves>;
  29943. /**
  29944. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29945. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29946. * 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;
  29947. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29948. */
  29949. set cameraColorCurves(value: Nullable<ColorCurves>);
  29950. /**
  29951. * Defines the detail map parameters for the material.
  29952. */
  29953. readonly detailMap: DetailMapConfiguration;
  29954. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29955. protected _worldViewProjectionMatrix: Matrix;
  29956. protected _globalAmbientColor: Color3;
  29957. protected _useLogarithmicDepth: boolean;
  29958. protected _rebuildInParallel: boolean;
  29959. /**
  29960. * Instantiates a new standard material.
  29961. * This is the default material used in Babylon. It is the best trade off between quality
  29962. * and performances.
  29963. * @see http://doc.babylonjs.com/babylon101/materials
  29964. * @param name Define the name of the material in the scene
  29965. * @param scene Define the scene the material belong to
  29966. */
  29967. constructor(name: string, scene: Scene);
  29968. /**
  29969. * Gets a boolean indicating that current material needs to register RTT
  29970. */
  29971. get hasRenderTargetTextures(): boolean;
  29972. /**
  29973. * Gets the current class name of the material e.g. "StandardMaterial"
  29974. * Mainly use in serialization.
  29975. * @returns the class name
  29976. */
  29977. getClassName(): string;
  29978. /**
  29979. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29980. * You can try switching to logarithmic depth.
  29981. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29982. */
  29983. get useLogarithmicDepth(): boolean;
  29984. set useLogarithmicDepth(value: boolean);
  29985. /**
  29986. * Specifies if the material will require alpha blending
  29987. * @returns a boolean specifying if alpha blending is needed
  29988. */
  29989. needAlphaBlending(): boolean;
  29990. /**
  29991. * Specifies if this material should be rendered in alpha test mode
  29992. * @returns a boolean specifying if an alpha test is needed.
  29993. */
  29994. needAlphaTesting(): boolean;
  29995. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29996. /**
  29997. * Get the texture used for alpha test purpose.
  29998. * @returns the diffuse texture in case of the standard material.
  29999. */
  30000. getAlphaTestTexture(): Nullable<BaseTexture>;
  30001. /**
  30002. * Get if the submesh is ready to be used and all its information available.
  30003. * Child classes can use it to update shaders
  30004. * @param mesh defines the mesh to check
  30005. * @param subMesh defines which submesh to check
  30006. * @param useInstances specifies that instances should be used
  30007. * @returns a boolean indicating that the submesh is ready or not
  30008. */
  30009. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30010. /**
  30011. * Builds the material UBO layouts.
  30012. * Used internally during the effect preparation.
  30013. */
  30014. buildUniformLayout(): void;
  30015. /**
  30016. * Unbinds the material from the mesh
  30017. */
  30018. unbind(): void;
  30019. /**
  30020. * Binds the submesh to this material by preparing the effect and shader to draw
  30021. * @param world defines the world transformation matrix
  30022. * @param mesh defines the mesh containing the submesh
  30023. * @param subMesh defines the submesh to bind the material to
  30024. */
  30025. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30026. /**
  30027. * Get the list of animatables in the material.
  30028. * @returns the list of animatables object used in the material
  30029. */
  30030. getAnimatables(): IAnimatable[];
  30031. /**
  30032. * Gets the active textures from the material
  30033. * @returns an array of textures
  30034. */
  30035. getActiveTextures(): BaseTexture[];
  30036. /**
  30037. * Specifies if the material uses a texture
  30038. * @param texture defines the texture to check against the material
  30039. * @returns a boolean specifying if the material uses the texture
  30040. */
  30041. hasTexture(texture: BaseTexture): boolean;
  30042. /**
  30043. * Disposes the material
  30044. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30045. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30046. */
  30047. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30048. /**
  30049. * Makes a duplicate of the material, and gives it a new name
  30050. * @param name defines the new name for the duplicated material
  30051. * @returns the cloned material
  30052. */
  30053. clone(name: string): StandardMaterial;
  30054. /**
  30055. * Serializes this material in a JSON representation
  30056. * @returns the serialized material object
  30057. */
  30058. serialize(): any;
  30059. /**
  30060. * Creates a standard material from parsed material data
  30061. * @param source defines the JSON representation of the material
  30062. * @param scene defines the hosting scene
  30063. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30064. * @returns a new standard material
  30065. */
  30066. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30067. /**
  30068. * Are diffuse textures enabled in the application.
  30069. */
  30070. static get DiffuseTextureEnabled(): boolean;
  30071. static set DiffuseTextureEnabled(value: boolean);
  30072. /**
  30073. * Are detail textures enabled in the application.
  30074. */
  30075. static get DetailTextureEnabled(): boolean;
  30076. static set DetailTextureEnabled(value: boolean);
  30077. /**
  30078. * Are ambient textures enabled in the application.
  30079. */
  30080. static get AmbientTextureEnabled(): boolean;
  30081. static set AmbientTextureEnabled(value: boolean);
  30082. /**
  30083. * Are opacity textures enabled in the application.
  30084. */
  30085. static get OpacityTextureEnabled(): boolean;
  30086. static set OpacityTextureEnabled(value: boolean);
  30087. /**
  30088. * Are reflection textures enabled in the application.
  30089. */
  30090. static get ReflectionTextureEnabled(): boolean;
  30091. static set ReflectionTextureEnabled(value: boolean);
  30092. /**
  30093. * Are emissive textures enabled in the application.
  30094. */
  30095. static get EmissiveTextureEnabled(): boolean;
  30096. static set EmissiveTextureEnabled(value: boolean);
  30097. /**
  30098. * Are specular textures enabled in the application.
  30099. */
  30100. static get SpecularTextureEnabled(): boolean;
  30101. static set SpecularTextureEnabled(value: boolean);
  30102. /**
  30103. * Are bump textures enabled in the application.
  30104. */
  30105. static get BumpTextureEnabled(): boolean;
  30106. static set BumpTextureEnabled(value: boolean);
  30107. /**
  30108. * Are lightmap textures enabled in the application.
  30109. */
  30110. static get LightmapTextureEnabled(): boolean;
  30111. static set LightmapTextureEnabled(value: boolean);
  30112. /**
  30113. * Are refraction textures enabled in the application.
  30114. */
  30115. static get RefractionTextureEnabled(): boolean;
  30116. static set RefractionTextureEnabled(value: boolean);
  30117. /**
  30118. * Are color grading textures enabled in the application.
  30119. */
  30120. static get ColorGradingTextureEnabled(): boolean;
  30121. static set ColorGradingTextureEnabled(value: boolean);
  30122. /**
  30123. * Are fresnels enabled in the application.
  30124. */
  30125. static get FresnelEnabled(): boolean;
  30126. static set FresnelEnabled(value: boolean);
  30127. }
  30128. }
  30129. declare module BABYLON {
  30130. /**
  30131. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30132. *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.
  30133. * The SPS is also a particle system. It provides some methods to manage the particles.
  30134. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30135. *
  30136. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  30137. */
  30138. export class SolidParticleSystem implements IDisposable {
  30139. /**
  30140. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30141. * Example : var p = SPS.particles[i];
  30142. */
  30143. particles: SolidParticle[];
  30144. /**
  30145. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30146. */
  30147. nbParticles: number;
  30148. /**
  30149. * If the particles must ever face the camera (default false). Useful for planar particles.
  30150. */
  30151. billboard: boolean;
  30152. /**
  30153. * Recompute normals when adding a shape
  30154. */
  30155. recomputeNormals: boolean;
  30156. /**
  30157. * This a counter ofr your own usage. It's not set by any SPS functions.
  30158. */
  30159. counter: number;
  30160. /**
  30161. * The SPS name. This name is also given to the underlying mesh.
  30162. */
  30163. name: string;
  30164. /**
  30165. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30166. */
  30167. mesh: Mesh;
  30168. /**
  30169. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30170. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30171. */
  30172. vars: any;
  30173. /**
  30174. * This array is populated when the SPS is set as 'pickable'.
  30175. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30176. * Each element of this array is an object `{idx: int, faceId: int}`.
  30177. * `idx` is the picked particle index in the `SPS.particles` array
  30178. * `faceId` is the picked face index counted within this particle.
  30179. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30180. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30181. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30182. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30183. */
  30184. pickedParticles: {
  30185. idx: number;
  30186. faceId: number;
  30187. }[];
  30188. /**
  30189. * This array is populated when the SPS is set as 'pickable'
  30190. * Each key of this array is a submesh index.
  30191. * Each element of this array is a second array defined like this :
  30192. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30193. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30194. * `idx` is the picked particle index in the `SPS.particles` array
  30195. * `faceId` is the picked face index counted within this particle.
  30196. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30197. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30198. */
  30199. pickedBySubMesh: {
  30200. idx: number;
  30201. faceId: number;
  30202. }[][];
  30203. /**
  30204. * This array is populated when `enableDepthSort` is set to true.
  30205. * Each element of this array is an instance of the class DepthSortedParticle.
  30206. */
  30207. depthSortedParticles: DepthSortedParticle[];
  30208. /**
  30209. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30210. * @hidden
  30211. */
  30212. _bSphereOnly: boolean;
  30213. /**
  30214. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30215. * @hidden
  30216. */
  30217. _bSphereRadiusFactor: number;
  30218. private _scene;
  30219. private _positions;
  30220. private _indices;
  30221. private _normals;
  30222. private _colors;
  30223. private _uvs;
  30224. private _indices32;
  30225. private _positions32;
  30226. private _normals32;
  30227. private _fixedNormal32;
  30228. private _colors32;
  30229. private _uvs32;
  30230. private _index;
  30231. private _updatable;
  30232. private _pickable;
  30233. private _isVisibilityBoxLocked;
  30234. private _alwaysVisible;
  30235. private _depthSort;
  30236. private _expandable;
  30237. private _shapeCounter;
  30238. private _copy;
  30239. private _color;
  30240. private _computeParticleColor;
  30241. private _computeParticleTexture;
  30242. private _computeParticleRotation;
  30243. private _computeParticleVertex;
  30244. private _computeBoundingBox;
  30245. private _depthSortParticles;
  30246. private _camera;
  30247. private _mustUnrotateFixedNormals;
  30248. private _particlesIntersect;
  30249. private _needs32Bits;
  30250. private _isNotBuilt;
  30251. private _lastParticleId;
  30252. private _idxOfId;
  30253. private _multimaterialEnabled;
  30254. private _useModelMaterial;
  30255. private _indicesByMaterial;
  30256. private _materialIndexes;
  30257. private _depthSortFunction;
  30258. private _materialSortFunction;
  30259. private _materials;
  30260. private _multimaterial;
  30261. private _materialIndexesById;
  30262. private _defaultMaterial;
  30263. private _autoUpdateSubMeshes;
  30264. private _tmpVertex;
  30265. /**
  30266. * Creates a SPS (Solid Particle System) object.
  30267. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30268. * @param scene (Scene) is the scene in which the SPS is added.
  30269. * @param options defines the options of the sps e.g.
  30270. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30271. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30272. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30273. * * 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.
  30274. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30275. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30276. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30277. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30278. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30279. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30280. */
  30281. constructor(name: string, scene: Scene, options?: {
  30282. updatable?: boolean;
  30283. isPickable?: boolean;
  30284. enableDepthSort?: boolean;
  30285. particleIntersection?: boolean;
  30286. boundingSphereOnly?: boolean;
  30287. bSphereRadiusFactor?: number;
  30288. expandable?: boolean;
  30289. useModelMaterial?: boolean;
  30290. enableMultiMaterial?: boolean;
  30291. });
  30292. /**
  30293. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30294. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30295. * @returns the created mesh
  30296. */
  30297. buildMesh(): Mesh;
  30298. /**
  30299. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30300. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30301. * Thus the particles generated from `digest()` have their property `position` set yet.
  30302. * @param mesh ( Mesh ) is the mesh to be digested
  30303. * @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
  30304. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30305. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30306. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30307. * @returns the current SPS
  30308. */
  30309. digest(mesh: Mesh, options?: {
  30310. facetNb?: number;
  30311. number?: number;
  30312. delta?: number;
  30313. storage?: [];
  30314. }): SolidParticleSystem;
  30315. /**
  30316. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30317. * @hidden
  30318. */
  30319. private _unrotateFixedNormals;
  30320. /**
  30321. * Resets the temporary working copy particle
  30322. * @hidden
  30323. */
  30324. private _resetCopy;
  30325. /**
  30326. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30327. * @param p the current index in the positions array to be updated
  30328. * @param ind the current index in the indices array
  30329. * @param shape a Vector3 array, the shape geometry
  30330. * @param positions the positions array to be updated
  30331. * @param meshInd the shape indices array
  30332. * @param indices the indices array to be updated
  30333. * @param meshUV the shape uv array
  30334. * @param uvs the uv array to be updated
  30335. * @param meshCol the shape color array
  30336. * @param colors the color array to be updated
  30337. * @param meshNor the shape normals array
  30338. * @param normals the normals array to be updated
  30339. * @param idx the particle index
  30340. * @param idxInShape the particle index in its shape
  30341. * @param options the addShape() method passed options
  30342. * @model the particle model
  30343. * @hidden
  30344. */
  30345. private _meshBuilder;
  30346. /**
  30347. * Returns a shape Vector3 array from positions float array
  30348. * @param positions float array
  30349. * @returns a vector3 array
  30350. * @hidden
  30351. */
  30352. private _posToShape;
  30353. /**
  30354. * Returns a shapeUV array from a float uvs (array deep copy)
  30355. * @param uvs as a float array
  30356. * @returns a shapeUV array
  30357. * @hidden
  30358. */
  30359. private _uvsToShapeUV;
  30360. /**
  30361. * Adds a new particle object in the particles array
  30362. * @param idx particle index in particles array
  30363. * @param id particle id
  30364. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30365. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30366. * @param model particle ModelShape object
  30367. * @param shapeId model shape identifier
  30368. * @param idxInShape index of the particle in the current model
  30369. * @param bInfo model bounding info object
  30370. * @param storage target storage array, if any
  30371. * @hidden
  30372. */
  30373. private _addParticle;
  30374. /**
  30375. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30376. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30377. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30378. * @param nb (positive integer) the number of particles to be created from this model
  30379. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30380. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30381. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30382. * @returns the number of shapes in the system
  30383. */
  30384. addShape(mesh: Mesh, nb: number, options?: {
  30385. positionFunction?: any;
  30386. vertexFunction?: any;
  30387. storage?: [];
  30388. }): number;
  30389. /**
  30390. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30391. * @hidden
  30392. */
  30393. private _rebuildParticle;
  30394. /**
  30395. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30396. * @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.
  30397. * @returns the SPS.
  30398. */
  30399. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30400. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30401. * Returns an array with the removed particles.
  30402. * 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.
  30403. * The SPS can't be empty so at least one particle needs to remain in place.
  30404. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30405. * @param start index of the first particle to remove
  30406. * @param end index of the last particle to remove (included)
  30407. * @returns an array populated with the removed particles
  30408. */
  30409. removeParticles(start: number, end: number): SolidParticle[];
  30410. /**
  30411. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30412. * @param solidParticleArray an array populated with Solid Particles objects
  30413. * @returns the SPS
  30414. */
  30415. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30416. /**
  30417. * Creates a new particle and modifies the SPS mesh geometry :
  30418. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30419. * - calls _addParticle() to populate the particle array
  30420. * factorized code from addShape() and insertParticlesFromArray()
  30421. * @param idx particle index in the particles array
  30422. * @param i particle index in its shape
  30423. * @param modelShape particle ModelShape object
  30424. * @param shape shape vertex array
  30425. * @param meshInd shape indices array
  30426. * @param meshUV shape uv array
  30427. * @param meshCol shape color array
  30428. * @param meshNor shape normals array
  30429. * @param bbInfo shape bounding info
  30430. * @param storage target particle storage
  30431. * @options addShape() passed options
  30432. * @hidden
  30433. */
  30434. private _insertNewParticle;
  30435. /**
  30436. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30437. * This method calls `updateParticle()` for each particle of the SPS.
  30438. * For an animated SPS, it is usually called within the render loop.
  30439. * 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.
  30440. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30441. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30442. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30443. * @returns the SPS.
  30444. */
  30445. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30446. /**
  30447. * Disposes the SPS.
  30448. */
  30449. dispose(): void;
  30450. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30451. * idx is the particle index in the SPS
  30452. * faceId is the picked face index counted within this particle.
  30453. * Returns null if the pickInfo can't identify a picked particle.
  30454. * @param pickingInfo (PickingInfo object)
  30455. * @returns {idx: number, faceId: number} or null
  30456. */
  30457. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30458. idx: number;
  30459. faceId: number;
  30460. }>;
  30461. /**
  30462. * Returns a SolidParticle object from its identifier : particle.id
  30463. * @param id (integer) the particle Id
  30464. * @returns the searched particle or null if not found in the SPS.
  30465. */
  30466. getParticleById(id: number): Nullable<SolidParticle>;
  30467. /**
  30468. * Returns a new array populated with the particles having the passed shapeId.
  30469. * @param shapeId (integer) the shape identifier
  30470. * @returns a new solid particle array
  30471. */
  30472. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30473. /**
  30474. * Populates the passed array "ref" with the particles having the passed shapeId.
  30475. * @param shapeId the shape identifier
  30476. * @returns the SPS
  30477. * @param ref
  30478. */
  30479. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30480. /**
  30481. * Computes the required SubMeshes according the materials assigned to the particles.
  30482. * @returns the solid particle system.
  30483. * Does nothing if called before the SPS mesh is built.
  30484. */
  30485. computeSubMeshes(): SolidParticleSystem;
  30486. /**
  30487. * Sorts the solid particles by material when MultiMaterial is enabled.
  30488. * Updates the indices32 array.
  30489. * Updates the indicesByMaterial array.
  30490. * Updates the mesh indices array.
  30491. * @returns the SPS
  30492. * @hidden
  30493. */
  30494. private _sortParticlesByMaterial;
  30495. /**
  30496. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30497. * @hidden
  30498. */
  30499. private _setMaterialIndexesById;
  30500. /**
  30501. * Returns an array with unique values of Materials from the passed array
  30502. * @param array the material array to be checked and filtered
  30503. * @hidden
  30504. */
  30505. private _filterUniqueMaterialId;
  30506. /**
  30507. * Sets a new Standard Material as _defaultMaterial if not already set.
  30508. * @hidden
  30509. */
  30510. private _setDefaultMaterial;
  30511. /**
  30512. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30513. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30514. * @returns the SPS.
  30515. */
  30516. refreshVisibleSize(): SolidParticleSystem;
  30517. /**
  30518. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30519. * @param size the size (float) of the visibility box
  30520. * note : this doesn't lock the SPS mesh bounding box.
  30521. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30522. */
  30523. setVisibilityBox(size: number): void;
  30524. /**
  30525. * Gets whether the SPS as always visible or not
  30526. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30527. */
  30528. get isAlwaysVisible(): boolean;
  30529. /**
  30530. * Sets the SPS as always visible or not
  30531. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30532. */
  30533. set isAlwaysVisible(val: boolean);
  30534. /**
  30535. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30536. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30537. */
  30538. set isVisibilityBoxLocked(val: boolean);
  30539. /**
  30540. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30541. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30542. */
  30543. get isVisibilityBoxLocked(): boolean;
  30544. /**
  30545. * Tells to `setParticles()` to compute the particle rotations or not.
  30546. * Default value : true. The SPS is faster when it's set to false.
  30547. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30548. */
  30549. set computeParticleRotation(val: boolean);
  30550. /**
  30551. * Tells to `setParticles()` to compute the particle colors or not.
  30552. * Default value : true. The SPS is faster when it's set to false.
  30553. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30554. */
  30555. set computeParticleColor(val: boolean);
  30556. set computeParticleTexture(val: boolean);
  30557. /**
  30558. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30559. * Default value : false. The SPS is faster when it's set to false.
  30560. * Note : the particle custom vertex positions aren't stored values.
  30561. */
  30562. set computeParticleVertex(val: boolean);
  30563. /**
  30564. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30565. */
  30566. set computeBoundingBox(val: boolean);
  30567. /**
  30568. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30569. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30570. * Default : `true`
  30571. */
  30572. set depthSortParticles(val: boolean);
  30573. /**
  30574. * Gets if `setParticles()` computes the particle rotations or not.
  30575. * Default value : true. The SPS is faster when it's set to false.
  30576. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30577. */
  30578. get computeParticleRotation(): boolean;
  30579. /**
  30580. * Gets if `setParticles()` computes the particle colors or not.
  30581. * Default value : true. The SPS is faster when it's set to false.
  30582. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30583. */
  30584. get computeParticleColor(): boolean;
  30585. /**
  30586. * Gets if `setParticles()` computes the particle textures or not.
  30587. * Default value : true. The SPS is faster when it's set to false.
  30588. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30589. */
  30590. get computeParticleTexture(): boolean;
  30591. /**
  30592. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30593. * Default value : false. The SPS is faster when it's set to false.
  30594. * Note : the particle custom vertex positions aren't stored values.
  30595. */
  30596. get computeParticleVertex(): boolean;
  30597. /**
  30598. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30599. */
  30600. get computeBoundingBox(): boolean;
  30601. /**
  30602. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30603. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30604. * Default : `true`
  30605. */
  30606. get depthSortParticles(): boolean;
  30607. /**
  30608. * Gets if the SPS is created as expandable at construction time.
  30609. * Default : `false`
  30610. */
  30611. get expandable(): boolean;
  30612. /**
  30613. * Gets if the SPS supports the Multi Materials
  30614. */
  30615. get multimaterialEnabled(): boolean;
  30616. /**
  30617. * Gets if the SPS uses the model materials for its own multimaterial.
  30618. */
  30619. get useModelMaterial(): boolean;
  30620. /**
  30621. * The SPS used material array.
  30622. */
  30623. get materials(): Material[];
  30624. /**
  30625. * Sets the SPS MultiMaterial from the passed materials.
  30626. * Note : the passed array is internally copied and not used then by reference.
  30627. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30628. */
  30629. setMultiMaterial(materials: Material[]): void;
  30630. /**
  30631. * The SPS computed multimaterial object
  30632. */
  30633. get multimaterial(): MultiMaterial;
  30634. set multimaterial(mm: MultiMaterial);
  30635. /**
  30636. * If the subMeshes must be updated on the next call to setParticles()
  30637. */
  30638. get autoUpdateSubMeshes(): boolean;
  30639. set autoUpdateSubMeshes(val: boolean);
  30640. /**
  30641. * This function does nothing. It may be overwritten to set all the particle first values.
  30642. * The SPS doesn't call this function, you may have to call it by your own.
  30643. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30644. */
  30645. initParticles(): void;
  30646. /**
  30647. * This function does nothing. It may be overwritten to recycle a particle.
  30648. * The SPS doesn't call this function, you may have to call it by your own.
  30649. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30650. * @param particle The particle to recycle
  30651. * @returns the recycled particle
  30652. */
  30653. recycleParticle(particle: SolidParticle): SolidParticle;
  30654. /**
  30655. * Updates a particle : this function should be overwritten by the user.
  30656. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30657. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30658. * @example : just set a particle position or velocity and recycle conditions
  30659. * @param particle The particle to update
  30660. * @returns the updated particle
  30661. */
  30662. updateParticle(particle: SolidParticle): SolidParticle;
  30663. /**
  30664. * Updates a vertex of a particle : it can be overwritten by the user.
  30665. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30666. * @param particle the current particle
  30667. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30668. * @param pt the index of the current vertex in the particle shape
  30669. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30670. * @example : just set a vertex particle position or color
  30671. * @returns the sps
  30672. */
  30673. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30674. /**
  30675. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30676. * This does nothing and may be overwritten by the user.
  30677. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30678. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30679. * @param update the boolean update value actually passed to setParticles()
  30680. */
  30681. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30682. /**
  30683. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30684. * This will be passed three parameters.
  30685. * This does nothing and may be overwritten by the user.
  30686. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30687. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30688. * @param update the boolean update value actually passed to setParticles()
  30689. */
  30690. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30691. }
  30692. }
  30693. declare module BABYLON {
  30694. /**
  30695. * Represents one particle of a solid particle system.
  30696. */
  30697. export class SolidParticle {
  30698. /**
  30699. * particle global index
  30700. */
  30701. idx: number;
  30702. /**
  30703. * particle identifier
  30704. */
  30705. id: number;
  30706. /**
  30707. * The color of the particle
  30708. */
  30709. color: Nullable<Color4>;
  30710. /**
  30711. * The world space position of the particle.
  30712. */
  30713. position: Vector3;
  30714. /**
  30715. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30716. */
  30717. rotation: Vector3;
  30718. /**
  30719. * The world space rotation quaternion of the particle.
  30720. */
  30721. rotationQuaternion: Nullable<Quaternion>;
  30722. /**
  30723. * The scaling of the particle.
  30724. */
  30725. scaling: Vector3;
  30726. /**
  30727. * The uvs of the particle.
  30728. */
  30729. uvs: Vector4;
  30730. /**
  30731. * The current speed of the particle.
  30732. */
  30733. velocity: Vector3;
  30734. /**
  30735. * The pivot point in the particle local space.
  30736. */
  30737. pivot: Vector3;
  30738. /**
  30739. * Must the particle be translated from its pivot point in its local space ?
  30740. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30741. * Default : false
  30742. */
  30743. translateFromPivot: boolean;
  30744. /**
  30745. * Is the particle active or not ?
  30746. */
  30747. alive: boolean;
  30748. /**
  30749. * Is the particle visible or not ?
  30750. */
  30751. isVisible: boolean;
  30752. /**
  30753. * Index of this particle in the global "positions" array (Internal use)
  30754. * @hidden
  30755. */
  30756. _pos: number;
  30757. /**
  30758. * @hidden Index of this particle in the global "indices" array (Internal use)
  30759. */
  30760. _ind: number;
  30761. /**
  30762. * @hidden ModelShape of this particle (Internal use)
  30763. */
  30764. _model: ModelShape;
  30765. /**
  30766. * ModelShape id of this particle
  30767. */
  30768. shapeId: number;
  30769. /**
  30770. * Index of the particle in its shape id
  30771. */
  30772. idxInShape: number;
  30773. /**
  30774. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30775. */
  30776. _modelBoundingInfo: BoundingInfo;
  30777. /**
  30778. * @hidden Particle BoundingInfo object (Internal use)
  30779. */
  30780. _boundingInfo: BoundingInfo;
  30781. /**
  30782. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30783. */
  30784. _sps: SolidParticleSystem;
  30785. /**
  30786. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30787. */
  30788. _stillInvisible: boolean;
  30789. /**
  30790. * @hidden Last computed particle rotation matrix
  30791. */
  30792. _rotationMatrix: number[];
  30793. /**
  30794. * Parent particle Id, if any.
  30795. * Default null.
  30796. */
  30797. parentId: Nullable<number>;
  30798. /**
  30799. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30800. */
  30801. materialIndex: Nullable<number>;
  30802. /**
  30803. * Custom object or properties.
  30804. */
  30805. props: Nullable<any>;
  30806. /**
  30807. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30808. * The possible values are :
  30809. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30810. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30811. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30812. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30813. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30814. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30815. * */
  30816. cullingStrategy: number;
  30817. /**
  30818. * @hidden Internal global position in the SPS.
  30819. */
  30820. _globalPosition: Vector3;
  30821. /**
  30822. * Creates a Solid Particle object.
  30823. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30824. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30825. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30826. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30827. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30828. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30829. * @param shapeId (integer) is the model shape identifier in the SPS.
  30830. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30831. * @param sps defines the sps it is associated to
  30832. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30833. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30834. */
  30835. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30836. /**
  30837. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30838. * @param target the particle target
  30839. * @returns the current particle
  30840. */
  30841. copyToRef(target: SolidParticle): SolidParticle;
  30842. /**
  30843. * Legacy support, changed scale to scaling
  30844. */
  30845. get scale(): Vector3;
  30846. /**
  30847. * Legacy support, changed scale to scaling
  30848. */
  30849. set scale(scale: Vector3);
  30850. /**
  30851. * Legacy support, changed quaternion to rotationQuaternion
  30852. */
  30853. get quaternion(): Nullable<Quaternion>;
  30854. /**
  30855. * Legacy support, changed quaternion to rotationQuaternion
  30856. */
  30857. set quaternion(q: Nullable<Quaternion>);
  30858. /**
  30859. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30860. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30861. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30862. * @returns true if it intersects
  30863. */
  30864. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30865. /**
  30866. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30867. * A particle is in the frustum if its bounding box intersects the frustum
  30868. * @param frustumPlanes defines the frustum to test
  30869. * @returns true if the particle is in the frustum planes
  30870. */
  30871. isInFrustum(frustumPlanes: Plane[]): boolean;
  30872. /**
  30873. * get the rotation matrix of the particle
  30874. * @hidden
  30875. */
  30876. getRotationMatrix(m: Matrix): void;
  30877. }
  30878. /**
  30879. * Represents the shape of the model used by one particle of a solid particle system.
  30880. * SPS internal tool, don't use it manually.
  30881. */
  30882. export class ModelShape {
  30883. /**
  30884. * The shape id
  30885. * @hidden
  30886. */
  30887. shapeID: number;
  30888. /**
  30889. * flat array of model positions (internal use)
  30890. * @hidden
  30891. */
  30892. _shape: Vector3[];
  30893. /**
  30894. * flat array of model UVs (internal use)
  30895. * @hidden
  30896. */
  30897. _shapeUV: number[];
  30898. /**
  30899. * color array of the model
  30900. * @hidden
  30901. */
  30902. _shapeColors: number[];
  30903. /**
  30904. * indices array of the model
  30905. * @hidden
  30906. */
  30907. _indices: number[];
  30908. /**
  30909. * normals array of the model
  30910. * @hidden
  30911. */
  30912. _normals: number[];
  30913. /**
  30914. * length of the shape in the model indices array (internal use)
  30915. * @hidden
  30916. */
  30917. _indicesLength: number;
  30918. /**
  30919. * Custom position function (internal use)
  30920. * @hidden
  30921. */
  30922. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30923. /**
  30924. * Custom vertex function (internal use)
  30925. * @hidden
  30926. */
  30927. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30928. /**
  30929. * Model material (internal use)
  30930. * @hidden
  30931. */
  30932. _material: Nullable<Material>;
  30933. /**
  30934. * 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.
  30935. * SPS internal tool, don't use it manually.
  30936. * @hidden
  30937. */
  30938. 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>);
  30939. }
  30940. /**
  30941. * Represents a Depth Sorted Particle in the solid particle system.
  30942. * @hidden
  30943. */
  30944. export class DepthSortedParticle {
  30945. /**
  30946. * Particle index
  30947. */
  30948. idx: number;
  30949. /**
  30950. * Index of the particle in the "indices" array
  30951. */
  30952. ind: number;
  30953. /**
  30954. * Length of the particle shape in the "indices" array
  30955. */
  30956. indicesLength: number;
  30957. /**
  30958. * Squared distance from the particle to the camera
  30959. */
  30960. sqDistance: number;
  30961. /**
  30962. * Material index when used with MultiMaterials
  30963. */
  30964. materialIndex: number;
  30965. /**
  30966. * Creates a new sorted particle
  30967. * @param materialIndex
  30968. */
  30969. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30970. }
  30971. /**
  30972. * Represents a solid particle vertex
  30973. */
  30974. export class SolidParticleVertex {
  30975. /**
  30976. * Vertex position
  30977. */
  30978. position: Vector3;
  30979. /**
  30980. * Vertex color
  30981. */
  30982. color: Color4;
  30983. /**
  30984. * Vertex UV
  30985. */
  30986. uv: Vector2;
  30987. /**
  30988. * Creates a new solid particle vertex
  30989. */
  30990. constructor();
  30991. /** Vertex x coordinate */
  30992. get x(): number;
  30993. set x(val: number);
  30994. /** Vertex y coordinate */
  30995. get y(): number;
  30996. set y(val: number);
  30997. /** Vertex z coordinate */
  30998. get z(): number;
  30999. set z(val: number);
  31000. }
  31001. }
  31002. declare module BABYLON {
  31003. /**
  31004. * @hidden
  31005. */
  31006. export class _MeshCollisionData {
  31007. _checkCollisions: boolean;
  31008. _collisionMask: number;
  31009. _collisionGroup: number;
  31010. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31011. _collider: Nullable<Collider>;
  31012. _oldPositionForCollisions: Vector3;
  31013. _diffPositionForCollisions: Vector3;
  31014. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31015. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31016. }
  31017. }
  31018. declare module BABYLON {
  31019. /** @hidden */
  31020. class _FacetDataStorage {
  31021. facetPositions: Vector3[];
  31022. facetNormals: Vector3[];
  31023. facetPartitioning: number[][];
  31024. facetNb: number;
  31025. partitioningSubdivisions: number;
  31026. partitioningBBoxRatio: number;
  31027. facetDataEnabled: boolean;
  31028. facetParameters: any;
  31029. bbSize: Vector3;
  31030. subDiv: {
  31031. max: number;
  31032. X: number;
  31033. Y: number;
  31034. Z: number;
  31035. };
  31036. facetDepthSort: boolean;
  31037. facetDepthSortEnabled: boolean;
  31038. depthSortedIndices: IndicesArray;
  31039. depthSortedFacets: {
  31040. ind: number;
  31041. sqDistance: number;
  31042. }[];
  31043. facetDepthSortFunction: (f1: {
  31044. ind: number;
  31045. sqDistance: number;
  31046. }, f2: {
  31047. ind: number;
  31048. sqDistance: number;
  31049. }) => number;
  31050. facetDepthSortFrom: Vector3;
  31051. facetDepthSortOrigin: Vector3;
  31052. invertedMatrix: Matrix;
  31053. }
  31054. /**
  31055. * @hidden
  31056. **/
  31057. class _InternalAbstractMeshDataInfo {
  31058. _hasVertexAlpha: boolean;
  31059. _useVertexColors: boolean;
  31060. _numBoneInfluencers: number;
  31061. _applyFog: boolean;
  31062. _receiveShadows: boolean;
  31063. _facetData: _FacetDataStorage;
  31064. _visibility: number;
  31065. _skeleton: Nullable<Skeleton>;
  31066. _layerMask: number;
  31067. _computeBonesUsingShaders: boolean;
  31068. _isActive: boolean;
  31069. _onlyForInstances: boolean;
  31070. _isActiveIntermediate: boolean;
  31071. _onlyForInstancesIntermediate: boolean;
  31072. _actAsRegularMesh: boolean;
  31073. }
  31074. /**
  31075. * Class used to store all common mesh properties
  31076. */
  31077. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31078. /** No occlusion */
  31079. static OCCLUSION_TYPE_NONE: number;
  31080. /** Occlusion set to optimisitic */
  31081. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31082. /** Occlusion set to strict */
  31083. static OCCLUSION_TYPE_STRICT: number;
  31084. /** Use an accurante occlusion algorithm */
  31085. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31086. /** Use a conservative occlusion algorithm */
  31087. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31088. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31089. * Test order :
  31090. * Is the bounding sphere outside the frustum ?
  31091. * If not, are the bounding box vertices outside the frustum ?
  31092. * It not, then the cullable object is in the frustum.
  31093. */
  31094. static readonly CULLINGSTRATEGY_STANDARD: number;
  31095. /** Culling strategy : Bounding Sphere Only.
  31096. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31097. * It's also less accurate than the standard because some not visible objects can still be selected.
  31098. * Test : is the bounding sphere outside the frustum ?
  31099. * If not, then the cullable object is in the frustum.
  31100. */
  31101. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31102. /** Culling strategy : Optimistic Inclusion.
  31103. * This in an inclusion test first, then the standard exclusion test.
  31104. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31105. * 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.
  31106. * Anyway, it's as accurate as the standard strategy.
  31107. * Test :
  31108. * Is the cullable object bounding sphere center in the frustum ?
  31109. * If not, apply the default culling strategy.
  31110. */
  31111. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31112. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31113. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31114. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31115. * 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.
  31116. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31117. * Test :
  31118. * Is the cullable object bounding sphere center in the frustum ?
  31119. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31120. */
  31121. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31122. /**
  31123. * No billboard
  31124. */
  31125. static get BILLBOARDMODE_NONE(): number;
  31126. /** Billboard on X axis */
  31127. static get BILLBOARDMODE_X(): number;
  31128. /** Billboard on Y axis */
  31129. static get BILLBOARDMODE_Y(): number;
  31130. /** Billboard on Z axis */
  31131. static get BILLBOARDMODE_Z(): number;
  31132. /** Billboard on all axes */
  31133. static get BILLBOARDMODE_ALL(): number;
  31134. /** Billboard on using position instead of orientation */
  31135. static get BILLBOARDMODE_USE_POSITION(): number;
  31136. /** @hidden */
  31137. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31138. /**
  31139. * The culling strategy to use to check whether the mesh must be rendered or not.
  31140. * This value can be changed at any time and will be used on the next render mesh selection.
  31141. * The possible values are :
  31142. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31143. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31144. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31145. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31146. * Please read each static variable documentation to get details about the culling process.
  31147. * */
  31148. cullingStrategy: number;
  31149. /**
  31150. * Gets the number of facets in the mesh
  31151. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31152. */
  31153. get facetNb(): number;
  31154. /**
  31155. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31156. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31157. */
  31158. get partitioningSubdivisions(): number;
  31159. set partitioningSubdivisions(nb: number);
  31160. /**
  31161. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31162. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31164. */
  31165. get partitioningBBoxRatio(): number;
  31166. set partitioningBBoxRatio(ratio: number);
  31167. /**
  31168. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31169. * Works only for updatable meshes.
  31170. * Doesn't work with multi-materials
  31171. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31172. */
  31173. get mustDepthSortFacets(): boolean;
  31174. set mustDepthSortFacets(sort: boolean);
  31175. /**
  31176. * The location (Vector3) where the facet depth sort must be computed from.
  31177. * By default, the active camera position.
  31178. * Used only when facet depth sort is enabled
  31179. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31180. */
  31181. get facetDepthSortFrom(): Vector3;
  31182. set facetDepthSortFrom(location: Vector3);
  31183. /**
  31184. * gets a boolean indicating if facetData is enabled
  31185. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31186. */
  31187. get isFacetDataEnabled(): boolean;
  31188. /** @hidden */
  31189. _updateNonUniformScalingState(value: boolean): boolean;
  31190. /**
  31191. * An event triggered when this mesh collides with another one
  31192. */
  31193. onCollideObservable: Observable<AbstractMesh>;
  31194. /** Set a function to call when this mesh collides with another one */
  31195. set onCollide(callback: () => void);
  31196. /**
  31197. * An event triggered when the collision's position changes
  31198. */
  31199. onCollisionPositionChangeObservable: Observable<Vector3>;
  31200. /** Set a function to call when the collision's position changes */
  31201. set onCollisionPositionChange(callback: () => void);
  31202. /**
  31203. * An event triggered when material is changed
  31204. */
  31205. onMaterialChangedObservable: Observable<AbstractMesh>;
  31206. /**
  31207. * Gets or sets the orientation for POV movement & rotation
  31208. */
  31209. definedFacingForward: boolean;
  31210. /** @hidden */
  31211. _occlusionQuery: Nullable<WebGLQuery>;
  31212. /** @hidden */
  31213. _renderingGroup: Nullable<RenderingGroup>;
  31214. /**
  31215. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31216. */
  31217. get visibility(): number;
  31218. /**
  31219. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31220. */
  31221. set visibility(value: number);
  31222. /** Gets or sets the alpha index used to sort transparent meshes
  31223. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31224. */
  31225. alphaIndex: number;
  31226. /**
  31227. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31228. */
  31229. isVisible: boolean;
  31230. /**
  31231. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31232. */
  31233. isPickable: boolean;
  31234. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31235. showSubMeshesBoundingBox: boolean;
  31236. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31237. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31238. */
  31239. isBlocker: boolean;
  31240. /**
  31241. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31242. */
  31243. enablePointerMoveEvents: boolean;
  31244. /**
  31245. * Specifies the rendering group id for this mesh (0 by default)
  31246. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31247. */
  31248. renderingGroupId: number;
  31249. private _material;
  31250. /** Gets or sets current material */
  31251. get material(): Nullable<Material>;
  31252. set material(value: Nullable<Material>);
  31253. /**
  31254. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31255. * @see http://doc.babylonjs.com/babylon101/shadows
  31256. */
  31257. get receiveShadows(): boolean;
  31258. set receiveShadows(value: boolean);
  31259. /** Defines color to use when rendering outline */
  31260. outlineColor: Color3;
  31261. /** Define width to use when rendering outline */
  31262. outlineWidth: number;
  31263. /** Defines color to use when rendering overlay */
  31264. overlayColor: Color3;
  31265. /** Defines alpha to use when rendering overlay */
  31266. overlayAlpha: number;
  31267. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31268. get hasVertexAlpha(): boolean;
  31269. set hasVertexAlpha(value: boolean);
  31270. /** 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) */
  31271. get useVertexColors(): boolean;
  31272. set useVertexColors(value: boolean);
  31273. /**
  31274. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31275. */
  31276. get computeBonesUsingShaders(): boolean;
  31277. set computeBonesUsingShaders(value: boolean);
  31278. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31279. get numBoneInfluencers(): number;
  31280. set numBoneInfluencers(value: number);
  31281. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31282. get applyFog(): boolean;
  31283. set applyFog(value: boolean);
  31284. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31285. useOctreeForRenderingSelection: boolean;
  31286. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31287. useOctreeForPicking: boolean;
  31288. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31289. useOctreeForCollisions: boolean;
  31290. /**
  31291. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31292. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31293. */
  31294. get layerMask(): number;
  31295. set layerMask(value: number);
  31296. /**
  31297. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31298. */
  31299. alwaysSelectAsActiveMesh: boolean;
  31300. /**
  31301. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31302. */
  31303. doNotSyncBoundingInfo: boolean;
  31304. /**
  31305. * Gets or sets the current action manager
  31306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31307. */
  31308. actionManager: Nullable<AbstractActionManager>;
  31309. private _meshCollisionData;
  31310. /**
  31311. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31312. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31313. */
  31314. ellipsoid: Vector3;
  31315. /**
  31316. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31317. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31318. */
  31319. ellipsoidOffset: Vector3;
  31320. /**
  31321. * Gets or sets a collision mask used to mask collisions (default is -1).
  31322. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31323. */
  31324. get collisionMask(): number;
  31325. set collisionMask(mask: number);
  31326. /**
  31327. * Gets or sets the current collision group mask (-1 by default).
  31328. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31329. */
  31330. get collisionGroup(): number;
  31331. set collisionGroup(mask: number);
  31332. /**
  31333. * Gets or sets current surrounding meshes (null by default).
  31334. *
  31335. * By default collision detection is tested against every mesh in the scene.
  31336. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31337. * meshes will be tested for the collision.
  31338. *
  31339. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31340. */
  31341. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31342. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31343. /**
  31344. * Defines edge width used when edgesRenderer is enabled
  31345. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31346. */
  31347. edgesWidth: number;
  31348. /**
  31349. * Defines edge color used when edgesRenderer is enabled
  31350. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31351. */
  31352. edgesColor: Color4;
  31353. /** @hidden */
  31354. _edgesRenderer: Nullable<IEdgesRenderer>;
  31355. /** @hidden */
  31356. _masterMesh: Nullable<AbstractMesh>;
  31357. /** @hidden */
  31358. _boundingInfo: Nullable<BoundingInfo>;
  31359. /** @hidden */
  31360. _renderId: number;
  31361. /**
  31362. * Gets or sets the list of subMeshes
  31363. * @see http://doc.babylonjs.com/how_to/multi_materials
  31364. */
  31365. subMeshes: SubMesh[];
  31366. /** @hidden */
  31367. _intersectionsInProgress: AbstractMesh[];
  31368. /** @hidden */
  31369. _unIndexed: boolean;
  31370. /** @hidden */
  31371. _lightSources: Light[];
  31372. /** Gets the list of lights affecting that mesh */
  31373. get lightSources(): Light[];
  31374. /** @hidden */
  31375. get _positions(): Nullable<Vector3[]>;
  31376. /** @hidden */
  31377. _waitingData: {
  31378. lods: Nullable<any>;
  31379. actions: Nullable<any>;
  31380. freezeWorldMatrix: Nullable<boolean>;
  31381. };
  31382. /** @hidden */
  31383. _bonesTransformMatrices: Nullable<Float32Array>;
  31384. /** @hidden */
  31385. _transformMatrixTexture: Nullable<RawTexture>;
  31386. /**
  31387. * Gets or sets a skeleton to apply skining transformations
  31388. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31389. */
  31390. set skeleton(value: Nullable<Skeleton>);
  31391. get skeleton(): Nullable<Skeleton>;
  31392. /**
  31393. * An event triggered when the mesh is rebuilt.
  31394. */
  31395. onRebuildObservable: Observable<AbstractMesh>;
  31396. /**
  31397. * Creates a new AbstractMesh
  31398. * @param name defines the name of the mesh
  31399. * @param scene defines the hosting scene
  31400. */
  31401. constructor(name: string, scene?: Nullable<Scene>);
  31402. /**
  31403. * Returns the string "AbstractMesh"
  31404. * @returns "AbstractMesh"
  31405. */
  31406. getClassName(): string;
  31407. /**
  31408. * Gets a string representation of the current mesh
  31409. * @param fullDetails defines a boolean indicating if full details must be included
  31410. * @returns a string representation of the current mesh
  31411. */
  31412. toString(fullDetails?: boolean): string;
  31413. /**
  31414. * @hidden
  31415. */
  31416. protected _getEffectiveParent(): Nullable<Node>;
  31417. /** @hidden */
  31418. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31419. /** @hidden */
  31420. _rebuild(): void;
  31421. /** @hidden */
  31422. _resyncLightSources(): void;
  31423. /** @hidden */
  31424. _resyncLightSource(light: Light): void;
  31425. /** @hidden */
  31426. _unBindEffect(): void;
  31427. /** @hidden */
  31428. _removeLightSource(light: Light, dispose: boolean): void;
  31429. private _markSubMeshesAsDirty;
  31430. /** @hidden */
  31431. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31432. /** @hidden */
  31433. _markSubMeshesAsAttributesDirty(): void;
  31434. /** @hidden */
  31435. _markSubMeshesAsMiscDirty(): void;
  31436. /**
  31437. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31438. */
  31439. get scaling(): Vector3;
  31440. set scaling(newScaling: Vector3);
  31441. /**
  31442. * Returns true if the mesh is blocked. Implemented by child classes
  31443. */
  31444. get isBlocked(): boolean;
  31445. /**
  31446. * Returns the mesh itself by default. Implemented by child classes
  31447. * @param camera defines the camera to use to pick the right LOD level
  31448. * @returns the currentAbstractMesh
  31449. */
  31450. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31451. /**
  31452. * Returns 0 by default. Implemented by child classes
  31453. * @returns an integer
  31454. */
  31455. getTotalVertices(): number;
  31456. /**
  31457. * Returns a positive integer : the total number of indices in this mesh geometry.
  31458. * @returns the numner of indices or zero if the mesh has no geometry.
  31459. */
  31460. getTotalIndices(): number;
  31461. /**
  31462. * Returns null by default. Implemented by child classes
  31463. * @returns null
  31464. */
  31465. getIndices(): Nullable<IndicesArray>;
  31466. /**
  31467. * Returns the array of the requested vertex data kind. Implemented by child classes
  31468. * @param kind defines the vertex data kind to use
  31469. * @returns null
  31470. */
  31471. getVerticesData(kind: string): Nullable<FloatArray>;
  31472. /**
  31473. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31474. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31475. * Note that a new underlying VertexBuffer object is created each call.
  31476. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31477. * @param kind defines vertex data kind:
  31478. * * VertexBuffer.PositionKind
  31479. * * VertexBuffer.UVKind
  31480. * * VertexBuffer.UV2Kind
  31481. * * VertexBuffer.UV3Kind
  31482. * * VertexBuffer.UV4Kind
  31483. * * VertexBuffer.UV5Kind
  31484. * * VertexBuffer.UV6Kind
  31485. * * VertexBuffer.ColorKind
  31486. * * VertexBuffer.MatricesIndicesKind
  31487. * * VertexBuffer.MatricesIndicesExtraKind
  31488. * * VertexBuffer.MatricesWeightsKind
  31489. * * VertexBuffer.MatricesWeightsExtraKind
  31490. * @param data defines the data source
  31491. * @param updatable defines if the data must be flagged as updatable (or static)
  31492. * @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
  31493. * @returns the current mesh
  31494. */
  31495. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31496. /**
  31497. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31498. * If the mesh has no geometry, it is simply returned as it is.
  31499. * @param kind defines vertex data kind:
  31500. * * VertexBuffer.PositionKind
  31501. * * VertexBuffer.UVKind
  31502. * * VertexBuffer.UV2Kind
  31503. * * VertexBuffer.UV3Kind
  31504. * * VertexBuffer.UV4Kind
  31505. * * VertexBuffer.UV5Kind
  31506. * * VertexBuffer.UV6Kind
  31507. * * VertexBuffer.ColorKind
  31508. * * VertexBuffer.MatricesIndicesKind
  31509. * * VertexBuffer.MatricesIndicesExtraKind
  31510. * * VertexBuffer.MatricesWeightsKind
  31511. * * VertexBuffer.MatricesWeightsExtraKind
  31512. * @param data defines the data source
  31513. * @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
  31514. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31515. * @returns the current mesh
  31516. */
  31517. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31518. /**
  31519. * Sets the mesh indices,
  31520. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31521. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31522. * @param totalVertices Defines the total number of vertices
  31523. * @returns the current mesh
  31524. */
  31525. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31526. /**
  31527. * Gets a boolean indicating if specific vertex data is present
  31528. * @param kind defines the vertex data kind to use
  31529. * @returns true is data kind is present
  31530. */
  31531. isVerticesDataPresent(kind: string): boolean;
  31532. /**
  31533. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31534. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31535. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31536. * @returns a BoundingInfo
  31537. */
  31538. getBoundingInfo(): BoundingInfo;
  31539. /**
  31540. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31541. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31542. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31543. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31544. * @returns the current mesh
  31545. */
  31546. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31547. /**
  31548. * Overwrite the current bounding info
  31549. * @param boundingInfo defines the new bounding info
  31550. * @returns the current mesh
  31551. */
  31552. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31553. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31554. get useBones(): boolean;
  31555. /** @hidden */
  31556. _preActivate(): void;
  31557. /** @hidden */
  31558. _preActivateForIntermediateRendering(renderId: number): void;
  31559. /** @hidden */
  31560. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31561. /** @hidden */
  31562. _postActivate(): void;
  31563. /** @hidden */
  31564. _freeze(): void;
  31565. /** @hidden */
  31566. _unFreeze(): void;
  31567. /**
  31568. * Gets the current world matrix
  31569. * @returns a Matrix
  31570. */
  31571. getWorldMatrix(): Matrix;
  31572. /** @hidden */
  31573. _getWorldMatrixDeterminant(): number;
  31574. /**
  31575. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31576. */
  31577. get isAnInstance(): boolean;
  31578. /**
  31579. * Gets a boolean indicating if this mesh has instances
  31580. */
  31581. get hasInstances(): boolean;
  31582. /**
  31583. * Gets a boolean indicating if this mesh has thin instances
  31584. */
  31585. get hasThinInstances(): boolean;
  31586. /**
  31587. * Perform relative position change from the point of view of behind the front of the mesh.
  31588. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31589. * Supports definition of mesh facing forward or backward
  31590. * @param amountRight defines the distance on the right axis
  31591. * @param amountUp defines the distance on the up axis
  31592. * @param amountForward defines the distance on the forward axis
  31593. * @returns the current mesh
  31594. */
  31595. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31596. /**
  31597. * Calculate relative position change from the point of view of behind the front of the mesh.
  31598. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31599. * Supports definition of mesh facing forward or backward
  31600. * @param amountRight defines the distance on the right axis
  31601. * @param amountUp defines the distance on the up axis
  31602. * @param amountForward defines the distance on the forward axis
  31603. * @returns the new displacement vector
  31604. */
  31605. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31606. /**
  31607. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31608. * Supports definition of mesh facing forward or backward
  31609. * @param flipBack defines the flip
  31610. * @param twirlClockwise defines the twirl
  31611. * @param tiltRight defines the tilt
  31612. * @returns the current mesh
  31613. */
  31614. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31615. /**
  31616. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31617. * Supports definition of mesh facing forward or backward.
  31618. * @param flipBack defines the flip
  31619. * @param twirlClockwise defines the twirl
  31620. * @param tiltRight defines the tilt
  31621. * @returns the new rotation vector
  31622. */
  31623. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31624. /**
  31625. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31626. * This means the mesh underlying bounding box and sphere are recomputed.
  31627. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31628. * @returns the current mesh
  31629. */
  31630. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31631. /** @hidden */
  31632. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31633. /** @hidden */
  31634. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31635. /** @hidden */
  31636. _updateBoundingInfo(): AbstractMesh;
  31637. /** @hidden */
  31638. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31639. /** @hidden */
  31640. protected _afterComputeWorldMatrix(): void;
  31641. /** @hidden */
  31642. get _effectiveMesh(): AbstractMesh;
  31643. /**
  31644. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31645. * A mesh is in the frustum if its bounding box intersects the frustum
  31646. * @param frustumPlanes defines the frustum to test
  31647. * @returns true if the mesh is in the frustum planes
  31648. */
  31649. isInFrustum(frustumPlanes: Plane[]): boolean;
  31650. /**
  31651. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31652. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31653. * @param frustumPlanes defines the frustum to test
  31654. * @returns true if the mesh is completely in the frustum planes
  31655. */
  31656. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31657. /**
  31658. * True if the mesh intersects another mesh or a SolidParticle object
  31659. * @param mesh defines a target mesh or SolidParticle to test
  31660. * @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)
  31661. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31662. * @returns true if there is an intersection
  31663. */
  31664. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31665. /**
  31666. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31667. * @param point defines the point to test
  31668. * @returns true if there is an intersection
  31669. */
  31670. intersectsPoint(point: Vector3): boolean;
  31671. /**
  31672. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31673. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31674. */
  31675. get checkCollisions(): boolean;
  31676. set checkCollisions(collisionEnabled: boolean);
  31677. /**
  31678. * Gets Collider object used to compute collisions (not physics)
  31679. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31680. */
  31681. get collider(): Nullable<Collider>;
  31682. /**
  31683. * Move the mesh using collision engine
  31684. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31685. * @param displacement defines the requested displacement vector
  31686. * @returns the current mesh
  31687. */
  31688. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31689. private _onCollisionPositionChange;
  31690. /** @hidden */
  31691. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31692. /** @hidden */
  31693. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31694. /** @hidden */
  31695. _checkCollision(collider: Collider): AbstractMesh;
  31696. /** @hidden */
  31697. _generatePointsArray(): boolean;
  31698. /**
  31699. * Checks if the passed Ray intersects with the mesh
  31700. * @param ray defines the ray to use
  31701. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31702. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31703. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31704. * @returns the picking info
  31705. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31706. */
  31707. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31708. /**
  31709. * Clones the current mesh
  31710. * @param name defines the mesh name
  31711. * @param newParent defines the new mesh parent
  31712. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31713. * @returns the new mesh
  31714. */
  31715. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31716. /**
  31717. * Disposes all the submeshes of the current meshnp
  31718. * @returns the current mesh
  31719. */
  31720. releaseSubMeshes(): AbstractMesh;
  31721. /**
  31722. * Releases resources associated with this abstract mesh.
  31723. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31724. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31725. */
  31726. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31727. /**
  31728. * Adds the passed mesh as a child to the current mesh
  31729. * @param mesh defines the child mesh
  31730. * @returns the current mesh
  31731. */
  31732. addChild(mesh: AbstractMesh): AbstractMesh;
  31733. /**
  31734. * Removes the passed mesh from the current mesh children list
  31735. * @param mesh defines the child mesh
  31736. * @returns the current mesh
  31737. */
  31738. removeChild(mesh: AbstractMesh): AbstractMesh;
  31739. /** @hidden */
  31740. private _initFacetData;
  31741. /**
  31742. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31743. * This method can be called within the render loop.
  31744. * 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
  31745. * @returns the current mesh
  31746. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31747. */
  31748. updateFacetData(): AbstractMesh;
  31749. /**
  31750. * Returns the facetLocalNormals array.
  31751. * The normals are expressed in the mesh local spac
  31752. * @returns an array of Vector3
  31753. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31754. */
  31755. getFacetLocalNormals(): Vector3[];
  31756. /**
  31757. * Returns the facetLocalPositions array.
  31758. * The facet positions are expressed in the mesh local space
  31759. * @returns an array of Vector3
  31760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31761. */
  31762. getFacetLocalPositions(): Vector3[];
  31763. /**
  31764. * Returns the facetLocalPartioning array
  31765. * @returns an array of array of numbers
  31766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31767. */
  31768. getFacetLocalPartitioning(): number[][];
  31769. /**
  31770. * Returns the i-th facet position in the world system.
  31771. * This method allocates a new Vector3 per call
  31772. * @param i defines the facet index
  31773. * @returns a new Vector3
  31774. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31775. */
  31776. getFacetPosition(i: number): Vector3;
  31777. /**
  31778. * Sets the reference Vector3 with the i-th facet position in the world system
  31779. * @param i defines the facet index
  31780. * @param ref defines the target vector
  31781. * @returns the current mesh
  31782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31783. */
  31784. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31785. /**
  31786. * Returns the i-th facet normal in the world system.
  31787. * This method allocates a new Vector3 per call
  31788. * @param i defines the facet index
  31789. * @returns a new Vector3
  31790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31791. */
  31792. getFacetNormal(i: number): Vector3;
  31793. /**
  31794. * Sets the reference Vector3 with the i-th facet normal in the world system
  31795. * @param i defines the facet index
  31796. * @param ref defines the target vector
  31797. * @returns the current mesh
  31798. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31799. */
  31800. getFacetNormalToRef(i: number, ref: Vector3): this;
  31801. /**
  31802. * 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)
  31803. * @param x defines x coordinate
  31804. * @param y defines y coordinate
  31805. * @param z defines z coordinate
  31806. * @returns the array of facet indexes
  31807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31808. */
  31809. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31810. /**
  31811. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31812. * @param projected sets as the (x,y,z) world projection on the facet
  31813. * @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
  31814. * @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
  31815. * @param x defines x coordinate
  31816. * @param y defines y coordinate
  31817. * @param z defines z coordinate
  31818. * @returns the face index if found (or null instead)
  31819. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31820. */
  31821. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31822. /**
  31823. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31824. * @param projected sets as the (x,y,z) local projection on the facet
  31825. * @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
  31826. * @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
  31827. * @param x defines x coordinate
  31828. * @param y defines y coordinate
  31829. * @param z defines z coordinate
  31830. * @returns the face index if found (or null instead)
  31831. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31832. */
  31833. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31834. /**
  31835. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31836. * @returns the parameters
  31837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31838. */
  31839. getFacetDataParameters(): any;
  31840. /**
  31841. * Disables the feature FacetData and frees the related memory
  31842. * @returns the current mesh
  31843. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31844. */
  31845. disableFacetData(): AbstractMesh;
  31846. /**
  31847. * Updates the AbstractMesh indices array
  31848. * @param indices defines the data source
  31849. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31850. * @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)
  31851. * @returns the current mesh
  31852. */
  31853. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31854. /**
  31855. * Creates new normals data for the mesh
  31856. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31857. * @returns the current mesh
  31858. */
  31859. createNormals(updatable: boolean): AbstractMesh;
  31860. /**
  31861. * Align the mesh with a normal
  31862. * @param normal defines the normal to use
  31863. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31864. * @returns the current mesh
  31865. */
  31866. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31867. /** @hidden */
  31868. _checkOcclusionQuery(): boolean;
  31869. /**
  31870. * Disables the mesh edge rendering mode
  31871. * @returns the currentAbstractMesh
  31872. */
  31873. disableEdgesRendering(): AbstractMesh;
  31874. /**
  31875. * Enables the edge rendering mode on the mesh.
  31876. * This mode makes the mesh edges visible
  31877. * @param epsilon defines the maximal distance between two angles to detect a face
  31878. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31879. * @returns the currentAbstractMesh
  31880. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31881. */
  31882. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31883. }
  31884. }
  31885. declare module BABYLON {
  31886. /**
  31887. * Interface used to define ActionEvent
  31888. */
  31889. export interface IActionEvent {
  31890. /** The mesh or sprite that triggered the action */
  31891. source: any;
  31892. /** The X mouse cursor position at the time of the event */
  31893. pointerX: number;
  31894. /** The Y mouse cursor position at the time of the event */
  31895. pointerY: number;
  31896. /** The mesh that is currently pointed at (can be null) */
  31897. meshUnderPointer: Nullable<AbstractMesh>;
  31898. /** the original (browser) event that triggered the ActionEvent */
  31899. sourceEvent?: any;
  31900. /** additional data for the event */
  31901. additionalData?: any;
  31902. }
  31903. /**
  31904. * ActionEvent is the event being sent when an action is triggered.
  31905. */
  31906. export class ActionEvent implements IActionEvent {
  31907. /** The mesh or sprite that triggered the action */
  31908. source: any;
  31909. /** The X mouse cursor position at the time of the event */
  31910. pointerX: number;
  31911. /** The Y mouse cursor position at the time of the event */
  31912. pointerY: number;
  31913. /** The mesh that is currently pointed at (can be null) */
  31914. meshUnderPointer: Nullable<AbstractMesh>;
  31915. /** the original (browser) event that triggered the ActionEvent */
  31916. sourceEvent?: any;
  31917. /** additional data for the event */
  31918. additionalData?: any;
  31919. /**
  31920. * Creates a new ActionEvent
  31921. * @param source The mesh or sprite that triggered the action
  31922. * @param pointerX The X mouse cursor position at the time of the event
  31923. * @param pointerY The Y mouse cursor position at the time of the event
  31924. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31925. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31926. * @param additionalData additional data for the event
  31927. */
  31928. constructor(
  31929. /** The mesh or sprite that triggered the action */
  31930. source: any,
  31931. /** The X mouse cursor position at the time of the event */
  31932. pointerX: number,
  31933. /** The Y mouse cursor position at the time of the event */
  31934. pointerY: number,
  31935. /** The mesh that is currently pointed at (can be null) */
  31936. meshUnderPointer: Nullable<AbstractMesh>,
  31937. /** the original (browser) event that triggered the ActionEvent */
  31938. sourceEvent?: any,
  31939. /** additional data for the event */
  31940. additionalData?: any);
  31941. /**
  31942. * Helper function to auto-create an ActionEvent from a source mesh.
  31943. * @param source The source mesh that triggered the event
  31944. * @param evt The original (browser) event
  31945. * @param additionalData additional data for the event
  31946. * @returns the new ActionEvent
  31947. */
  31948. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31949. /**
  31950. * Helper function to auto-create an ActionEvent from a source sprite
  31951. * @param source The source sprite that triggered the event
  31952. * @param scene Scene associated with the sprite
  31953. * @param evt The original (browser) event
  31954. * @param additionalData additional data for the event
  31955. * @returns the new ActionEvent
  31956. */
  31957. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31958. /**
  31959. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31960. * @param scene the scene where the event occurred
  31961. * @param evt The original (browser) event
  31962. * @returns the new ActionEvent
  31963. */
  31964. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31965. /**
  31966. * Helper function to auto-create an ActionEvent from a primitive
  31967. * @param prim defines the target primitive
  31968. * @param pointerPos defines the pointer position
  31969. * @param evt The original (browser) event
  31970. * @param additionalData additional data for the event
  31971. * @returns the new ActionEvent
  31972. */
  31973. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31974. }
  31975. }
  31976. declare module BABYLON {
  31977. /**
  31978. * Abstract class used to decouple action Manager from scene and meshes.
  31979. * Do not instantiate.
  31980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31981. */
  31982. export abstract class AbstractActionManager implements IDisposable {
  31983. /** Gets the list of active triggers */
  31984. static Triggers: {
  31985. [key: string]: number;
  31986. };
  31987. /** Gets the cursor to use when hovering items */
  31988. hoverCursor: string;
  31989. /** Gets the list of actions */
  31990. actions: IAction[];
  31991. /**
  31992. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31993. */
  31994. isRecursive: boolean;
  31995. /**
  31996. * Releases all associated resources
  31997. */
  31998. abstract dispose(): void;
  31999. /**
  32000. * Does this action manager has pointer triggers
  32001. */
  32002. abstract get hasPointerTriggers(): boolean;
  32003. /**
  32004. * Does this action manager has pick triggers
  32005. */
  32006. abstract get hasPickTriggers(): boolean;
  32007. /**
  32008. * Process a specific trigger
  32009. * @param trigger defines the trigger to process
  32010. * @param evt defines the event details to be processed
  32011. */
  32012. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32013. /**
  32014. * Does this action manager handles actions of any of the given triggers
  32015. * @param triggers defines the triggers to be tested
  32016. * @return a boolean indicating whether one (or more) of the triggers is handled
  32017. */
  32018. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32019. /**
  32020. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32021. * speed.
  32022. * @param triggerA defines the trigger to be tested
  32023. * @param triggerB defines the trigger to be tested
  32024. * @return a boolean indicating whether one (or more) of the triggers is handled
  32025. */
  32026. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32027. /**
  32028. * Does this action manager handles actions of a given trigger
  32029. * @param trigger defines the trigger to be tested
  32030. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32031. * @return whether the trigger is handled
  32032. */
  32033. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32034. /**
  32035. * Serialize this manager to a JSON object
  32036. * @param name defines the property name to store this manager
  32037. * @returns a JSON representation of this manager
  32038. */
  32039. abstract serialize(name: string): any;
  32040. /**
  32041. * Registers an action to this action manager
  32042. * @param action defines the action to be registered
  32043. * @return the action amended (prepared) after registration
  32044. */
  32045. abstract registerAction(action: IAction): Nullable<IAction>;
  32046. /**
  32047. * Unregisters an action to this action manager
  32048. * @param action defines the action to be unregistered
  32049. * @return a boolean indicating whether the action has been unregistered
  32050. */
  32051. abstract unregisterAction(action: IAction): Boolean;
  32052. /**
  32053. * Does exist one action manager with at least one trigger
  32054. **/
  32055. static get HasTriggers(): boolean;
  32056. /**
  32057. * Does exist one action manager with at least one pick trigger
  32058. **/
  32059. static get HasPickTriggers(): boolean;
  32060. /**
  32061. * Does exist one action manager that handles actions of a given trigger
  32062. * @param trigger defines the trigger to be tested
  32063. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32064. **/
  32065. static HasSpecificTrigger(trigger: number): boolean;
  32066. }
  32067. }
  32068. declare module BABYLON {
  32069. /**
  32070. * Defines how a node can be built from a string name.
  32071. */
  32072. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32073. /**
  32074. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32075. */
  32076. export class Node implements IBehaviorAware<Node> {
  32077. /** @hidden */
  32078. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32079. private static _NodeConstructors;
  32080. /**
  32081. * Add a new node constructor
  32082. * @param type defines the type name of the node to construct
  32083. * @param constructorFunc defines the constructor function
  32084. */
  32085. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32086. /**
  32087. * Returns a node constructor based on type name
  32088. * @param type defines the type name
  32089. * @param name defines the new node name
  32090. * @param scene defines the hosting scene
  32091. * @param options defines optional options to transmit to constructors
  32092. * @returns the new constructor or null
  32093. */
  32094. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32095. /**
  32096. * Gets or sets the name of the node
  32097. */
  32098. name: string;
  32099. /**
  32100. * Gets or sets the id of the node
  32101. */
  32102. id: string;
  32103. /**
  32104. * Gets or sets the unique id of the node
  32105. */
  32106. uniqueId: number;
  32107. /**
  32108. * Gets or sets a string used to store user defined state for the node
  32109. */
  32110. state: string;
  32111. /**
  32112. * Gets or sets an object used to store user defined information for the node
  32113. */
  32114. metadata: any;
  32115. /**
  32116. * For internal use only. Please do not use.
  32117. */
  32118. reservedDataStore: any;
  32119. /**
  32120. * List of inspectable custom properties (used by the Inspector)
  32121. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32122. */
  32123. inspectableCustomProperties: IInspectable[];
  32124. private _doNotSerialize;
  32125. /**
  32126. * Gets or sets a boolean used to define if the node must be serialized
  32127. */
  32128. get doNotSerialize(): boolean;
  32129. set doNotSerialize(value: boolean);
  32130. /** @hidden */
  32131. _isDisposed: boolean;
  32132. /**
  32133. * Gets a list of Animations associated with the node
  32134. */
  32135. animations: Animation[];
  32136. protected _ranges: {
  32137. [name: string]: Nullable<AnimationRange>;
  32138. };
  32139. /**
  32140. * Callback raised when the node is ready to be used
  32141. */
  32142. onReady: Nullable<(node: Node) => void>;
  32143. private _isEnabled;
  32144. private _isParentEnabled;
  32145. private _isReady;
  32146. /** @hidden */
  32147. _currentRenderId: number;
  32148. private _parentUpdateId;
  32149. /** @hidden */
  32150. _childUpdateId: number;
  32151. /** @hidden */
  32152. _waitingParentId: Nullable<string>;
  32153. /** @hidden */
  32154. _scene: Scene;
  32155. /** @hidden */
  32156. _cache: any;
  32157. private _parentNode;
  32158. private _children;
  32159. /** @hidden */
  32160. _worldMatrix: Matrix;
  32161. /** @hidden */
  32162. _worldMatrixDeterminant: number;
  32163. /** @hidden */
  32164. _worldMatrixDeterminantIsDirty: boolean;
  32165. /** @hidden */
  32166. private _sceneRootNodesIndex;
  32167. /**
  32168. * Gets a boolean indicating if the node has been disposed
  32169. * @returns true if the node was disposed
  32170. */
  32171. isDisposed(): boolean;
  32172. /**
  32173. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32174. * @see https://doc.babylonjs.com/how_to/parenting
  32175. */
  32176. set parent(parent: Nullable<Node>);
  32177. get parent(): Nullable<Node>;
  32178. /** @hidden */
  32179. _addToSceneRootNodes(): void;
  32180. /** @hidden */
  32181. _removeFromSceneRootNodes(): void;
  32182. private _animationPropertiesOverride;
  32183. /**
  32184. * Gets or sets the animation properties override
  32185. */
  32186. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32187. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32188. /**
  32189. * Gets a string idenfifying the name of the class
  32190. * @returns "Node" string
  32191. */
  32192. getClassName(): string;
  32193. /** @hidden */
  32194. readonly _isNode: boolean;
  32195. /**
  32196. * An event triggered when the mesh is disposed
  32197. */
  32198. onDisposeObservable: Observable<Node>;
  32199. private _onDisposeObserver;
  32200. /**
  32201. * Sets a callback that will be raised when the node will be disposed
  32202. */
  32203. set onDispose(callback: () => void);
  32204. /**
  32205. * Creates a new Node
  32206. * @param name the name and id to be given to this node
  32207. * @param scene the scene this node will be added to
  32208. */
  32209. constructor(name: string, scene?: Nullable<Scene>);
  32210. /**
  32211. * Gets the scene of the node
  32212. * @returns a scene
  32213. */
  32214. getScene(): Scene;
  32215. /**
  32216. * Gets the engine of the node
  32217. * @returns a Engine
  32218. */
  32219. getEngine(): Engine;
  32220. private _behaviors;
  32221. /**
  32222. * Attach a behavior to the node
  32223. * @see http://doc.babylonjs.com/features/behaviour
  32224. * @param behavior defines the behavior to attach
  32225. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32226. * @returns the current Node
  32227. */
  32228. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32229. /**
  32230. * Remove an attached behavior
  32231. * @see http://doc.babylonjs.com/features/behaviour
  32232. * @param behavior defines the behavior to attach
  32233. * @returns the current Node
  32234. */
  32235. removeBehavior(behavior: Behavior<Node>): Node;
  32236. /**
  32237. * Gets the list of attached behaviors
  32238. * @see http://doc.babylonjs.com/features/behaviour
  32239. */
  32240. get behaviors(): Behavior<Node>[];
  32241. /**
  32242. * Gets an attached behavior by name
  32243. * @param name defines the name of the behavior to look for
  32244. * @see http://doc.babylonjs.com/features/behaviour
  32245. * @returns null if behavior was not found else the requested behavior
  32246. */
  32247. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32248. /**
  32249. * Returns the latest update of the World matrix
  32250. * @returns a Matrix
  32251. */
  32252. getWorldMatrix(): Matrix;
  32253. /** @hidden */
  32254. _getWorldMatrixDeterminant(): number;
  32255. /**
  32256. * Returns directly the latest state of the mesh World matrix.
  32257. * A Matrix is returned.
  32258. */
  32259. get worldMatrixFromCache(): Matrix;
  32260. /** @hidden */
  32261. _initCache(): void;
  32262. /** @hidden */
  32263. updateCache(force?: boolean): void;
  32264. /** @hidden */
  32265. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32266. /** @hidden */
  32267. _updateCache(ignoreParentClass?: boolean): void;
  32268. /** @hidden */
  32269. _isSynchronized(): boolean;
  32270. /** @hidden */
  32271. _markSyncedWithParent(): void;
  32272. /** @hidden */
  32273. isSynchronizedWithParent(): boolean;
  32274. /** @hidden */
  32275. isSynchronized(): boolean;
  32276. /**
  32277. * Is this node ready to be used/rendered
  32278. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32279. * @return true if the node is ready
  32280. */
  32281. isReady(completeCheck?: boolean): boolean;
  32282. /**
  32283. * Is this node enabled?
  32284. * 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
  32285. * @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
  32286. * @return whether this node (and its parent) is enabled
  32287. */
  32288. isEnabled(checkAncestors?: boolean): boolean;
  32289. /** @hidden */
  32290. protected _syncParentEnabledState(): void;
  32291. /**
  32292. * Set the enabled state of this node
  32293. * @param value defines the new enabled state
  32294. */
  32295. setEnabled(value: boolean): void;
  32296. /**
  32297. * Is this node a descendant of the given node?
  32298. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32299. * @param ancestor defines the parent node to inspect
  32300. * @returns a boolean indicating if this node is a descendant of the given node
  32301. */
  32302. isDescendantOf(ancestor: Node): boolean;
  32303. /** @hidden */
  32304. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32305. /**
  32306. * Will return all nodes that have this node as ascendant
  32307. * @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
  32308. * @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
  32309. * @return all children nodes of all types
  32310. */
  32311. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32312. /**
  32313. * Get all child-meshes of this node
  32314. * @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)
  32315. * @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
  32316. * @returns an array of AbstractMesh
  32317. */
  32318. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32319. /**
  32320. * Get all direct children of this node
  32321. * @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
  32322. * @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)
  32323. * @returns an array of Node
  32324. */
  32325. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32326. /** @hidden */
  32327. _setReady(state: boolean): void;
  32328. /**
  32329. * Get an animation by name
  32330. * @param name defines the name of the animation to look for
  32331. * @returns null if not found else the requested animation
  32332. */
  32333. getAnimationByName(name: string): Nullable<Animation>;
  32334. /**
  32335. * Creates an animation range for this node
  32336. * @param name defines the name of the range
  32337. * @param from defines the starting key
  32338. * @param to defines the end key
  32339. */
  32340. createAnimationRange(name: string, from: number, to: number): void;
  32341. /**
  32342. * Delete a specific animation range
  32343. * @param name defines the name of the range to delete
  32344. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32345. */
  32346. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32347. /**
  32348. * Get an animation range by name
  32349. * @param name defines the name of the animation range to look for
  32350. * @returns null if not found else the requested animation range
  32351. */
  32352. getAnimationRange(name: string): Nullable<AnimationRange>;
  32353. /**
  32354. * Gets the list of all animation ranges defined on this node
  32355. * @returns an array
  32356. */
  32357. getAnimationRanges(): Nullable<AnimationRange>[];
  32358. /**
  32359. * Will start the animation sequence
  32360. * @param name defines the range frames for animation sequence
  32361. * @param loop defines if the animation should loop (false by default)
  32362. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32363. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32364. * @returns the object created for this animation. If range does not exist, it will return null
  32365. */
  32366. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32367. /**
  32368. * Serialize animation ranges into a JSON compatible object
  32369. * @returns serialization object
  32370. */
  32371. serializeAnimationRanges(): any;
  32372. /**
  32373. * Computes the world matrix of the node
  32374. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32375. * @returns the world matrix
  32376. */
  32377. computeWorldMatrix(force?: boolean): Matrix;
  32378. /**
  32379. * Releases resources associated with this node.
  32380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32382. */
  32383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32384. /**
  32385. * Parse animation range data from a serialization object and store them into a given node
  32386. * @param node defines where to store the animation ranges
  32387. * @param parsedNode defines the serialization object to read data from
  32388. * @param scene defines the hosting scene
  32389. */
  32390. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32391. /**
  32392. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32393. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32394. * @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
  32395. * @returns the new bounding vectors
  32396. */
  32397. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32398. min: Vector3;
  32399. max: Vector3;
  32400. };
  32401. }
  32402. }
  32403. declare module BABYLON {
  32404. /**
  32405. * @hidden
  32406. */
  32407. export class _IAnimationState {
  32408. key: number;
  32409. repeatCount: number;
  32410. workValue?: any;
  32411. loopMode?: number;
  32412. offsetValue?: any;
  32413. highLimitValue?: any;
  32414. }
  32415. /**
  32416. * Class used to store any kind of animation
  32417. */
  32418. export class Animation {
  32419. /**Name of the animation */
  32420. name: string;
  32421. /**Property to animate */
  32422. targetProperty: string;
  32423. /**The frames per second of the animation */
  32424. framePerSecond: number;
  32425. /**The data type of the animation */
  32426. dataType: number;
  32427. /**The loop mode of the animation */
  32428. loopMode?: number | undefined;
  32429. /**Specifies if blending should be enabled */
  32430. enableBlending?: boolean | undefined;
  32431. /**
  32432. * Use matrix interpolation instead of using direct key value when animating matrices
  32433. */
  32434. static AllowMatricesInterpolation: boolean;
  32435. /**
  32436. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32437. */
  32438. static AllowMatrixDecomposeForInterpolation: boolean;
  32439. /** Define the Url to load snippets */
  32440. static SnippetUrl: string;
  32441. /** Snippet ID if the animation was created from the snippet server */
  32442. snippetId: string;
  32443. /**
  32444. * Stores the key frames of the animation
  32445. */
  32446. private _keys;
  32447. /**
  32448. * Stores the easing function of the animation
  32449. */
  32450. private _easingFunction;
  32451. /**
  32452. * @hidden Internal use only
  32453. */
  32454. _runtimeAnimations: RuntimeAnimation[];
  32455. /**
  32456. * The set of event that will be linked to this animation
  32457. */
  32458. private _events;
  32459. /**
  32460. * Stores an array of target property paths
  32461. */
  32462. targetPropertyPath: string[];
  32463. /**
  32464. * Stores the blending speed of the animation
  32465. */
  32466. blendingSpeed: number;
  32467. /**
  32468. * Stores the animation ranges for the animation
  32469. */
  32470. private _ranges;
  32471. /**
  32472. * @hidden Internal use
  32473. */
  32474. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32475. /**
  32476. * Sets up an animation
  32477. * @param property The property to animate
  32478. * @param animationType The animation type to apply
  32479. * @param framePerSecond The frames per second of the animation
  32480. * @param easingFunction The easing function used in the animation
  32481. * @returns The created animation
  32482. */
  32483. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32484. /**
  32485. * Create and start an animation on a node
  32486. * @param name defines the name of the global animation that will be run on all nodes
  32487. * @param node defines the root node where the animation will take place
  32488. * @param targetProperty defines property to animate
  32489. * @param framePerSecond defines the number of frame per second yo use
  32490. * @param totalFrame defines the number of frames in total
  32491. * @param from defines the initial value
  32492. * @param to defines the final value
  32493. * @param loopMode defines which loop mode you want to use (off by default)
  32494. * @param easingFunction defines the easing function to use (linear by default)
  32495. * @param onAnimationEnd defines the callback to call when animation end
  32496. * @returns the animatable created for this animation
  32497. */
  32498. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32499. /**
  32500. * Create and start an animation on a node and its descendants
  32501. * @param name defines the name of the global animation that will be run on all nodes
  32502. * @param node defines the root node where the animation will take place
  32503. * @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
  32504. * @param targetProperty defines property to animate
  32505. * @param framePerSecond defines the number of frame per second to use
  32506. * @param totalFrame defines the number of frames in total
  32507. * @param from defines the initial value
  32508. * @param to defines the final value
  32509. * @param loopMode defines which loop mode you want to use (off by default)
  32510. * @param easingFunction defines the easing function to use (linear by default)
  32511. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32512. * @returns the list of animatables created for all nodes
  32513. * @example https://www.babylonjs-playground.com/#MH0VLI
  32514. */
  32515. 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[]>;
  32516. /**
  32517. * Creates a new animation, merges it with the existing animations and starts it
  32518. * @param name Name of the animation
  32519. * @param node Node which contains the scene that begins the animations
  32520. * @param targetProperty Specifies which property to animate
  32521. * @param framePerSecond The frames per second of the animation
  32522. * @param totalFrame The total number of frames
  32523. * @param from The frame at the beginning of the animation
  32524. * @param to The frame at the end of the animation
  32525. * @param loopMode Specifies the loop mode of the animation
  32526. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32527. * @param onAnimationEnd Callback to run once the animation is complete
  32528. * @returns Nullable animation
  32529. */
  32530. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32531. /**
  32532. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32533. * @param sourceAnimation defines the Animation containing keyframes to convert
  32534. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32535. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32536. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32537. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32538. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32539. */
  32540. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32541. /**
  32542. * Transition property of an host to the target Value
  32543. * @param property The property to transition
  32544. * @param targetValue The target Value of the property
  32545. * @param host The object where the property to animate belongs
  32546. * @param scene Scene used to run the animation
  32547. * @param frameRate Framerate (in frame/s) to use
  32548. * @param transition The transition type we want to use
  32549. * @param duration The duration of the animation, in milliseconds
  32550. * @param onAnimationEnd Callback trigger at the end of the animation
  32551. * @returns Nullable animation
  32552. */
  32553. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32554. /**
  32555. * Return the array of runtime animations currently using this animation
  32556. */
  32557. get runtimeAnimations(): RuntimeAnimation[];
  32558. /**
  32559. * Specifies if any of the runtime animations are currently running
  32560. */
  32561. get hasRunningRuntimeAnimations(): boolean;
  32562. /**
  32563. * Initializes the animation
  32564. * @param name Name of the animation
  32565. * @param targetProperty Property to animate
  32566. * @param framePerSecond The frames per second of the animation
  32567. * @param dataType The data type of the animation
  32568. * @param loopMode The loop mode of the animation
  32569. * @param enableBlending Specifies if blending should be enabled
  32570. */
  32571. constructor(
  32572. /**Name of the animation */
  32573. name: string,
  32574. /**Property to animate */
  32575. targetProperty: string,
  32576. /**The frames per second of the animation */
  32577. framePerSecond: number,
  32578. /**The data type of the animation */
  32579. dataType: number,
  32580. /**The loop mode of the animation */
  32581. loopMode?: number | undefined,
  32582. /**Specifies if blending should be enabled */
  32583. enableBlending?: boolean | undefined);
  32584. /**
  32585. * Converts the animation to a string
  32586. * @param fullDetails support for multiple levels of logging within scene loading
  32587. * @returns String form of the animation
  32588. */
  32589. toString(fullDetails?: boolean): string;
  32590. /**
  32591. * Add an event to this animation
  32592. * @param event Event to add
  32593. */
  32594. addEvent(event: AnimationEvent): void;
  32595. /**
  32596. * Remove all events found at the given frame
  32597. * @param frame The frame to remove events from
  32598. */
  32599. removeEvents(frame: number): void;
  32600. /**
  32601. * Retrieves all the events from the animation
  32602. * @returns Events from the animation
  32603. */
  32604. getEvents(): AnimationEvent[];
  32605. /**
  32606. * Creates an animation range
  32607. * @param name Name of the animation range
  32608. * @param from Starting frame of the animation range
  32609. * @param to Ending frame of the animation
  32610. */
  32611. createRange(name: string, from: number, to: number): void;
  32612. /**
  32613. * Deletes an animation range by name
  32614. * @param name Name of the animation range to delete
  32615. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32616. */
  32617. deleteRange(name: string, deleteFrames?: boolean): void;
  32618. /**
  32619. * Gets the animation range by name, or null if not defined
  32620. * @param name Name of the animation range
  32621. * @returns Nullable animation range
  32622. */
  32623. getRange(name: string): Nullable<AnimationRange>;
  32624. /**
  32625. * Gets the key frames from the animation
  32626. * @returns The key frames of the animation
  32627. */
  32628. getKeys(): Array<IAnimationKey>;
  32629. /**
  32630. * Gets the highest frame rate of the animation
  32631. * @returns Highest frame rate of the animation
  32632. */
  32633. getHighestFrame(): number;
  32634. /**
  32635. * Gets the easing function of the animation
  32636. * @returns Easing function of the animation
  32637. */
  32638. getEasingFunction(): IEasingFunction;
  32639. /**
  32640. * Sets the easing function of the animation
  32641. * @param easingFunction A custom mathematical formula for animation
  32642. */
  32643. setEasingFunction(easingFunction: EasingFunction): void;
  32644. /**
  32645. * Interpolates a scalar linearly
  32646. * @param startValue Start value of the animation curve
  32647. * @param endValue End value of the animation curve
  32648. * @param gradient Scalar amount to interpolate
  32649. * @returns Interpolated scalar value
  32650. */
  32651. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32652. /**
  32653. * Interpolates a scalar cubically
  32654. * @param startValue Start value of the animation curve
  32655. * @param outTangent End tangent of the animation
  32656. * @param endValue End value of the animation curve
  32657. * @param inTangent Start tangent of the animation curve
  32658. * @param gradient Scalar amount to interpolate
  32659. * @returns Interpolated scalar value
  32660. */
  32661. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32662. /**
  32663. * Interpolates a quaternion using a spherical linear interpolation
  32664. * @param startValue Start value of the animation curve
  32665. * @param endValue End value of the animation curve
  32666. * @param gradient Scalar amount to interpolate
  32667. * @returns Interpolated quaternion value
  32668. */
  32669. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32670. /**
  32671. * Interpolates a quaternion cubically
  32672. * @param startValue Start value of the animation curve
  32673. * @param outTangent End tangent of the animation curve
  32674. * @param endValue End value of the animation curve
  32675. * @param inTangent Start tangent of the animation curve
  32676. * @param gradient Scalar amount to interpolate
  32677. * @returns Interpolated quaternion value
  32678. */
  32679. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32680. /**
  32681. * Interpolates a Vector3 linearl
  32682. * @param startValue Start value of the animation curve
  32683. * @param endValue End value of the animation curve
  32684. * @param gradient Scalar amount to interpolate
  32685. * @returns Interpolated scalar value
  32686. */
  32687. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32688. /**
  32689. * Interpolates a Vector3 cubically
  32690. * @param startValue Start value of the animation curve
  32691. * @param outTangent End tangent of the animation
  32692. * @param endValue End value of the animation curve
  32693. * @param inTangent Start tangent of the animation curve
  32694. * @param gradient Scalar amount to interpolate
  32695. * @returns InterpolatedVector3 value
  32696. */
  32697. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32698. /**
  32699. * Interpolates a Vector2 linearly
  32700. * @param startValue Start value of the animation curve
  32701. * @param endValue End value of the animation curve
  32702. * @param gradient Scalar amount to interpolate
  32703. * @returns Interpolated Vector2 value
  32704. */
  32705. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32706. /**
  32707. * Interpolates a Vector2 cubically
  32708. * @param startValue Start value of the animation curve
  32709. * @param outTangent End tangent of the animation
  32710. * @param endValue End value of the animation curve
  32711. * @param inTangent Start tangent of the animation curve
  32712. * @param gradient Scalar amount to interpolate
  32713. * @returns Interpolated Vector2 value
  32714. */
  32715. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32716. /**
  32717. * Interpolates a size linearly
  32718. * @param startValue Start value of the animation curve
  32719. * @param endValue End value of the animation curve
  32720. * @param gradient Scalar amount to interpolate
  32721. * @returns Interpolated Size value
  32722. */
  32723. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32724. /**
  32725. * Interpolates a Color3 linearly
  32726. * @param startValue Start value of the animation curve
  32727. * @param endValue End value of the animation curve
  32728. * @param gradient Scalar amount to interpolate
  32729. * @returns Interpolated Color3 value
  32730. */
  32731. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32732. /**
  32733. * Interpolates a Color4 linearly
  32734. * @param startValue Start value of the animation curve
  32735. * @param endValue End value of the animation curve
  32736. * @param gradient Scalar amount to interpolate
  32737. * @returns Interpolated Color3 value
  32738. */
  32739. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32740. /**
  32741. * @hidden Internal use only
  32742. */
  32743. _getKeyValue(value: any): any;
  32744. /**
  32745. * @hidden Internal use only
  32746. */
  32747. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32748. /**
  32749. * Defines the function to use to interpolate matrices
  32750. * @param startValue defines the start matrix
  32751. * @param endValue defines the end matrix
  32752. * @param gradient defines the gradient between both matrices
  32753. * @param result defines an optional target matrix where to store the interpolation
  32754. * @returns the interpolated matrix
  32755. */
  32756. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32757. /**
  32758. * Makes a copy of the animation
  32759. * @returns Cloned animation
  32760. */
  32761. clone(): Animation;
  32762. /**
  32763. * Sets the key frames of the animation
  32764. * @param values The animation key frames to set
  32765. */
  32766. setKeys(values: Array<IAnimationKey>): void;
  32767. /**
  32768. * Serializes the animation to an object
  32769. * @returns Serialized object
  32770. */
  32771. serialize(): any;
  32772. /**
  32773. * Float animation type
  32774. */
  32775. static readonly ANIMATIONTYPE_FLOAT: number;
  32776. /**
  32777. * Vector3 animation type
  32778. */
  32779. static readonly ANIMATIONTYPE_VECTOR3: number;
  32780. /**
  32781. * Quaternion animation type
  32782. */
  32783. static readonly ANIMATIONTYPE_QUATERNION: number;
  32784. /**
  32785. * Matrix animation type
  32786. */
  32787. static readonly ANIMATIONTYPE_MATRIX: number;
  32788. /**
  32789. * Color3 animation type
  32790. */
  32791. static readonly ANIMATIONTYPE_COLOR3: number;
  32792. /**
  32793. * Color3 animation type
  32794. */
  32795. static readonly ANIMATIONTYPE_COLOR4: number;
  32796. /**
  32797. * Vector2 animation type
  32798. */
  32799. static readonly ANIMATIONTYPE_VECTOR2: number;
  32800. /**
  32801. * Size animation type
  32802. */
  32803. static readonly ANIMATIONTYPE_SIZE: number;
  32804. /**
  32805. * Relative Loop Mode
  32806. */
  32807. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32808. /**
  32809. * Cycle Loop Mode
  32810. */
  32811. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32812. /**
  32813. * Constant Loop Mode
  32814. */
  32815. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32816. /** @hidden */
  32817. static _UniversalLerp(left: any, right: any, amount: number): any;
  32818. /**
  32819. * Parses an animation object and creates an animation
  32820. * @param parsedAnimation Parsed animation object
  32821. * @returns Animation object
  32822. */
  32823. static Parse(parsedAnimation: any): Animation;
  32824. /**
  32825. * Appends the serialized animations from the source animations
  32826. * @param source Source containing the animations
  32827. * @param destination Target to store the animations
  32828. */
  32829. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32830. /**
  32831. * Creates a new animation or an array of animations from a snippet saved in a remote file
  32832. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  32833. * @param url defines the url to load from
  32834. * @returns a promise that will resolve to the new animation or an array of animations
  32835. */
  32836. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  32837. /**
  32838. * Creates an animation or an array of animations from a snippet saved by the Inspector
  32839. * @param snippetId defines the snippet to load
  32840. * @returns a promise that will resolve to the new animation or a new array of animations
  32841. */
  32842. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  32843. }
  32844. }
  32845. declare module BABYLON {
  32846. /**
  32847. * Interface containing an array of animations
  32848. */
  32849. export interface IAnimatable {
  32850. /**
  32851. * Array of animations
  32852. */
  32853. animations: Nullable<Array<Animation>>;
  32854. }
  32855. }
  32856. declare module BABYLON {
  32857. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32858. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32859. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32860. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32861. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32862. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32863. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32864. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32865. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32866. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32867. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32868. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32869. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32870. /**
  32871. * Decorator used to define property that can be serialized as reference to a camera
  32872. * @param sourceName defines the name of the property to decorate
  32873. */
  32874. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32875. /**
  32876. * Class used to help serialization objects
  32877. */
  32878. export class SerializationHelper {
  32879. /** @hidden */
  32880. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32881. /** @hidden */
  32882. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32883. /** @hidden */
  32884. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32885. /** @hidden */
  32886. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32887. /**
  32888. * Appends the serialized animations from the source animations
  32889. * @param source Source containing the animations
  32890. * @param destination Target to store the animations
  32891. */
  32892. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32893. /**
  32894. * Static function used to serialized a specific entity
  32895. * @param entity defines the entity to serialize
  32896. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32897. * @returns a JSON compatible object representing the serialization of the entity
  32898. */
  32899. static Serialize<T>(entity: T, serializationObject?: any): any;
  32900. /**
  32901. * Creates a new entity from a serialization data object
  32902. * @param creationFunction defines a function used to instanciated the new entity
  32903. * @param source defines the source serialization data
  32904. * @param scene defines the hosting scene
  32905. * @param rootUrl defines the root url for resources
  32906. * @returns a new entity
  32907. */
  32908. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32909. /**
  32910. * Clones an object
  32911. * @param creationFunction defines the function used to instanciate the new object
  32912. * @param source defines the source object
  32913. * @returns the cloned object
  32914. */
  32915. static Clone<T>(creationFunction: () => T, source: T): T;
  32916. /**
  32917. * Instanciates a new object based on a source one (some data will be shared between both object)
  32918. * @param creationFunction defines the function used to instanciate the new object
  32919. * @param source defines the source object
  32920. * @returns the new object
  32921. */
  32922. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32923. }
  32924. }
  32925. declare module BABYLON {
  32926. /**
  32927. * Base class of all the textures in babylon.
  32928. * It groups all the common properties the materials, post process, lights... might need
  32929. * in order to make a correct use of the texture.
  32930. */
  32931. export class BaseTexture implements IAnimatable {
  32932. /**
  32933. * Default anisotropic filtering level for the application.
  32934. * It is set to 4 as a good tradeoff between perf and quality.
  32935. */
  32936. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32937. /**
  32938. * Gets or sets the unique id of the texture
  32939. */
  32940. uniqueId: number;
  32941. /**
  32942. * Define the name of the texture.
  32943. */
  32944. name: string;
  32945. /**
  32946. * Gets or sets an object used to store user defined information.
  32947. */
  32948. metadata: any;
  32949. /**
  32950. * For internal use only. Please do not use.
  32951. */
  32952. reservedDataStore: any;
  32953. private _hasAlpha;
  32954. /**
  32955. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32956. */
  32957. set hasAlpha(value: boolean);
  32958. get hasAlpha(): boolean;
  32959. /**
  32960. * Defines if the alpha value should be determined via the rgb values.
  32961. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32962. */
  32963. getAlphaFromRGB: boolean;
  32964. /**
  32965. * Intensity or strength of the texture.
  32966. * It is commonly used by materials to fine tune the intensity of the texture
  32967. */
  32968. level: number;
  32969. /**
  32970. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32971. * This is part of the texture as textures usually maps to one uv set.
  32972. */
  32973. coordinatesIndex: number;
  32974. private _coordinatesMode;
  32975. /**
  32976. * How a texture is mapped.
  32977. *
  32978. * | Value | Type | Description |
  32979. * | ----- | ----------------------------------- | ----------- |
  32980. * | 0 | EXPLICIT_MODE | |
  32981. * | 1 | SPHERICAL_MODE | |
  32982. * | 2 | PLANAR_MODE | |
  32983. * | 3 | CUBIC_MODE | |
  32984. * | 4 | PROJECTION_MODE | |
  32985. * | 5 | SKYBOX_MODE | |
  32986. * | 6 | INVCUBIC_MODE | |
  32987. * | 7 | EQUIRECTANGULAR_MODE | |
  32988. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32989. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32990. */
  32991. set coordinatesMode(value: number);
  32992. get coordinatesMode(): number;
  32993. /**
  32994. * | Value | Type | Description |
  32995. * | ----- | ------------------ | ----------- |
  32996. * | 0 | CLAMP_ADDRESSMODE | |
  32997. * | 1 | WRAP_ADDRESSMODE | |
  32998. * | 2 | MIRROR_ADDRESSMODE | |
  32999. */
  33000. wrapU: number;
  33001. /**
  33002. * | Value | Type | Description |
  33003. * | ----- | ------------------ | ----------- |
  33004. * | 0 | CLAMP_ADDRESSMODE | |
  33005. * | 1 | WRAP_ADDRESSMODE | |
  33006. * | 2 | MIRROR_ADDRESSMODE | |
  33007. */
  33008. wrapV: number;
  33009. /**
  33010. * | Value | Type | Description |
  33011. * | ----- | ------------------ | ----------- |
  33012. * | 0 | CLAMP_ADDRESSMODE | |
  33013. * | 1 | WRAP_ADDRESSMODE | |
  33014. * | 2 | MIRROR_ADDRESSMODE | |
  33015. */
  33016. wrapR: number;
  33017. /**
  33018. * With compliant hardware and browser (supporting anisotropic filtering)
  33019. * this defines the level of anisotropic filtering in the texture.
  33020. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33021. */
  33022. anisotropicFilteringLevel: number;
  33023. /**
  33024. * Define if the texture is a cube texture or if false a 2d texture.
  33025. */
  33026. get isCube(): boolean;
  33027. set isCube(value: boolean);
  33028. /**
  33029. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33030. */
  33031. get is3D(): boolean;
  33032. set is3D(value: boolean);
  33033. /**
  33034. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33035. */
  33036. get is2DArray(): boolean;
  33037. set is2DArray(value: boolean);
  33038. /**
  33039. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33040. * HDR texture are usually stored in linear space.
  33041. * This only impacts the PBR and Background materials
  33042. */
  33043. gammaSpace: boolean;
  33044. /**
  33045. * Gets or sets whether or not the texture contains RGBD data.
  33046. */
  33047. get isRGBD(): boolean;
  33048. set isRGBD(value: boolean);
  33049. /**
  33050. * Is Z inverted in the texture (useful in a cube texture).
  33051. */
  33052. invertZ: boolean;
  33053. /**
  33054. * Are mip maps generated for this texture or not.
  33055. */
  33056. get noMipmap(): boolean;
  33057. /**
  33058. * @hidden
  33059. */
  33060. lodLevelInAlpha: boolean;
  33061. /**
  33062. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33063. */
  33064. get lodGenerationOffset(): number;
  33065. set lodGenerationOffset(value: number);
  33066. /**
  33067. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33068. */
  33069. get lodGenerationScale(): number;
  33070. set lodGenerationScale(value: number);
  33071. /**
  33072. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33073. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33074. * average roughness values.
  33075. */
  33076. get linearSpecularLOD(): boolean;
  33077. set linearSpecularLOD(value: boolean);
  33078. /**
  33079. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33080. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33081. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33082. */
  33083. get irradianceTexture(): Nullable<BaseTexture>;
  33084. set irradianceTexture(value: Nullable<BaseTexture>);
  33085. /**
  33086. * Define if the texture is a render target.
  33087. */
  33088. isRenderTarget: boolean;
  33089. /**
  33090. * Define the unique id of the texture in the scene.
  33091. */
  33092. get uid(): string;
  33093. /** @hidden */
  33094. _prefiltered: boolean;
  33095. /**
  33096. * Return a string representation of the texture.
  33097. * @returns the texture as a string
  33098. */
  33099. toString(): string;
  33100. /**
  33101. * Get the class name of the texture.
  33102. * @returns "BaseTexture"
  33103. */
  33104. getClassName(): string;
  33105. /**
  33106. * Define the list of animation attached to the texture.
  33107. */
  33108. animations: Animation[];
  33109. /**
  33110. * An event triggered when the texture is disposed.
  33111. */
  33112. onDisposeObservable: Observable<BaseTexture>;
  33113. private _onDisposeObserver;
  33114. /**
  33115. * Callback triggered when the texture has been disposed.
  33116. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33117. */
  33118. set onDispose(callback: () => void);
  33119. /**
  33120. * Define the current state of the loading sequence when in delayed load mode.
  33121. */
  33122. delayLoadState: number;
  33123. private _scene;
  33124. private _engine;
  33125. /** @hidden */
  33126. _texture: Nullable<InternalTexture>;
  33127. private _uid;
  33128. /**
  33129. * Define if the texture is preventinga material to render or not.
  33130. * If not and the texture is not ready, the engine will use a default black texture instead.
  33131. */
  33132. get isBlocking(): boolean;
  33133. /**
  33134. * Instantiates a new BaseTexture.
  33135. * Base class of all the textures in babylon.
  33136. * It groups all the common properties the materials, post process, lights... might need
  33137. * in order to make a correct use of the texture.
  33138. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33139. */
  33140. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33141. /**
  33142. * Get the scene the texture belongs to.
  33143. * @returns the scene or null if undefined
  33144. */
  33145. getScene(): Nullable<Scene>;
  33146. /** @hidden */
  33147. protected _getEngine(): Nullable<ThinEngine>;
  33148. /**
  33149. * Get the texture transform matrix used to offset tile the texture for istance.
  33150. * @returns the transformation matrix
  33151. */
  33152. getTextureMatrix(): Matrix;
  33153. /**
  33154. * Get the texture reflection matrix used to rotate/transform the reflection.
  33155. * @returns the reflection matrix
  33156. */
  33157. getReflectionTextureMatrix(): Matrix;
  33158. /**
  33159. * Get the underlying lower level texture from Babylon.
  33160. * @returns the insternal texture
  33161. */
  33162. getInternalTexture(): Nullable<InternalTexture>;
  33163. /**
  33164. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33165. * @returns true if ready or not blocking
  33166. */
  33167. isReadyOrNotBlocking(): boolean;
  33168. /**
  33169. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33170. * @returns true if fully ready
  33171. */
  33172. isReady(): boolean;
  33173. private _cachedSize;
  33174. /**
  33175. * Get the size of the texture.
  33176. * @returns the texture size.
  33177. */
  33178. getSize(): ISize;
  33179. /**
  33180. * Get the base size of the texture.
  33181. * It can be different from the size if the texture has been resized for POT for instance
  33182. * @returns the base size
  33183. */
  33184. getBaseSize(): ISize;
  33185. /**
  33186. * Update the sampling mode of the texture.
  33187. * Default is Trilinear mode.
  33188. *
  33189. * | Value | Type | Description |
  33190. * | ----- | ------------------ | ----------- |
  33191. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33192. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33193. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33194. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33195. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33196. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33197. * | 7 | NEAREST_LINEAR | |
  33198. * | 8 | NEAREST_NEAREST | |
  33199. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33200. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33201. * | 11 | LINEAR_LINEAR | |
  33202. * | 12 | LINEAR_NEAREST | |
  33203. *
  33204. * > _mag_: magnification filter (close to the viewer)
  33205. * > _min_: minification filter (far from the viewer)
  33206. * > _mip_: filter used between mip map levels
  33207. *@param samplingMode Define the new sampling mode of the texture
  33208. */
  33209. updateSamplingMode(samplingMode: number): void;
  33210. /**
  33211. * Scales the texture if is `canRescale()`
  33212. * @param ratio the resize factor we want to use to rescale
  33213. */
  33214. scale(ratio: number): void;
  33215. /**
  33216. * Get if the texture can rescale.
  33217. */
  33218. get canRescale(): boolean;
  33219. /** @hidden */
  33220. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33221. /** @hidden */
  33222. _rebuild(): void;
  33223. /**
  33224. * Triggers the load sequence in delayed load mode.
  33225. */
  33226. delayLoad(): void;
  33227. /**
  33228. * Clones the texture.
  33229. * @returns the cloned texture
  33230. */
  33231. clone(): Nullable<BaseTexture>;
  33232. /**
  33233. * Get the texture underlying type (INT, FLOAT...)
  33234. */
  33235. get textureType(): number;
  33236. /**
  33237. * Get the texture underlying format (RGB, RGBA...)
  33238. */
  33239. get textureFormat(): number;
  33240. /**
  33241. * Indicates that textures need to be re-calculated for all materials
  33242. */
  33243. protected _markAllSubMeshesAsTexturesDirty(): void;
  33244. /**
  33245. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33246. * This will returns an RGBA array buffer containing either in values (0-255) or
  33247. * float values (0-1) depending of the underlying buffer type.
  33248. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33249. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33250. * @param buffer defines a user defined buffer to fill with data (can be null)
  33251. * @returns The Array buffer containing the pixels data.
  33252. */
  33253. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33254. /**
  33255. * Release and destroy the underlying lower level texture aka internalTexture.
  33256. */
  33257. releaseInternalTexture(): void;
  33258. /** @hidden */
  33259. get _lodTextureHigh(): Nullable<BaseTexture>;
  33260. /** @hidden */
  33261. get _lodTextureMid(): Nullable<BaseTexture>;
  33262. /** @hidden */
  33263. get _lodTextureLow(): Nullable<BaseTexture>;
  33264. /**
  33265. * Dispose the texture and release its associated resources.
  33266. */
  33267. dispose(): void;
  33268. /**
  33269. * Serialize the texture into a JSON representation that can be parsed later on.
  33270. * @returns the JSON representation of the texture
  33271. */
  33272. serialize(): any;
  33273. /**
  33274. * Helper function to be called back once a list of texture contains only ready textures.
  33275. * @param textures Define the list of textures to wait for
  33276. * @param callback Define the callback triggered once the entire list will be ready
  33277. */
  33278. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33279. private static _isScene;
  33280. }
  33281. }
  33282. declare module BABYLON {
  33283. /**
  33284. * Options to be used when creating an effect.
  33285. */
  33286. export interface IEffectCreationOptions {
  33287. /**
  33288. * Atrributes that will be used in the shader.
  33289. */
  33290. attributes: string[];
  33291. /**
  33292. * Uniform varible names that will be set in the shader.
  33293. */
  33294. uniformsNames: string[];
  33295. /**
  33296. * Uniform buffer variable names that will be set in the shader.
  33297. */
  33298. uniformBuffersNames: string[];
  33299. /**
  33300. * Sampler texture variable names that will be set in the shader.
  33301. */
  33302. samplers: string[];
  33303. /**
  33304. * Define statements that will be set in the shader.
  33305. */
  33306. defines: any;
  33307. /**
  33308. * Possible fallbacks for this effect to improve performance when needed.
  33309. */
  33310. fallbacks: Nullable<IEffectFallbacks>;
  33311. /**
  33312. * Callback that will be called when the shader is compiled.
  33313. */
  33314. onCompiled: Nullable<(effect: Effect) => void>;
  33315. /**
  33316. * Callback that will be called if an error occurs during shader compilation.
  33317. */
  33318. onError: Nullable<(effect: Effect, errors: string) => void>;
  33319. /**
  33320. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33321. */
  33322. indexParameters?: any;
  33323. /**
  33324. * Max number of lights that can be used in the shader.
  33325. */
  33326. maxSimultaneousLights?: number;
  33327. /**
  33328. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33329. */
  33330. transformFeedbackVaryings?: Nullable<string[]>;
  33331. /**
  33332. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  33333. */
  33334. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33335. }
  33336. /**
  33337. * Effect containing vertex and fragment shader that can be executed on an object.
  33338. */
  33339. export class Effect implements IDisposable {
  33340. /**
  33341. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33342. */
  33343. static ShadersRepository: string;
  33344. /**
  33345. * Enable logging of the shader code when a compilation error occurs
  33346. */
  33347. static LogShaderCodeOnCompilationError: boolean;
  33348. /**
  33349. * Name of the effect.
  33350. */
  33351. name: any;
  33352. /**
  33353. * String container all the define statements that should be set on the shader.
  33354. */
  33355. defines: string;
  33356. /**
  33357. * Callback that will be called when the shader is compiled.
  33358. */
  33359. onCompiled: Nullable<(effect: Effect) => void>;
  33360. /**
  33361. * Callback that will be called if an error occurs during shader compilation.
  33362. */
  33363. onError: Nullable<(effect: Effect, errors: string) => void>;
  33364. /**
  33365. * Callback that will be called when effect is bound.
  33366. */
  33367. onBind: Nullable<(effect: Effect) => void>;
  33368. /**
  33369. * Unique ID of the effect.
  33370. */
  33371. uniqueId: number;
  33372. /**
  33373. * Observable that will be called when the shader is compiled.
  33374. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33375. */
  33376. onCompileObservable: Observable<Effect>;
  33377. /**
  33378. * Observable that will be called if an error occurs during shader compilation.
  33379. */
  33380. onErrorObservable: Observable<Effect>;
  33381. /** @hidden */
  33382. _onBindObservable: Nullable<Observable<Effect>>;
  33383. /**
  33384. * @hidden
  33385. * Specifies if the effect was previously ready
  33386. */
  33387. _wasPreviouslyReady: boolean;
  33388. /**
  33389. * Observable that will be called when effect is bound.
  33390. */
  33391. get onBindObservable(): Observable<Effect>;
  33392. /** @hidden */
  33393. _bonesComputationForcedToCPU: boolean;
  33394. private static _uniqueIdSeed;
  33395. private _engine;
  33396. private _uniformBuffersNames;
  33397. private _uniformBuffersNamesList;
  33398. private _uniformsNames;
  33399. private _samplerList;
  33400. private _samplers;
  33401. private _isReady;
  33402. private _compilationError;
  33403. private _allFallbacksProcessed;
  33404. private _attributesNames;
  33405. private _attributes;
  33406. private _attributeLocationByName;
  33407. private _uniforms;
  33408. /**
  33409. * Key for the effect.
  33410. * @hidden
  33411. */
  33412. _key: string;
  33413. private _indexParameters;
  33414. private _fallbacks;
  33415. private _vertexSourceCode;
  33416. private _fragmentSourceCode;
  33417. private _vertexSourceCodeOverride;
  33418. private _fragmentSourceCodeOverride;
  33419. private _transformFeedbackVaryings;
  33420. /**
  33421. * Compiled shader to webGL program.
  33422. * @hidden
  33423. */
  33424. _pipelineContext: Nullable<IPipelineContext>;
  33425. private _valueCache;
  33426. private static _baseCache;
  33427. /**
  33428. * Instantiates an effect.
  33429. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33430. * @param baseName Name of the effect.
  33431. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33432. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33433. * @param samplers List of sampler variables that will be passed to the shader.
  33434. * @param engine Engine to be used to render the effect
  33435. * @param defines Define statements to be added to the shader.
  33436. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33437. * @param onCompiled Callback that will be called when the shader is compiled.
  33438. * @param onError Callback that will be called if an error occurs during shader compilation.
  33439. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33440. */
  33441. 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);
  33442. private _useFinalCode;
  33443. /**
  33444. * Unique key for this effect
  33445. */
  33446. get key(): string;
  33447. /**
  33448. * If the effect has been compiled and prepared.
  33449. * @returns if the effect is compiled and prepared.
  33450. */
  33451. isReady(): boolean;
  33452. private _isReadyInternal;
  33453. /**
  33454. * The engine the effect was initialized with.
  33455. * @returns the engine.
  33456. */
  33457. getEngine(): Engine;
  33458. /**
  33459. * The pipeline context for this effect
  33460. * @returns the associated pipeline context
  33461. */
  33462. getPipelineContext(): Nullable<IPipelineContext>;
  33463. /**
  33464. * The set of names of attribute variables for the shader.
  33465. * @returns An array of attribute names.
  33466. */
  33467. getAttributesNames(): string[];
  33468. /**
  33469. * Returns the attribute at the given index.
  33470. * @param index The index of the attribute.
  33471. * @returns The location of the attribute.
  33472. */
  33473. getAttributeLocation(index: number): number;
  33474. /**
  33475. * Returns the attribute based on the name of the variable.
  33476. * @param name of the attribute to look up.
  33477. * @returns the attribute location.
  33478. */
  33479. getAttributeLocationByName(name: string): number;
  33480. /**
  33481. * The number of attributes.
  33482. * @returns the numnber of attributes.
  33483. */
  33484. getAttributesCount(): number;
  33485. /**
  33486. * Gets the index of a uniform variable.
  33487. * @param uniformName of the uniform to look up.
  33488. * @returns the index.
  33489. */
  33490. getUniformIndex(uniformName: string): number;
  33491. /**
  33492. * Returns the attribute based on the name of the variable.
  33493. * @param uniformName of the uniform to look up.
  33494. * @returns the location of the uniform.
  33495. */
  33496. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33497. /**
  33498. * Returns an array of sampler variable names
  33499. * @returns The array of sampler variable names.
  33500. */
  33501. getSamplers(): string[];
  33502. /**
  33503. * Returns an array of uniform variable names
  33504. * @returns The array of uniform variable names.
  33505. */
  33506. getUniformNames(): string[];
  33507. /**
  33508. * Returns an array of uniform buffer variable names
  33509. * @returns The array of uniform buffer variable names.
  33510. */
  33511. getUniformBuffersNames(): string[];
  33512. /**
  33513. * Returns the index parameters used to create the effect
  33514. * @returns The index parameters object
  33515. */
  33516. getIndexParameters(): any;
  33517. /**
  33518. * The error from the last compilation.
  33519. * @returns the error string.
  33520. */
  33521. getCompilationError(): string;
  33522. /**
  33523. * Gets a boolean indicating that all fallbacks were used during compilation
  33524. * @returns true if all fallbacks were used
  33525. */
  33526. allFallbacksProcessed(): boolean;
  33527. /**
  33528. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33529. * @param func The callback to be used.
  33530. */
  33531. executeWhenCompiled(func: (effect: Effect) => void): void;
  33532. private _checkIsReady;
  33533. private _loadShader;
  33534. /**
  33535. * Gets the vertex shader source code of this effect
  33536. */
  33537. get vertexSourceCode(): string;
  33538. /**
  33539. * Gets the fragment shader source code of this effect
  33540. */
  33541. get fragmentSourceCode(): string;
  33542. /**
  33543. * Recompiles the webGL program
  33544. * @param vertexSourceCode The source code for the vertex shader.
  33545. * @param fragmentSourceCode The source code for the fragment shader.
  33546. * @param onCompiled Callback called when completed.
  33547. * @param onError Callback called on error.
  33548. * @hidden
  33549. */
  33550. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33551. /**
  33552. * Prepares the effect
  33553. * @hidden
  33554. */
  33555. _prepareEffect(): void;
  33556. private _getShaderCodeAndErrorLine;
  33557. private _processCompilationErrors;
  33558. /**
  33559. * Checks if the effect is supported. (Must be called after compilation)
  33560. */
  33561. get isSupported(): boolean;
  33562. /**
  33563. * Binds a texture to the engine to be used as output of the shader.
  33564. * @param channel Name of the output variable.
  33565. * @param texture Texture to bind.
  33566. * @hidden
  33567. */
  33568. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33569. /**
  33570. * Sets a texture on the engine to be used in the shader.
  33571. * @param channel Name of the sampler variable.
  33572. * @param texture Texture to set.
  33573. */
  33574. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33575. /**
  33576. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33577. * @param channel Name of the sampler variable.
  33578. * @param texture Texture to set.
  33579. */
  33580. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33581. /**
  33582. * Sets an array of textures on the engine to be used in the shader.
  33583. * @param channel Name of the variable.
  33584. * @param textures Textures to set.
  33585. */
  33586. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33587. /**
  33588. * 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)
  33589. * @param channel Name of the sampler variable.
  33590. * @param postProcess Post process to get the input texture from.
  33591. */
  33592. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33593. /**
  33594. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33595. * 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)
  33596. * @param channel Name of the sampler variable.
  33597. * @param postProcess Post process to get the output texture from.
  33598. */
  33599. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33600. /** @hidden */
  33601. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33602. /** @hidden */
  33603. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33604. /** @hidden */
  33605. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33606. /** @hidden */
  33607. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33608. /**
  33609. * Binds a buffer to a uniform.
  33610. * @param buffer Buffer to bind.
  33611. * @param name Name of the uniform variable to bind to.
  33612. */
  33613. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33614. /**
  33615. * Binds block to a uniform.
  33616. * @param blockName Name of the block to bind.
  33617. * @param index Index to bind.
  33618. */
  33619. bindUniformBlock(blockName: string, index: number): void;
  33620. /**
  33621. * Sets an interger value on a uniform variable.
  33622. * @param uniformName Name of the variable.
  33623. * @param value Value to be set.
  33624. * @returns this effect.
  33625. */
  33626. setInt(uniformName: string, value: number): Effect;
  33627. /**
  33628. * Sets an int array on a uniform variable.
  33629. * @param uniformName Name of the variable.
  33630. * @param array array to be set.
  33631. * @returns this effect.
  33632. */
  33633. setIntArray(uniformName: string, array: Int32Array): Effect;
  33634. /**
  33635. * 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)
  33636. * @param uniformName Name of the variable.
  33637. * @param array array to be set.
  33638. * @returns this effect.
  33639. */
  33640. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33641. /**
  33642. * 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)
  33643. * @param uniformName Name of the variable.
  33644. * @param array array to be set.
  33645. * @returns this effect.
  33646. */
  33647. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33648. /**
  33649. * 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)
  33650. * @param uniformName Name of the variable.
  33651. * @param array array to be set.
  33652. * @returns this effect.
  33653. */
  33654. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33655. /**
  33656. * Sets an float array on a uniform variable.
  33657. * @param uniformName Name of the variable.
  33658. * @param array array to be set.
  33659. * @returns this effect.
  33660. */
  33661. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33662. /**
  33663. * 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)
  33664. * @param uniformName Name of the variable.
  33665. * @param array array to be set.
  33666. * @returns this effect.
  33667. */
  33668. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33669. /**
  33670. * 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)
  33671. * @param uniformName Name of the variable.
  33672. * @param array array to be set.
  33673. * @returns this effect.
  33674. */
  33675. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33676. /**
  33677. * 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)
  33678. * @param uniformName Name of the variable.
  33679. * @param array array to be set.
  33680. * @returns this effect.
  33681. */
  33682. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33683. /**
  33684. * Sets an array on a uniform variable.
  33685. * @param uniformName Name of the variable.
  33686. * @param array array to be set.
  33687. * @returns this effect.
  33688. */
  33689. setArray(uniformName: string, array: number[]): Effect;
  33690. /**
  33691. * 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)
  33692. * @param uniformName Name of the variable.
  33693. * @param array array to be set.
  33694. * @returns this effect.
  33695. */
  33696. setArray2(uniformName: string, array: number[]): Effect;
  33697. /**
  33698. * 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)
  33699. * @param uniformName Name of the variable.
  33700. * @param array array to be set.
  33701. * @returns this effect.
  33702. */
  33703. setArray3(uniformName: string, array: number[]): Effect;
  33704. /**
  33705. * 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)
  33706. * @param uniformName Name of the variable.
  33707. * @param array array to be set.
  33708. * @returns this effect.
  33709. */
  33710. setArray4(uniformName: string, array: number[]): Effect;
  33711. /**
  33712. * Sets matrices on a uniform variable.
  33713. * @param uniformName Name of the variable.
  33714. * @param matrices matrices to be set.
  33715. * @returns this effect.
  33716. */
  33717. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33718. /**
  33719. * Sets matrix on a uniform variable.
  33720. * @param uniformName Name of the variable.
  33721. * @param matrix matrix to be set.
  33722. * @returns this effect.
  33723. */
  33724. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33725. /**
  33726. * 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)
  33727. * @param uniformName Name of the variable.
  33728. * @param matrix matrix to be set.
  33729. * @returns this effect.
  33730. */
  33731. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33732. /**
  33733. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33734. * @param uniformName Name of the variable.
  33735. * @param matrix matrix to be set.
  33736. * @returns this effect.
  33737. */
  33738. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33739. /**
  33740. * Sets a float on a uniform variable.
  33741. * @param uniformName Name of the variable.
  33742. * @param value value to be set.
  33743. * @returns this effect.
  33744. */
  33745. setFloat(uniformName: string, value: number): Effect;
  33746. /**
  33747. * Sets a boolean on a uniform variable.
  33748. * @param uniformName Name of the variable.
  33749. * @param bool value to be set.
  33750. * @returns this effect.
  33751. */
  33752. setBool(uniformName: string, bool: boolean): Effect;
  33753. /**
  33754. * Sets a Vector2 on a uniform variable.
  33755. * @param uniformName Name of the variable.
  33756. * @param vector2 vector2 to be set.
  33757. * @returns this effect.
  33758. */
  33759. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33760. /**
  33761. * Sets a float2 on a uniform variable.
  33762. * @param uniformName Name of the variable.
  33763. * @param x First float in float2.
  33764. * @param y Second float in float2.
  33765. * @returns this effect.
  33766. */
  33767. setFloat2(uniformName: string, x: number, y: number): Effect;
  33768. /**
  33769. * Sets a Vector3 on a uniform variable.
  33770. * @param uniformName Name of the variable.
  33771. * @param vector3 Value to be set.
  33772. * @returns this effect.
  33773. */
  33774. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33775. /**
  33776. * Sets a float3 on a uniform variable.
  33777. * @param uniformName Name of the variable.
  33778. * @param x First float in float3.
  33779. * @param y Second float in float3.
  33780. * @param z Third float in float3.
  33781. * @returns this effect.
  33782. */
  33783. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33784. /**
  33785. * Sets a Vector4 on a uniform variable.
  33786. * @param uniformName Name of the variable.
  33787. * @param vector4 Value to be set.
  33788. * @returns this effect.
  33789. */
  33790. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33791. /**
  33792. * Sets a float4 on a uniform variable.
  33793. * @param uniformName Name of the variable.
  33794. * @param x First float in float4.
  33795. * @param y Second float in float4.
  33796. * @param z Third float in float4.
  33797. * @param w Fourth float in float4.
  33798. * @returns this effect.
  33799. */
  33800. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33801. /**
  33802. * Sets a Color3 on a uniform variable.
  33803. * @param uniformName Name of the variable.
  33804. * @param color3 Value to be set.
  33805. * @returns this effect.
  33806. */
  33807. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33808. /**
  33809. * Sets a Color4 on a uniform variable.
  33810. * @param uniformName Name of the variable.
  33811. * @param color3 Value to be set.
  33812. * @param alpha Alpha value to be set.
  33813. * @returns this effect.
  33814. */
  33815. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33816. /**
  33817. * Sets a Color4 on a uniform variable
  33818. * @param uniformName defines the name of the variable
  33819. * @param color4 defines the value to be set
  33820. * @returns this effect.
  33821. */
  33822. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33823. /** Release all associated resources */
  33824. dispose(): void;
  33825. /**
  33826. * This function will add a new shader to the shader store
  33827. * @param name the name of the shader
  33828. * @param pixelShader optional pixel shader content
  33829. * @param vertexShader optional vertex shader content
  33830. */
  33831. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33832. /**
  33833. * Store of each shader (The can be looked up using effect.key)
  33834. */
  33835. static ShadersStore: {
  33836. [key: string]: string;
  33837. };
  33838. /**
  33839. * Store of each included file for a shader (The can be looked up using effect.key)
  33840. */
  33841. static IncludesShadersStore: {
  33842. [key: string]: string;
  33843. };
  33844. /**
  33845. * Resets the cache of effects.
  33846. */
  33847. static ResetCache(): void;
  33848. }
  33849. }
  33850. declare module BABYLON {
  33851. /**
  33852. * Interface used to describe the capabilities of the engine relatively to the current browser
  33853. */
  33854. export interface EngineCapabilities {
  33855. /** Maximum textures units per fragment shader */
  33856. maxTexturesImageUnits: number;
  33857. /** Maximum texture units per vertex shader */
  33858. maxVertexTextureImageUnits: number;
  33859. /** Maximum textures units in the entire pipeline */
  33860. maxCombinedTexturesImageUnits: number;
  33861. /** Maximum texture size */
  33862. maxTextureSize: number;
  33863. /** Maximum texture samples */
  33864. maxSamples?: number;
  33865. /** Maximum cube texture size */
  33866. maxCubemapTextureSize: number;
  33867. /** Maximum render texture size */
  33868. maxRenderTextureSize: number;
  33869. /** Maximum number of vertex attributes */
  33870. maxVertexAttribs: number;
  33871. /** Maximum number of varyings */
  33872. maxVaryingVectors: number;
  33873. /** Maximum number of uniforms per vertex shader */
  33874. maxVertexUniformVectors: number;
  33875. /** Maximum number of uniforms per fragment shader */
  33876. maxFragmentUniformVectors: number;
  33877. /** Defines if standard derivates (dx/dy) are supported */
  33878. standardDerivatives: boolean;
  33879. /** Defines if s3tc texture compression is supported */
  33880. s3tc?: WEBGL_compressed_texture_s3tc;
  33881. /** Defines if pvrtc texture compression is supported */
  33882. pvrtc: any;
  33883. /** Defines if etc1 texture compression is supported */
  33884. etc1: any;
  33885. /** Defines if etc2 texture compression is supported */
  33886. etc2: any;
  33887. /** Defines if astc texture compression is supported */
  33888. astc: any;
  33889. /** Defines if float textures are supported */
  33890. textureFloat: boolean;
  33891. /** Defines if vertex array objects are supported */
  33892. vertexArrayObject: boolean;
  33893. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33894. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33895. /** Gets the maximum level of anisotropy supported */
  33896. maxAnisotropy: number;
  33897. /** Defines if instancing is supported */
  33898. instancedArrays: boolean;
  33899. /** Defines if 32 bits indices are supported */
  33900. uintIndices: boolean;
  33901. /** Defines if high precision shaders are supported */
  33902. highPrecisionShaderSupported: boolean;
  33903. /** Defines if depth reading in the fragment shader is supported */
  33904. fragmentDepthSupported: boolean;
  33905. /** Defines if float texture linear filtering is supported*/
  33906. textureFloatLinearFiltering: boolean;
  33907. /** Defines if rendering to float textures is supported */
  33908. textureFloatRender: boolean;
  33909. /** Defines if half float textures are supported*/
  33910. textureHalfFloat: boolean;
  33911. /** Defines if half float texture linear filtering is supported*/
  33912. textureHalfFloatLinearFiltering: boolean;
  33913. /** Defines if rendering to half float textures is supported */
  33914. textureHalfFloatRender: boolean;
  33915. /** Defines if textureLOD shader command is supported */
  33916. textureLOD: boolean;
  33917. /** Defines if draw buffers extension is supported */
  33918. drawBuffersExtension: boolean;
  33919. /** Defines if depth textures are supported */
  33920. depthTextureExtension: boolean;
  33921. /** Defines if float color buffer are supported */
  33922. colorBufferFloat: boolean;
  33923. /** Gets disjoint timer query extension (null if not supported) */
  33924. timerQuery?: EXT_disjoint_timer_query;
  33925. /** Defines if timestamp can be used with timer query */
  33926. canUseTimestampForTimerQuery: boolean;
  33927. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33928. multiview?: any;
  33929. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33930. oculusMultiview?: any;
  33931. /** Function used to let the system compiles shaders in background */
  33932. parallelShaderCompile?: {
  33933. COMPLETION_STATUS_KHR: number;
  33934. };
  33935. /** Max number of texture samples for MSAA */
  33936. maxMSAASamples: number;
  33937. /** Defines if the blend min max extension is supported */
  33938. blendMinMax: boolean;
  33939. }
  33940. }
  33941. declare module BABYLON {
  33942. /**
  33943. * @hidden
  33944. **/
  33945. export class DepthCullingState {
  33946. private _isDepthTestDirty;
  33947. private _isDepthMaskDirty;
  33948. private _isDepthFuncDirty;
  33949. private _isCullFaceDirty;
  33950. private _isCullDirty;
  33951. private _isZOffsetDirty;
  33952. private _isFrontFaceDirty;
  33953. private _depthTest;
  33954. private _depthMask;
  33955. private _depthFunc;
  33956. private _cull;
  33957. private _cullFace;
  33958. private _zOffset;
  33959. private _frontFace;
  33960. /**
  33961. * Initializes the state.
  33962. */
  33963. constructor();
  33964. get isDirty(): boolean;
  33965. get zOffset(): number;
  33966. set zOffset(value: number);
  33967. get cullFace(): Nullable<number>;
  33968. set cullFace(value: Nullable<number>);
  33969. get cull(): Nullable<boolean>;
  33970. set cull(value: Nullable<boolean>);
  33971. get depthFunc(): Nullable<number>;
  33972. set depthFunc(value: Nullable<number>);
  33973. get depthMask(): boolean;
  33974. set depthMask(value: boolean);
  33975. get depthTest(): boolean;
  33976. set depthTest(value: boolean);
  33977. get frontFace(): Nullable<number>;
  33978. set frontFace(value: Nullable<number>);
  33979. reset(): void;
  33980. apply(gl: WebGLRenderingContext): void;
  33981. }
  33982. }
  33983. declare module BABYLON {
  33984. /**
  33985. * @hidden
  33986. **/
  33987. export class StencilState {
  33988. /** 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 */
  33989. static readonly ALWAYS: number;
  33990. /** Passed to stencilOperation to specify that stencil value must be kept */
  33991. static readonly KEEP: number;
  33992. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33993. static readonly REPLACE: number;
  33994. private _isStencilTestDirty;
  33995. private _isStencilMaskDirty;
  33996. private _isStencilFuncDirty;
  33997. private _isStencilOpDirty;
  33998. private _stencilTest;
  33999. private _stencilMask;
  34000. private _stencilFunc;
  34001. private _stencilFuncRef;
  34002. private _stencilFuncMask;
  34003. private _stencilOpStencilFail;
  34004. private _stencilOpDepthFail;
  34005. private _stencilOpStencilDepthPass;
  34006. get isDirty(): boolean;
  34007. get stencilFunc(): number;
  34008. set stencilFunc(value: number);
  34009. get stencilFuncRef(): number;
  34010. set stencilFuncRef(value: number);
  34011. get stencilFuncMask(): number;
  34012. set stencilFuncMask(value: number);
  34013. get stencilOpStencilFail(): number;
  34014. set stencilOpStencilFail(value: number);
  34015. get stencilOpDepthFail(): number;
  34016. set stencilOpDepthFail(value: number);
  34017. get stencilOpStencilDepthPass(): number;
  34018. set stencilOpStencilDepthPass(value: number);
  34019. get stencilMask(): number;
  34020. set stencilMask(value: number);
  34021. get stencilTest(): boolean;
  34022. set stencilTest(value: boolean);
  34023. constructor();
  34024. reset(): void;
  34025. apply(gl: WebGLRenderingContext): void;
  34026. }
  34027. }
  34028. declare module BABYLON {
  34029. /**
  34030. * @hidden
  34031. **/
  34032. export class AlphaState {
  34033. private _isAlphaBlendDirty;
  34034. private _isBlendFunctionParametersDirty;
  34035. private _isBlendEquationParametersDirty;
  34036. private _isBlendConstantsDirty;
  34037. private _alphaBlend;
  34038. private _blendFunctionParameters;
  34039. private _blendEquationParameters;
  34040. private _blendConstants;
  34041. /**
  34042. * Initializes the state.
  34043. */
  34044. constructor();
  34045. get isDirty(): boolean;
  34046. get alphaBlend(): boolean;
  34047. set alphaBlend(value: boolean);
  34048. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34049. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34050. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34051. reset(): void;
  34052. apply(gl: WebGLRenderingContext): void;
  34053. }
  34054. }
  34055. declare module BABYLON {
  34056. /** @hidden */
  34057. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34058. attributeProcessor(attribute: string): string;
  34059. varyingProcessor(varying: string, isFragment: boolean): string;
  34060. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34061. }
  34062. }
  34063. declare module BABYLON {
  34064. /**
  34065. * Interface for attribute information associated with buffer instanciation
  34066. */
  34067. export interface InstancingAttributeInfo {
  34068. /**
  34069. * Name of the GLSL attribute
  34070. * if attribute index is not specified, this is used to retrieve the index from the effect
  34071. */
  34072. attributeName: string;
  34073. /**
  34074. * Index/offset of the attribute in the vertex shader
  34075. * if not specified, this will be computes from the name.
  34076. */
  34077. index?: number;
  34078. /**
  34079. * size of the attribute, 1, 2, 3 or 4
  34080. */
  34081. attributeSize: number;
  34082. /**
  34083. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34084. */
  34085. offset: number;
  34086. /**
  34087. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34088. * default to 1
  34089. */
  34090. divisor?: number;
  34091. /**
  34092. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34093. * default is FLOAT
  34094. */
  34095. attributeType?: number;
  34096. /**
  34097. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34098. */
  34099. normalized?: boolean;
  34100. }
  34101. }
  34102. declare module BABYLON {
  34103. interface ThinEngine {
  34104. /**
  34105. * Update a video texture
  34106. * @param texture defines the texture to update
  34107. * @param video defines the video element to use
  34108. * @param invertY defines if data must be stored with Y axis inverted
  34109. */
  34110. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34111. }
  34112. }
  34113. declare module BABYLON {
  34114. /**
  34115. * Settings for finer control over video usage
  34116. */
  34117. export interface VideoTextureSettings {
  34118. /**
  34119. * Applies `autoplay` to video, if specified
  34120. */
  34121. autoPlay?: boolean;
  34122. /**
  34123. * Applies `loop` to video, if specified
  34124. */
  34125. loop?: boolean;
  34126. /**
  34127. * Automatically updates internal texture from video at every frame in the render loop
  34128. */
  34129. autoUpdateTexture: boolean;
  34130. /**
  34131. * Image src displayed during the video loading or until the user interacts with the video.
  34132. */
  34133. poster?: string;
  34134. }
  34135. /**
  34136. * If you want to display a video in your scene, this is the special texture for that.
  34137. * This special texture works similar to other textures, with the exception of a few parameters.
  34138. * @see https://doc.babylonjs.com/how_to/video_texture
  34139. */
  34140. export class VideoTexture extends Texture {
  34141. /**
  34142. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34143. */
  34144. readonly autoUpdateTexture: boolean;
  34145. /**
  34146. * The video instance used by the texture internally
  34147. */
  34148. readonly video: HTMLVideoElement;
  34149. private _onUserActionRequestedObservable;
  34150. /**
  34151. * Event triggerd when a dom action is required by the user to play the video.
  34152. * This happens due to recent changes in browser policies preventing video to auto start.
  34153. */
  34154. get onUserActionRequestedObservable(): Observable<Texture>;
  34155. private _generateMipMaps;
  34156. private _stillImageCaptured;
  34157. private _displayingPosterTexture;
  34158. private _settings;
  34159. private _createInternalTextureOnEvent;
  34160. private _frameId;
  34161. private _currentSrc;
  34162. /**
  34163. * Creates a video texture.
  34164. * If you want to display a video in your scene, this is the special texture for that.
  34165. * This special texture works similar to other textures, with the exception of a few parameters.
  34166. * @see https://doc.babylonjs.com/how_to/video_texture
  34167. * @param name optional name, will detect from video source, if not defined
  34168. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34169. * @param scene is obviously the current scene.
  34170. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34171. * @param invertY is false by default but can be used to invert video on Y axis
  34172. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34173. * @param settings allows finer control over video usage
  34174. */
  34175. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34176. private _getName;
  34177. private _getVideo;
  34178. private _createInternalTexture;
  34179. private reset;
  34180. /**
  34181. * @hidden Internal method to initiate `update`.
  34182. */
  34183. _rebuild(): void;
  34184. /**
  34185. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34186. */
  34187. update(): void;
  34188. /**
  34189. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34190. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34191. */
  34192. updateTexture(isVisible: boolean): void;
  34193. protected _updateInternalTexture: () => void;
  34194. /**
  34195. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34196. * @param url New url.
  34197. */
  34198. updateURL(url: string): void;
  34199. /**
  34200. * Clones the texture.
  34201. * @returns the cloned texture
  34202. */
  34203. clone(): VideoTexture;
  34204. /**
  34205. * Dispose the texture and release its associated resources.
  34206. */
  34207. dispose(): void;
  34208. /**
  34209. * Creates a video texture straight from a stream.
  34210. * @param scene Define the scene the texture should be created in
  34211. * @param stream Define the stream the texture should be created from
  34212. * @returns The created video texture as a promise
  34213. */
  34214. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34215. /**
  34216. * Creates a video texture straight from your WebCam video feed.
  34217. * @param scene Define the scene the texture should be created in
  34218. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34219. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34220. * @returns The created video texture as a promise
  34221. */
  34222. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34223. minWidth: number;
  34224. maxWidth: number;
  34225. minHeight: number;
  34226. maxHeight: number;
  34227. deviceId: string;
  34228. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34229. /**
  34230. * Creates a video texture straight from your WebCam video feed.
  34231. * @param scene Define the scene the texture should be created in
  34232. * @param onReady Define a callback to triggered once the texture will be ready
  34233. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34234. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34235. */
  34236. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34237. minWidth: number;
  34238. maxWidth: number;
  34239. minHeight: number;
  34240. maxHeight: number;
  34241. deviceId: string;
  34242. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34243. }
  34244. }
  34245. declare module BABYLON {
  34246. /**
  34247. * Defines the interface used by objects working like Scene
  34248. * @hidden
  34249. */
  34250. export interface ISceneLike {
  34251. _addPendingData(data: any): void;
  34252. _removePendingData(data: any): void;
  34253. offlineProvider: IOfflineProvider;
  34254. }
  34255. /** Interface defining initialization parameters for Engine class */
  34256. export interface EngineOptions extends WebGLContextAttributes {
  34257. /**
  34258. * Defines if the engine should no exceed a specified device ratio
  34259. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34260. */
  34261. limitDeviceRatio?: number;
  34262. /**
  34263. * Defines if webvr should be enabled automatically
  34264. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34265. */
  34266. autoEnableWebVR?: boolean;
  34267. /**
  34268. * Defines if webgl2 should be turned off even if supported
  34269. * @see http://doc.babylonjs.com/features/webgl2
  34270. */
  34271. disableWebGL2Support?: boolean;
  34272. /**
  34273. * Defines if webaudio should be initialized as well
  34274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34275. */
  34276. audioEngine?: boolean;
  34277. /**
  34278. * Defines if animations should run using a deterministic lock step
  34279. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34280. */
  34281. deterministicLockstep?: boolean;
  34282. /** Defines the maximum steps to use with deterministic lock step mode */
  34283. lockstepMaxSteps?: number;
  34284. /** Defines the seconds between each deterministic lock step */
  34285. timeStep?: number;
  34286. /**
  34287. * Defines that engine should ignore context lost events
  34288. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34289. */
  34290. doNotHandleContextLost?: boolean;
  34291. /**
  34292. * Defines that engine should ignore modifying touch action attribute and style
  34293. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34294. */
  34295. doNotHandleTouchAction?: boolean;
  34296. /**
  34297. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34298. */
  34299. useHighPrecisionFloats?: boolean;
  34300. /**
  34301. * Make the canvas XR Compatible for XR sessions
  34302. */
  34303. xrCompatible?: boolean;
  34304. }
  34305. /**
  34306. * The base engine class (root of all engines)
  34307. */
  34308. export class ThinEngine {
  34309. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34310. static ExceptionList: ({
  34311. key: string;
  34312. capture: string;
  34313. captureConstraint: number;
  34314. targets: string[];
  34315. } | {
  34316. key: string;
  34317. capture: null;
  34318. captureConstraint: null;
  34319. targets: string[];
  34320. })[];
  34321. /** @hidden */
  34322. static _TextureLoaders: IInternalTextureLoader[];
  34323. /**
  34324. * Returns the current npm package of the sdk
  34325. */
  34326. static get NpmPackage(): string;
  34327. /**
  34328. * Returns the current version of the framework
  34329. */
  34330. static get Version(): string;
  34331. /**
  34332. * Returns a string describing the current engine
  34333. */
  34334. get description(): string;
  34335. /**
  34336. * Gets or sets the epsilon value used by collision engine
  34337. */
  34338. static CollisionsEpsilon: number;
  34339. /**
  34340. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34341. */
  34342. static get ShadersRepository(): string;
  34343. static set ShadersRepository(value: string);
  34344. /** @hidden */
  34345. _shaderProcessor: IShaderProcessor;
  34346. /**
  34347. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34348. */
  34349. forcePOTTextures: boolean;
  34350. /**
  34351. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34352. */
  34353. isFullscreen: boolean;
  34354. /**
  34355. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34356. */
  34357. cullBackFaces: boolean;
  34358. /**
  34359. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34360. */
  34361. renderEvenInBackground: boolean;
  34362. /**
  34363. * Gets or sets a boolean indicating that cache can be kept between frames
  34364. */
  34365. preventCacheWipeBetweenFrames: boolean;
  34366. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34367. validateShaderPrograms: boolean;
  34368. /**
  34369. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34370. * This can provide greater z depth for distant objects.
  34371. */
  34372. useReverseDepthBuffer: boolean;
  34373. /**
  34374. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34375. */
  34376. disableUniformBuffers: boolean;
  34377. /** @hidden */
  34378. _uniformBuffers: UniformBuffer[];
  34379. /**
  34380. * Gets a boolean indicating that the engine supports uniform buffers
  34381. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34382. */
  34383. get supportsUniformBuffers(): boolean;
  34384. /** @hidden */
  34385. _gl: WebGLRenderingContext;
  34386. /** @hidden */
  34387. _webGLVersion: number;
  34388. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34389. protected _windowIsBackground: boolean;
  34390. protected _creationOptions: EngineOptions;
  34391. protected _highPrecisionShadersAllowed: boolean;
  34392. /** @hidden */
  34393. get _shouldUseHighPrecisionShader(): boolean;
  34394. /**
  34395. * Gets a boolean indicating that only power of 2 textures are supported
  34396. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34397. */
  34398. get needPOTTextures(): boolean;
  34399. /** @hidden */
  34400. _badOS: boolean;
  34401. /** @hidden */
  34402. _badDesktopOS: boolean;
  34403. private _hardwareScalingLevel;
  34404. /** @hidden */
  34405. _caps: EngineCapabilities;
  34406. private _isStencilEnable;
  34407. private _glVersion;
  34408. private _glRenderer;
  34409. private _glVendor;
  34410. /** @hidden */
  34411. _videoTextureSupported: boolean;
  34412. protected _renderingQueueLaunched: boolean;
  34413. protected _activeRenderLoops: (() => void)[];
  34414. /**
  34415. * Observable signaled when a context lost event is raised
  34416. */
  34417. onContextLostObservable: Observable<ThinEngine>;
  34418. /**
  34419. * Observable signaled when a context restored event is raised
  34420. */
  34421. onContextRestoredObservable: Observable<ThinEngine>;
  34422. private _onContextLost;
  34423. private _onContextRestored;
  34424. protected _contextWasLost: boolean;
  34425. /** @hidden */
  34426. _doNotHandleContextLost: boolean;
  34427. /**
  34428. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34429. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34430. */
  34431. get doNotHandleContextLost(): boolean;
  34432. set doNotHandleContextLost(value: boolean);
  34433. /**
  34434. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34435. */
  34436. disableVertexArrayObjects: boolean;
  34437. /** @hidden */
  34438. protected _colorWrite: boolean;
  34439. /** @hidden */
  34440. protected _colorWriteChanged: boolean;
  34441. /** @hidden */
  34442. protected _depthCullingState: DepthCullingState;
  34443. /** @hidden */
  34444. protected _stencilState: StencilState;
  34445. /** @hidden */
  34446. _alphaState: AlphaState;
  34447. /** @hidden */
  34448. _alphaMode: number;
  34449. /** @hidden */
  34450. _alphaEquation: number;
  34451. /** @hidden */
  34452. _internalTexturesCache: InternalTexture[];
  34453. /** @hidden */
  34454. protected _activeChannel: number;
  34455. private _currentTextureChannel;
  34456. /** @hidden */
  34457. protected _boundTexturesCache: {
  34458. [key: string]: Nullable<InternalTexture>;
  34459. };
  34460. /** @hidden */
  34461. protected _currentEffect: Nullable<Effect>;
  34462. /** @hidden */
  34463. protected _currentProgram: Nullable<WebGLProgram>;
  34464. private _compiledEffects;
  34465. private _vertexAttribArraysEnabled;
  34466. /** @hidden */
  34467. protected _cachedViewport: Nullable<IViewportLike>;
  34468. private _cachedVertexArrayObject;
  34469. /** @hidden */
  34470. protected _cachedVertexBuffers: any;
  34471. /** @hidden */
  34472. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34473. /** @hidden */
  34474. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34475. /** @hidden */
  34476. _currentRenderTarget: Nullable<InternalTexture>;
  34477. private _uintIndicesCurrentlySet;
  34478. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34479. /** @hidden */
  34480. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34481. /** @hidden */
  34482. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34483. private _currentBufferPointers;
  34484. private _currentInstanceLocations;
  34485. private _currentInstanceBuffers;
  34486. private _textureUnits;
  34487. /** @hidden */
  34488. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34489. /** @hidden */
  34490. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34491. /** @hidden */
  34492. _boundRenderFunction: any;
  34493. private _vaoRecordInProgress;
  34494. private _mustWipeVertexAttributes;
  34495. private _emptyTexture;
  34496. private _emptyCubeTexture;
  34497. private _emptyTexture3D;
  34498. private _emptyTexture2DArray;
  34499. /** @hidden */
  34500. _frameHandler: number;
  34501. private _nextFreeTextureSlots;
  34502. private _maxSimultaneousTextures;
  34503. private _activeRequests;
  34504. /** @hidden */
  34505. _transformTextureUrl: Nullable<(url: string) => string>;
  34506. protected get _supportsHardwareTextureRescaling(): boolean;
  34507. private _framebufferDimensionsObject;
  34508. /**
  34509. * sets the object from which width and height will be taken from when getting render width and height
  34510. * Will fallback to the gl object
  34511. * @param dimensions the framebuffer width and height that will be used.
  34512. */
  34513. set framebufferDimensionsObject(dimensions: Nullable<{
  34514. framebufferWidth: number;
  34515. framebufferHeight: number;
  34516. }>);
  34517. /**
  34518. * Gets the current viewport
  34519. */
  34520. get currentViewport(): Nullable<IViewportLike>;
  34521. /**
  34522. * Gets the default empty texture
  34523. */
  34524. get emptyTexture(): InternalTexture;
  34525. /**
  34526. * Gets the default empty 3D texture
  34527. */
  34528. get emptyTexture3D(): InternalTexture;
  34529. /**
  34530. * Gets the default empty 2D array texture
  34531. */
  34532. get emptyTexture2DArray(): InternalTexture;
  34533. /**
  34534. * Gets the default empty cube texture
  34535. */
  34536. get emptyCubeTexture(): InternalTexture;
  34537. /**
  34538. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34539. */
  34540. readonly premultipliedAlpha: boolean;
  34541. /**
  34542. * Observable event triggered before each texture is initialized
  34543. */
  34544. onBeforeTextureInitObservable: Observable<Texture>;
  34545. /**
  34546. * Creates a new engine
  34547. * @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
  34548. * @param antialias defines enable antialiasing (default: false)
  34549. * @param options defines further options to be sent to the getContext() function
  34550. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34551. */
  34552. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34553. private _rebuildInternalTextures;
  34554. private _rebuildEffects;
  34555. /**
  34556. * Gets a boolean indicating if all created effects are ready
  34557. * @returns true if all effects are ready
  34558. */
  34559. areAllEffectsReady(): boolean;
  34560. protected _rebuildBuffers(): void;
  34561. protected _initGLContext(): void;
  34562. /**
  34563. * Gets version of the current webGL context
  34564. */
  34565. get webGLVersion(): number;
  34566. /**
  34567. * Gets a string idenfifying the name of the class
  34568. * @returns "Engine" string
  34569. */
  34570. getClassName(): string;
  34571. /**
  34572. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34573. */
  34574. get isStencilEnable(): boolean;
  34575. /** @hidden */
  34576. _prepareWorkingCanvas(): void;
  34577. /**
  34578. * Reset the texture cache to empty state
  34579. */
  34580. resetTextureCache(): void;
  34581. /**
  34582. * Gets an object containing information about the current webGL context
  34583. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34584. */
  34585. getGlInfo(): {
  34586. vendor: string;
  34587. renderer: string;
  34588. version: string;
  34589. };
  34590. /**
  34591. * Defines the hardware scaling level.
  34592. * By default the hardware scaling level is computed from the window device ratio.
  34593. * 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.
  34594. * @param level defines the level to use
  34595. */
  34596. setHardwareScalingLevel(level: number): void;
  34597. /**
  34598. * Gets the current hardware scaling level.
  34599. * By default the hardware scaling level is computed from the window device ratio.
  34600. * 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.
  34601. * @returns a number indicating the current hardware scaling level
  34602. */
  34603. getHardwareScalingLevel(): number;
  34604. /**
  34605. * Gets the list of loaded textures
  34606. * @returns an array containing all loaded textures
  34607. */
  34608. getLoadedTexturesCache(): InternalTexture[];
  34609. /**
  34610. * Gets the object containing all engine capabilities
  34611. * @returns the EngineCapabilities object
  34612. */
  34613. getCaps(): EngineCapabilities;
  34614. /**
  34615. * stop executing a render loop function and remove it from the execution array
  34616. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34617. */
  34618. stopRenderLoop(renderFunction?: () => void): void;
  34619. /** @hidden */
  34620. _renderLoop(): void;
  34621. /**
  34622. * Gets the HTML canvas attached with the current webGL context
  34623. * @returns a HTML canvas
  34624. */
  34625. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34626. /**
  34627. * Gets host window
  34628. * @returns the host window object
  34629. */
  34630. getHostWindow(): Nullable<Window>;
  34631. /**
  34632. * Gets the current render width
  34633. * @param useScreen defines if screen size must be used (or the current render target if any)
  34634. * @returns a number defining the current render width
  34635. */
  34636. getRenderWidth(useScreen?: boolean): number;
  34637. /**
  34638. * Gets the current render height
  34639. * @param useScreen defines if screen size must be used (or the current render target if any)
  34640. * @returns a number defining the current render height
  34641. */
  34642. getRenderHeight(useScreen?: boolean): number;
  34643. /**
  34644. * Can be used to override the current requestAnimationFrame requester.
  34645. * @hidden
  34646. */
  34647. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34648. /**
  34649. * Register and execute a render loop. The engine can have more than one render function
  34650. * @param renderFunction defines the function to continuously execute
  34651. */
  34652. runRenderLoop(renderFunction: () => void): void;
  34653. /**
  34654. * Clear the current render buffer or the current render target (if any is set up)
  34655. * @param color defines the color to use
  34656. * @param backBuffer defines if the back buffer must be cleared
  34657. * @param depth defines if the depth buffer must be cleared
  34658. * @param stencil defines if the stencil buffer must be cleared
  34659. */
  34660. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34661. private _viewportCached;
  34662. /** @hidden */
  34663. _viewport(x: number, y: number, width: number, height: number): void;
  34664. /**
  34665. * Set the WebGL's viewport
  34666. * @param viewport defines the viewport element to be used
  34667. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34668. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34669. */
  34670. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34671. /**
  34672. * Begin a new frame
  34673. */
  34674. beginFrame(): void;
  34675. /**
  34676. * Enf the current frame
  34677. */
  34678. endFrame(): void;
  34679. /**
  34680. * Resize the view according to the canvas' size
  34681. */
  34682. resize(): void;
  34683. /**
  34684. * Force a specific size of the canvas
  34685. * @param width defines the new canvas' width
  34686. * @param height defines the new canvas' height
  34687. */
  34688. setSize(width: number, height: number): void;
  34689. /**
  34690. * Binds the frame buffer to the specified texture.
  34691. * @param texture The texture to render to or null for the default canvas
  34692. * @param faceIndex The face of the texture to render to in case of cube texture
  34693. * @param requiredWidth The width of the target to render to
  34694. * @param requiredHeight The height of the target to render to
  34695. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34696. * @param lodLevel defines the lod level to bind to the frame buffer
  34697. * @param layer defines the 2d array index to bind to frame buffer to
  34698. */
  34699. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34700. /** @hidden */
  34701. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34702. /**
  34703. * Unbind the current render target texture from the webGL context
  34704. * @param texture defines the render target texture to unbind
  34705. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34706. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34707. */
  34708. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34709. /**
  34710. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34711. */
  34712. flushFramebuffer(): void;
  34713. /**
  34714. * Unbind the current render target and bind the default framebuffer
  34715. */
  34716. restoreDefaultFramebuffer(): void;
  34717. /** @hidden */
  34718. protected _resetVertexBufferBinding(): void;
  34719. /**
  34720. * Creates a vertex buffer
  34721. * @param data the data for the vertex buffer
  34722. * @returns the new WebGL static buffer
  34723. */
  34724. createVertexBuffer(data: DataArray): DataBuffer;
  34725. private _createVertexBuffer;
  34726. /**
  34727. * Creates a dynamic vertex buffer
  34728. * @param data the data for the dynamic vertex buffer
  34729. * @returns the new WebGL dynamic buffer
  34730. */
  34731. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34732. protected _resetIndexBufferBinding(): void;
  34733. /**
  34734. * Creates a new index buffer
  34735. * @param indices defines the content of the index buffer
  34736. * @param updatable defines if the index buffer must be updatable
  34737. * @returns a new webGL buffer
  34738. */
  34739. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34740. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34741. /**
  34742. * Bind a webGL buffer to the webGL context
  34743. * @param buffer defines the buffer to bind
  34744. */
  34745. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34746. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34747. private bindBuffer;
  34748. /**
  34749. * update the bound buffer with the given data
  34750. * @param data defines the data to update
  34751. */
  34752. updateArrayBuffer(data: Float32Array): void;
  34753. private _vertexAttribPointer;
  34754. /** @hidden */
  34755. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34756. private _bindVertexBuffersAttributes;
  34757. /**
  34758. * Records a vertex array object
  34759. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34760. * @param vertexBuffers defines the list of vertex buffers to store
  34761. * @param indexBuffer defines the index buffer to store
  34762. * @param effect defines the effect to store
  34763. * @returns the new vertex array object
  34764. */
  34765. recordVertexArrayObject(vertexBuffers: {
  34766. [key: string]: VertexBuffer;
  34767. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34768. /**
  34769. * Bind a specific vertex array object
  34770. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34771. * @param vertexArrayObject defines the vertex array object to bind
  34772. * @param indexBuffer defines the index buffer to bind
  34773. */
  34774. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34775. /**
  34776. * Bind webGl buffers directly to the webGL context
  34777. * @param vertexBuffer defines the vertex buffer to bind
  34778. * @param indexBuffer defines the index buffer to bind
  34779. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34780. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34781. * @param effect defines the effect associated with the vertex buffer
  34782. */
  34783. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34784. private _unbindVertexArrayObject;
  34785. /**
  34786. * Bind a list of vertex buffers to the webGL context
  34787. * @param vertexBuffers defines the list of vertex buffers to bind
  34788. * @param indexBuffer defines the index buffer to bind
  34789. * @param effect defines the effect associated with the vertex buffers
  34790. */
  34791. bindBuffers(vertexBuffers: {
  34792. [key: string]: Nullable<VertexBuffer>;
  34793. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34794. /**
  34795. * Unbind all instance attributes
  34796. */
  34797. unbindInstanceAttributes(): void;
  34798. /**
  34799. * Release and free the memory of a vertex array object
  34800. * @param vao defines the vertex array object to delete
  34801. */
  34802. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34803. /** @hidden */
  34804. _releaseBuffer(buffer: DataBuffer): boolean;
  34805. protected _deleteBuffer(buffer: DataBuffer): void;
  34806. /**
  34807. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34808. * @param instancesBuffer defines the webGL buffer to update and bind
  34809. * @param data defines the data to store in the buffer
  34810. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34811. */
  34812. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34813. /**
  34814. * Bind the content of a webGL buffer used with instantiation
  34815. * @param instancesBuffer defines the webGL buffer to bind
  34816. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34817. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34818. */
  34819. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34820. /**
  34821. * Disable the instance attribute corresponding to the name in parameter
  34822. * @param name defines the name of the attribute to disable
  34823. */
  34824. disableInstanceAttributeByName(name: string): void;
  34825. /**
  34826. * Disable the instance attribute corresponding to the location in parameter
  34827. * @param attributeLocation defines the attribute location of the attribute to disable
  34828. */
  34829. disableInstanceAttribute(attributeLocation: number): void;
  34830. /**
  34831. * Disable the attribute corresponding to the location in parameter
  34832. * @param attributeLocation defines the attribute location of the attribute to disable
  34833. */
  34834. disableAttributeByIndex(attributeLocation: number): void;
  34835. /**
  34836. * Send a draw order
  34837. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34838. * @param indexStart defines the starting index
  34839. * @param indexCount defines the number of index to draw
  34840. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34841. */
  34842. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34843. /**
  34844. * Draw a list of points
  34845. * @param verticesStart defines the index of first vertex to draw
  34846. * @param verticesCount defines the count of vertices to draw
  34847. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34848. */
  34849. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34850. /**
  34851. * Draw a list of unindexed primitives
  34852. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34853. * @param verticesStart defines the index of first vertex to draw
  34854. * @param verticesCount defines the count of vertices to draw
  34855. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34856. */
  34857. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34858. /**
  34859. * Draw a list of indexed primitives
  34860. * @param fillMode defines the primitive to use
  34861. * @param indexStart defines the starting index
  34862. * @param indexCount defines the number of index to draw
  34863. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34864. */
  34865. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34866. /**
  34867. * Draw a list of unindexed primitives
  34868. * @param fillMode defines the primitive to use
  34869. * @param verticesStart defines the index of first vertex to draw
  34870. * @param verticesCount defines the count of vertices to draw
  34871. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34872. */
  34873. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34874. private _drawMode;
  34875. /** @hidden */
  34876. protected _reportDrawCall(): void;
  34877. /** @hidden */
  34878. _releaseEffect(effect: Effect): void;
  34879. /** @hidden */
  34880. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34881. /**
  34882. * Create a new effect (used to store vertex/fragment shaders)
  34883. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34884. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34885. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34886. * @param samplers defines an array of string used to represent textures
  34887. * @param defines defines the string containing the defines to use to compile the shaders
  34888. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34889. * @param onCompiled defines a function to call when the effect creation is successful
  34890. * @param onError defines a function to call when the effect creation has failed
  34891. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34892. * @returns the new Effect
  34893. */
  34894. 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;
  34895. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34896. private _compileShader;
  34897. private _compileRawShader;
  34898. /** @hidden */
  34899. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34900. /**
  34901. * Directly creates a webGL program
  34902. * @param pipelineContext defines the pipeline context to attach to
  34903. * @param vertexCode defines the vertex shader code to use
  34904. * @param fragmentCode defines the fragment shader code to use
  34905. * @param context defines the webGL context to use (if not set, the current one will be used)
  34906. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34907. * @returns the new webGL program
  34908. */
  34909. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34910. /**
  34911. * Creates a webGL program
  34912. * @param pipelineContext defines the pipeline context to attach to
  34913. * @param vertexCode defines the vertex shader code to use
  34914. * @param fragmentCode defines the fragment shader code to use
  34915. * @param defines defines the string containing the defines to use to compile the shaders
  34916. * @param context defines the webGL context to use (if not set, the current one will be used)
  34917. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34918. * @returns the new webGL program
  34919. */
  34920. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34921. /**
  34922. * Creates a new pipeline context
  34923. * @returns the new pipeline
  34924. */
  34925. createPipelineContext(): IPipelineContext;
  34926. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34927. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34928. /** @hidden */
  34929. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34930. /** @hidden */
  34931. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34932. /** @hidden */
  34933. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34934. /**
  34935. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34936. * @param pipelineContext defines the pipeline context to use
  34937. * @param uniformsNames defines the list of uniform names
  34938. * @returns an array of webGL uniform locations
  34939. */
  34940. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34941. /**
  34942. * Gets the lsit of active attributes for a given webGL program
  34943. * @param pipelineContext defines the pipeline context to use
  34944. * @param attributesNames defines the list of attribute names to get
  34945. * @returns an array of indices indicating the offset of each attribute
  34946. */
  34947. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34948. /**
  34949. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34950. * @param effect defines the effect to activate
  34951. */
  34952. enableEffect(effect: Nullable<Effect>): void;
  34953. /**
  34954. * Set the value of an uniform to a number (int)
  34955. * @param uniform defines the webGL uniform location where to store the value
  34956. * @param value defines the int number to store
  34957. */
  34958. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34959. /**
  34960. * Set the value of an uniform to an array of int32
  34961. * @param uniform defines the webGL uniform location where to store the value
  34962. * @param array defines the array of int32 to store
  34963. */
  34964. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34965. /**
  34966. * Set the value of an uniform to an array of int32 (stored as vec2)
  34967. * @param uniform defines the webGL uniform location where to store the value
  34968. * @param array defines the array of int32 to store
  34969. */
  34970. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34971. /**
  34972. * Set the value of an uniform to an array of int32 (stored as vec3)
  34973. * @param uniform defines the webGL uniform location where to store the value
  34974. * @param array defines the array of int32 to store
  34975. */
  34976. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34977. /**
  34978. * Set the value of an uniform to an array of int32 (stored as vec4)
  34979. * @param uniform defines the webGL uniform location where to store the value
  34980. * @param array defines the array of int32 to store
  34981. */
  34982. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34983. /**
  34984. * Set the value of an uniform to an array of number
  34985. * @param uniform defines the webGL uniform location where to store the value
  34986. * @param array defines the array of number to store
  34987. */
  34988. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34989. /**
  34990. * Set the value of an uniform to an array of number (stored as vec2)
  34991. * @param uniform defines the webGL uniform location where to store the value
  34992. * @param array defines the array of number to store
  34993. */
  34994. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34995. /**
  34996. * Set the value of an uniform to an array of number (stored as vec3)
  34997. * @param uniform defines the webGL uniform location where to store the value
  34998. * @param array defines the array of number to store
  34999. */
  35000. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35001. /**
  35002. * Set the value of an uniform to an array of number (stored as vec4)
  35003. * @param uniform defines the webGL uniform location where to store the value
  35004. * @param array defines the array of number to store
  35005. */
  35006. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35007. /**
  35008. * Set the value of an uniform to an array of float32 (stored as matrices)
  35009. * @param uniform defines the webGL uniform location where to store the value
  35010. * @param matrices defines the array of float32 to store
  35011. */
  35012. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35013. /**
  35014. * Set the value of an uniform to a matrix (3x3)
  35015. * @param uniform defines the webGL uniform location where to store the value
  35016. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35017. */
  35018. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35019. /**
  35020. * Set the value of an uniform to a matrix (2x2)
  35021. * @param uniform defines the webGL uniform location where to store the value
  35022. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35023. */
  35024. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35025. /**
  35026. * Set the value of an uniform to a number (float)
  35027. * @param uniform defines the webGL uniform location where to store the value
  35028. * @param value defines the float number to store
  35029. */
  35030. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35031. /**
  35032. * Set the value of an uniform to a vec2
  35033. * @param uniform defines the webGL uniform location where to store the value
  35034. * @param x defines the 1st component of the value
  35035. * @param y defines the 2nd component of the value
  35036. */
  35037. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35038. /**
  35039. * Set the value of an uniform to a vec3
  35040. * @param uniform defines the webGL uniform location where to store the value
  35041. * @param x defines the 1st component of the value
  35042. * @param y defines the 2nd component of the value
  35043. * @param z defines the 3rd component of the value
  35044. */
  35045. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35046. /**
  35047. * Set the value of an uniform to a vec4
  35048. * @param uniform defines the webGL uniform location where to store the value
  35049. * @param x defines the 1st component of the value
  35050. * @param y defines the 2nd component of the value
  35051. * @param z defines the 3rd component of the value
  35052. * @param w defines the 4th component of the value
  35053. */
  35054. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35055. /**
  35056. * Apply all cached states (depth, culling, stencil and alpha)
  35057. */
  35058. applyStates(): void;
  35059. /**
  35060. * Enable or disable color writing
  35061. * @param enable defines the state to set
  35062. */
  35063. setColorWrite(enable: boolean): void;
  35064. /**
  35065. * Gets a boolean indicating if color writing is enabled
  35066. * @returns the current color writing state
  35067. */
  35068. getColorWrite(): boolean;
  35069. /**
  35070. * Gets the depth culling state manager
  35071. */
  35072. get depthCullingState(): DepthCullingState;
  35073. /**
  35074. * Gets the alpha state manager
  35075. */
  35076. get alphaState(): AlphaState;
  35077. /**
  35078. * Gets the stencil state manager
  35079. */
  35080. get stencilState(): StencilState;
  35081. /**
  35082. * Clears the list of texture accessible through engine.
  35083. * This can help preventing texture load conflict due to name collision.
  35084. */
  35085. clearInternalTexturesCache(): void;
  35086. /**
  35087. * Force the entire cache to be cleared
  35088. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35089. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35090. */
  35091. wipeCaches(bruteForce?: boolean): void;
  35092. /** @hidden */
  35093. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35094. min: number;
  35095. mag: number;
  35096. };
  35097. /** @hidden */
  35098. _createTexture(): WebGLTexture;
  35099. /**
  35100. * Usually called from Texture.ts.
  35101. * Passed information to create a WebGLTexture
  35102. * @param url defines a value which contains one of the following:
  35103. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35104. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35105. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35106. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35107. * @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)
  35108. * @param scene needed for loading to the correct scene
  35109. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35110. * @param onLoad optional callback to be called upon successful completion
  35111. * @param onError optional callback to be called upon failure
  35112. * @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
  35113. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35114. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35115. * @param forcedExtension defines the extension to use to pick the right loader
  35116. * @param mimeType defines an optional mime type
  35117. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35118. */
  35119. createTexture(url: 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;
  35120. /**
  35121. * Loads an image as an HTMLImageElement.
  35122. * @param input url string, ArrayBuffer, or Blob to load
  35123. * @param onLoad callback called when the image successfully loads
  35124. * @param onError callback called when the image fails to load
  35125. * @param offlineProvider offline provider for caching
  35126. * @param mimeType optional mime type
  35127. * @returns the HTMLImageElement of the loaded image
  35128. * @hidden
  35129. */
  35130. 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>;
  35131. /**
  35132. * @hidden
  35133. */
  35134. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35135. private _unpackFlipYCached;
  35136. /**
  35137. * In case you are sharing the context with other applications, it might
  35138. * be interested to not cache the unpack flip y state to ensure a consistent
  35139. * value would be set.
  35140. */
  35141. enableUnpackFlipYCached: boolean;
  35142. /** @hidden */
  35143. _unpackFlipY(value: boolean): void;
  35144. /** @hidden */
  35145. _getUnpackAlignement(): number;
  35146. private _getTextureTarget;
  35147. /**
  35148. * Update the sampling mode of a given texture
  35149. * @param samplingMode defines the required sampling mode
  35150. * @param texture defines the texture to update
  35151. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35152. */
  35153. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35154. /**
  35155. * Update the sampling mode of a given texture
  35156. * @param texture defines the texture to update
  35157. * @param wrapU defines the texture wrap mode of the u coordinates
  35158. * @param wrapV defines the texture wrap mode of the v coordinates
  35159. * @param wrapR defines the texture wrap mode of the r coordinates
  35160. */
  35161. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35162. /** @hidden */
  35163. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35164. width: number;
  35165. height: number;
  35166. layers?: number;
  35167. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35168. /** @hidden */
  35169. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35170. /** @hidden */
  35171. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35172. /**
  35173. * Update a portion of an internal texture
  35174. * @param texture defines the texture to update
  35175. * @param imageData defines the data to store into the texture
  35176. * @param xOffset defines the x coordinates of the update rectangle
  35177. * @param yOffset defines the y coordinates of the update rectangle
  35178. * @param width defines the width of the update rectangle
  35179. * @param height defines the height of the update rectangle
  35180. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35181. * @param lod defines the lod level to update (0 by default)
  35182. */
  35183. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35184. /** @hidden */
  35185. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35186. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35187. private _prepareWebGLTexture;
  35188. /** @hidden */
  35189. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35190. private _getDepthStencilBuffer;
  35191. /** @hidden */
  35192. _releaseFramebufferObjects(texture: InternalTexture): void;
  35193. /** @hidden */
  35194. _releaseTexture(texture: InternalTexture): void;
  35195. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35196. protected _setProgram(program: WebGLProgram): void;
  35197. protected _boundUniforms: {
  35198. [key: number]: WebGLUniformLocation;
  35199. };
  35200. /**
  35201. * Binds an effect to the webGL context
  35202. * @param effect defines the effect to bind
  35203. */
  35204. bindSamplers(effect: Effect): void;
  35205. private _activateCurrentTexture;
  35206. /** @hidden */
  35207. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35208. /** @hidden */
  35209. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35210. /**
  35211. * Unbind all textures from the webGL context
  35212. */
  35213. unbindAllTextures(): void;
  35214. /**
  35215. * Sets a texture to the according uniform.
  35216. * @param channel The texture channel
  35217. * @param uniform The uniform to set
  35218. * @param texture The texture to apply
  35219. */
  35220. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35221. private _bindSamplerUniformToChannel;
  35222. private _getTextureWrapMode;
  35223. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35224. /**
  35225. * Sets an array of texture to the webGL context
  35226. * @param channel defines the channel where the texture array must be set
  35227. * @param uniform defines the associated uniform location
  35228. * @param textures defines the array of textures to bind
  35229. */
  35230. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35231. /** @hidden */
  35232. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35233. private _setTextureParameterFloat;
  35234. private _setTextureParameterInteger;
  35235. /**
  35236. * Unbind all vertex attributes from the webGL context
  35237. */
  35238. unbindAllAttributes(): void;
  35239. /**
  35240. * 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
  35241. */
  35242. releaseEffects(): void;
  35243. /**
  35244. * Dispose and release all associated resources
  35245. */
  35246. dispose(): void;
  35247. /**
  35248. * Attach a new callback raised when context lost event is fired
  35249. * @param callback defines the callback to call
  35250. */
  35251. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35252. /**
  35253. * Attach a new callback raised when context restored event is fired
  35254. * @param callback defines the callback to call
  35255. */
  35256. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35257. /**
  35258. * Get the current error code of the webGL context
  35259. * @returns the error code
  35260. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35261. */
  35262. getError(): number;
  35263. private _canRenderToFloatFramebuffer;
  35264. private _canRenderToHalfFloatFramebuffer;
  35265. private _canRenderToFramebuffer;
  35266. /** @hidden */
  35267. _getWebGLTextureType(type: number): number;
  35268. /** @hidden */
  35269. _getInternalFormat(format: number): number;
  35270. /** @hidden */
  35271. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35272. /** @hidden */
  35273. _getRGBAMultiSampleBufferFormat(type: number): number;
  35274. /** @hidden */
  35275. _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;
  35276. /**
  35277. * Loads a file from a url
  35278. * @param url url to load
  35279. * @param onSuccess callback called when the file successfully loads
  35280. * @param onProgress callback called while file is loading (if the server supports this mode)
  35281. * @param offlineProvider defines the offline provider for caching
  35282. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35283. * @param onError callback called when the file fails to load
  35284. * @returns a file request object
  35285. * @hidden
  35286. */
  35287. 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;
  35288. /**
  35289. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35290. * @param x defines the x coordinate of the rectangle where pixels must be read
  35291. * @param y defines the y coordinate of the rectangle where pixels must be read
  35292. * @param width defines the width of the rectangle where pixels must be read
  35293. * @param height defines the height of the rectangle where pixels must be read
  35294. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35295. * @returns a Uint8Array containing RGBA colors
  35296. */
  35297. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35298. private static _isSupported;
  35299. /**
  35300. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35301. * @returns true if the engine can be created
  35302. * @ignorenaming
  35303. */
  35304. static isSupported(): boolean;
  35305. /**
  35306. * Find the next highest power of two.
  35307. * @param x Number to start search from.
  35308. * @return Next highest power of two.
  35309. */
  35310. static CeilingPOT(x: number): number;
  35311. /**
  35312. * Find the next lowest power of two.
  35313. * @param x Number to start search from.
  35314. * @return Next lowest power of two.
  35315. */
  35316. static FloorPOT(x: number): number;
  35317. /**
  35318. * Find the nearest power of two.
  35319. * @param x Number to start search from.
  35320. * @return Next nearest power of two.
  35321. */
  35322. static NearestPOT(x: number): number;
  35323. /**
  35324. * Get the closest exponent of two
  35325. * @param value defines the value to approximate
  35326. * @param max defines the maximum value to return
  35327. * @param mode defines how to define the closest value
  35328. * @returns closest exponent of two of the given value
  35329. */
  35330. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35331. /**
  35332. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35333. * @param func - the function to be called
  35334. * @param requester - the object that will request the next frame. Falls back to window.
  35335. * @returns frame number
  35336. */
  35337. static QueueNewFrame(func: () => void, requester?: any): number;
  35338. /**
  35339. * Gets host document
  35340. * @returns the host document object
  35341. */
  35342. getHostDocument(): Nullable<Document>;
  35343. }
  35344. }
  35345. declare module BABYLON {
  35346. /**
  35347. * Class representing spherical harmonics coefficients to the 3rd degree
  35348. */
  35349. export class SphericalHarmonics {
  35350. /**
  35351. * Defines whether or not the harmonics have been prescaled for rendering.
  35352. */
  35353. preScaled: boolean;
  35354. /**
  35355. * The l0,0 coefficients of the spherical harmonics
  35356. */
  35357. l00: Vector3;
  35358. /**
  35359. * The l1,-1 coefficients of the spherical harmonics
  35360. */
  35361. l1_1: Vector3;
  35362. /**
  35363. * The l1,0 coefficients of the spherical harmonics
  35364. */
  35365. l10: Vector3;
  35366. /**
  35367. * The l1,1 coefficients of the spherical harmonics
  35368. */
  35369. l11: Vector3;
  35370. /**
  35371. * The l2,-2 coefficients of the spherical harmonics
  35372. */
  35373. l2_2: Vector3;
  35374. /**
  35375. * The l2,-1 coefficients of the spherical harmonics
  35376. */
  35377. l2_1: Vector3;
  35378. /**
  35379. * The l2,0 coefficients of the spherical harmonics
  35380. */
  35381. l20: Vector3;
  35382. /**
  35383. * The l2,1 coefficients of the spherical harmonics
  35384. */
  35385. l21: Vector3;
  35386. /**
  35387. * The l2,2 coefficients of the spherical harmonics
  35388. */
  35389. l22: Vector3;
  35390. /**
  35391. * Adds a light to the spherical harmonics
  35392. * @param direction the direction of the light
  35393. * @param color the color of the light
  35394. * @param deltaSolidAngle the delta solid angle of the light
  35395. */
  35396. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35397. /**
  35398. * Scales the spherical harmonics by the given amount
  35399. * @param scale the amount to scale
  35400. */
  35401. scaleInPlace(scale: number): void;
  35402. /**
  35403. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35404. *
  35405. * ```
  35406. * E_lm = A_l * L_lm
  35407. * ```
  35408. *
  35409. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35410. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35411. * the scaling factors are given in equation 9.
  35412. */
  35413. convertIncidentRadianceToIrradiance(): void;
  35414. /**
  35415. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35416. *
  35417. * ```
  35418. * L = (1/pi) * E * rho
  35419. * ```
  35420. *
  35421. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35422. */
  35423. convertIrradianceToLambertianRadiance(): void;
  35424. /**
  35425. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35426. * required operations at run time.
  35427. *
  35428. * This is simply done by scaling back the SH with Ylm constants parameter.
  35429. * The trigonometric part being applied by the shader at run time.
  35430. */
  35431. preScaleForRendering(): void;
  35432. /**
  35433. * Constructs a spherical harmonics from an array.
  35434. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35435. * @returns the spherical harmonics
  35436. */
  35437. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35438. /**
  35439. * Gets the spherical harmonics from polynomial
  35440. * @param polynomial the spherical polynomial
  35441. * @returns the spherical harmonics
  35442. */
  35443. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35444. }
  35445. /**
  35446. * Class representing spherical polynomial coefficients to the 3rd degree
  35447. */
  35448. export class SphericalPolynomial {
  35449. private _harmonics;
  35450. /**
  35451. * The spherical harmonics used to create the polynomials.
  35452. */
  35453. get preScaledHarmonics(): SphericalHarmonics;
  35454. /**
  35455. * The x coefficients of the spherical polynomial
  35456. */
  35457. x: Vector3;
  35458. /**
  35459. * The y coefficients of the spherical polynomial
  35460. */
  35461. y: Vector3;
  35462. /**
  35463. * The z coefficients of the spherical polynomial
  35464. */
  35465. z: Vector3;
  35466. /**
  35467. * The xx coefficients of the spherical polynomial
  35468. */
  35469. xx: Vector3;
  35470. /**
  35471. * The yy coefficients of the spherical polynomial
  35472. */
  35473. yy: Vector3;
  35474. /**
  35475. * The zz coefficients of the spherical polynomial
  35476. */
  35477. zz: Vector3;
  35478. /**
  35479. * The xy coefficients of the spherical polynomial
  35480. */
  35481. xy: Vector3;
  35482. /**
  35483. * The yz coefficients of the spherical polynomial
  35484. */
  35485. yz: Vector3;
  35486. /**
  35487. * The zx coefficients of the spherical polynomial
  35488. */
  35489. zx: Vector3;
  35490. /**
  35491. * Adds an ambient color to the spherical polynomial
  35492. * @param color the color to add
  35493. */
  35494. addAmbient(color: Color3): void;
  35495. /**
  35496. * Scales the spherical polynomial by the given amount
  35497. * @param scale the amount to scale
  35498. */
  35499. scaleInPlace(scale: number): void;
  35500. /**
  35501. * Gets the spherical polynomial from harmonics
  35502. * @param harmonics the spherical harmonics
  35503. * @returns the spherical polynomial
  35504. */
  35505. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35506. /**
  35507. * Constructs a spherical polynomial from an array.
  35508. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35509. * @returns the spherical polynomial
  35510. */
  35511. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35512. }
  35513. }
  35514. declare module BABYLON {
  35515. /**
  35516. * Defines the source of the internal texture
  35517. */
  35518. export enum InternalTextureSource {
  35519. /**
  35520. * The source of the texture data is unknown
  35521. */
  35522. Unknown = 0,
  35523. /**
  35524. * Texture data comes from an URL
  35525. */
  35526. Url = 1,
  35527. /**
  35528. * Texture data is only used for temporary storage
  35529. */
  35530. Temp = 2,
  35531. /**
  35532. * Texture data comes from raw data (ArrayBuffer)
  35533. */
  35534. Raw = 3,
  35535. /**
  35536. * Texture content is dynamic (video or dynamic texture)
  35537. */
  35538. Dynamic = 4,
  35539. /**
  35540. * Texture content is generated by rendering to it
  35541. */
  35542. RenderTarget = 5,
  35543. /**
  35544. * Texture content is part of a multi render target process
  35545. */
  35546. MultiRenderTarget = 6,
  35547. /**
  35548. * Texture data comes from a cube data file
  35549. */
  35550. Cube = 7,
  35551. /**
  35552. * Texture data comes from a raw cube data
  35553. */
  35554. CubeRaw = 8,
  35555. /**
  35556. * Texture data come from a prefiltered cube data file
  35557. */
  35558. CubePrefiltered = 9,
  35559. /**
  35560. * Texture content is raw 3D data
  35561. */
  35562. Raw3D = 10,
  35563. /**
  35564. * Texture content is raw 2D array data
  35565. */
  35566. Raw2DArray = 11,
  35567. /**
  35568. * Texture content is a depth texture
  35569. */
  35570. Depth = 12,
  35571. /**
  35572. * Texture data comes from a raw cube data encoded with RGBD
  35573. */
  35574. CubeRawRGBD = 13
  35575. }
  35576. /**
  35577. * Class used to store data associated with WebGL texture data for the engine
  35578. * This class should not be used directly
  35579. */
  35580. export class InternalTexture {
  35581. /** @hidden */
  35582. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35583. /**
  35584. * Defines if the texture is ready
  35585. */
  35586. isReady: boolean;
  35587. /**
  35588. * Defines if the texture is a cube texture
  35589. */
  35590. isCube: boolean;
  35591. /**
  35592. * Defines if the texture contains 3D data
  35593. */
  35594. is3D: boolean;
  35595. /**
  35596. * Defines if the texture contains 2D array data
  35597. */
  35598. is2DArray: boolean;
  35599. /**
  35600. * Defines if the texture contains multiview data
  35601. */
  35602. isMultiview: boolean;
  35603. /**
  35604. * Gets the URL used to load this texture
  35605. */
  35606. url: string;
  35607. /**
  35608. * Gets the sampling mode of the texture
  35609. */
  35610. samplingMode: number;
  35611. /**
  35612. * Gets a boolean indicating if the texture needs mipmaps generation
  35613. */
  35614. generateMipMaps: boolean;
  35615. /**
  35616. * Gets the number of samples used by the texture (WebGL2+ only)
  35617. */
  35618. samples: number;
  35619. /**
  35620. * Gets the type of the texture (int, float...)
  35621. */
  35622. type: number;
  35623. /**
  35624. * Gets the format of the texture (RGB, RGBA...)
  35625. */
  35626. format: number;
  35627. /**
  35628. * Observable called when the texture is loaded
  35629. */
  35630. onLoadedObservable: Observable<InternalTexture>;
  35631. /**
  35632. * Gets the width of the texture
  35633. */
  35634. width: number;
  35635. /**
  35636. * Gets the height of the texture
  35637. */
  35638. height: number;
  35639. /**
  35640. * Gets the depth of the texture
  35641. */
  35642. depth: number;
  35643. /**
  35644. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35645. */
  35646. baseWidth: number;
  35647. /**
  35648. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35649. */
  35650. baseHeight: number;
  35651. /**
  35652. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35653. */
  35654. baseDepth: number;
  35655. /**
  35656. * Gets a boolean indicating if the texture is inverted on Y axis
  35657. */
  35658. invertY: boolean;
  35659. /** @hidden */
  35660. _invertVScale: boolean;
  35661. /** @hidden */
  35662. _associatedChannel: number;
  35663. /** @hidden */
  35664. _source: InternalTextureSource;
  35665. /** @hidden */
  35666. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35667. /** @hidden */
  35668. _bufferView: Nullable<ArrayBufferView>;
  35669. /** @hidden */
  35670. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35671. /** @hidden */
  35672. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35673. /** @hidden */
  35674. _size: number;
  35675. /** @hidden */
  35676. _extension: string;
  35677. /** @hidden */
  35678. _files: Nullable<string[]>;
  35679. /** @hidden */
  35680. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35681. /** @hidden */
  35682. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35683. /** @hidden */
  35684. _framebuffer: Nullable<WebGLFramebuffer>;
  35685. /** @hidden */
  35686. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35687. /** @hidden */
  35688. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35689. /** @hidden */
  35690. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35691. /** @hidden */
  35692. _attachments: Nullable<number[]>;
  35693. /** @hidden */
  35694. _cachedCoordinatesMode: Nullable<number>;
  35695. /** @hidden */
  35696. _cachedWrapU: Nullable<number>;
  35697. /** @hidden */
  35698. _cachedWrapV: Nullable<number>;
  35699. /** @hidden */
  35700. _cachedWrapR: Nullable<number>;
  35701. /** @hidden */
  35702. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35703. /** @hidden */
  35704. _isDisabled: boolean;
  35705. /** @hidden */
  35706. _compression: Nullable<string>;
  35707. /** @hidden */
  35708. _generateStencilBuffer: boolean;
  35709. /** @hidden */
  35710. _generateDepthBuffer: boolean;
  35711. /** @hidden */
  35712. _comparisonFunction: number;
  35713. /** @hidden */
  35714. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35715. /** @hidden */
  35716. _lodGenerationScale: number;
  35717. /** @hidden */
  35718. _lodGenerationOffset: number;
  35719. /** @hidden */
  35720. _depthStencilTexture: Nullable<InternalTexture>;
  35721. /** @hidden */
  35722. _colorTextureArray: Nullable<WebGLTexture>;
  35723. /** @hidden */
  35724. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35725. /** @hidden */
  35726. _lodTextureHigh: Nullable<BaseTexture>;
  35727. /** @hidden */
  35728. _lodTextureMid: Nullable<BaseTexture>;
  35729. /** @hidden */
  35730. _lodTextureLow: Nullable<BaseTexture>;
  35731. /** @hidden */
  35732. _isRGBD: boolean;
  35733. /** @hidden */
  35734. _linearSpecularLOD: boolean;
  35735. /** @hidden */
  35736. _irradianceTexture: Nullable<BaseTexture>;
  35737. /** @hidden */
  35738. _webGLTexture: Nullable<WebGLTexture>;
  35739. /** @hidden */
  35740. _references: number;
  35741. private _engine;
  35742. /**
  35743. * Gets the Engine the texture belongs to.
  35744. * @returns The babylon engine
  35745. */
  35746. getEngine(): ThinEngine;
  35747. /**
  35748. * Gets the data source type of the texture
  35749. */
  35750. get source(): InternalTextureSource;
  35751. /**
  35752. * Creates a new InternalTexture
  35753. * @param engine defines the engine to use
  35754. * @param source defines the type of data that will be used
  35755. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35756. */
  35757. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35758. /**
  35759. * Increments the number of references (ie. the number of Texture that point to it)
  35760. */
  35761. incrementReferences(): void;
  35762. /**
  35763. * Change the size of the texture (not the size of the content)
  35764. * @param width defines the new width
  35765. * @param height defines the new height
  35766. * @param depth defines the new depth (1 by default)
  35767. */
  35768. updateSize(width: int, height: int, depth?: int): void;
  35769. /** @hidden */
  35770. _rebuild(): void;
  35771. /** @hidden */
  35772. _swapAndDie(target: InternalTexture): void;
  35773. /**
  35774. * Dispose the current allocated resources
  35775. */
  35776. dispose(): void;
  35777. }
  35778. }
  35779. declare module BABYLON {
  35780. /**
  35781. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35782. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35783. */
  35784. export class Analyser {
  35785. /**
  35786. * Gets or sets the smoothing
  35787. * @ignorenaming
  35788. */
  35789. SMOOTHING: number;
  35790. /**
  35791. * Gets or sets the FFT table size
  35792. * @ignorenaming
  35793. */
  35794. FFT_SIZE: number;
  35795. /**
  35796. * Gets or sets the bar graph amplitude
  35797. * @ignorenaming
  35798. */
  35799. BARGRAPHAMPLITUDE: number;
  35800. /**
  35801. * Gets or sets the position of the debug canvas
  35802. * @ignorenaming
  35803. */
  35804. DEBUGCANVASPOS: {
  35805. x: number;
  35806. y: number;
  35807. };
  35808. /**
  35809. * Gets or sets the debug canvas size
  35810. * @ignorenaming
  35811. */
  35812. DEBUGCANVASSIZE: {
  35813. width: number;
  35814. height: number;
  35815. };
  35816. private _byteFreqs;
  35817. private _byteTime;
  35818. private _floatFreqs;
  35819. private _webAudioAnalyser;
  35820. private _debugCanvas;
  35821. private _debugCanvasContext;
  35822. private _scene;
  35823. private _registerFunc;
  35824. private _audioEngine;
  35825. /**
  35826. * Creates a new analyser
  35827. * @param scene defines hosting scene
  35828. */
  35829. constructor(scene: Scene);
  35830. /**
  35831. * Get the number of data values you will have to play with for the visualization
  35832. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35833. * @returns a number
  35834. */
  35835. getFrequencyBinCount(): number;
  35836. /**
  35837. * Gets the current frequency data as a byte array
  35838. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35839. * @returns a Uint8Array
  35840. */
  35841. getByteFrequencyData(): Uint8Array;
  35842. /**
  35843. * Gets the current waveform as a byte array
  35844. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35845. * @returns a Uint8Array
  35846. */
  35847. getByteTimeDomainData(): Uint8Array;
  35848. /**
  35849. * Gets the current frequency data as a float array
  35850. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35851. * @returns a Float32Array
  35852. */
  35853. getFloatFrequencyData(): Float32Array;
  35854. /**
  35855. * Renders the debug canvas
  35856. */
  35857. drawDebugCanvas(): void;
  35858. /**
  35859. * Stops rendering the debug canvas and removes it
  35860. */
  35861. stopDebugCanvas(): void;
  35862. /**
  35863. * Connects two audio nodes
  35864. * @param inputAudioNode defines first node to connect
  35865. * @param outputAudioNode defines second node to connect
  35866. */
  35867. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35868. /**
  35869. * Releases all associated resources
  35870. */
  35871. dispose(): void;
  35872. }
  35873. }
  35874. declare module BABYLON {
  35875. /**
  35876. * This represents an audio engine and it is responsible
  35877. * to play, synchronize and analyse sounds throughout the application.
  35878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35879. */
  35880. export interface IAudioEngine extends IDisposable {
  35881. /**
  35882. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35883. */
  35884. readonly canUseWebAudio: boolean;
  35885. /**
  35886. * Gets the current AudioContext if available.
  35887. */
  35888. readonly audioContext: Nullable<AudioContext>;
  35889. /**
  35890. * The master gain node defines the global audio volume of your audio engine.
  35891. */
  35892. readonly masterGain: GainNode;
  35893. /**
  35894. * Gets whether or not mp3 are supported by your browser.
  35895. */
  35896. readonly isMP3supported: boolean;
  35897. /**
  35898. * Gets whether or not ogg are supported by your browser.
  35899. */
  35900. readonly isOGGsupported: boolean;
  35901. /**
  35902. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35903. * @ignoreNaming
  35904. */
  35905. WarnedWebAudioUnsupported: boolean;
  35906. /**
  35907. * Defines if the audio engine relies on a custom unlocked button.
  35908. * In this case, the embedded button will not be displayed.
  35909. */
  35910. useCustomUnlockedButton: boolean;
  35911. /**
  35912. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35913. */
  35914. readonly unlocked: boolean;
  35915. /**
  35916. * Event raised when audio has been unlocked on the browser.
  35917. */
  35918. onAudioUnlockedObservable: Observable<AudioEngine>;
  35919. /**
  35920. * Event raised when audio has been locked on the browser.
  35921. */
  35922. onAudioLockedObservable: Observable<AudioEngine>;
  35923. /**
  35924. * Flags the audio engine in Locked state.
  35925. * This happens due to new browser policies preventing audio to autoplay.
  35926. */
  35927. lock(): void;
  35928. /**
  35929. * Unlocks the audio engine once a user action has been done on the dom.
  35930. * This is helpful to resume play once browser policies have been satisfied.
  35931. */
  35932. unlock(): void;
  35933. /**
  35934. * Gets the global volume sets on the master gain.
  35935. * @returns the global volume if set or -1 otherwise
  35936. */
  35937. getGlobalVolume(): number;
  35938. /**
  35939. * Sets the global volume of your experience (sets on the master gain).
  35940. * @param newVolume Defines the new global volume of the application
  35941. */
  35942. setGlobalVolume(newVolume: number): void;
  35943. /**
  35944. * Connect the audio engine to an audio analyser allowing some amazing
  35945. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35947. * @param analyser The analyser to connect to the engine
  35948. */
  35949. connectToAnalyser(analyser: Analyser): void;
  35950. }
  35951. /**
  35952. * This represents the default audio engine used in babylon.
  35953. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35955. */
  35956. export class AudioEngine implements IAudioEngine {
  35957. private _audioContext;
  35958. private _audioContextInitialized;
  35959. private _muteButton;
  35960. private _hostElement;
  35961. /**
  35962. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35963. */
  35964. canUseWebAudio: boolean;
  35965. /**
  35966. * The master gain node defines the global audio volume of your audio engine.
  35967. */
  35968. masterGain: GainNode;
  35969. /**
  35970. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35971. * @ignoreNaming
  35972. */
  35973. WarnedWebAudioUnsupported: boolean;
  35974. /**
  35975. * Gets whether or not mp3 are supported by your browser.
  35976. */
  35977. isMP3supported: boolean;
  35978. /**
  35979. * Gets whether or not ogg are supported by your browser.
  35980. */
  35981. isOGGsupported: boolean;
  35982. /**
  35983. * Gets whether audio has been unlocked on the device.
  35984. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35985. * a user interaction has happened.
  35986. */
  35987. unlocked: boolean;
  35988. /**
  35989. * Defines if the audio engine relies on a custom unlocked button.
  35990. * In this case, the embedded button will not be displayed.
  35991. */
  35992. useCustomUnlockedButton: boolean;
  35993. /**
  35994. * Event raised when audio has been unlocked on the browser.
  35995. */
  35996. onAudioUnlockedObservable: Observable<AudioEngine>;
  35997. /**
  35998. * Event raised when audio has been locked on the browser.
  35999. */
  36000. onAudioLockedObservable: Observable<AudioEngine>;
  36001. /**
  36002. * Gets the current AudioContext if available.
  36003. */
  36004. get audioContext(): Nullable<AudioContext>;
  36005. private _connectedAnalyser;
  36006. /**
  36007. * Instantiates a new audio engine.
  36008. *
  36009. * There should be only one per page as some browsers restrict the number
  36010. * of audio contexts you can create.
  36011. * @param hostElement defines the host element where to display the mute icon if necessary
  36012. */
  36013. constructor(hostElement?: Nullable<HTMLElement>);
  36014. /**
  36015. * Flags the audio engine in Locked state.
  36016. * This happens due to new browser policies preventing audio to autoplay.
  36017. */
  36018. lock(): void;
  36019. /**
  36020. * Unlocks the audio engine once a user action has been done on the dom.
  36021. * This is helpful to resume play once browser policies have been satisfied.
  36022. */
  36023. unlock(): void;
  36024. private _resumeAudioContext;
  36025. private _initializeAudioContext;
  36026. private _tryToRun;
  36027. private _triggerRunningState;
  36028. private _triggerSuspendedState;
  36029. private _displayMuteButton;
  36030. private _moveButtonToTopLeft;
  36031. private _onResize;
  36032. private _hideMuteButton;
  36033. /**
  36034. * Destroy and release the resources associated with the audio ccontext.
  36035. */
  36036. dispose(): void;
  36037. /**
  36038. * Gets the global volume sets on the master gain.
  36039. * @returns the global volume if set or -1 otherwise
  36040. */
  36041. getGlobalVolume(): number;
  36042. /**
  36043. * Sets the global volume of your experience (sets on the master gain).
  36044. * @param newVolume Defines the new global volume of the application
  36045. */
  36046. setGlobalVolume(newVolume: number): void;
  36047. /**
  36048. * Connect the audio engine to an audio analyser allowing some amazing
  36049. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36051. * @param analyser The analyser to connect to the engine
  36052. */
  36053. connectToAnalyser(analyser: Analyser): void;
  36054. }
  36055. }
  36056. declare module BABYLON {
  36057. /**
  36058. * Interface used to present a loading screen while loading a scene
  36059. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36060. */
  36061. export interface ILoadingScreen {
  36062. /**
  36063. * Function called to display the loading screen
  36064. */
  36065. displayLoadingUI: () => void;
  36066. /**
  36067. * Function called to hide the loading screen
  36068. */
  36069. hideLoadingUI: () => void;
  36070. /**
  36071. * Gets or sets the color to use for the background
  36072. */
  36073. loadingUIBackgroundColor: string;
  36074. /**
  36075. * Gets or sets the text to display while loading
  36076. */
  36077. loadingUIText: string;
  36078. }
  36079. /**
  36080. * Class used for the default loading screen
  36081. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36082. */
  36083. export class DefaultLoadingScreen implements ILoadingScreen {
  36084. private _renderingCanvas;
  36085. private _loadingText;
  36086. private _loadingDivBackgroundColor;
  36087. private _loadingDiv;
  36088. private _loadingTextDiv;
  36089. /** Gets or sets the logo url to use for the default loading screen */
  36090. static DefaultLogoUrl: string;
  36091. /** Gets or sets the spinner url to use for the default loading screen */
  36092. static DefaultSpinnerUrl: string;
  36093. /**
  36094. * Creates a new default loading screen
  36095. * @param _renderingCanvas defines the canvas used to render the scene
  36096. * @param _loadingText defines the default text to display
  36097. * @param _loadingDivBackgroundColor defines the default background color
  36098. */
  36099. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36100. /**
  36101. * Function called to display the loading screen
  36102. */
  36103. displayLoadingUI(): void;
  36104. /**
  36105. * Function called to hide the loading screen
  36106. */
  36107. hideLoadingUI(): void;
  36108. /**
  36109. * Gets or sets the text to display while loading
  36110. */
  36111. set loadingUIText(text: string);
  36112. get loadingUIText(): string;
  36113. /**
  36114. * Gets or sets the color to use for the background
  36115. */
  36116. get loadingUIBackgroundColor(): string;
  36117. set loadingUIBackgroundColor(color: string);
  36118. private _resizeLoadingUI;
  36119. }
  36120. }
  36121. declare module BABYLON {
  36122. /**
  36123. * Interface for any object that can request an animation frame
  36124. */
  36125. export interface ICustomAnimationFrameRequester {
  36126. /**
  36127. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36128. */
  36129. renderFunction?: Function;
  36130. /**
  36131. * Called to request the next frame to render to
  36132. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36133. */
  36134. requestAnimationFrame: Function;
  36135. /**
  36136. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36137. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36138. */
  36139. requestID?: number;
  36140. }
  36141. }
  36142. declare module BABYLON {
  36143. /**
  36144. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36145. */
  36146. export class PerformanceMonitor {
  36147. private _enabled;
  36148. private _rollingFrameTime;
  36149. private _lastFrameTimeMs;
  36150. /**
  36151. * constructor
  36152. * @param frameSampleSize The number of samples required to saturate the sliding window
  36153. */
  36154. constructor(frameSampleSize?: number);
  36155. /**
  36156. * Samples current frame
  36157. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36158. */
  36159. sampleFrame(timeMs?: number): void;
  36160. /**
  36161. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36162. */
  36163. get averageFrameTime(): number;
  36164. /**
  36165. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36166. */
  36167. get averageFrameTimeVariance(): number;
  36168. /**
  36169. * Returns the frame time of the most recent frame
  36170. */
  36171. get instantaneousFrameTime(): number;
  36172. /**
  36173. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36174. */
  36175. get averageFPS(): number;
  36176. /**
  36177. * Returns the average framerate in frames per second using the most recent frame time
  36178. */
  36179. get instantaneousFPS(): number;
  36180. /**
  36181. * Returns true if enough samples have been taken to completely fill the sliding window
  36182. */
  36183. get isSaturated(): boolean;
  36184. /**
  36185. * Enables contributions to the sliding window sample set
  36186. */
  36187. enable(): void;
  36188. /**
  36189. * Disables contributions to the sliding window sample set
  36190. * Samples will not be interpolated over the disabled period
  36191. */
  36192. disable(): void;
  36193. /**
  36194. * Returns true if sampling is enabled
  36195. */
  36196. get isEnabled(): boolean;
  36197. /**
  36198. * Resets performance monitor
  36199. */
  36200. reset(): void;
  36201. }
  36202. /**
  36203. * RollingAverage
  36204. *
  36205. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36206. */
  36207. export class RollingAverage {
  36208. /**
  36209. * Current average
  36210. */
  36211. average: number;
  36212. /**
  36213. * Current variance
  36214. */
  36215. variance: number;
  36216. protected _samples: Array<number>;
  36217. protected _sampleCount: number;
  36218. protected _pos: number;
  36219. protected _m2: number;
  36220. /**
  36221. * constructor
  36222. * @param length The number of samples required to saturate the sliding window
  36223. */
  36224. constructor(length: number);
  36225. /**
  36226. * Adds a sample to the sample set
  36227. * @param v The sample value
  36228. */
  36229. add(v: number): void;
  36230. /**
  36231. * Returns previously added values or null if outside of history or outside the sliding window domain
  36232. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36233. * @return Value previously recorded with add() or null if outside of range
  36234. */
  36235. history(i: number): number;
  36236. /**
  36237. * Returns true if enough samples have been taken to completely fill the sliding window
  36238. * @return true if sample-set saturated
  36239. */
  36240. isSaturated(): boolean;
  36241. /**
  36242. * Resets the rolling average (equivalent to 0 samples taken so far)
  36243. */
  36244. reset(): void;
  36245. /**
  36246. * Wraps a value around the sample range boundaries
  36247. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36248. * @return Wrapped position in sample range
  36249. */
  36250. protected _wrapPosition(i: number): number;
  36251. }
  36252. }
  36253. declare module BABYLON {
  36254. /**
  36255. * This class is used to track a performance counter which is number based.
  36256. * The user has access to many properties which give statistics of different nature.
  36257. *
  36258. * The implementer can track two kinds of Performance Counter: time and count.
  36259. * 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.
  36260. * 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.
  36261. */
  36262. export class PerfCounter {
  36263. /**
  36264. * Gets or sets a global boolean to turn on and off all the counters
  36265. */
  36266. static Enabled: boolean;
  36267. /**
  36268. * Returns the smallest value ever
  36269. */
  36270. get min(): number;
  36271. /**
  36272. * Returns the biggest value ever
  36273. */
  36274. get max(): number;
  36275. /**
  36276. * Returns the average value since the performance counter is running
  36277. */
  36278. get average(): number;
  36279. /**
  36280. * Returns the average value of the last second the counter was monitored
  36281. */
  36282. get lastSecAverage(): number;
  36283. /**
  36284. * Returns the current value
  36285. */
  36286. get current(): number;
  36287. /**
  36288. * Gets the accumulated total
  36289. */
  36290. get total(): number;
  36291. /**
  36292. * Gets the total value count
  36293. */
  36294. get count(): number;
  36295. /**
  36296. * Creates a new counter
  36297. */
  36298. constructor();
  36299. /**
  36300. * Call this method to start monitoring a new frame.
  36301. * 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.
  36302. */
  36303. fetchNewFrame(): void;
  36304. /**
  36305. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36306. * @param newCount the count value to add to the monitored count
  36307. * @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.
  36308. */
  36309. addCount(newCount: number, fetchResult: boolean): void;
  36310. /**
  36311. * Start monitoring this performance counter
  36312. */
  36313. beginMonitoring(): void;
  36314. /**
  36315. * Compute the time lapsed since the previous beginMonitoring() call.
  36316. * @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
  36317. */
  36318. endMonitoring(newFrame?: boolean): void;
  36319. private _fetchResult;
  36320. private _startMonitoringTime;
  36321. private _min;
  36322. private _max;
  36323. private _average;
  36324. private _current;
  36325. private _totalValueCount;
  36326. private _totalAccumulated;
  36327. private _lastSecAverage;
  36328. private _lastSecAccumulated;
  36329. private _lastSecTime;
  36330. private _lastSecValueCount;
  36331. }
  36332. }
  36333. declare module BABYLON {
  36334. interface ThinEngine {
  36335. /**
  36336. * Sets alpha constants used by some alpha blending modes
  36337. * @param r defines the red component
  36338. * @param g defines the green component
  36339. * @param b defines the blue component
  36340. * @param a defines the alpha component
  36341. */
  36342. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36343. /**
  36344. * Sets the current alpha mode
  36345. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36346. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36347. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36348. */
  36349. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36350. /**
  36351. * Gets the current alpha mode
  36352. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36353. * @returns the current alpha mode
  36354. */
  36355. getAlphaMode(): number;
  36356. /**
  36357. * Sets the current alpha equation
  36358. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36359. */
  36360. setAlphaEquation(equation: number): void;
  36361. /**
  36362. * Gets the current alpha equation.
  36363. * @returns the current alpha equation
  36364. */
  36365. getAlphaEquation(): number;
  36366. }
  36367. }
  36368. declare module BABYLON {
  36369. interface ThinEngine {
  36370. /** @hidden */
  36371. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36372. }
  36373. }
  36374. declare module BABYLON {
  36375. /**
  36376. * Defines the interface used by display changed events
  36377. */
  36378. export interface IDisplayChangedEventArgs {
  36379. /** Gets the vrDisplay object (if any) */
  36380. vrDisplay: Nullable<any>;
  36381. /** Gets a boolean indicating if webVR is supported */
  36382. vrSupported: boolean;
  36383. }
  36384. /**
  36385. * Defines the interface used by objects containing a viewport (like a camera)
  36386. */
  36387. interface IViewportOwnerLike {
  36388. /**
  36389. * Gets or sets the viewport
  36390. */
  36391. viewport: IViewportLike;
  36392. }
  36393. /**
  36394. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36395. */
  36396. export class Engine extends ThinEngine {
  36397. /** Defines that alpha blending is disabled */
  36398. static readonly ALPHA_DISABLE: number;
  36399. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36400. static readonly ALPHA_ADD: number;
  36401. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36402. static readonly ALPHA_COMBINE: number;
  36403. /** Defines that alpha blending to DEST - SRC * DEST */
  36404. static readonly ALPHA_SUBTRACT: number;
  36405. /** Defines that alpha blending to SRC * DEST */
  36406. static readonly ALPHA_MULTIPLY: number;
  36407. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36408. static readonly ALPHA_MAXIMIZED: number;
  36409. /** Defines that alpha blending to SRC + DEST */
  36410. static readonly ALPHA_ONEONE: number;
  36411. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36412. static readonly ALPHA_PREMULTIPLIED: number;
  36413. /**
  36414. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36415. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36416. */
  36417. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36418. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36419. static readonly ALPHA_INTERPOLATE: number;
  36420. /**
  36421. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36422. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36423. */
  36424. static readonly ALPHA_SCREENMODE: number;
  36425. /** Defines that the ressource is not delayed*/
  36426. static readonly DELAYLOADSTATE_NONE: number;
  36427. /** Defines that the ressource was successfully delay loaded */
  36428. static readonly DELAYLOADSTATE_LOADED: number;
  36429. /** Defines that the ressource is currently delay loading */
  36430. static readonly DELAYLOADSTATE_LOADING: number;
  36431. /** Defines that the ressource is delayed and has not started loading */
  36432. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36433. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36434. static readonly NEVER: number;
  36435. /** 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 */
  36436. static readonly ALWAYS: number;
  36437. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36438. static readonly LESS: number;
  36439. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36440. static readonly EQUAL: number;
  36441. /** 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 */
  36442. static readonly LEQUAL: number;
  36443. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36444. static readonly GREATER: number;
  36445. /** 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 */
  36446. static readonly GEQUAL: number;
  36447. /** 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 */
  36448. static readonly NOTEQUAL: number;
  36449. /** Passed to stencilOperation to specify that stencil value must be kept */
  36450. static readonly KEEP: number;
  36451. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36452. static readonly REPLACE: number;
  36453. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36454. static readonly INCR: number;
  36455. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36456. static readonly DECR: number;
  36457. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36458. static readonly INVERT: number;
  36459. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36460. static readonly INCR_WRAP: number;
  36461. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36462. static readonly DECR_WRAP: number;
  36463. /** Texture is not repeating outside of 0..1 UVs */
  36464. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36465. /** Texture is repeating outside of 0..1 UVs */
  36466. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36467. /** Texture is repeating and mirrored */
  36468. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36469. /** ALPHA */
  36470. static readonly TEXTUREFORMAT_ALPHA: number;
  36471. /** LUMINANCE */
  36472. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36473. /** LUMINANCE_ALPHA */
  36474. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36475. /** RGB */
  36476. static readonly TEXTUREFORMAT_RGB: number;
  36477. /** RGBA */
  36478. static readonly TEXTUREFORMAT_RGBA: number;
  36479. /** RED */
  36480. static readonly TEXTUREFORMAT_RED: number;
  36481. /** RED (2nd reference) */
  36482. static readonly TEXTUREFORMAT_R: number;
  36483. /** RG */
  36484. static readonly TEXTUREFORMAT_RG: number;
  36485. /** RED_INTEGER */
  36486. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36487. /** RED_INTEGER (2nd reference) */
  36488. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36489. /** RG_INTEGER */
  36490. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36491. /** RGB_INTEGER */
  36492. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36493. /** RGBA_INTEGER */
  36494. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36495. /** UNSIGNED_BYTE */
  36496. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36497. /** UNSIGNED_BYTE (2nd reference) */
  36498. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36499. /** FLOAT */
  36500. static readonly TEXTURETYPE_FLOAT: number;
  36501. /** HALF_FLOAT */
  36502. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36503. /** BYTE */
  36504. static readonly TEXTURETYPE_BYTE: number;
  36505. /** SHORT */
  36506. static readonly TEXTURETYPE_SHORT: number;
  36507. /** UNSIGNED_SHORT */
  36508. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36509. /** INT */
  36510. static readonly TEXTURETYPE_INT: number;
  36511. /** UNSIGNED_INT */
  36512. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36513. /** UNSIGNED_SHORT_4_4_4_4 */
  36514. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36515. /** UNSIGNED_SHORT_5_5_5_1 */
  36516. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36517. /** UNSIGNED_SHORT_5_6_5 */
  36518. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36519. /** UNSIGNED_INT_2_10_10_10_REV */
  36520. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36521. /** UNSIGNED_INT_24_8 */
  36522. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36523. /** UNSIGNED_INT_10F_11F_11F_REV */
  36524. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36525. /** UNSIGNED_INT_5_9_9_9_REV */
  36526. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36527. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36528. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36529. /** nearest is mag = nearest and min = nearest and mip = linear */
  36530. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36531. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36532. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36533. /** Trilinear is mag = linear and min = linear and mip = linear */
  36534. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36535. /** nearest is mag = nearest and min = nearest and mip = linear */
  36536. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36537. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36538. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36539. /** Trilinear is mag = linear and min = linear and mip = linear */
  36540. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36541. /** mag = nearest and min = nearest and mip = nearest */
  36542. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36543. /** mag = nearest and min = linear and mip = nearest */
  36544. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36545. /** mag = nearest and min = linear and mip = linear */
  36546. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36547. /** mag = nearest and min = linear and mip = none */
  36548. static readonly TEXTURE_NEAREST_LINEAR: number;
  36549. /** mag = nearest and min = nearest and mip = none */
  36550. static readonly TEXTURE_NEAREST_NEAREST: number;
  36551. /** mag = linear and min = nearest and mip = nearest */
  36552. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36553. /** mag = linear and min = nearest and mip = linear */
  36554. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36555. /** mag = linear and min = linear and mip = none */
  36556. static readonly TEXTURE_LINEAR_LINEAR: number;
  36557. /** mag = linear and min = nearest and mip = none */
  36558. static readonly TEXTURE_LINEAR_NEAREST: number;
  36559. /** Explicit coordinates mode */
  36560. static readonly TEXTURE_EXPLICIT_MODE: number;
  36561. /** Spherical coordinates mode */
  36562. static readonly TEXTURE_SPHERICAL_MODE: number;
  36563. /** Planar coordinates mode */
  36564. static readonly TEXTURE_PLANAR_MODE: number;
  36565. /** Cubic coordinates mode */
  36566. static readonly TEXTURE_CUBIC_MODE: number;
  36567. /** Projection coordinates mode */
  36568. static readonly TEXTURE_PROJECTION_MODE: number;
  36569. /** Skybox coordinates mode */
  36570. static readonly TEXTURE_SKYBOX_MODE: number;
  36571. /** Inverse Cubic coordinates mode */
  36572. static readonly TEXTURE_INVCUBIC_MODE: number;
  36573. /** Equirectangular coordinates mode */
  36574. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36575. /** Equirectangular Fixed coordinates mode */
  36576. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36577. /** Equirectangular Fixed Mirrored coordinates mode */
  36578. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36579. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36580. static readonly SCALEMODE_FLOOR: number;
  36581. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36582. static readonly SCALEMODE_NEAREST: number;
  36583. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36584. static readonly SCALEMODE_CEILING: number;
  36585. /**
  36586. * Returns the current npm package of the sdk
  36587. */
  36588. static get NpmPackage(): string;
  36589. /**
  36590. * Returns the current version of the framework
  36591. */
  36592. static get Version(): string;
  36593. /** Gets the list of created engines */
  36594. static get Instances(): Engine[];
  36595. /**
  36596. * Gets the latest created engine
  36597. */
  36598. static get LastCreatedEngine(): Nullable<Engine>;
  36599. /**
  36600. * Gets the latest created scene
  36601. */
  36602. static get LastCreatedScene(): Nullable<Scene>;
  36603. /**
  36604. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36605. * @param flag defines which part of the materials must be marked as dirty
  36606. * @param predicate defines a predicate used to filter which materials should be affected
  36607. */
  36608. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36609. /**
  36610. * Method called to create the default loading screen.
  36611. * This can be overriden in your own app.
  36612. * @param canvas The rendering canvas element
  36613. * @returns The loading screen
  36614. */
  36615. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36616. /**
  36617. * Method called to create the default rescale post process on each engine.
  36618. */
  36619. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36620. /**
  36621. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36622. **/
  36623. enableOfflineSupport: boolean;
  36624. /**
  36625. * 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)
  36626. **/
  36627. disableManifestCheck: boolean;
  36628. /**
  36629. * Gets the list of created scenes
  36630. */
  36631. scenes: Scene[];
  36632. /**
  36633. * Event raised when a new scene is created
  36634. */
  36635. onNewSceneAddedObservable: Observable<Scene>;
  36636. /**
  36637. * Gets the list of created postprocesses
  36638. */
  36639. postProcesses: PostProcess[];
  36640. /**
  36641. * Gets a boolean indicating if the pointer is currently locked
  36642. */
  36643. isPointerLock: boolean;
  36644. /**
  36645. * Observable event triggered each time the rendering canvas is resized
  36646. */
  36647. onResizeObservable: Observable<Engine>;
  36648. /**
  36649. * Observable event triggered each time the canvas loses focus
  36650. */
  36651. onCanvasBlurObservable: Observable<Engine>;
  36652. /**
  36653. * Observable event triggered each time the canvas gains focus
  36654. */
  36655. onCanvasFocusObservable: Observable<Engine>;
  36656. /**
  36657. * Observable event triggered each time the canvas receives pointerout event
  36658. */
  36659. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36660. /**
  36661. * Observable raised when the engine begins a new frame
  36662. */
  36663. onBeginFrameObservable: Observable<Engine>;
  36664. /**
  36665. * If set, will be used to request the next animation frame for the render loop
  36666. */
  36667. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36668. /**
  36669. * Observable raised when the engine ends the current frame
  36670. */
  36671. onEndFrameObservable: Observable<Engine>;
  36672. /**
  36673. * Observable raised when the engine is about to compile a shader
  36674. */
  36675. onBeforeShaderCompilationObservable: Observable<Engine>;
  36676. /**
  36677. * Observable raised when the engine has jsut compiled a shader
  36678. */
  36679. onAfterShaderCompilationObservable: Observable<Engine>;
  36680. /**
  36681. * Gets the audio engine
  36682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36683. * @ignorenaming
  36684. */
  36685. static audioEngine: IAudioEngine;
  36686. /**
  36687. * Default AudioEngine factory responsible of creating the Audio Engine.
  36688. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36689. */
  36690. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36691. /**
  36692. * Default offline support factory responsible of creating a tool used to store data locally.
  36693. * By default, this will create a Database object if the workload has been embedded.
  36694. */
  36695. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36696. private _loadingScreen;
  36697. private _pointerLockRequested;
  36698. private _rescalePostProcess;
  36699. private _deterministicLockstep;
  36700. private _lockstepMaxSteps;
  36701. private _timeStep;
  36702. protected get _supportsHardwareTextureRescaling(): boolean;
  36703. private _fps;
  36704. private _deltaTime;
  36705. /** @hidden */
  36706. _drawCalls: PerfCounter;
  36707. /** 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 */
  36708. canvasTabIndex: number;
  36709. /**
  36710. * Turn this value on if you want to pause FPS computation when in background
  36711. */
  36712. disablePerformanceMonitorInBackground: boolean;
  36713. private _performanceMonitor;
  36714. /**
  36715. * Gets the performance monitor attached to this engine
  36716. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36717. */
  36718. get performanceMonitor(): PerformanceMonitor;
  36719. private _onFocus;
  36720. private _onBlur;
  36721. private _onCanvasPointerOut;
  36722. private _onCanvasBlur;
  36723. private _onCanvasFocus;
  36724. private _onFullscreenChange;
  36725. private _onPointerLockChange;
  36726. /**
  36727. * Gets the HTML element used to attach event listeners
  36728. * @returns a HTML element
  36729. */
  36730. getInputElement(): Nullable<HTMLElement>;
  36731. /**
  36732. * Creates a new engine
  36733. * @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
  36734. * @param antialias defines enable antialiasing (default: false)
  36735. * @param options defines further options to be sent to the getContext() function
  36736. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36737. */
  36738. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36739. /**
  36740. * Gets current aspect ratio
  36741. * @param viewportOwner defines the camera to use to get the aspect ratio
  36742. * @param useScreen defines if screen size must be used (or the current render target if any)
  36743. * @returns a number defining the aspect ratio
  36744. */
  36745. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36746. /**
  36747. * Gets current screen aspect ratio
  36748. * @returns a number defining the aspect ratio
  36749. */
  36750. getScreenAspectRatio(): number;
  36751. /**
  36752. * Gets the client rect of the HTML canvas attached with the current webGL context
  36753. * @returns a client rectanglee
  36754. */
  36755. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36756. /**
  36757. * Gets the client rect of the HTML element used for events
  36758. * @returns a client rectanglee
  36759. */
  36760. getInputElementClientRect(): Nullable<ClientRect>;
  36761. /**
  36762. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36763. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36764. * @returns true if engine is in deterministic lock step mode
  36765. */
  36766. isDeterministicLockStep(): boolean;
  36767. /**
  36768. * Gets the max steps when engine is running in deterministic lock step
  36769. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36770. * @returns the max steps
  36771. */
  36772. getLockstepMaxSteps(): number;
  36773. /**
  36774. * Returns the time in ms between steps when using deterministic lock step.
  36775. * @returns time step in (ms)
  36776. */
  36777. getTimeStep(): number;
  36778. /**
  36779. * Force the mipmap generation for the given render target texture
  36780. * @param texture defines the render target texture to use
  36781. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36782. */
  36783. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36784. /** States */
  36785. /**
  36786. * Set various states to the webGL context
  36787. * @param culling defines backface culling state
  36788. * @param zOffset defines the value to apply to zOffset (0 by default)
  36789. * @param force defines if states must be applied even if cache is up to date
  36790. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36791. */
  36792. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36793. /**
  36794. * Set the z offset to apply to current rendering
  36795. * @param value defines the offset to apply
  36796. */
  36797. setZOffset(value: number): void;
  36798. /**
  36799. * Gets the current value of the zOffset
  36800. * @returns the current zOffset state
  36801. */
  36802. getZOffset(): number;
  36803. /**
  36804. * Enable or disable depth buffering
  36805. * @param enable defines the state to set
  36806. */
  36807. setDepthBuffer(enable: boolean): void;
  36808. /**
  36809. * Gets a boolean indicating if depth writing is enabled
  36810. * @returns the current depth writing state
  36811. */
  36812. getDepthWrite(): boolean;
  36813. /**
  36814. * Enable or disable depth writing
  36815. * @param enable defines the state to set
  36816. */
  36817. setDepthWrite(enable: boolean): void;
  36818. /**
  36819. * Gets a boolean indicating if stencil buffer is enabled
  36820. * @returns the current stencil buffer state
  36821. */
  36822. getStencilBuffer(): boolean;
  36823. /**
  36824. * Enable or disable the stencil buffer
  36825. * @param enable defines if the stencil buffer must be enabled or disabled
  36826. */
  36827. setStencilBuffer(enable: boolean): void;
  36828. /**
  36829. * Gets the current stencil mask
  36830. * @returns a number defining the new stencil mask to use
  36831. */
  36832. getStencilMask(): number;
  36833. /**
  36834. * Sets the current stencil mask
  36835. * @param mask defines the new stencil mask to use
  36836. */
  36837. setStencilMask(mask: number): void;
  36838. /**
  36839. * Gets the current stencil function
  36840. * @returns a number defining the stencil function to use
  36841. */
  36842. getStencilFunction(): number;
  36843. /**
  36844. * Gets the current stencil reference value
  36845. * @returns a number defining the stencil reference value to use
  36846. */
  36847. getStencilFunctionReference(): number;
  36848. /**
  36849. * Gets the current stencil mask
  36850. * @returns a number defining the stencil mask to use
  36851. */
  36852. getStencilFunctionMask(): number;
  36853. /**
  36854. * Sets the current stencil function
  36855. * @param stencilFunc defines the new stencil function to use
  36856. */
  36857. setStencilFunction(stencilFunc: number): void;
  36858. /**
  36859. * Sets the current stencil reference
  36860. * @param reference defines the new stencil reference to use
  36861. */
  36862. setStencilFunctionReference(reference: number): void;
  36863. /**
  36864. * Sets the current stencil mask
  36865. * @param mask defines the new stencil mask to use
  36866. */
  36867. setStencilFunctionMask(mask: number): void;
  36868. /**
  36869. * Gets the current stencil operation when stencil fails
  36870. * @returns a number defining stencil operation to use when stencil fails
  36871. */
  36872. getStencilOperationFail(): number;
  36873. /**
  36874. * Gets the current stencil operation when depth fails
  36875. * @returns a number defining stencil operation to use when depth fails
  36876. */
  36877. getStencilOperationDepthFail(): number;
  36878. /**
  36879. * Gets the current stencil operation when stencil passes
  36880. * @returns a number defining stencil operation to use when stencil passes
  36881. */
  36882. getStencilOperationPass(): number;
  36883. /**
  36884. * Sets the stencil operation to use when stencil fails
  36885. * @param operation defines the stencil operation to use when stencil fails
  36886. */
  36887. setStencilOperationFail(operation: number): void;
  36888. /**
  36889. * Sets the stencil operation to use when depth fails
  36890. * @param operation defines the stencil operation to use when depth fails
  36891. */
  36892. setStencilOperationDepthFail(operation: number): void;
  36893. /**
  36894. * Sets the stencil operation to use when stencil passes
  36895. * @param operation defines the stencil operation to use when stencil passes
  36896. */
  36897. setStencilOperationPass(operation: number): void;
  36898. /**
  36899. * Sets a boolean indicating if the dithering state is enabled or disabled
  36900. * @param value defines the dithering state
  36901. */
  36902. setDitheringState(value: boolean): void;
  36903. /**
  36904. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36905. * @param value defines the rasterizer state
  36906. */
  36907. setRasterizerState(value: boolean): void;
  36908. /**
  36909. * Gets the current depth function
  36910. * @returns a number defining the depth function
  36911. */
  36912. getDepthFunction(): Nullable<number>;
  36913. /**
  36914. * Sets the current depth function
  36915. * @param depthFunc defines the function to use
  36916. */
  36917. setDepthFunction(depthFunc: number): void;
  36918. /**
  36919. * Sets the current depth function to GREATER
  36920. */
  36921. setDepthFunctionToGreater(): void;
  36922. /**
  36923. * Sets the current depth function to GEQUAL
  36924. */
  36925. setDepthFunctionToGreaterOrEqual(): void;
  36926. /**
  36927. * Sets the current depth function to LESS
  36928. */
  36929. setDepthFunctionToLess(): void;
  36930. /**
  36931. * Sets the current depth function to LEQUAL
  36932. */
  36933. setDepthFunctionToLessOrEqual(): void;
  36934. private _cachedStencilBuffer;
  36935. private _cachedStencilFunction;
  36936. private _cachedStencilMask;
  36937. private _cachedStencilOperationPass;
  36938. private _cachedStencilOperationFail;
  36939. private _cachedStencilOperationDepthFail;
  36940. private _cachedStencilReference;
  36941. /**
  36942. * Caches the the state of the stencil buffer
  36943. */
  36944. cacheStencilState(): void;
  36945. /**
  36946. * Restores the state of the stencil buffer
  36947. */
  36948. restoreStencilState(): void;
  36949. /**
  36950. * Directly set the WebGL Viewport
  36951. * @param x defines the x coordinate of the viewport (in screen space)
  36952. * @param y defines the y coordinate of the viewport (in screen space)
  36953. * @param width defines the width of the viewport (in screen space)
  36954. * @param height defines the height of the viewport (in screen space)
  36955. * @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
  36956. */
  36957. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36958. /**
  36959. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36960. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36961. * @param y defines the y-coordinate of the corner of the clear rectangle
  36962. * @param width defines the width of the clear rectangle
  36963. * @param height defines the height of the clear rectangle
  36964. * @param clearColor defines the clear color
  36965. */
  36966. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36967. /**
  36968. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36969. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36970. * @param y defines the y-coordinate of the corner of the clear rectangle
  36971. * @param width defines the width of the clear rectangle
  36972. * @param height defines the height of the clear rectangle
  36973. */
  36974. enableScissor(x: number, y: number, width: number, height: number): void;
  36975. /**
  36976. * Disable previously set scissor test rectangle
  36977. */
  36978. disableScissor(): void;
  36979. protected _reportDrawCall(): void;
  36980. /**
  36981. * Initializes a webVR display and starts listening to display change events
  36982. * The onVRDisplayChangedObservable will be notified upon these changes
  36983. * @returns The onVRDisplayChangedObservable
  36984. */
  36985. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36986. /** @hidden */
  36987. _prepareVRComponent(): void;
  36988. /** @hidden */
  36989. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36990. /** @hidden */
  36991. _submitVRFrame(): void;
  36992. /**
  36993. * Call this function to leave webVR mode
  36994. * Will do nothing if webVR is not supported or if there is no webVR device
  36995. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36996. */
  36997. disableVR(): void;
  36998. /**
  36999. * Gets a boolean indicating that the system is in VR mode and is presenting
  37000. * @returns true if VR mode is engaged
  37001. */
  37002. isVRPresenting(): boolean;
  37003. /** @hidden */
  37004. _requestVRFrame(): void;
  37005. /** @hidden */
  37006. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37007. /**
  37008. * Gets the source code of the vertex shader associated with a specific webGL program
  37009. * @param program defines the program to use
  37010. * @returns a string containing the source code of the vertex shader associated with the program
  37011. */
  37012. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37013. /**
  37014. * Gets the source code of the fragment shader associated with a specific webGL program
  37015. * @param program defines the program to use
  37016. * @returns a string containing the source code of the fragment shader associated with the program
  37017. */
  37018. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37019. /**
  37020. * Sets a depth stencil texture from a render target to the according uniform.
  37021. * @param channel The texture channel
  37022. * @param uniform The uniform to set
  37023. * @param texture The render target texture containing the depth stencil texture to apply
  37024. */
  37025. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37026. /**
  37027. * Sets a texture to the webGL context from a postprocess
  37028. * @param channel defines the channel to use
  37029. * @param postProcess defines the source postprocess
  37030. */
  37031. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37032. /**
  37033. * Binds the output of the passed in post process to the texture channel specified
  37034. * @param channel The channel the texture should be bound to
  37035. * @param postProcess The post process which's output should be bound
  37036. */
  37037. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37038. protected _rebuildBuffers(): void;
  37039. /** @hidden */
  37040. _renderFrame(): void;
  37041. _renderLoop(): void;
  37042. /** @hidden */
  37043. _renderViews(): boolean;
  37044. /**
  37045. * Toggle full screen mode
  37046. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37047. */
  37048. switchFullscreen(requestPointerLock: boolean): void;
  37049. /**
  37050. * Enters full screen mode
  37051. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37052. */
  37053. enterFullscreen(requestPointerLock: boolean): void;
  37054. /**
  37055. * Exits full screen mode
  37056. */
  37057. exitFullscreen(): void;
  37058. /**
  37059. * Enters Pointerlock mode
  37060. */
  37061. enterPointerlock(): void;
  37062. /**
  37063. * Exits Pointerlock mode
  37064. */
  37065. exitPointerlock(): void;
  37066. /**
  37067. * Begin a new frame
  37068. */
  37069. beginFrame(): void;
  37070. /**
  37071. * Enf the current frame
  37072. */
  37073. endFrame(): void;
  37074. resize(): void;
  37075. /**
  37076. * Force a specific size of the canvas
  37077. * @param width defines the new canvas' width
  37078. * @param height defines the new canvas' height
  37079. */
  37080. setSize(width: number, height: number): void;
  37081. /**
  37082. * Updates a dynamic vertex buffer.
  37083. * @param vertexBuffer the vertex buffer to update
  37084. * @param data the data used to update the vertex buffer
  37085. * @param byteOffset the byte offset of the data
  37086. * @param byteLength the byte length of the data
  37087. */
  37088. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37089. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37090. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37091. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37092. _releaseTexture(texture: InternalTexture): void;
  37093. /**
  37094. * @hidden
  37095. * Rescales a texture
  37096. * @param source input texutre
  37097. * @param destination destination texture
  37098. * @param scene scene to use to render the resize
  37099. * @param internalFormat format to use when resizing
  37100. * @param onComplete callback to be called when resize has completed
  37101. */
  37102. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37103. /**
  37104. * Gets the current framerate
  37105. * @returns a number representing the framerate
  37106. */
  37107. getFps(): number;
  37108. /**
  37109. * Gets the time spent between current and previous frame
  37110. * @returns a number representing the delta time in ms
  37111. */
  37112. getDeltaTime(): number;
  37113. private _measureFps;
  37114. /** @hidden */
  37115. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37116. /**
  37117. * Update a dynamic index buffer
  37118. * @param indexBuffer defines the target index buffer
  37119. * @param indices defines the data to update
  37120. * @param offset defines the offset in the target index buffer where update should start
  37121. */
  37122. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37123. /**
  37124. * Updates the sample count of a render target texture
  37125. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37126. * @param texture defines the texture to update
  37127. * @param samples defines the sample count to set
  37128. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37129. */
  37130. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37131. /**
  37132. * Updates a depth texture Comparison Mode and Function.
  37133. * If the comparison Function is equal to 0, the mode will be set to none.
  37134. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37135. * @param texture The texture to set the comparison function for
  37136. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37137. */
  37138. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37139. /**
  37140. * Creates a webGL buffer to use with instanciation
  37141. * @param capacity defines the size of the buffer
  37142. * @returns the webGL buffer
  37143. */
  37144. createInstancesBuffer(capacity: number): DataBuffer;
  37145. /**
  37146. * Delete a webGL buffer used with instanciation
  37147. * @param buffer defines the webGL buffer to delete
  37148. */
  37149. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37150. private _clientWaitAsync;
  37151. /** @hidden */
  37152. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37153. dispose(): void;
  37154. private _disableTouchAction;
  37155. /**
  37156. * Display the loading screen
  37157. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37158. */
  37159. displayLoadingUI(): void;
  37160. /**
  37161. * Hide the loading screen
  37162. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37163. */
  37164. hideLoadingUI(): void;
  37165. /**
  37166. * Gets the current loading screen object
  37167. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37168. */
  37169. get loadingScreen(): ILoadingScreen;
  37170. /**
  37171. * Sets the current loading screen object
  37172. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37173. */
  37174. set loadingScreen(loadingScreen: ILoadingScreen);
  37175. /**
  37176. * Sets the current loading screen text
  37177. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37178. */
  37179. set loadingUIText(text: string);
  37180. /**
  37181. * Sets the current loading screen background color
  37182. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37183. */
  37184. set loadingUIBackgroundColor(color: string);
  37185. /** Pointerlock and fullscreen */
  37186. /**
  37187. * Ask the browser to promote the current element to pointerlock mode
  37188. * @param element defines the DOM element to promote
  37189. */
  37190. static _RequestPointerlock(element: HTMLElement): void;
  37191. /**
  37192. * Asks the browser to exit pointerlock mode
  37193. */
  37194. static _ExitPointerlock(): void;
  37195. /**
  37196. * Ask the browser to promote the current element to fullscreen rendering mode
  37197. * @param element defines the DOM element to promote
  37198. */
  37199. static _RequestFullscreen(element: HTMLElement): void;
  37200. /**
  37201. * Asks the browser to exit fullscreen mode
  37202. */
  37203. static _ExitFullscreen(): void;
  37204. }
  37205. }
  37206. declare module BABYLON {
  37207. /**
  37208. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37209. * during the life time of the application.
  37210. */
  37211. export class EngineStore {
  37212. /** Gets the list of created engines */
  37213. static Instances: Engine[];
  37214. /** @hidden */
  37215. static _LastCreatedScene: Nullable<Scene>;
  37216. /**
  37217. * Gets the latest created engine
  37218. */
  37219. static get LastCreatedEngine(): Nullable<Engine>;
  37220. /**
  37221. * Gets the latest created scene
  37222. */
  37223. static get LastCreatedScene(): Nullable<Scene>;
  37224. /**
  37225. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37226. * @ignorenaming
  37227. */
  37228. static UseFallbackTexture: boolean;
  37229. /**
  37230. * Texture content used if a texture cannot loaded
  37231. * @ignorenaming
  37232. */
  37233. static FallbackTexture: string;
  37234. }
  37235. }
  37236. declare module BABYLON {
  37237. /**
  37238. * Helper class that provides a small promise polyfill
  37239. */
  37240. export class PromisePolyfill {
  37241. /**
  37242. * Static function used to check if the polyfill is required
  37243. * If this is the case then the function will inject the polyfill to window.Promise
  37244. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37245. */
  37246. static Apply(force?: boolean): void;
  37247. }
  37248. }
  37249. declare module BABYLON {
  37250. /**
  37251. * Interface for screenshot methods with describe argument called `size` as object with options
  37252. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37253. */
  37254. export interface IScreenshotSize {
  37255. /**
  37256. * number in pixels for canvas height
  37257. */
  37258. height?: number;
  37259. /**
  37260. * multiplier allowing render at a higher or lower resolution
  37261. * If value is defined then height and width will be ignored and taken from camera
  37262. */
  37263. precision?: number;
  37264. /**
  37265. * number in pixels for canvas width
  37266. */
  37267. width?: number;
  37268. }
  37269. }
  37270. declare module BABYLON {
  37271. interface IColor4Like {
  37272. r: float;
  37273. g: float;
  37274. b: float;
  37275. a: float;
  37276. }
  37277. /**
  37278. * Class containing a set of static utilities functions
  37279. */
  37280. export class Tools {
  37281. /**
  37282. * Gets or sets the base URL to use to load assets
  37283. */
  37284. static get BaseUrl(): string;
  37285. static set BaseUrl(value: string);
  37286. /**
  37287. * Enable/Disable Custom HTTP Request Headers globally.
  37288. * default = false
  37289. * @see CustomRequestHeaders
  37290. */
  37291. static UseCustomRequestHeaders: boolean;
  37292. /**
  37293. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37294. * i.e. when loading files, where the server/service expects an Authorization header
  37295. */
  37296. static CustomRequestHeaders: {
  37297. [key: string]: string;
  37298. };
  37299. /**
  37300. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37301. */
  37302. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37303. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37304. /**
  37305. * Default behaviour for cors in the application.
  37306. * It can be a string if the expected behavior is identical in the entire app.
  37307. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37308. */
  37309. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37310. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37311. /**
  37312. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37313. * @ignorenaming
  37314. */
  37315. static get UseFallbackTexture(): boolean;
  37316. static set UseFallbackTexture(value: boolean);
  37317. /**
  37318. * Use this object to register external classes like custom textures or material
  37319. * to allow the laoders to instantiate them
  37320. */
  37321. static get RegisteredExternalClasses(): {
  37322. [key: string]: Object;
  37323. };
  37324. static set RegisteredExternalClasses(classes: {
  37325. [key: string]: Object;
  37326. });
  37327. /**
  37328. * Texture content used if a texture cannot loaded
  37329. * @ignorenaming
  37330. */
  37331. static get fallbackTexture(): string;
  37332. static set fallbackTexture(value: string);
  37333. /**
  37334. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37335. * @param u defines the coordinate on X axis
  37336. * @param v defines the coordinate on Y axis
  37337. * @param width defines the width of the source data
  37338. * @param height defines the height of the source data
  37339. * @param pixels defines the source byte array
  37340. * @param color defines the output color
  37341. */
  37342. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37343. /**
  37344. * Interpolates between a and b via alpha
  37345. * @param a The lower value (returned when alpha = 0)
  37346. * @param b The upper value (returned when alpha = 1)
  37347. * @param alpha The interpolation-factor
  37348. * @return The mixed value
  37349. */
  37350. static Mix(a: number, b: number, alpha: number): number;
  37351. /**
  37352. * Tries to instantiate a new object from a given class name
  37353. * @param className defines the class name to instantiate
  37354. * @returns the new object or null if the system was not able to do the instantiation
  37355. */
  37356. static Instantiate(className: string): any;
  37357. /**
  37358. * Provides a slice function that will work even on IE
  37359. * @param data defines the array to slice
  37360. * @param start defines the start of the data (optional)
  37361. * @param end defines the end of the data (optional)
  37362. * @returns the new sliced array
  37363. */
  37364. static Slice<T>(data: T, start?: number, end?: number): T;
  37365. /**
  37366. * Polyfill for setImmediate
  37367. * @param action defines the action to execute after the current execution block
  37368. */
  37369. static SetImmediate(action: () => void): void;
  37370. /**
  37371. * Function indicating if a number is an exponent of 2
  37372. * @param value defines the value to test
  37373. * @returns true if the value is an exponent of 2
  37374. */
  37375. static IsExponentOfTwo(value: number): boolean;
  37376. private static _tmpFloatArray;
  37377. /**
  37378. * Returns the nearest 32-bit single precision float representation of a Number
  37379. * @param value A Number. If the parameter is of a different type, it will get converted
  37380. * to a number or to NaN if it cannot be converted
  37381. * @returns number
  37382. */
  37383. static FloatRound(value: number): number;
  37384. /**
  37385. * Extracts the filename from a path
  37386. * @param path defines the path to use
  37387. * @returns the filename
  37388. */
  37389. static GetFilename(path: string): string;
  37390. /**
  37391. * Extracts the "folder" part of a path (everything before the filename).
  37392. * @param uri The URI to extract the info from
  37393. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37394. * @returns The "folder" part of the path
  37395. */
  37396. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37397. /**
  37398. * Extracts text content from a DOM element hierarchy
  37399. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37400. */
  37401. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37402. /**
  37403. * Convert an angle in radians to degrees
  37404. * @param angle defines the angle to convert
  37405. * @returns the angle in degrees
  37406. */
  37407. static ToDegrees(angle: number): number;
  37408. /**
  37409. * Convert an angle in degrees to radians
  37410. * @param angle defines the angle to convert
  37411. * @returns the angle in radians
  37412. */
  37413. static ToRadians(angle: number): number;
  37414. /**
  37415. * Returns an array if obj is not an array
  37416. * @param obj defines the object to evaluate as an array
  37417. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37418. * @returns either obj directly if obj is an array or a new array containing obj
  37419. */
  37420. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37421. /**
  37422. * Gets the pointer prefix to use
  37423. * @param engine defines the engine we are finding the prefix for
  37424. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37425. */
  37426. static GetPointerPrefix(engine: Engine): string;
  37427. /**
  37428. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37429. * @param url define the url we are trying
  37430. * @param element define the dom element where to configure the cors policy
  37431. */
  37432. static SetCorsBehavior(url: string | string[], element: {
  37433. crossOrigin: string | null;
  37434. }): void;
  37435. /**
  37436. * Removes unwanted characters from an url
  37437. * @param url defines the url to clean
  37438. * @returns the cleaned url
  37439. */
  37440. static CleanUrl(url: string): string;
  37441. /**
  37442. * Gets or sets a function used to pre-process url before using them to load assets
  37443. */
  37444. static get PreprocessUrl(): (url: string) => string;
  37445. static set PreprocessUrl(processor: (url: string) => string);
  37446. /**
  37447. * Loads an image as an HTMLImageElement.
  37448. * @param input url string, ArrayBuffer, or Blob to load
  37449. * @param onLoad callback called when the image successfully loads
  37450. * @param onError callback called when the image fails to load
  37451. * @param offlineProvider offline provider for caching
  37452. * @param mimeType optional mime type
  37453. * @returns the HTMLImageElement of the loaded image
  37454. */
  37455. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37456. /**
  37457. * Loads a file from a url
  37458. * @param url url string, ArrayBuffer, or Blob to load
  37459. * @param onSuccess callback called when the file successfully loads
  37460. * @param onProgress callback called while file is loading (if the server supports this mode)
  37461. * @param offlineProvider defines the offline provider for caching
  37462. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37463. * @param onError callback called when the file fails to load
  37464. * @returns a file request object
  37465. */
  37466. 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;
  37467. /**
  37468. * Loads a file from a url
  37469. * @param url the file url to load
  37470. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37471. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37472. */
  37473. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37474. /**
  37475. * Load a script (identified by an url). When the url returns, the
  37476. * content of this file is added into a new script element, attached to the DOM (body element)
  37477. * @param scriptUrl defines the url of the script to laod
  37478. * @param onSuccess defines the callback called when the script is loaded
  37479. * @param onError defines the callback to call if an error occurs
  37480. * @param scriptId defines the id of the script element
  37481. */
  37482. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37483. /**
  37484. * Load an asynchronous script (identified by an url). When the url returns, the
  37485. * content of this file is added into a new script element, attached to the DOM (body element)
  37486. * @param scriptUrl defines the url of the script to laod
  37487. * @param scriptId defines the id of the script element
  37488. * @returns a promise request object
  37489. */
  37490. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37491. /**
  37492. * Loads a file from a blob
  37493. * @param fileToLoad defines the blob to use
  37494. * @param callback defines the callback to call when data is loaded
  37495. * @param progressCallback defines the callback to call during loading process
  37496. * @returns a file request object
  37497. */
  37498. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37499. /**
  37500. * Reads a file from a File object
  37501. * @param file defines the file to load
  37502. * @param onSuccess defines the callback to call when data is loaded
  37503. * @param onProgress defines the callback to call during loading process
  37504. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37505. * @param onError defines the callback to call when an error occurs
  37506. * @returns a file request object
  37507. */
  37508. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37509. /**
  37510. * Creates a data url from a given string content
  37511. * @param content defines the content to convert
  37512. * @returns the new data url link
  37513. */
  37514. static FileAsURL(content: string): string;
  37515. /**
  37516. * Format the given number to a specific decimal format
  37517. * @param value defines the number to format
  37518. * @param decimals defines the number of decimals to use
  37519. * @returns the formatted string
  37520. */
  37521. static Format(value: number, decimals?: number): string;
  37522. /**
  37523. * Tries to copy an object by duplicating every property
  37524. * @param source defines the source object
  37525. * @param destination defines the target object
  37526. * @param doNotCopyList defines a list of properties to avoid
  37527. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37528. */
  37529. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37530. /**
  37531. * Gets a boolean indicating if the given object has no own property
  37532. * @param obj defines the object to test
  37533. * @returns true if object has no own property
  37534. */
  37535. static IsEmpty(obj: any): boolean;
  37536. /**
  37537. * Function used to register events at window level
  37538. * @param windowElement defines the Window object to use
  37539. * @param events defines the events to register
  37540. */
  37541. static RegisterTopRootEvents(windowElement: Window, events: {
  37542. name: string;
  37543. handler: Nullable<(e: FocusEvent) => any>;
  37544. }[]): void;
  37545. /**
  37546. * Function used to unregister events from window level
  37547. * @param windowElement defines the Window object to use
  37548. * @param events defines the events to unregister
  37549. */
  37550. static UnregisterTopRootEvents(windowElement: Window, events: {
  37551. name: string;
  37552. handler: Nullable<(e: FocusEvent) => any>;
  37553. }[]): void;
  37554. /**
  37555. * @ignore
  37556. */
  37557. static _ScreenshotCanvas: HTMLCanvasElement;
  37558. /**
  37559. * Dumps the current bound framebuffer
  37560. * @param width defines the rendering width
  37561. * @param height defines the rendering height
  37562. * @param engine defines the hosting engine
  37563. * @param successCallback defines the callback triggered once the data are available
  37564. * @param mimeType defines the mime type of the result
  37565. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37566. */
  37567. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37568. /**
  37569. * Converts the canvas data to blob.
  37570. * This acts as a polyfill for browsers not supporting the to blob function.
  37571. * @param canvas Defines the canvas to extract the data from
  37572. * @param successCallback Defines the callback triggered once the data are available
  37573. * @param mimeType Defines the mime type of the result
  37574. */
  37575. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37576. /**
  37577. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37578. * @param successCallback defines the callback triggered once the data are available
  37579. * @param mimeType defines the mime type of the result
  37580. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37581. */
  37582. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37583. /**
  37584. * Downloads a blob in the browser
  37585. * @param blob defines the blob to download
  37586. * @param fileName defines the name of the downloaded file
  37587. */
  37588. static Download(blob: Blob, fileName: string): void;
  37589. /**
  37590. * Captures a screenshot of the current rendering
  37591. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37592. * @param engine defines the rendering engine
  37593. * @param camera defines the source camera
  37594. * @param size This parameter can be set to a single number or to an object with the
  37595. * following (optional) properties: precision, width, height. If a single number is passed,
  37596. * it will be used for both width and height. If an object is passed, the screenshot size
  37597. * will be derived from the parameters. The precision property is a multiplier allowing
  37598. * rendering at a higher or lower resolution
  37599. * @param successCallback defines the callback receives a single parameter which contains the
  37600. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37601. * src parameter of an <img> to display it
  37602. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37603. * Check your browser for supported MIME types
  37604. */
  37605. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37606. /**
  37607. * Captures a screenshot of the current rendering
  37608. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37609. * @param engine defines the rendering engine
  37610. * @param camera defines the source camera
  37611. * @param size This parameter can be set to a single number or to an object with the
  37612. * following (optional) properties: precision, width, height. If a single number is passed,
  37613. * it will be used for both width and height. If an object is passed, the screenshot size
  37614. * will be derived from the parameters. The precision property is a multiplier allowing
  37615. * rendering at a higher or lower resolution
  37616. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37617. * Check your browser for supported MIME types
  37618. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37619. * to the src parameter of an <img> to display it
  37620. */
  37621. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37622. /**
  37623. * Generates an image screenshot from the specified camera.
  37624. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37625. * @param engine The engine to use for rendering
  37626. * @param camera The camera to use for rendering
  37627. * @param size This parameter can be set to a single number or to an object with the
  37628. * following (optional) properties: precision, width, height. If a single number is passed,
  37629. * it will be used for both width and height. If an object is passed, the screenshot size
  37630. * will be derived from the parameters. The precision property is a multiplier allowing
  37631. * rendering at a higher or lower resolution
  37632. * @param successCallback The callback receives a single parameter which contains the
  37633. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37634. * src parameter of an <img> to display it
  37635. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37636. * Check your browser for supported MIME types
  37637. * @param samples Texture samples (default: 1)
  37638. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37639. * @param fileName A name for for the downloaded file.
  37640. */
  37641. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37642. /**
  37643. * Generates an image screenshot from the specified camera.
  37644. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37645. * @param engine The engine to use for rendering
  37646. * @param camera The camera to use for rendering
  37647. * @param size This parameter can be set to a single number or to an object with the
  37648. * following (optional) properties: precision, width, height. If a single number is passed,
  37649. * it will be used for both width and height. If an object is passed, the screenshot size
  37650. * will be derived from the parameters. The precision property is a multiplier allowing
  37651. * rendering at a higher or lower resolution
  37652. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37653. * Check your browser for supported MIME types
  37654. * @param samples Texture samples (default: 1)
  37655. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37656. * @param fileName A name for for the downloaded file.
  37657. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37658. * to the src parameter of an <img> to display it
  37659. */
  37660. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37661. /**
  37662. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37663. * Be aware Math.random() could cause collisions, but:
  37664. * "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"
  37665. * @returns a pseudo random id
  37666. */
  37667. static RandomId(): string;
  37668. /**
  37669. * Test if the given uri is a base64 string
  37670. * @param uri The uri to test
  37671. * @return True if the uri is a base64 string or false otherwise
  37672. */
  37673. static IsBase64(uri: string): boolean;
  37674. /**
  37675. * Decode the given base64 uri.
  37676. * @param uri The uri to decode
  37677. * @return The decoded base64 data.
  37678. */
  37679. static DecodeBase64(uri: string): ArrayBuffer;
  37680. /**
  37681. * Gets the absolute url.
  37682. * @param url the input url
  37683. * @return the absolute url
  37684. */
  37685. static GetAbsoluteUrl(url: string): string;
  37686. /**
  37687. * No log
  37688. */
  37689. static readonly NoneLogLevel: number;
  37690. /**
  37691. * Only message logs
  37692. */
  37693. static readonly MessageLogLevel: number;
  37694. /**
  37695. * Only warning logs
  37696. */
  37697. static readonly WarningLogLevel: number;
  37698. /**
  37699. * Only error logs
  37700. */
  37701. static readonly ErrorLogLevel: number;
  37702. /**
  37703. * All logs
  37704. */
  37705. static readonly AllLogLevel: number;
  37706. /**
  37707. * Gets a value indicating the number of loading errors
  37708. * @ignorenaming
  37709. */
  37710. static get errorsCount(): number;
  37711. /**
  37712. * Callback called when a new log is added
  37713. */
  37714. static OnNewCacheEntry: (entry: string) => void;
  37715. /**
  37716. * Log a message to the console
  37717. * @param message defines the message to log
  37718. */
  37719. static Log(message: string): void;
  37720. /**
  37721. * Write a warning message to the console
  37722. * @param message defines the message to log
  37723. */
  37724. static Warn(message: string): void;
  37725. /**
  37726. * Write an error message to the console
  37727. * @param message defines the message to log
  37728. */
  37729. static Error(message: string): void;
  37730. /**
  37731. * Gets current log cache (list of logs)
  37732. */
  37733. static get LogCache(): string;
  37734. /**
  37735. * Clears the log cache
  37736. */
  37737. static ClearLogCache(): void;
  37738. /**
  37739. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37740. */
  37741. static set LogLevels(level: number);
  37742. /**
  37743. * Checks if the window object exists
  37744. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37745. */
  37746. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37747. /**
  37748. * No performance log
  37749. */
  37750. static readonly PerformanceNoneLogLevel: number;
  37751. /**
  37752. * Use user marks to log performance
  37753. */
  37754. static readonly PerformanceUserMarkLogLevel: number;
  37755. /**
  37756. * Log performance to the console
  37757. */
  37758. static readonly PerformanceConsoleLogLevel: number;
  37759. private static _performance;
  37760. /**
  37761. * Sets the current performance log level
  37762. */
  37763. static set PerformanceLogLevel(level: number);
  37764. private static _StartPerformanceCounterDisabled;
  37765. private static _EndPerformanceCounterDisabled;
  37766. private static _StartUserMark;
  37767. private static _EndUserMark;
  37768. private static _StartPerformanceConsole;
  37769. private static _EndPerformanceConsole;
  37770. /**
  37771. * Starts a performance counter
  37772. */
  37773. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37774. /**
  37775. * Ends a specific performance coutner
  37776. */
  37777. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37778. /**
  37779. * Gets either window.performance.now() if supported or Date.now() else
  37780. */
  37781. static get Now(): number;
  37782. /**
  37783. * This method will return the name of the class used to create the instance of the given object.
  37784. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37785. * @param object the object to get the class name from
  37786. * @param isType defines if the object is actually a type
  37787. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37788. */
  37789. static GetClassName(object: any, isType?: boolean): string;
  37790. /**
  37791. * Gets the first element of an array satisfying a given predicate
  37792. * @param array defines the array to browse
  37793. * @param predicate defines the predicate to use
  37794. * @returns null if not found or the element
  37795. */
  37796. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37797. /**
  37798. * This method will return the name of the full name of the class, including its owning module (if any).
  37799. * 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).
  37800. * @param object the object to get the class name from
  37801. * @param isType defines if the object is actually a type
  37802. * @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.
  37803. * @ignorenaming
  37804. */
  37805. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37806. /**
  37807. * Returns a promise that resolves after the given amount of time.
  37808. * @param delay Number of milliseconds to delay
  37809. * @returns Promise that resolves after the given amount of time
  37810. */
  37811. static DelayAsync(delay: number): Promise<void>;
  37812. /**
  37813. * Utility function to detect if the current user agent is Safari
  37814. * @returns whether or not the current user agent is safari
  37815. */
  37816. static IsSafari(): boolean;
  37817. }
  37818. /**
  37819. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37820. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37821. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37822. * @param name The name of the class, case should be preserved
  37823. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37824. */
  37825. export function className(name: string, module?: string): (target: Object) => void;
  37826. /**
  37827. * An implementation of a loop for asynchronous functions.
  37828. */
  37829. export class AsyncLoop {
  37830. /**
  37831. * Defines the number of iterations for the loop
  37832. */
  37833. iterations: number;
  37834. /**
  37835. * Defines the current index of the loop.
  37836. */
  37837. index: number;
  37838. private _done;
  37839. private _fn;
  37840. private _successCallback;
  37841. /**
  37842. * Constructor.
  37843. * @param iterations the number of iterations.
  37844. * @param func the function to run each iteration
  37845. * @param successCallback the callback that will be called upon succesful execution
  37846. * @param offset starting offset.
  37847. */
  37848. constructor(
  37849. /**
  37850. * Defines the number of iterations for the loop
  37851. */
  37852. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37853. /**
  37854. * Execute the next iteration. Must be called after the last iteration was finished.
  37855. */
  37856. executeNext(): void;
  37857. /**
  37858. * Break the loop and run the success callback.
  37859. */
  37860. breakLoop(): void;
  37861. /**
  37862. * Create and run an async loop.
  37863. * @param iterations the number of iterations.
  37864. * @param fn the function to run each iteration
  37865. * @param successCallback the callback that will be called upon succesful execution
  37866. * @param offset starting offset.
  37867. * @returns the created async loop object
  37868. */
  37869. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37870. /**
  37871. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37872. * @param iterations total number of iterations
  37873. * @param syncedIterations number of synchronous iterations in each async iteration.
  37874. * @param fn the function to call each iteration.
  37875. * @param callback a success call back that will be called when iterating stops.
  37876. * @param breakFunction a break condition (optional)
  37877. * @param timeout timeout settings for the setTimeout function. default - 0.
  37878. * @returns the created async loop object
  37879. */
  37880. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37881. }
  37882. }
  37883. declare module BABYLON {
  37884. /**
  37885. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37886. * The underlying implementation relies on an associative array to ensure the best performances.
  37887. * The value can be anything including 'null' but except 'undefined'
  37888. */
  37889. export class StringDictionary<T> {
  37890. /**
  37891. * This will clear this dictionary and copy the content from the 'source' one.
  37892. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37893. * @param source the dictionary to take the content from and copy to this dictionary
  37894. */
  37895. copyFrom(source: StringDictionary<T>): void;
  37896. /**
  37897. * Get a value based from its key
  37898. * @param key the given key to get the matching value from
  37899. * @return the value if found, otherwise undefined is returned
  37900. */
  37901. get(key: string): T | undefined;
  37902. /**
  37903. * Get a value from its key or add it if it doesn't exist.
  37904. * This method will ensure you that a given key/data will be present in the dictionary.
  37905. * @param key the given key to get the matching value from
  37906. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37907. * The factory will only be invoked if there's no data for the given key.
  37908. * @return the value corresponding to the key.
  37909. */
  37910. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37911. /**
  37912. * Get a value from its key if present in the dictionary otherwise add it
  37913. * @param key the key to get the value from
  37914. * @param val if there's no such key/value pair in the dictionary add it with this value
  37915. * @return the value corresponding to the key
  37916. */
  37917. getOrAdd(key: string, val: T): T;
  37918. /**
  37919. * Check if there's a given key in the dictionary
  37920. * @param key the key to check for
  37921. * @return true if the key is present, false otherwise
  37922. */
  37923. contains(key: string): boolean;
  37924. /**
  37925. * Add a new key and its corresponding value
  37926. * @param key the key to add
  37927. * @param value the value corresponding to the key
  37928. * @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
  37929. */
  37930. add(key: string, value: T): boolean;
  37931. /**
  37932. * Update a specific value associated to a key
  37933. * @param key defines the key to use
  37934. * @param value defines the value to store
  37935. * @returns true if the value was updated (or false if the key was not found)
  37936. */
  37937. set(key: string, value: T): boolean;
  37938. /**
  37939. * Get the element of the given key and remove it from the dictionary
  37940. * @param key defines the key to search
  37941. * @returns the value associated with the key or null if not found
  37942. */
  37943. getAndRemove(key: string): Nullable<T>;
  37944. /**
  37945. * Remove a key/value from the dictionary.
  37946. * @param key the key to remove
  37947. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37948. */
  37949. remove(key: string): boolean;
  37950. /**
  37951. * Clear the whole content of the dictionary
  37952. */
  37953. clear(): void;
  37954. /**
  37955. * Gets the current count
  37956. */
  37957. get count(): number;
  37958. /**
  37959. * Execute a callback on each key/val of the dictionary.
  37960. * Note that you can remove any element in this dictionary in the callback implementation
  37961. * @param callback the callback to execute on a given key/value pair
  37962. */
  37963. forEach(callback: (key: string, val: T) => void): void;
  37964. /**
  37965. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37966. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37967. * Note that you can remove any element in this dictionary in the callback implementation
  37968. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37969. * @returns the first item
  37970. */
  37971. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37972. private _count;
  37973. private _data;
  37974. }
  37975. }
  37976. declare module BABYLON {
  37977. /** @hidden */
  37978. export interface ICollisionCoordinator {
  37979. createCollider(): Collider;
  37980. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37981. init(scene: Scene): void;
  37982. }
  37983. /** @hidden */
  37984. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37985. private _scene;
  37986. private _scaledPosition;
  37987. private _scaledVelocity;
  37988. private _finalPosition;
  37989. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37990. createCollider(): Collider;
  37991. init(scene: Scene): void;
  37992. private _collideWithWorld;
  37993. }
  37994. }
  37995. declare module BABYLON {
  37996. /**
  37997. * Class used to manage all inputs for the scene.
  37998. */
  37999. export class InputManager {
  38000. /** The distance in pixel that you have to move to prevent some events */
  38001. static DragMovementThreshold: number;
  38002. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38003. static LongPressDelay: number;
  38004. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38005. static DoubleClickDelay: number;
  38006. /** If you need to check double click without raising a single click at first click, enable this flag */
  38007. static ExclusiveDoubleClickMode: boolean;
  38008. private _wheelEventName;
  38009. private _onPointerMove;
  38010. private _onPointerDown;
  38011. private _onPointerUp;
  38012. private _initClickEvent;
  38013. private _initActionManager;
  38014. private _delayedSimpleClick;
  38015. private _delayedSimpleClickTimeout;
  38016. private _previousDelayedSimpleClickTimeout;
  38017. private _meshPickProceed;
  38018. private _previousButtonPressed;
  38019. private _currentPickResult;
  38020. private _previousPickResult;
  38021. private _totalPointersPressed;
  38022. private _doubleClickOccured;
  38023. private _pointerOverMesh;
  38024. private _pickedDownMesh;
  38025. private _pickedUpMesh;
  38026. private _pointerX;
  38027. private _pointerY;
  38028. private _unTranslatedPointerX;
  38029. private _unTranslatedPointerY;
  38030. private _startingPointerPosition;
  38031. private _previousStartingPointerPosition;
  38032. private _startingPointerTime;
  38033. private _previousStartingPointerTime;
  38034. private _pointerCaptures;
  38035. private _onKeyDown;
  38036. private _onKeyUp;
  38037. private _onCanvasFocusObserver;
  38038. private _onCanvasBlurObserver;
  38039. private _scene;
  38040. /**
  38041. * Creates a new InputManager
  38042. * @param scene defines the hosting scene
  38043. */
  38044. constructor(scene: Scene);
  38045. /**
  38046. * Gets the mesh that is currently under the pointer
  38047. */
  38048. get meshUnderPointer(): Nullable<AbstractMesh>;
  38049. /**
  38050. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38051. */
  38052. get unTranslatedPointer(): Vector2;
  38053. /**
  38054. * Gets or sets the current on-screen X position of the pointer
  38055. */
  38056. get pointerX(): number;
  38057. set pointerX(value: number);
  38058. /**
  38059. * Gets or sets the current on-screen Y position of the pointer
  38060. */
  38061. get pointerY(): number;
  38062. set pointerY(value: number);
  38063. private _updatePointerPosition;
  38064. private _processPointerMove;
  38065. private _setRayOnPointerInfo;
  38066. private _checkPrePointerObservable;
  38067. /**
  38068. * Use this method to simulate a pointer move on a mesh
  38069. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38070. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38071. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38072. */
  38073. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38074. /**
  38075. * Use this method to simulate a pointer down on a mesh
  38076. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38077. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38078. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38079. */
  38080. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38081. private _processPointerDown;
  38082. /** @hidden */
  38083. _isPointerSwiping(): boolean;
  38084. /**
  38085. * Use this method to simulate a pointer up on a mesh
  38086. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38087. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38088. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38089. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38090. */
  38091. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38092. private _processPointerUp;
  38093. /**
  38094. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38095. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38096. * @returns true if the pointer was captured
  38097. */
  38098. isPointerCaptured(pointerId?: number): boolean;
  38099. /**
  38100. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38101. * @param attachUp defines if you want to attach events to pointerup
  38102. * @param attachDown defines if you want to attach events to pointerdown
  38103. * @param attachMove defines if you want to attach events to pointermove
  38104. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38105. */
  38106. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38107. /**
  38108. * Detaches all event handlers
  38109. */
  38110. detachControl(): void;
  38111. /**
  38112. * Force the value of meshUnderPointer
  38113. * @param mesh defines the mesh to use
  38114. */
  38115. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38116. /**
  38117. * Gets the mesh under the pointer
  38118. * @returns a Mesh or null if no mesh is under the pointer
  38119. */
  38120. getPointerOverMesh(): Nullable<AbstractMesh>;
  38121. }
  38122. }
  38123. declare module BABYLON {
  38124. /**
  38125. * This class defines the direct association between an animation and a target
  38126. */
  38127. export class TargetedAnimation {
  38128. /**
  38129. * Animation to perform
  38130. */
  38131. animation: Animation;
  38132. /**
  38133. * Target to animate
  38134. */
  38135. target: any;
  38136. /**
  38137. * Returns the string "TargetedAnimation"
  38138. * @returns "TargetedAnimation"
  38139. */
  38140. getClassName(): string;
  38141. /**
  38142. * Serialize the object
  38143. * @returns the JSON object representing the current entity
  38144. */
  38145. serialize(): any;
  38146. }
  38147. /**
  38148. * Use this class to create coordinated animations on multiple targets
  38149. */
  38150. export class AnimationGroup implements IDisposable {
  38151. /** The name of the animation group */
  38152. name: string;
  38153. private _scene;
  38154. private _targetedAnimations;
  38155. private _animatables;
  38156. private _from;
  38157. private _to;
  38158. private _isStarted;
  38159. private _isPaused;
  38160. private _speedRatio;
  38161. private _loopAnimation;
  38162. private _isAdditive;
  38163. /**
  38164. * Gets or sets the unique id of the node
  38165. */
  38166. uniqueId: number;
  38167. /**
  38168. * This observable will notify when one animation have ended
  38169. */
  38170. onAnimationEndObservable: Observable<TargetedAnimation>;
  38171. /**
  38172. * Observer raised when one animation loops
  38173. */
  38174. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38175. /**
  38176. * Observer raised when all animations have looped
  38177. */
  38178. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38179. /**
  38180. * This observable will notify when all animations have ended.
  38181. */
  38182. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38183. /**
  38184. * This observable will notify when all animations have paused.
  38185. */
  38186. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38187. /**
  38188. * This observable will notify when all animations are playing.
  38189. */
  38190. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38191. /**
  38192. * Gets the first frame
  38193. */
  38194. get from(): number;
  38195. /**
  38196. * Gets the last frame
  38197. */
  38198. get to(): number;
  38199. /**
  38200. * Define if the animations are started
  38201. */
  38202. get isStarted(): boolean;
  38203. /**
  38204. * Gets a value indicating that the current group is playing
  38205. */
  38206. get isPlaying(): boolean;
  38207. /**
  38208. * Gets or sets the speed ratio to use for all animations
  38209. */
  38210. get speedRatio(): number;
  38211. /**
  38212. * Gets or sets the speed ratio to use for all animations
  38213. */
  38214. set speedRatio(value: number);
  38215. /**
  38216. * Gets or sets if all animations should loop or not
  38217. */
  38218. get loopAnimation(): boolean;
  38219. set loopAnimation(value: boolean);
  38220. /**
  38221. * Gets or sets if all animations should be evaluated additively
  38222. */
  38223. get isAdditive(): boolean;
  38224. set isAdditive(value: boolean);
  38225. /**
  38226. * Gets the targeted animations for this animation group
  38227. */
  38228. get targetedAnimations(): Array<TargetedAnimation>;
  38229. /**
  38230. * returning the list of animatables controlled by this animation group.
  38231. */
  38232. get animatables(): Array<Animatable>;
  38233. /**
  38234. * Gets the list of target animations
  38235. */
  38236. get children(): TargetedAnimation[];
  38237. /**
  38238. * Instantiates a new Animation Group.
  38239. * This helps managing several animations at once.
  38240. * @see http://doc.babylonjs.com/how_to/group
  38241. * @param name Defines the name of the group
  38242. * @param scene Defines the scene the group belongs to
  38243. */
  38244. constructor(
  38245. /** The name of the animation group */
  38246. name: string, scene?: Nullable<Scene>);
  38247. /**
  38248. * Add an animation (with its target) in the group
  38249. * @param animation defines the animation we want to add
  38250. * @param target defines the target of the animation
  38251. * @returns the TargetedAnimation object
  38252. */
  38253. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38254. /**
  38255. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38256. * It can add constant keys at begin or end
  38257. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38258. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38259. * @returns the animation group
  38260. */
  38261. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38262. private _animationLoopCount;
  38263. private _animationLoopFlags;
  38264. private _processLoop;
  38265. /**
  38266. * Start all animations on given targets
  38267. * @param loop defines if animations must loop
  38268. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38269. * @param from defines the from key (optional)
  38270. * @param to defines the to key (optional)
  38271. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38272. * @returns the current animation group
  38273. */
  38274. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38275. /**
  38276. * Pause all animations
  38277. * @returns the animation group
  38278. */
  38279. pause(): AnimationGroup;
  38280. /**
  38281. * Play all animations to initial state
  38282. * This function will start() the animations if they were not started or will restart() them if they were paused
  38283. * @param loop defines if animations must loop
  38284. * @returns the animation group
  38285. */
  38286. play(loop?: boolean): AnimationGroup;
  38287. /**
  38288. * Reset all animations to initial state
  38289. * @returns the animation group
  38290. */
  38291. reset(): AnimationGroup;
  38292. /**
  38293. * Restart animations from key 0
  38294. * @returns the animation group
  38295. */
  38296. restart(): AnimationGroup;
  38297. /**
  38298. * Stop all animations
  38299. * @returns the animation group
  38300. */
  38301. stop(): AnimationGroup;
  38302. /**
  38303. * Set animation weight for all animatables
  38304. * @param weight defines the weight to use
  38305. * @return the animationGroup
  38306. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38307. */
  38308. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38309. /**
  38310. * Synchronize and normalize all animatables with a source animatable
  38311. * @param root defines the root animatable to synchronize with
  38312. * @return the animationGroup
  38313. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38314. */
  38315. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38316. /**
  38317. * Goes to a specific frame in this animation group
  38318. * @param frame the frame number to go to
  38319. * @return the animationGroup
  38320. */
  38321. goToFrame(frame: number): AnimationGroup;
  38322. /**
  38323. * Dispose all associated resources
  38324. */
  38325. dispose(): void;
  38326. private _checkAnimationGroupEnded;
  38327. /**
  38328. * Clone the current animation group and returns a copy
  38329. * @param newName defines the name of the new group
  38330. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38331. * @returns the new aniamtion group
  38332. */
  38333. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38334. /**
  38335. * Serializes the animationGroup to an object
  38336. * @returns Serialized object
  38337. */
  38338. serialize(): any;
  38339. /**
  38340. * Returns a new AnimationGroup object parsed from the source provided.
  38341. * @param parsedAnimationGroup defines the source
  38342. * @param scene defines the scene that will receive the animationGroup
  38343. * @returns a new AnimationGroup
  38344. */
  38345. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38346. /**
  38347. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38348. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38349. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38350. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38351. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38352. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38353. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38354. */
  38355. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38356. /**
  38357. * Returns the string "AnimationGroup"
  38358. * @returns "AnimationGroup"
  38359. */
  38360. getClassName(): string;
  38361. /**
  38362. * Creates a detailled string about the object
  38363. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38364. * @returns a string representing the object
  38365. */
  38366. toString(fullDetails?: boolean): string;
  38367. }
  38368. }
  38369. declare module BABYLON {
  38370. /**
  38371. * Define an interface for all classes that will hold resources
  38372. */
  38373. export interface IDisposable {
  38374. /**
  38375. * Releases all held resources
  38376. */
  38377. dispose(): void;
  38378. }
  38379. /** Interface defining initialization parameters for Scene class */
  38380. export interface SceneOptions {
  38381. /**
  38382. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38383. * It will improve performance when the number of geometries becomes important.
  38384. */
  38385. useGeometryUniqueIdsMap?: boolean;
  38386. /**
  38387. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38388. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38389. */
  38390. useMaterialMeshMap?: boolean;
  38391. /**
  38392. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38393. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38394. */
  38395. useClonedMeshMap?: boolean;
  38396. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38397. virtual?: boolean;
  38398. }
  38399. /**
  38400. * Represents a scene to be rendered by the engine.
  38401. * @see http://doc.babylonjs.com/features/scene
  38402. */
  38403. export class Scene extends AbstractScene implements IAnimatable {
  38404. /** The fog is deactivated */
  38405. static readonly FOGMODE_NONE: number;
  38406. /** The fog density is following an exponential function */
  38407. static readonly FOGMODE_EXP: number;
  38408. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38409. static readonly FOGMODE_EXP2: number;
  38410. /** The fog density is following a linear function. */
  38411. static readonly FOGMODE_LINEAR: number;
  38412. /**
  38413. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38414. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38415. */
  38416. static MinDeltaTime: number;
  38417. /**
  38418. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38419. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38420. */
  38421. static MaxDeltaTime: number;
  38422. /**
  38423. * Factory used to create the default material.
  38424. * @param name The name of the material to create
  38425. * @param scene The scene to create the material for
  38426. * @returns The default material
  38427. */
  38428. static DefaultMaterialFactory(scene: Scene): Material;
  38429. /**
  38430. * Factory used to create the a collision coordinator.
  38431. * @returns The collision coordinator
  38432. */
  38433. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38434. /** @hidden */
  38435. _inputManager: InputManager;
  38436. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38437. cameraToUseForPointers: Nullable<Camera>;
  38438. /** @hidden */
  38439. readonly _isScene: boolean;
  38440. /** @hidden */
  38441. _blockEntityCollection: boolean;
  38442. /**
  38443. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38444. */
  38445. autoClear: boolean;
  38446. /**
  38447. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38448. */
  38449. autoClearDepthAndStencil: boolean;
  38450. /**
  38451. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38452. */
  38453. clearColor: Color4;
  38454. /**
  38455. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38456. */
  38457. ambientColor: Color3;
  38458. /**
  38459. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38460. * It should only be one of the following (if not the default embedded one):
  38461. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38462. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38463. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38464. * The material properties need to be setup according to the type of texture in use.
  38465. */
  38466. environmentBRDFTexture: BaseTexture;
  38467. /** @hidden */
  38468. protected _environmentTexture: Nullable<BaseTexture>;
  38469. /**
  38470. * Texture used in all pbr material as the reflection texture.
  38471. * As in the majority of the scene they are the same (exception for multi room and so on),
  38472. * this is easier to reference from here than from all the materials.
  38473. */
  38474. get environmentTexture(): Nullable<BaseTexture>;
  38475. /**
  38476. * Texture used in all pbr material as the reflection texture.
  38477. * As in the majority of the scene they are the same (exception for multi room and so on),
  38478. * this is easier to set here than in all the materials.
  38479. */
  38480. set environmentTexture(value: Nullable<BaseTexture>);
  38481. /** @hidden */
  38482. protected _environmentIntensity: number;
  38483. /**
  38484. * Intensity of the environment in all pbr material.
  38485. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38486. * As in the majority of the scene they are the same (exception for multi room and so on),
  38487. * this is easier to reference from here than from all the materials.
  38488. */
  38489. get environmentIntensity(): number;
  38490. /**
  38491. * Intensity of the environment in all pbr material.
  38492. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38493. * As in the majority of the scene they are the same (exception for multi room and so on),
  38494. * this is easier to set here than in all the materials.
  38495. */
  38496. set environmentIntensity(value: number);
  38497. /** @hidden */
  38498. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38499. /**
  38500. * Default image processing configuration used either in the rendering
  38501. * Forward main pass or through the imageProcessingPostProcess if present.
  38502. * As in the majority of the scene they are the same (exception for multi camera),
  38503. * this is easier to reference from here than from all the materials and post process.
  38504. *
  38505. * No setter as we it is a shared configuration, you can set the values instead.
  38506. */
  38507. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38508. private _forceWireframe;
  38509. /**
  38510. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38511. */
  38512. set forceWireframe(value: boolean);
  38513. get forceWireframe(): boolean;
  38514. private _skipFrustumClipping;
  38515. /**
  38516. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38517. */
  38518. set skipFrustumClipping(value: boolean);
  38519. get skipFrustumClipping(): boolean;
  38520. private _forcePointsCloud;
  38521. /**
  38522. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38523. */
  38524. set forcePointsCloud(value: boolean);
  38525. get forcePointsCloud(): boolean;
  38526. /**
  38527. * Gets or sets the active clipplane 1
  38528. */
  38529. clipPlane: Nullable<Plane>;
  38530. /**
  38531. * Gets or sets the active clipplane 2
  38532. */
  38533. clipPlane2: Nullable<Plane>;
  38534. /**
  38535. * Gets or sets the active clipplane 3
  38536. */
  38537. clipPlane3: Nullable<Plane>;
  38538. /**
  38539. * Gets or sets the active clipplane 4
  38540. */
  38541. clipPlane4: Nullable<Plane>;
  38542. /**
  38543. * Gets or sets the active clipplane 5
  38544. */
  38545. clipPlane5: Nullable<Plane>;
  38546. /**
  38547. * Gets or sets the active clipplane 6
  38548. */
  38549. clipPlane6: Nullable<Plane>;
  38550. /**
  38551. * Gets or sets a boolean indicating if animations are enabled
  38552. */
  38553. animationsEnabled: boolean;
  38554. private _animationPropertiesOverride;
  38555. /**
  38556. * Gets or sets the animation properties override
  38557. */
  38558. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38559. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38560. /**
  38561. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38562. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38563. */
  38564. useConstantAnimationDeltaTime: boolean;
  38565. /**
  38566. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38567. * Please note that it requires to run a ray cast through the scene on every frame
  38568. */
  38569. constantlyUpdateMeshUnderPointer: boolean;
  38570. /**
  38571. * Defines the HTML cursor to use when hovering over interactive elements
  38572. */
  38573. hoverCursor: string;
  38574. /**
  38575. * Defines the HTML default cursor to use (empty by default)
  38576. */
  38577. defaultCursor: string;
  38578. /**
  38579. * Defines whether cursors are handled by the scene.
  38580. */
  38581. doNotHandleCursors: boolean;
  38582. /**
  38583. * This is used to call preventDefault() on pointer down
  38584. * in order to block unwanted artifacts like system double clicks
  38585. */
  38586. preventDefaultOnPointerDown: boolean;
  38587. /**
  38588. * This is used to call preventDefault() on pointer up
  38589. * in order to block unwanted artifacts like system double clicks
  38590. */
  38591. preventDefaultOnPointerUp: boolean;
  38592. /**
  38593. * Gets or sets user defined metadata
  38594. */
  38595. metadata: any;
  38596. /**
  38597. * For internal use only. Please do not use.
  38598. */
  38599. reservedDataStore: any;
  38600. /**
  38601. * Gets the name of the plugin used to load this scene (null by default)
  38602. */
  38603. loadingPluginName: string;
  38604. /**
  38605. * Use this array to add regular expressions used to disable offline support for specific urls
  38606. */
  38607. disableOfflineSupportExceptionRules: RegExp[];
  38608. /**
  38609. * An event triggered when the scene is disposed.
  38610. */
  38611. onDisposeObservable: Observable<Scene>;
  38612. private _onDisposeObserver;
  38613. /** Sets a function to be executed when this scene is disposed. */
  38614. set onDispose(callback: () => void);
  38615. /**
  38616. * An event triggered before rendering the scene (right after animations and physics)
  38617. */
  38618. onBeforeRenderObservable: Observable<Scene>;
  38619. private _onBeforeRenderObserver;
  38620. /** Sets a function to be executed before rendering this scene */
  38621. set beforeRender(callback: Nullable<() => void>);
  38622. /**
  38623. * An event triggered after rendering the scene
  38624. */
  38625. onAfterRenderObservable: Observable<Scene>;
  38626. /**
  38627. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38628. */
  38629. onAfterRenderCameraObservable: Observable<Camera>;
  38630. private _onAfterRenderObserver;
  38631. /** Sets a function to be executed after rendering this scene */
  38632. set afterRender(callback: Nullable<() => void>);
  38633. /**
  38634. * An event triggered before animating the scene
  38635. */
  38636. onBeforeAnimationsObservable: Observable<Scene>;
  38637. /**
  38638. * An event triggered after animations processing
  38639. */
  38640. onAfterAnimationsObservable: Observable<Scene>;
  38641. /**
  38642. * An event triggered before draw calls are ready to be sent
  38643. */
  38644. onBeforeDrawPhaseObservable: Observable<Scene>;
  38645. /**
  38646. * An event triggered after draw calls have been sent
  38647. */
  38648. onAfterDrawPhaseObservable: Observable<Scene>;
  38649. /**
  38650. * An event triggered when the scene is ready
  38651. */
  38652. onReadyObservable: Observable<Scene>;
  38653. /**
  38654. * An event triggered before rendering a camera
  38655. */
  38656. onBeforeCameraRenderObservable: Observable<Camera>;
  38657. private _onBeforeCameraRenderObserver;
  38658. /** Sets a function to be executed before rendering a camera*/
  38659. set beforeCameraRender(callback: () => void);
  38660. /**
  38661. * An event triggered after rendering a camera
  38662. */
  38663. onAfterCameraRenderObservable: Observable<Camera>;
  38664. private _onAfterCameraRenderObserver;
  38665. /** Sets a function to be executed after rendering a camera*/
  38666. set afterCameraRender(callback: () => void);
  38667. /**
  38668. * An event triggered when active meshes evaluation is about to start
  38669. */
  38670. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38671. /**
  38672. * An event triggered when active meshes evaluation is done
  38673. */
  38674. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38675. /**
  38676. * An event triggered when particles rendering is about to start
  38677. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38678. */
  38679. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38680. /**
  38681. * An event triggered when particles rendering is done
  38682. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38683. */
  38684. onAfterParticlesRenderingObservable: Observable<Scene>;
  38685. /**
  38686. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38687. */
  38688. onDataLoadedObservable: Observable<Scene>;
  38689. /**
  38690. * An event triggered when a camera is created
  38691. */
  38692. onNewCameraAddedObservable: Observable<Camera>;
  38693. /**
  38694. * An event triggered when a camera is removed
  38695. */
  38696. onCameraRemovedObservable: Observable<Camera>;
  38697. /**
  38698. * An event triggered when a light is created
  38699. */
  38700. onNewLightAddedObservable: Observable<Light>;
  38701. /**
  38702. * An event triggered when a light is removed
  38703. */
  38704. onLightRemovedObservable: Observable<Light>;
  38705. /**
  38706. * An event triggered when a geometry is created
  38707. */
  38708. onNewGeometryAddedObservable: Observable<Geometry>;
  38709. /**
  38710. * An event triggered when a geometry is removed
  38711. */
  38712. onGeometryRemovedObservable: Observable<Geometry>;
  38713. /**
  38714. * An event triggered when a transform node is created
  38715. */
  38716. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38717. /**
  38718. * An event triggered when a transform node is removed
  38719. */
  38720. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38721. /**
  38722. * An event triggered when a mesh is created
  38723. */
  38724. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38725. /**
  38726. * An event triggered when a mesh is removed
  38727. */
  38728. onMeshRemovedObservable: Observable<AbstractMesh>;
  38729. /**
  38730. * An event triggered when a skeleton is created
  38731. */
  38732. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38733. /**
  38734. * An event triggered when a skeleton is removed
  38735. */
  38736. onSkeletonRemovedObservable: Observable<Skeleton>;
  38737. /**
  38738. * An event triggered when a material is created
  38739. */
  38740. onNewMaterialAddedObservable: Observable<Material>;
  38741. /**
  38742. * An event triggered when a material is removed
  38743. */
  38744. onMaterialRemovedObservable: Observable<Material>;
  38745. /**
  38746. * An event triggered when a texture is created
  38747. */
  38748. onNewTextureAddedObservable: Observable<BaseTexture>;
  38749. /**
  38750. * An event triggered when a texture is removed
  38751. */
  38752. onTextureRemovedObservable: Observable<BaseTexture>;
  38753. /**
  38754. * An event triggered when render targets are about to be rendered
  38755. * Can happen multiple times per frame.
  38756. */
  38757. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38758. /**
  38759. * An event triggered when render targets were rendered.
  38760. * Can happen multiple times per frame.
  38761. */
  38762. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38763. /**
  38764. * An event triggered before calculating deterministic simulation step
  38765. */
  38766. onBeforeStepObservable: Observable<Scene>;
  38767. /**
  38768. * An event triggered after calculating deterministic simulation step
  38769. */
  38770. onAfterStepObservable: Observable<Scene>;
  38771. /**
  38772. * An event triggered when the activeCamera property is updated
  38773. */
  38774. onActiveCameraChanged: Observable<Scene>;
  38775. /**
  38776. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38777. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38778. * 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)
  38779. */
  38780. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38781. /**
  38782. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38783. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38784. * 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)
  38785. */
  38786. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38787. /**
  38788. * This Observable will when a mesh has been imported into the scene.
  38789. */
  38790. onMeshImportedObservable: Observable<AbstractMesh>;
  38791. /**
  38792. * This Observable will when an animation file has been imported into the scene.
  38793. */
  38794. onAnimationFileImportedObservable: Observable<Scene>;
  38795. /**
  38796. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38797. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38798. */
  38799. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38800. /** @hidden */
  38801. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38802. /**
  38803. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38804. */
  38805. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38806. /**
  38807. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38808. */
  38809. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38810. /**
  38811. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38812. */
  38813. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38814. /** Callback called when a pointer move is detected */
  38815. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38816. /** Callback called when a pointer down is detected */
  38817. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38818. /** Callback called when a pointer up is detected */
  38819. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38820. /** Callback called when a pointer pick is detected */
  38821. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38822. /**
  38823. * 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).
  38824. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38825. */
  38826. onPrePointerObservable: Observable<PointerInfoPre>;
  38827. /**
  38828. * Observable event triggered each time an input event is received from the rendering canvas
  38829. */
  38830. onPointerObservable: Observable<PointerInfo>;
  38831. /**
  38832. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38833. */
  38834. get unTranslatedPointer(): Vector2;
  38835. /**
  38836. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38837. */
  38838. static get DragMovementThreshold(): number;
  38839. static set DragMovementThreshold(value: number);
  38840. /**
  38841. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38842. */
  38843. static get LongPressDelay(): number;
  38844. static set LongPressDelay(value: number);
  38845. /**
  38846. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38847. */
  38848. static get DoubleClickDelay(): number;
  38849. static set DoubleClickDelay(value: number);
  38850. /** If you need to check double click without raising a single click at first click, enable this flag */
  38851. static get ExclusiveDoubleClickMode(): boolean;
  38852. static set ExclusiveDoubleClickMode(value: boolean);
  38853. /** @hidden */
  38854. _mirroredCameraPosition: Nullable<Vector3>;
  38855. /**
  38856. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38857. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38858. */
  38859. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38860. /**
  38861. * Observable event triggered each time an keyboard event is received from the hosting window
  38862. */
  38863. onKeyboardObservable: Observable<KeyboardInfo>;
  38864. private _useRightHandedSystem;
  38865. /**
  38866. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38867. */
  38868. set useRightHandedSystem(value: boolean);
  38869. get useRightHandedSystem(): boolean;
  38870. private _timeAccumulator;
  38871. private _currentStepId;
  38872. private _currentInternalStep;
  38873. /**
  38874. * Sets the step Id used by deterministic lock step
  38875. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38876. * @param newStepId defines the step Id
  38877. */
  38878. setStepId(newStepId: number): void;
  38879. /**
  38880. * Gets the step Id used by deterministic lock step
  38881. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38882. * @returns the step Id
  38883. */
  38884. getStepId(): number;
  38885. /**
  38886. * Gets the internal step used by deterministic lock step
  38887. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38888. * @returns the internal step
  38889. */
  38890. getInternalStep(): number;
  38891. private _fogEnabled;
  38892. /**
  38893. * Gets or sets a boolean indicating if fog is enabled on this scene
  38894. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38895. * (Default is true)
  38896. */
  38897. set fogEnabled(value: boolean);
  38898. get fogEnabled(): boolean;
  38899. private _fogMode;
  38900. /**
  38901. * Gets or sets the fog mode to use
  38902. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38903. * | mode | value |
  38904. * | --- | --- |
  38905. * | FOGMODE_NONE | 0 |
  38906. * | FOGMODE_EXP | 1 |
  38907. * | FOGMODE_EXP2 | 2 |
  38908. * | FOGMODE_LINEAR | 3 |
  38909. */
  38910. set fogMode(value: number);
  38911. get fogMode(): number;
  38912. /**
  38913. * Gets or sets the fog color to use
  38914. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38915. * (Default is Color3(0.2, 0.2, 0.3))
  38916. */
  38917. fogColor: Color3;
  38918. /**
  38919. * Gets or sets the fog density to use
  38920. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38921. * (Default is 0.1)
  38922. */
  38923. fogDensity: number;
  38924. /**
  38925. * Gets or sets the fog start distance to use
  38926. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38927. * (Default is 0)
  38928. */
  38929. fogStart: number;
  38930. /**
  38931. * Gets or sets the fog end distance to use
  38932. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38933. * (Default is 1000)
  38934. */
  38935. fogEnd: number;
  38936. private _shadowsEnabled;
  38937. /**
  38938. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38939. */
  38940. set shadowsEnabled(value: boolean);
  38941. get shadowsEnabled(): boolean;
  38942. private _lightsEnabled;
  38943. /**
  38944. * Gets or sets a boolean indicating if lights are enabled on this scene
  38945. */
  38946. set lightsEnabled(value: boolean);
  38947. get lightsEnabled(): boolean;
  38948. /** All of the active cameras added to this scene. */
  38949. activeCameras: Camera[];
  38950. /** @hidden */
  38951. _activeCamera: Nullable<Camera>;
  38952. /** Gets or sets the current active camera */
  38953. get activeCamera(): Nullable<Camera>;
  38954. set activeCamera(value: Nullable<Camera>);
  38955. private _defaultMaterial;
  38956. /** The default material used on meshes when no material is affected */
  38957. get defaultMaterial(): Material;
  38958. /** The default material used on meshes when no material is affected */
  38959. set defaultMaterial(value: Material);
  38960. private _texturesEnabled;
  38961. /**
  38962. * Gets or sets a boolean indicating if textures are enabled on this scene
  38963. */
  38964. set texturesEnabled(value: boolean);
  38965. get texturesEnabled(): boolean;
  38966. /**
  38967. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38968. */
  38969. physicsEnabled: boolean;
  38970. /**
  38971. * Gets or sets a boolean indicating if particles are enabled on this scene
  38972. */
  38973. particlesEnabled: boolean;
  38974. /**
  38975. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38976. */
  38977. spritesEnabled: boolean;
  38978. private _skeletonsEnabled;
  38979. /**
  38980. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38981. */
  38982. set skeletonsEnabled(value: boolean);
  38983. get skeletonsEnabled(): boolean;
  38984. /**
  38985. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38986. */
  38987. lensFlaresEnabled: boolean;
  38988. /**
  38989. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38990. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38991. */
  38992. collisionsEnabled: boolean;
  38993. private _collisionCoordinator;
  38994. /** @hidden */
  38995. get collisionCoordinator(): ICollisionCoordinator;
  38996. /**
  38997. * Defines the gravity applied to this scene (used only for collisions)
  38998. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38999. */
  39000. gravity: Vector3;
  39001. /**
  39002. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39003. */
  39004. postProcessesEnabled: boolean;
  39005. /**
  39006. * The list of postprocesses added to the scene
  39007. */
  39008. postProcesses: PostProcess[];
  39009. /**
  39010. * Gets the current postprocess manager
  39011. */
  39012. postProcessManager: PostProcessManager;
  39013. /**
  39014. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39015. */
  39016. renderTargetsEnabled: boolean;
  39017. /**
  39018. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39019. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39020. */
  39021. dumpNextRenderTargets: boolean;
  39022. /**
  39023. * The list of user defined render targets added to the scene
  39024. */
  39025. customRenderTargets: RenderTargetTexture[];
  39026. /**
  39027. * Defines if texture loading must be delayed
  39028. * If true, textures will only be loaded when they need to be rendered
  39029. */
  39030. useDelayedTextureLoading: boolean;
  39031. /**
  39032. * Gets the list of meshes imported to the scene through SceneLoader
  39033. */
  39034. importedMeshesFiles: String[];
  39035. /**
  39036. * Gets or sets a boolean indicating if probes are enabled on this scene
  39037. */
  39038. probesEnabled: boolean;
  39039. /**
  39040. * Gets or sets the current offline provider to use to store scene data
  39041. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39042. */
  39043. offlineProvider: IOfflineProvider;
  39044. /**
  39045. * Gets or sets the action manager associated with the scene
  39046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39047. */
  39048. actionManager: AbstractActionManager;
  39049. private _meshesForIntersections;
  39050. /**
  39051. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39052. */
  39053. proceduralTexturesEnabled: boolean;
  39054. private _engine;
  39055. private _totalVertices;
  39056. /** @hidden */
  39057. _activeIndices: PerfCounter;
  39058. /** @hidden */
  39059. _activeParticles: PerfCounter;
  39060. /** @hidden */
  39061. _activeBones: PerfCounter;
  39062. private _animationRatio;
  39063. /** @hidden */
  39064. _animationTimeLast: number;
  39065. /** @hidden */
  39066. _animationTime: number;
  39067. /**
  39068. * Gets or sets a general scale for animation speed
  39069. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39070. */
  39071. animationTimeScale: number;
  39072. /** @hidden */
  39073. _cachedMaterial: Nullable<Material>;
  39074. /** @hidden */
  39075. _cachedEffect: Nullable<Effect>;
  39076. /** @hidden */
  39077. _cachedVisibility: Nullable<number>;
  39078. private _renderId;
  39079. private _frameId;
  39080. private _executeWhenReadyTimeoutId;
  39081. private _intermediateRendering;
  39082. private _viewUpdateFlag;
  39083. private _projectionUpdateFlag;
  39084. /** @hidden */
  39085. _toBeDisposed: Nullable<IDisposable>[];
  39086. private _activeRequests;
  39087. /** @hidden */
  39088. _pendingData: any[];
  39089. private _isDisposed;
  39090. /**
  39091. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39092. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39093. */
  39094. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39095. private _activeMeshes;
  39096. private _processedMaterials;
  39097. private _renderTargets;
  39098. /** @hidden */
  39099. _activeParticleSystems: SmartArray<IParticleSystem>;
  39100. private _activeSkeletons;
  39101. private _softwareSkinnedMeshes;
  39102. private _renderingManager;
  39103. /** @hidden */
  39104. _activeAnimatables: Animatable[];
  39105. private _transformMatrix;
  39106. private _sceneUbo;
  39107. /** @hidden */
  39108. _viewMatrix: Matrix;
  39109. private _projectionMatrix;
  39110. /** @hidden */
  39111. _forcedViewPosition: Nullable<Vector3>;
  39112. /** @hidden */
  39113. _frustumPlanes: Plane[];
  39114. /**
  39115. * Gets the list of frustum planes (built from the active camera)
  39116. */
  39117. get frustumPlanes(): Plane[];
  39118. /**
  39119. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39120. * This is useful if there are more lights that the maximum simulteanous authorized
  39121. */
  39122. requireLightSorting: boolean;
  39123. /** @hidden */
  39124. readonly useMaterialMeshMap: boolean;
  39125. /** @hidden */
  39126. readonly useClonedMeshMap: boolean;
  39127. private _externalData;
  39128. private _uid;
  39129. /**
  39130. * @hidden
  39131. * Backing store of defined scene components.
  39132. */
  39133. _components: ISceneComponent[];
  39134. /**
  39135. * @hidden
  39136. * Backing store of defined scene components.
  39137. */
  39138. _serializableComponents: ISceneSerializableComponent[];
  39139. /**
  39140. * List of components to register on the next registration step.
  39141. */
  39142. private _transientComponents;
  39143. /**
  39144. * Registers the transient components if needed.
  39145. */
  39146. private _registerTransientComponents;
  39147. /**
  39148. * @hidden
  39149. * Add a component to the scene.
  39150. * Note that the ccomponent could be registered on th next frame if this is called after
  39151. * the register component stage.
  39152. * @param component Defines the component to add to the scene
  39153. */
  39154. _addComponent(component: ISceneComponent): void;
  39155. /**
  39156. * @hidden
  39157. * Gets a component from the scene.
  39158. * @param name defines the name of the component to retrieve
  39159. * @returns the component or null if not present
  39160. */
  39161. _getComponent(name: string): Nullable<ISceneComponent>;
  39162. /**
  39163. * @hidden
  39164. * Defines the actions happening before camera updates.
  39165. */
  39166. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39167. /**
  39168. * @hidden
  39169. * Defines the actions happening before clear the canvas.
  39170. */
  39171. _beforeClearStage: Stage<SimpleStageAction>;
  39172. /**
  39173. * @hidden
  39174. * Defines the actions when collecting render targets for the frame.
  39175. */
  39176. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39177. /**
  39178. * @hidden
  39179. * Defines the actions happening for one camera in the frame.
  39180. */
  39181. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39182. /**
  39183. * @hidden
  39184. * Defines the actions happening during the per mesh ready checks.
  39185. */
  39186. _isReadyForMeshStage: Stage<MeshStageAction>;
  39187. /**
  39188. * @hidden
  39189. * Defines the actions happening before evaluate active mesh checks.
  39190. */
  39191. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39192. /**
  39193. * @hidden
  39194. * Defines the actions happening during the evaluate sub mesh checks.
  39195. */
  39196. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39197. /**
  39198. * @hidden
  39199. * Defines the actions happening during the active mesh stage.
  39200. */
  39201. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39202. /**
  39203. * @hidden
  39204. * Defines the actions happening during the per camera render target step.
  39205. */
  39206. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39207. /**
  39208. * @hidden
  39209. * Defines the actions happening just before the active camera is drawing.
  39210. */
  39211. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39212. /**
  39213. * @hidden
  39214. * Defines the actions happening just before a render target is drawing.
  39215. */
  39216. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39217. /**
  39218. * @hidden
  39219. * Defines the actions happening just before a rendering group is drawing.
  39220. */
  39221. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39222. /**
  39223. * @hidden
  39224. * Defines the actions happening just before a mesh is drawing.
  39225. */
  39226. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39227. /**
  39228. * @hidden
  39229. * Defines the actions happening just after a mesh has been drawn.
  39230. */
  39231. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39232. /**
  39233. * @hidden
  39234. * Defines the actions happening just after a rendering group has been drawn.
  39235. */
  39236. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39237. /**
  39238. * @hidden
  39239. * Defines the actions happening just after the active camera has been drawn.
  39240. */
  39241. _afterCameraDrawStage: Stage<CameraStageAction>;
  39242. /**
  39243. * @hidden
  39244. * Defines the actions happening just after a render target has been drawn.
  39245. */
  39246. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39247. /**
  39248. * @hidden
  39249. * Defines the actions happening just after rendering all cameras and computing intersections.
  39250. */
  39251. _afterRenderStage: Stage<SimpleStageAction>;
  39252. /**
  39253. * @hidden
  39254. * Defines the actions happening when a pointer move event happens.
  39255. */
  39256. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39257. /**
  39258. * @hidden
  39259. * Defines the actions happening when a pointer down event happens.
  39260. */
  39261. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39262. /**
  39263. * @hidden
  39264. * Defines the actions happening when a pointer up event happens.
  39265. */
  39266. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39267. /**
  39268. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39269. */
  39270. private geometriesByUniqueId;
  39271. /**
  39272. * Creates a new Scene
  39273. * @param engine defines the engine to use to render this scene
  39274. * @param options defines the scene options
  39275. */
  39276. constructor(engine: Engine, options?: SceneOptions);
  39277. /**
  39278. * Gets a string idenfifying the name of the class
  39279. * @returns "Scene" string
  39280. */
  39281. getClassName(): string;
  39282. private _defaultMeshCandidates;
  39283. /**
  39284. * @hidden
  39285. */
  39286. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39287. private _defaultSubMeshCandidates;
  39288. /**
  39289. * @hidden
  39290. */
  39291. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39292. /**
  39293. * Sets the default candidate providers for the scene.
  39294. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39295. * and getCollidingSubMeshCandidates to their default function
  39296. */
  39297. setDefaultCandidateProviders(): void;
  39298. /**
  39299. * Gets the mesh that is currently under the pointer
  39300. */
  39301. get meshUnderPointer(): Nullable<AbstractMesh>;
  39302. /**
  39303. * Gets or sets the current on-screen X position of the pointer
  39304. */
  39305. get pointerX(): number;
  39306. set pointerX(value: number);
  39307. /**
  39308. * Gets or sets the current on-screen Y position of the pointer
  39309. */
  39310. get pointerY(): number;
  39311. set pointerY(value: number);
  39312. /**
  39313. * Gets the cached material (ie. the latest rendered one)
  39314. * @returns the cached material
  39315. */
  39316. getCachedMaterial(): Nullable<Material>;
  39317. /**
  39318. * Gets the cached effect (ie. the latest rendered one)
  39319. * @returns the cached effect
  39320. */
  39321. getCachedEffect(): Nullable<Effect>;
  39322. /**
  39323. * Gets the cached visibility state (ie. the latest rendered one)
  39324. * @returns the cached visibility state
  39325. */
  39326. getCachedVisibility(): Nullable<number>;
  39327. /**
  39328. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39329. * @param material defines the current material
  39330. * @param effect defines the current effect
  39331. * @param visibility defines the current visibility state
  39332. * @returns true if one parameter is not cached
  39333. */
  39334. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39335. /**
  39336. * Gets the engine associated with the scene
  39337. * @returns an Engine
  39338. */
  39339. getEngine(): Engine;
  39340. /**
  39341. * Gets the total number of vertices rendered per frame
  39342. * @returns the total number of vertices rendered per frame
  39343. */
  39344. getTotalVertices(): number;
  39345. /**
  39346. * Gets the performance counter for total vertices
  39347. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39348. */
  39349. get totalVerticesPerfCounter(): PerfCounter;
  39350. /**
  39351. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39352. * @returns the total number of active indices rendered per frame
  39353. */
  39354. getActiveIndices(): number;
  39355. /**
  39356. * Gets the performance counter for active indices
  39357. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39358. */
  39359. get totalActiveIndicesPerfCounter(): PerfCounter;
  39360. /**
  39361. * Gets the total number of active particles rendered per frame
  39362. * @returns the total number of active particles rendered per frame
  39363. */
  39364. getActiveParticles(): number;
  39365. /**
  39366. * Gets the performance counter for active particles
  39367. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39368. */
  39369. get activeParticlesPerfCounter(): PerfCounter;
  39370. /**
  39371. * Gets the total number of active bones rendered per frame
  39372. * @returns the total number of active bones rendered per frame
  39373. */
  39374. getActiveBones(): number;
  39375. /**
  39376. * Gets the performance counter for active bones
  39377. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39378. */
  39379. get activeBonesPerfCounter(): PerfCounter;
  39380. /**
  39381. * Gets the array of active meshes
  39382. * @returns an array of AbstractMesh
  39383. */
  39384. getActiveMeshes(): SmartArray<AbstractMesh>;
  39385. /**
  39386. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39387. * @returns a number
  39388. */
  39389. getAnimationRatio(): number;
  39390. /**
  39391. * Gets an unique Id for the current render phase
  39392. * @returns a number
  39393. */
  39394. getRenderId(): number;
  39395. /**
  39396. * Gets an unique Id for the current frame
  39397. * @returns a number
  39398. */
  39399. getFrameId(): number;
  39400. /** Call this function if you want to manually increment the render Id*/
  39401. incrementRenderId(): void;
  39402. private _createUbo;
  39403. /**
  39404. * Use this method to simulate a pointer move on a mesh
  39405. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39406. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39407. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39408. * @returns the current scene
  39409. */
  39410. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39411. /**
  39412. * Use this method to simulate a pointer down on a mesh
  39413. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39414. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39415. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39416. * @returns the current scene
  39417. */
  39418. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39419. /**
  39420. * Use this method to simulate a pointer up on a mesh
  39421. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39422. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39423. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39424. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39425. * @returns the current scene
  39426. */
  39427. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39428. /**
  39429. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39430. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39431. * @returns true if the pointer was captured
  39432. */
  39433. isPointerCaptured(pointerId?: number): boolean;
  39434. /**
  39435. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39436. * @param attachUp defines if you want to attach events to pointerup
  39437. * @param attachDown defines if you want to attach events to pointerdown
  39438. * @param attachMove defines if you want to attach events to pointermove
  39439. */
  39440. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39441. /** Detaches all event handlers*/
  39442. detachControl(): void;
  39443. /**
  39444. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39445. * Delay loaded resources are not taking in account
  39446. * @return true if all required resources are ready
  39447. */
  39448. isReady(): boolean;
  39449. /** Resets all cached information relative to material (including effect and visibility) */
  39450. resetCachedMaterial(): void;
  39451. /**
  39452. * Registers a function to be called before every frame render
  39453. * @param func defines the function to register
  39454. */
  39455. registerBeforeRender(func: () => void): void;
  39456. /**
  39457. * Unregisters a function called before every frame render
  39458. * @param func defines the function to unregister
  39459. */
  39460. unregisterBeforeRender(func: () => void): void;
  39461. /**
  39462. * Registers a function to be called after every frame render
  39463. * @param func defines the function to register
  39464. */
  39465. registerAfterRender(func: () => void): void;
  39466. /**
  39467. * Unregisters a function called after every frame render
  39468. * @param func defines the function to unregister
  39469. */
  39470. unregisterAfterRender(func: () => void): void;
  39471. private _executeOnceBeforeRender;
  39472. /**
  39473. * The provided function will run before render once and will be disposed afterwards.
  39474. * A timeout delay can be provided so that the function will be executed in N ms.
  39475. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39476. * @param func The function to be executed.
  39477. * @param timeout optional delay in ms
  39478. */
  39479. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39480. /** @hidden */
  39481. _addPendingData(data: any): void;
  39482. /** @hidden */
  39483. _removePendingData(data: any): void;
  39484. /**
  39485. * Returns the number of items waiting to be loaded
  39486. * @returns the number of items waiting to be loaded
  39487. */
  39488. getWaitingItemsCount(): number;
  39489. /**
  39490. * Returns a boolean indicating if the scene is still loading data
  39491. */
  39492. get isLoading(): boolean;
  39493. /**
  39494. * Registers a function to be executed when the scene is ready
  39495. * @param {Function} func - the function to be executed
  39496. */
  39497. executeWhenReady(func: () => void): void;
  39498. /**
  39499. * Returns a promise that resolves when the scene is ready
  39500. * @returns A promise that resolves when the scene is ready
  39501. */
  39502. whenReadyAsync(): Promise<void>;
  39503. /** @hidden */
  39504. _checkIsReady(): void;
  39505. /**
  39506. * Gets all animatable attached to the scene
  39507. */
  39508. get animatables(): Animatable[];
  39509. /**
  39510. * Resets the last animation time frame.
  39511. * Useful to override when animations start running when loading a scene for the first time.
  39512. */
  39513. resetLastAnimationTimeFrame(): void;
  39514. /**
  39515. * Gets the current view matrix
  39516. * @returns a Matrix
  39517. */
  39518. getViewMatrix(): Matrix;
  39519. /**
  39520. * Gets the current projection matrix
  39521. * @returns a Matrix
  39522. */
  39523. getProjectionMatrix(): Matrix;
  39524. /**
  39525. * Gets the current transform matrix
  39526. * @returns a Matrix made of View * Projection
  39527. */
  39528. getTransformMatrix(): Matrix;
  39529. /**
  39530. * Sets the current transform matrix
  39531. * @param viewL defines the View matrix to use
  39532. * @param projectionL defines the Projection matrix to use
  39533. * @param viewR defines the right View matrix to use (if provided)
  39534. * @param projectionR defines the right Projection matrix to use (if provided)
  39535. */
  39536. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39537. /**
  39538. * Gets the uniform buffer used to store scene data
  39539. * @returns a UniformBuffer
  39540. */
  39541. getSceneUniformBuffer(): UniformBuffer;
  39542. /**
  39543. * Gets an unique (relatively to the current scene) Id
  39544. * @returns an unique number for the scene
  39545. */
  39546. getUniqueId(): number;
  39547. /**
  39548. * Add a mesh to the list of scene's meshes
  39549. * @param newMesh defines the mesh to add
  39550. * @param recursive if all child meshes should also be added to the scene
  39551. */
  39552. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39553. /**
  39554. * Remove a mesh for the list of scene's meshes
  39555. * @param toRemove defines the mesh to remove
  39556. * @param recursive if all child meshes should also be removed from the scene
  39557. * @returns the index where the mesh was in the mesh list
  39558. */
  39559. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39560. /**
  39561. * Add a transform node to the list of scene's transform nodes
  39562. * @param newTransformNode defines the transform node to add
  39563. */
  39564. addTransformNode(newTransformNode: TransformNode): void;
  39565. /**
  39566. * Remove a transform node for the list of scene's transform nodes
  39567. * @param toRemove defines the transform node to remove
  39568. * @returns the index where the transform node was in the transform node list
  39569. */
  39570. removeTransformNode(toRemove: TransformNode): number;
  39571. /**
  39572. * Remove a skeleton for the list of scene's skeletons
  39573. * @param toRemove defines the skeleton to remove
  39574. * @returns the index where the skeleton was in the skeleton list
  39575. */
  39576. removeSkeleton(toRemove: Skeleton): number;
  39577. /**
  39578. * Remove a morph target for the list of scene's morph targets
  39579. * @param toRemove defines the morph target to remove
  39580. * @returns the index where the morph target was in the morph target list
  39581. */
  39582. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39583. /**
  39584. * Remove a light for the list of scene's lights
  39585. * @param toRemove defines the light to remove
  39586. * @returns the index where the light was in the light list
  39587. */
  39588. removeLight(toRemove: Light): number;
  39589. /**
  39590. * Remove a camera for the list of scene's cameras
  39591. * @param toRemove defines the camera to remove
  39592. * @returns the index where the camera was in the camera list
  39593. */
  39594. removeCamera(toRemove: Camera): number;
  39595. /**
  39596. * Remove a particle system for the list of scene's particle systems
  39597. * @param toRemove defines the particle system to remove
  39598. * @returns the index where the particle system was in the particle system list
  39599. */
  39600. removeParticleSystem(toRemove: IParticleSystem): number;
  39601. /**
  39602. * Remove a animation for the list of scene's animations
  39603. * @param toRemove defines the animation to remove
  39604. * @returns the index where the animation was in the animation list
  39605. */
  39606. removeAnimation(toRemove: Animation): number;
  39607. /**
  39608. * Will stop the animation of the given target
  39609. * @param target - the target
  39610. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39611. * @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)
  39612. */
  39613. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39614. /**
  39615. * Removes the given animation group from this scene.
  39616. * @param toRemove The animation group to remove
  39617. * @returns The index of the removed animation group
  39618. */
  39619. removeAnimationGroup(toRemove: AnimationGroup): number;
  39620. /**
  39621. * Removes the given multi-material from this scene.
  39622. * @param toRemove The multi-material to remove
  39623. * @returns The index of the removed multi-material
  39624. */
  39625. removeMultiMaterial(toRemove: MultiMaterial): number;
  39626. /**
  39627. * Removes the given material from this scene.
  39628. * @param toRemove The material to remove
  39629. * @returns The index of the removed material
  39630. */
  39631. removeMaterial(toRemove: Material): number;
  39632. /**
  39633. * Removes the given action manager from this scene.
  39634. * @param toRemove The action manager to remove
  39635. * @returns The index of the removed action manager
  39636. */
  39637. removeActionManager(toRemove: AbstractActionManager): number;
  39638. /**
  39639. * Removes the given texture from this scene.
  39640. * @param toRemove The texture to remove
  39641. * @returns The index of the removed texture
  39642. */
  39643. removeTexture(toRemove: BaseTexture): number;
  39644. /**
  39645. * Adds the given light to this scene
  39646. * @param newLight The light to add
  39647. */
  39648. addLight(newLight: Light): void;
  39649. /**
  39650. * Sorts the list list based on light priorities
  39651. */
  39652. sortLightsByPriority(): void;
  39653. /**
  39654. * Adds the given camera to this scene
  39655. * @param newCamera The camera to add
  39656. */
  39657. addCamera(newCamera: Camera): void;
  39658. /**
  39659. * Adds the given skeleton to this scene
  39660. * @param newSkeleton The skeleton to add
  39661. */
  39662. addSkeleton(newSkeleton: Skeleton): void;
  39663. /**
  39664. * Adds the given particle system to this scene
  39665. * @param newParticleSystem The particle system to add
  39666. */
  39667. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39668. /**
  39669. * Adds the given animation to this scene
  39670. * @param newAnimation The animation to add
  39671. */
  39672. addAnimation(newAnimation: Animation): void;
  39673. /**
  39674. * Adds the given animation group to this scene.
  39675. * @param newAnimationGroup The animation group to add
  39676. */
  39677. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39678. /**
  39679. * Adds the given multi-material to this scene
  39680. * @param newMultiMaterial The multi-material to add
  39681. */
  39682. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39683. /**
  39684. * Adds the given material to this scene
  39685. * @param newMaterial The material to add
  39686. */
  39687. addMaterial(newMaterial: Material): void;
  39688. /**
  39689. * Adds the given morph target to this scene
  39690. * @param newMorphTargetManager The morph target to add
  39691. */
  39692. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39693. /**
  39694. * Adds the given geometry to this scene
  39695. * @param newGeometry The geometry to add
  39696. */
  39697. addGeometry(newGeometry: Geometry): void;
  39698. /**
  39699. * Adds the given action manager to this scene
  39700. * @param newActionManager The action manager to add
  39701. */
  39702. addActionManager(newActionManager: AbstractActionManager): void;
  39703. /**
  39704. * Adds the given texture to this scene.
  39705. * @param newTexture The texture to add
  39706. */
  39707. addTexture(newTexture: BaseTexture): void;
  39708. /**
  39709. * Switch active camera
  39710. * @param newCamera defines the new active camera
  39711. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39712. */
  39713. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39714. /**
  39715. * sets the active camera of the scene using its ID
  39716. * @param id defines the camera's ID
  39717. * @return the new active camera or null if none found.
  39718. */
  39719. setActiveCameraByID(id: string): Nullable<Camera>;
  39720. /**
  39721. * sets the active camera of the scene using its name
  39722. * @param name defines the camera's name
  39723. * @returns the new active camera or null if none found.
  39724. */
  39725. setActiveCameraByName(name: string): Nullable<Camera>;
  39726. /**
  39727. * get an animation group using its name
  39728. * @param name defines the material's name
  39729. * @return the animation group or null if none found.
  39730. */
  39731. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39732. /**
  39733. * Get a material using its unique id
  39734. * @param uniqueId defines the material's unique id
  39735. * @return the material or null if none found.
  39736. */
  39737. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39738. /**
  39739. * get a material using its id
  39740. * @param id defines the material's ID
  39741. * @return the material or null if none found.
  39742. */
  39743. getMaterialByID(id: string): Nullable<Material>;
  39744. /**
  39745. * Gets a the last added material using a given id
  39746. * @param id defines the material's ID
  39747. * @return the last material with the given id or null if none found.
  39748. */
  39749. getLastMaterialByID(id: string): Nullable<Material>;
  39750. /**
  39751. * Gets a material using its name
  39752. * @param name defines the material's name
  39753. * @return the material or null if none found.
  39754. */
  39755. getMaterialByName(name: string): Nullable<Material>;
  39756. /**
  39757. * Get a texture using its unique id
  39758. * @param uniqueId defines the texture's unique id
  39759. * @return the texture or null if none found.
  39760. */
  39761. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39762. /**
  39763. * Gets a camera using its id
  39764. * @param id defines the id to look for
  39765. * @returns the camera or null if not found
  39766. */
  39767. getCameraByID(id: string): Nullable<Camera>;
  39768. /**
  39769. * Gets a camera using its unique id
  39770. * @param uniqueId defines the unique id to look for
  39771. * @returns the camera or null if not found
  39772. */
  39773. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39774. /**
  39775. * Gets a camera using its name
  39776. * @param name defines the camera's name
  39777. * @return the camera or null if none found.
  39778. */
  39779. getCameraByName(name: string): Nullable<Camera>;
  39780. /**
  39781. * Gets a bone using its id
  39782. * @param id defines the bone's id
  39783. * @return the bone or null if not found
  39784. */
  39785. getBoneByID(id: string): Nullable<Bone>;
  39786. /**
  39787. * Gets a bone using its id
  39788. * @param name defines the bone's name
  39789. * @return the bone or null if not found
  39790. */
  39791. getBoneByName(name: string): Nullable<Bone>;
  39792. /**
  39793. * Gets a light node using its name
  39794. * @param name defines the the light's name
  39795. * @return the light or null if none found.
  39796. */
  39797. getLightByName(name: string): Nullable<Light>;
  39798. /**
  39799. * Gets a light node using its id
  39800. * @param id defines the light's id
  39801. * @return the light or null if none found.
  39802. */
  39803. getLightByID(id: string): Nullable<Light>;
  39804. /**
  39805. * Gets a light node using its scene-generated unique ID
  39806. * @param uniqueId defines the light's unique id
  39807. * @return the light or null if none found.
  39808. */
  39809. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39810. /**
  39811. * Gets a particle system by id
  39812. * @param id defines the particle system id
  39813. * @return the corresponding system or null if none found
  39814. */
  39815. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39816. /**
  39817. * Gets a geometry using its ID
  39818. * @param id defines the geometry's id
  39819. * @return the geometry or null if none found.
  39820. */
  39821. getGeometryByID(id: string): Nullable<Geometry>;
  39822. private _getGeometryByUniqueID;
  39823. /**
  39824. * Add a new geometry to this scene
  39825. * @param geometry defines the geometry to be added to the scene.
  39826. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39827. * @return a boolean defining if the geometry was added or not
  39828. */
  39829. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39830. /**
  39831. * Removes an existing geometry
  39832. * @param geometry defines the geometry to be removed from the scene
  39833. * @return a boolean defining if the geometry was removed or not
  39834. */
  39835. removeGeometry(geometry: Geometry): boolean;
  39836. /**
  39837. * Gets the list of geometries attached to the scene
  39838. * @returns an array of Geometry
  39839. */
  39840. getGeometries(): Geometry[];
  39841. /**
  39842. * Gets the first added mesh found of a given ID
  39843. * @param id defines the id to search for
  39844. * @return the mesh found or null if not found at all
  39845. */
  39846. getMeshByID(id: string): Nullable<AbstractMesh>;
  39847. /**
  39848. * Gets a list of meshes using their id
  39849. * @param id defines the id to search for
  39850. * @returns a list of meshes
  39851. */
  39852. getMeshesByID(id: string): Array<AbstractMesh>;
  39853. /**
  39854. * Gets the first added transform node found of a given ID
  39855. * @param id defines the id to search for
  39856. * @return the found transform node or null if not found at all.
  39857. */
  39858. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39859. /**
  39860. * Gets a transform node with its auto-generated unique id
  39861. * @param uniqueId efines the unique id to search for
  39862. * @return the found transform node or null if not found at all.
  39863. */
  39864. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39865. /**
  39866. * Gets a list of transform nodes using their id
  39867. * @param id defines the id to search for
  39868. * @returns a list of transform nodes
  39869. */
  39870. getTransformNodesByID(id: string): Array<TransformNode>;
  39871. /**
  39872. * Gets a mesh with its auto-generated unique id
  39873. * @param uniqueId defines the unique id to search for
  39874. * @return the found mesh or null if not found at all.
  39875. */
  39876. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39877. /**
  39878. * Gets a the last added mesh using a given id
  39879. * @param id defines the id to search for
  39880. * @return the found mesh or null if not found at all.
  39881. */
  39882. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39883. /**
  39884. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39885. * @param id defines the id to search for
  39886. * @return the found node or null if not found at all
  39887. */
  39888. getLastEntryByID(id: string): Nullable<Node>;
  39889. /**
  39890. * Gets a node (Mesh, Camera, Light) using a given id
  39891. * @param id defines the id to search for
  39892. * @return the found node or null if not found at all
  39893. */
  39894. getNodeByID(id: string): Nullable<Node>;
  39895. /**
  39896. * Gets a node (Mesh, Camera, Light) using a given name
  39897. * @param name defines the name to search for
  39898. * @return the found node or null if not found at all.
  39899. */
  39900. getNodeByName(name: string): Nullable<Node>;
  39901. /**
  39902. * Gets a mesh using a given name
  39903. * @param name defines the name to search for
  39904. * @return the found mesh or null if not found at all.
  39905. */
  39906. getMeshByName(name: string): Nullable<AbstractMesh>;
  39907. /**
  39908. * Gets a transform node using a given name
  39909. * @param name defines the name to search for
  39910. * @return the found transform node or null if not found at all.
  39911. */
  39912. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39913. /**
  39914. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39915. * @param id defines the id to search for
  39916. * @return the found skeleton or null if not found at all.
  39917. */
  39918. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39919. /**
  39920. * Gets a skeleton using a given auto generated unique id
  39921. * @param uniqueId defines the unique id to search for
  39922. * @return the found skeleton or null if not found at all.
  39923. */
  39924. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39925. /**
  39926. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39927. * @param id defines the id to search for
  39928. * @return the found skeleton or null if not found at all.
  39929. */
  39930. getSkeletonById(id: string): Nullable<Skeleton>;
  39931. /**
  39932. * Gets a skeleton using a given name
  39933. * @param name defines the name to search for
  39934. * @return the found skeleton or null if not found at all.
  39935. */
  39936. getSkeletonByName(name: string): Nullable<Skeleton>;
  39937. /**
  39938. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39939. * @param id defines the id to search for
  39940. * @return the found morph target manager or null if not found at all.
  39941. */
  39942. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39943. /**
  39944. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39945. * @param id defines the id to search for
  39946. * @return the found morph target or null if not found at all.
  39947. */
  39948. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39949. /**
  39950. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39951. * @param name defines the name to search for
  39952. * @return the found morph target or null if not found at all.
  39953. */
  39954. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39955. /**
  39956. * Gets a boolean indicating if the given mesh is active
  39957. * @param mesh defines the mesh to look for
  39958. * @returns true if the mesh is in the active list
  39959. */
  39960. isActiveMesh(mesh: AbstractMesh): boolean;
  39961. /**
  39962. * Return a unique id as a string which can serve as an identifier for the scene
  39963. */
  39964. get uid(): string;
  39965. /**
  39966. * Add an externaly attached data from its key.
  39967. * This method call will fail and return false, if such key already exists.
  39968. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39969. * @param key the unique key that identifies the data
  39970. * @param data the data object to associate to the key for this Engine instance
  39971. * @return true if no such key were already present and the data was added successfully, false otherwise
  39972. */
  39973. addExternalData<T>(key: string, data: T): boolean;
  39974. /**
  39975. * Get an externaly attached data from its key
  39976. * @param key the unique key that identifies the data
  39977. * @return the associated data, if present (can be null), or undefined if not present
  39978. */
  39979. getExternalData<T>(key: string): Nullable<T>;
  39980. /**
  39981. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39982. * @param key the unique key that identifies the data
  39983. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39984. * @return the associated data, can be null if the factory returned null.
  39985. */
  39986. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39987. /**
  39988. * Remove an externaly attached data from the Engine instance
  39989. * @param key the unique key that identifies the data
  39990. * @return true if the data was successfully removed, false if it doesn't exist
  39991. */
  39992. removeExternalData(key: string): boolean;
  39993. private _evaluateSubMesh;
  39994. /**
  39995. * Clear the processed materials smart array preventing retention point in material dispose.
  39996. */
  39997. freeProcessedMaterials(): void;
  39998. private _preventFreeActiveMeshesAndRenderingGroups;
  39999. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40000. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40001. * when disposing several meshes in a row or a hierarchy of meshes.
  40002. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40003. */
  40004. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40005. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40006. /**
  40007. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40008. */
  40009. freeActiveMeshes(): void;
  40010. /**
  40011. * Clear the info related to rendering groups preventing retention points during dispose.
  40012. */
  40013. freeRenderingGroups(): void;
  40014. /** @hidden */
  40015. _isInIntermediateRendering(): boolean;
  40016. /**
  40017. * Lambda returning the list of potentially active meshes.
  40018. */
  40019. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40020. /**
  40021. * Lambda returning the list of potentially active sub meshes.
  40022. */
  40023. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40024. /**
  40025. * Lambda returning the list of potentially intersecting sub meshes.
  40026. */
  40027. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40028. /**
  40029. * Lambda returning the list of potentially colliding sub meshes.
  40030. */
  40031. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40032. private _activeMeshesFrozen;
  40033. private _skipEvaluateActiveMeshesCompletely;
  40034. /**
  40035. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40036. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40037. * @returns the current scene
  40038. */
  40039. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40040. /**
  40041. * Use this function to restart evaluating active meshes on every frame
  40042. * @returns the current scene
  40043. */
  40044. unfreezeActiveMeshes(): Scene;
  40045. private _evaluateActiveMeshes;
  40046. private _activeMesh;
  40047. /**
  40048. * Update the transform matrix to update from the current active camera
  40049. * @param force defines a boolean used to force the update even if cache is up to date
  40050. */
  40051. updateTransformMatrix(force?: boolean): void;
  40052. private _bindFrameBuffer;
  40053. /** @hidden */
  40054. _allowPostProcessClearColor: boolean;
  40055. /** @hidden */
  40056. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40057. private _processSubCameras;
  40058. private _checkIntersections;
  40059. /** @hidden */
  40060. _advancePhysicsEngineStep(step: number): void;
  40061. /**
  40062. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40063. */
  40064. getDeterministicFrameTime: () => number;
  40065. /** @hidden */
  40066. _animate(): void;
  40067. /** Execute all animations (for a frame) */
  40068. animate(): void;
  40069. /**
  40070. * Render the scene
  40071. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40072. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40073. */
  40074. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40075. /**
  40076. * Freeze all materials
  40077. * A frozen material will not be updatable but should be faster to render
  40078. */
  40079. freezeMaterials(): void;
  40080. /**
  40081. * Unfreeze all materials
  40082. * A frozen material will not be updatable but should be faster to render
  40083. */
  40084. unfreezeMaterials(): void;
  40085. /**
  40086. * Releases all held ressources
  40087. */
  40088. dispose(): void;
  40089. /**
  40090. * Gets if the scene is already disposed
  40091. */
  40092. get isDisposed(): boolean;
  40093. /**
  40094. * Call this function to reduce memory footprint of the scene.
  40095. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40096. */
  40097. clearCachedVertexData(): void;
  40098. /**
  40099. * This function will remove the local cached buffer data from texture.
  40100. * It will save memory but will prevent the texture from being rebuilt
  40101. */
  40102. cleanCachedTextureBuffer(): void;
  40103. /**
  40104. * Get the world extend vectors with an optional filter
  40105. *
  40106. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40107. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40108. */
  40109. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40110. min: Vector3;
  40111. max: Vector3;
  40112. };
  40113. /**
  40114. * Creates a ray that can be used to pick in the scene
  40115. * @param x defines the x coordinate of the origin (on-screen)
  40116. * @param y defines the y coordinate of the origin (on-screen)
  40117. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40118. * @param camera defines the camera to use for the picking
  40119. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40120. * @returns a Ray
  40121. */
  40122. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40123. /**
  40124. * Creates a ray that can be used to pick in the scene
  40125. * @param x defines the x coordinate of the origin (on-screen)
  40126. * @param y defines the y coordinate of the origin (on-screen)
  40127. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40128. * @param result defines the ray where to store the picking ray
  40129. * @param camera defines the camera to use for the picking
  40130. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40131. * @returns the current scene
  40132. */
  40133. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40134. /**
  40135. * Creates a ray that can be used to pick in the scene
  40136. * @param x defines the x coordinate of the origin (on-screen)
  40137. * @param y defines the y coordinate of the origin (on-screen)
  40138. * @param camera defines the camera to use for the picking
  40139. * @returns a Ray
  40140. */
  40141. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40142. /**
  40143. * Creates a ray that can be used to pick in the scene
  40144. * @param x defines the x coordinate of the origin (on-screen)
  40145. * @param y defines the y coordinate of the origin (on-screen)
  40146. * @param result defines the ray where to store the picking ray
  40147. * @param camera defines the camera to use for the picking
  40148. * @returns the current scene
  40149. */
  40150. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40151. /** Launch a ray to try to pick a mesh in the scene
  40152. * @param x position on screen
  40153. * @param y position on screen
  40154. * @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
  40155. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40156. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40157. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40158. * @returns a PickingInfo
  40159. */
  40160. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40161. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40162. * @param x position on screen
  40163. * @param y position on screen
  40164. * @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
  40165. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40166. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40167. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  40168. */
  40169. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40170. /** Use the given ray to pick a mesh in the scene
  40171. * @param ray The ray to use to pick meshes
  40172. * @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
  40173. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40174. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40175. * @returns a PickingInfo
  40176. */
  40177. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40178. /**
  40179. * Launch a ray to try to pick a mesh in the scene
  40180. * @param x X position on screen
  40181. * @param y Y position on screen
  40182. * @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
  40183. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40184. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40185. * @returns an array of PickingInfo
  40186. */
  40187. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40188. /**
  40189. * Launch a ray to try to pick a mesh in the scene
  40190. * @param ray Ray to use
  40191. * @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
  40192. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40193. * @returns an array of PickingInfo
  40194. */
  40195. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40196. /**
  40197. * Force the value of meshUnderPointer
  40198. * @param mesh defines the mesh to use
  40199. */
  40200. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40201. /**
  40202. * Gets the mesh under the pointer
  40203. * @returns a Mesh or null if no mesh is under the pointer
  40204. */
  40205. getPointerOverMesh(): Nullable<AbstractMesh>;
  40206. /** @hidden */
  40207. _rebuildGeometries(): void;
  40208. /** @hidden */
  40209. _rebuildTextures(): void;
  40210. private _getByTags;
  40211. /**
  40212. * Get a list of meshes by tags
  40213. * @param tagsQuery defines the tags query to use
  40214. * @param forEach defines a predicate used to filter results
  40215. * @returns an array of Mesh
  40216. */
  40217. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40218. /**
  40219. * Get a list of cameras by tags
  40220. * @param tagsQuery defines the tags query to use
  40221. * @param forEach defines a predicate used to filter results
  40222. * @returns an array of Camera
  40223. */
  40224. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40225. /**
  40226. * Get a list of lights by tags
  40227. * @param tagsQuery defines the tags query to use
  40228. * @param forEach defines a predicate used to filter results
  40229. * @returns an array of Light
  40230. */
  40231. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40232. /**
  40233. * Get a list of materials by tags
  40234. * @param tagsQuery defines the tags query to use
  40235. * @param forEach defines a predicate used to filter results
  40236. * @returns an array of Material
  40237. */
  40238. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40239. /**
  40240. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40241. * This allowed control for front to back rendering or reversly depending of the special needs.
  40242. *
  40243. * @param renderingGroupId The rendering group id corresponding to its index
  40244. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40245. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40246. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40247. */
  40248. 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;
  40249. /**
  40250. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40251. *
  40252. * @param renderingGroupId The rendering group id corresponding to its index
  40253. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40254. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40255. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40256. */
  40257. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40258. /**
  40259. * Gets the current auto clear configuration for one rendering group of the rendering
  40260. * manager.
  40261. * @param index the rendering group index to get the information for
  40262. * @returns The auto clear setup for the requested rendering group
  40263. */
  40264. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40265. private _blockMaterialDirtyMechanism;
  40266. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40267. get blockMaterialDirtyMechanism(): boolean;
  40268. set blockMaterialDirtyMechanism(value: boolean);
  40269. /**
  40270. * Will flag all materials as dirty to trigger new shader compilation
  40271. * @param flag defines the flag used to specify which material part must be marked as dirty
  40272. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40273. */
  40274. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40275. /** @hidden */
  40276. _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;
  40277. /** @hidden */
  40278. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40279. /** @hidden */
  40280. _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;
  40281. /** @hidden */
  40282. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40283. /** @hidden */
  40284. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40285. /** @hidden */
  40286. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40287. }
  40288. }
  40289. declare module BABYLON {
  40290. /**
  40291. * Set of assets to keep when moving a scene into an asset container.
  40292. */
  40293. export class KeepAssets extends AbstractScene {
  40294. }
  40295. /**
  40296. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40297. */
  40298. export class InstantiatedEntries {
  40299. /**
  40300. * List of new root nodes (eg. nodes with no parent)
  40301. */
  40302. rootNodes: TransformNode[];
  40303. /**
  40304. * List of new skeletons
  40305. */
  40306. skeletons: Skeleton[];
  40307. /**
  40308. * List of new animation groups
  40309. */
  40310. animationGroups: AnimationGroup[];
  40311. }
  40312. /**
  40313. * Container with a set of assets that can be added or removed from a scene.
  40314. */
  40315. export class AssetContainer extends AbstractScene {
  40316. private _wasAddedToScene;
  40317. /**
  40318. * The scene the AssetContainer belongs to.
  40319. */
  40320. scene: Scene;
  40321. /**
  40322. * Instantiates an AssetContainer.
  40323. * @param scene The scene the AssetContainer belongs to.
  40324. */
  40325. constructor(scene: Scene);
  40326. /**
  40327. * Instantiate or clone all meshes and add the new ones to the scene.
  40328. * Skeletons and animation groups will all be cloned
  40329. * @param nameFunction defines an optional function used to get new names for clones
  40330. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40331. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40332. */
  40333. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40334. /**
  40335. * Adds all the assets from the container to the scene.
  40336. */
  40337. addAllToScene(): void;
  40338. /**
  40339. * Removes all the assets in the container from the scene
  40340. */
  40341. removeAllFromScene(): void;
  40342. /**
  40343. * Disposes all the assets in the container
  40344. */
  40345. dispose(): void;
  40346. private _moveAssets;
  40347. /**
  40348. * Removes all the assets contained in the scene and adds them to the container.
  40349. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40350. */
  40351. moveAllFromScene(keepAssets?: KeepAssets): void;
  40352. /**
  40353. * 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.
  40354. * @returns the root mesh
  40355. */
  40356. createRootMesh(): Mesh;
  40357. /**
  40358. * Merge animations (direct and animation groups) from this asset container into a scene
  40359. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40360. * @param animatables set of animatables to retarget to a node from the scene
  40361. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40362. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40363. */
  40364. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40365. }
  40366. }
  40367. declare module BABYLON {
  40368. /**
  40369. * Defines how the parser contract is defined.
  40370. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40371. */
  40372. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40373. /**
  40374. * Defines how the individual parser contract is defined.
  40375. * These parser can parse an individual asset
  40376. */
  40377. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40378. /**
  40379. * Base class of the scene acting as a container for the different elements composing a scene.
  40380. * This class is dynamically extended by the different components of the scene increasing
  40381. * flexibility and reducing coupling
  40382. */
  40383. export abstract class AbstractScene {
  40384. /**
  40385. * Stores the list of available parsers in the application.
  40386. */
  40387. private static _BabylonFileParsers;
  40388. /**
  40389. * Stores the list of available individual parsers in the application.
  40390. */
  40391. private static _IndividualBabylonFileParsers;
  40392. /**
  40393. * Adds a parser in the list of available ones
  40394. * @param name Defines the name of the parser
  40395. * @param parser Defines the parser to add
  40396. */
  40397. static AddParser(name: string, parser: BabylonFileParser): void;
  40398. /**
  40399. * Gets a general parser from the list of avaialble ones
  40400. * @param name Defines the name of the parser
  40401. * @returns the requested parser or null
  40402. */
  40403. static GetParser(name: string): Nullable<BabylonFileParser>;
  40404. /**
  40405. * Adds n individual parser in the list of available ones
  40406. * @param name Defines the name of the parser
  40407. * @param parser Defines the parser to add
  40408. */
  40409. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40410. /**
  40411. * Gets an individual parser from the list of avaialble ones
  40412. * @param name Defines the name of the parser
  40413. * @returns the requested parser or null
  40414. */
  40415. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40416. /**
  40417. * Parser json data and populate both a scene and its associated container object
  40418. * @param jsonData Defines the data to parse
  40419. * @param scene Defines the scene to parse the data for
  40420. * @param container Defines the container attached to the parsing sequence
  40421. * @param rootUrl Defines the root url of the data
  40422. */
  40423. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40424. /**
  40425. * Gets the list of root nodes (ie. nodes with no parent)
  40426. */
  40427. rootNodes: Node[];
  40428. /** All of the cameras added to this scene
  40429. * @see http://doc.babylonjs.com/babylon101/cameras
  40430. */
  40431. cameras: Camera[];
  40432. /**
  40433. * All of the lights added to this scene
  40434. * @see http://doc.babylonjs.com/babylon101/lights
  40435. */
  40436. lights: Light[];
  40437. /**
  40438. * All of the (abstract) meshes added to this scene
  40439. */
  40440. meshes: AbstractMesh[];
  40441. /**
  40442. * The list of skeletons added to the scene
  40443. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40444. */
  40445. skeletons: Skeleton[];
  40446. /**
  40447. * All of the particle systems added to this scene
  40448. * @see http://doc.babylonjs.com/babylon101/particles
  40449. */
  40450. particleSystems: IParticleSystem[];
  40451. /**
  40452. * Gets a list of Animations associated with the scene
  40453. */
  40454. animations: Animation[];
  40455. /**
  40456. * All of the animation groups added to this scene
  40457. * @see http://doc.babylonjs.com/how_to/group
  40458. */
  40459. animationGroups: AnimationGroup[];
  40460. /**
  40461. * All of the multi-materials added to this scene
  40462. * @see http://doc.babylonjs.com/how_to/multi_materials
  40463. */
  40464. multiMaterials: MultiMaterial[];
  40465. /**
  40466. * All of the materials added to this scene
  40467. * In the context of a Scene, it is not supposed to be modified manually.
  40468. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40469. * Note also that the order of the Material within the array is not significant and might change.
  40470. * @see http://doc.babylonjs.com/babylon101/materials
  40471. */
  40472. materials: Material[];
  40473. /**
  40474. * The list of morph target managers added to the scene
  40475. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40476. */
  40477. morphTargetManagers: MorphTargetManager[];
  40478. /**
  40479. * The list of geometries used in the scene.
  40480. */
  40481. geometries: Geometry[];
  40482. /**
  40483. * All of the tranform nodes added to this scene
  40484. * In the context of a Scene, it is not supposed to be modified manually.
  40485. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40486. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40487. * @see http://doc.babylonjs.com/how_to/transformnode
  40488. */
  40489. transformNodes: TransformNode[];
  40490. /**
  40491. * ActionManagers available on the scene.
  40492. */
  40493. actionManagers: AbstractActionManager[];
  40494. /**
  40495. * Textures to keep.
  40496. */
  40497. textures: BaseTexture[];
  40498. /**
  40499. * Environment texture for the scene
  40500. */
  40501. environmentTexture: Nullable<BaseTexture>;
  40502. /**
  40503. * @returns all meshes, lights, cameras, transformNodes and bones
  40504. */
  40505. getNodes(): Array<Node>;
  40506. }
  40507. }
  40508. declare module BABYLON {
  40509. /**
  40510. * Interface used to define options for Sound class
  40511. */
  40512. export interface ISoundOptions {
  40513. /**
  40514. * Does the sound autoplay once loaded.
  40515. */
  40516. autoplay?: boolean;
  40517. /**
  40518. * Does the sound loop after it finishes playing once.
  40519. */
  40520. loop?: boolean;
  40521. /**
  40522. * Sound's volume
  40523. */
  40524. volume?: number;
  40525. /**
  40526. * Is it a spatial sound?
  40527. */
  40528. spatialSound?: boolean;
  40529. /**
  40530. * Maximum distance to hear that sound
  40531. */
  40532. maxDistance?: number;
  40533. /**
  40534. * Uses user defined attenuation function
  40535. */
  40536. useCustomAttenuation?: boolean;
  40537. /**
  40538. * Define the roll off factor of spatial sounds.
  40539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40540. */
  40541. rolloffFactor?: number;
  40542. /**
  40543. * Define the reference distance the sound should be heard perfectly.
  40544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40545. */
  40546. refDistance?: number;
  40547. /**
  40548. * Define the distance attenuation model the sound will follow.
  40549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40550. */
  40551. distanceModel?: string;
  40552. /**
  40553. * Defines the playback speed (1 by default)
  40554. */
  40555. playbackRate?: number;
  40556. /**
  40557. * Defines if the sound is from a streaming source
  40558. */
  40559. streaming?: boolean;
  40560. /**
  40561. * Defines an optional length (in seconds) inside the sound file
  40562. */
  40563. length?: number;
  40564. /**
  40565. * Defines an optional offset (in seconds) inside the sound file
  40566. */
  40567. offset?: number;
  40568. /**
  40569. * If true, URLs will not be required to state the audio file codec to use.
  40570. */
  40571. skipCodecCheck?: boolean;
  40572. }
  40573. /**
  40574. * Defines a sound that can be played in the application.
  40575. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40577. */
  40578. export class Sound {
  40579. /**
  40580. * The name of the sound in the scene.
  40581. */
  40582. name: string;
  40583. /**
  40584. * Does the sound autoplay once loaded.
  40585. */
  40586. autoplay: boolean;
  40587. /**
  40588. * Does the sound loop after it finishes playing once.
  40589. */
  40590. loop: boolean;
  40591. /**
  40592. * Does the sound use a custom attenuation curve to simulate the falloff
  40593. * happening when the source gets further away from the camera.
  40594. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40595. */
  40596. useCustomAttenuation: boolean;
  40597. /**
  40598. * The sound track id this sound belongs to.
  40599. */
  40600. soundTrackId: number;
  40601. /**
  40602. * Is this sound currently played.
  40603. */
  40604. isPlaying: boolean;
  40605. /**
  40606. * Is this sound currently paused.
  40607. */
  40608. isPaused: boolean;
  40609. /**
  40610. * Does this sound enables spatial sound.
  40611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40612. */
  40613. spatialSound: boolean;
  40614. /**
  40615. * Define the reference distance the sound should be heard perfectly.
  40616. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40617. */
  40618. refDistance: number;
  40619. /**
  40620. * Define the roll off factor of spatial sounds.
  40621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40622. */
  40623. rolloffFactor: number;
  40624. /**
  40625. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40627. */
  40628. maxDistance: number;
  40629. /**
  40630. * Define the distance attenuation model the sound will follow.
  40631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40632. */
  40633. distanceModel: string;
  40634. /**
  40635. * @hidden
  40636. * Back Compat
  40637. **/
  40638. onended: () => any;
  40639. /**
  40640. * Gets or sets an object used to store user defined information for the sound.
  40641. */
  40642. metadata: any;
  40643. /**
  40644. * Observable event when the current playing sound finishes.
  40645. */
  40646. onEndedObservable: Observable<Sound>;
  40647. private _panningModel;
  40648. private _playbackRate;
  40649. private _streaming;
  40650. private _startTime;
  40651. private _startOffset;
  40652. private _position;
  40653. /** @hidden */
  40654. _positionInEmitterSpace: boolean;
  40655. private _localDirection;
  40656. private _volume;
  40657. private _isReadyToPlay;
  40658. private _isDirectional;
  40659. private _readyToPlayCallback;
  40660. private _audioBuffer;
  40661. private _soundSource;
  40662. private _streamingSource;
  40663. private _soundPanner;
  40664. private _soundGain;
  40665. private _inputAudioNode;
  40666. private _outputAudioNode;
  40667. private _coneInnerAngle;
  40668. private _coneOuterAngle;
  40669. private _coneOuterGain;
  40670. private _scene;
  40671. private _connectedTransformNode;
  40672. private _customAttenuationFunction;
  40673. private _registerFunc;
  40674. private _isOutputConnected;
  40675. private _htmlAudioElement;
  40676. private _urlType;
  40677. private _length?;
  40678. private _offset?;
  40679. /** @hidden */
  40680. static _SceneComponentInitialization: (scene: Scene) => void;
  40681. /**
  40682. * Create a sound and attach it to a scene
  40683. * @param name Name of your sound
  40684. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40685. * @param scene defines the scene the sound belongs to
  40686. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40687. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40688. */
  40689. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40690. /**
  40691. * Release the sound and its associated resources
  40692. */
  40693. dispose(): void;
  40694. /**
  40695. * Gets if the sounds is ready to be played or not.
  40696. * @returns true if ready, otherwise false
  40697. */
  40698. isReady(): boolean;
  40699. private _soundLoaded;
  40700. /**
  40701. * Sets the data of the sound from an audiobuffer
  40702. * @param audioBuffer The audioBuffer containing the data
  40703. */
  40704. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40705. /**
  40706. * Updates the current sounds options such as maxdistance, loop...
  40707. * @param options A JSON object containing values named as the object properties
  40708. */
  40709. updateOptions(options: ISoundOptions): void;
  40710. private _createSpatialParameters;
  40711. private _updateSpatialParameters;
  40712. /**
  40713. * Switch the panning model to HRTF:
  40714. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40716. */
  40717. switchPanningModelToHRTF(): void;
  40718. /**
  40719. * Switch the panning model to Equal Power:
  40720. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40721. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40722. */
  40723. switchPanningModelToEqualPower(): void;
  40724. private _switchPanningModel;
  40725. /**
  40726. * Connect this sound to a sound track audio node like gain...
  40727. * @param soundTrackAudioNode the sound track audio node to connect to
  40728. */
  40729. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40730. /**
  40731. * Transform this sound into a directional source
  40732. * @param coneInnerAngle Size of the inner cone in degree
  40733. * @param coneOuterAngle Size of the outer cone in degree
  40734. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40735. */
  40736. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40737. /**
  40738. * Gets or sets the inner angle for the directional cone.
  40739. */
  40740. get directionalConeInnerAngle(): number;
  40741. /**
  40742. * Gets or sets the inner angle for the directional cone.
  40743. */
  40744. set directionalConeInnerAngle(value: number);
  40745. /**
  40746. * Gets or sets the outer angle for the directional cone.
  40747. */
  40748. get directionalConeOuterAngle(): number;
  40749. /**
  40750. * Gets or sets the outer angle for the directional cone.
  40751. */
  40752. set directionalConeOuterAngle(value: number);
  40753. /**
  40754. * Sets the position of the emitter if spatial sound is enabled
  40755. * @param newPosition Defines the new posisiton
  40756. */
  40757. setPosition(newPosition: Vector3): void;
  40758. /**
  40759. * Sets the local direction of the emitter if spatial sound is enabled
  40760. * @param newLocalDirection Defines the new local direction
  40761. */
  40762. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40763. private _updateDirection;
  40764. /** @hidden */
  40765. updateDistanceFromListener(): void;
  40766. /**
  40767. * Sets a new custom attenuation function for the sound.
  40768. * @param callback Defines the function used for the attenuation
  40769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40770. */
  40771. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40772. /**
  40773. * Play the sound
  40774. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40775. * @param offset (optional) Start the sound at a specific time in seconds
  40776. * @param length (optional) Sound duration (in seconds)
  40777. */
  40778. play(time?: number, offset?: number, length?: number): void;
  40779. private _onended;
  40780. /**
  40781. * Stop the sound
  40782. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40783. */
  40784. stop(time?: number): void;
  40785. /**
  40786. * Put the sound in pause
  40787. */
  40788. pause(): void;
  40789. /**
  40790. * Sets a dedicated volume for this sounds
  40791. * @param newVolume Define the new volume of the sound
  40792. * @param time Define time for gradual change to new volume
  40793. */
  40794. setVolume(newVolume: number, time?: number): void;
  40795. /**
  40796. * Set the sound play back rate
  40797. * @param newPlaybackRate Define the playback rate the sound should be played at
  40798. */
  40799. setPlaybackRate(newPlaybackRate: number): void;
  40800. /**
  40801. * Gets the volume of the sound.
  40802. * @returns the volume of the sound
  40803. */
  40804. getVolume(): number;
  40805. /**
  40806. * Attach the sound to a dedicated mesh
  40807. * @param transformNode The transform node to connect the sound with
  40808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40809. */
  40810. attachToMesh(transformNode: TransformNode): void;
  40811. /**
  40812. * Detach the sound from the previously attached mesh
  40813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40814. */
  40815. detachFromMesh(): void;
  40816. private _onRegisterAfterWorldMatrixUpdate;
  40817. /**
  40818. * Clone the current sound in the scene.
  40819. * @returns the new sound clone
  40820. */
  40821. clone(): Nullable<Sound>;
  40822. /**
  40823. * Gets the current underlying audio buffer containing the data
  40824. * @returns the audio buffer
  40825. */
  40826. getAudioBuffer(): Nullable<AudioBuffer>;
  40827. /**
  40828. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40829. * @returns the source node
  40830. */
  40831. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40832. /**
  40833. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40834. * @returns the gain node
  40835. */
  40836. getSoundGain(): Nullable<GainNode>;
  40837. /**
  40838. * Serializes the Sound in a JSON representation
  40839. * @returns the JSON representation of the sound
  40840. */
  40841. serialize(): any;
  40842. /**
  40843. * Parse a JSON representation of a sound to innstantiate in a given scene
  40844. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40845. * @param scene Define the scene the new parsed sound should be created in
  40846. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40847. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40848. * @returns the newly parsed sound
  40849. */
  40850. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40851. }
  40852. }
  40853. declare module BABYLON {
  40854. /**
  40855. * This defines an action helpful to play a defined sound on a triggered action.
  40856. */
  40857. export class PlaySoundAction extends Action {
  40858. private _sound;
  40859. /**
  40860. * Instantiate the action
  40861. * @param triggerOptions defines the trigger options
  40862. * @param sound defines the sound to play
  40863. * @param condition defines the trigger related conditions
  40864. */
  40865. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40866. /** @hidden */
  40867. _prepare(): void;
  40868. /**
  40869. * Execute the action and play the sound.
  40870. */
  40871. execute(): void;
  40872. /**
  40873. * Serializes the actions and its related information.
  40874. * @param parent defines the object to serialize in
  40875. * @returns the serialized object
  40876. */
  40877. serialize(parent: any): any;
  40878. }
  40879. /**
  40880. * This defines an action helpful to stop a defined sound on a triggered action.
  40881. */
  40882. export class StopSoundAction extends Action {
  40883. private _sound;
  40884. /**
  40885. * Instantiate the action
  40886. * @param triggerOptions defines the trigger options
  40887. * @param sound defines the sound to stop
  40888. * @param condition defines the trigger related conditions
  40889. */
  40890. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40891. /** @hidden */
  40892. _prepare(): void;
  40893. /**
  40894. * Execute the action and stop the sound.
  40895. */
  40896. execute(): void;
  40897. /**
  40898. * Serializes the actions and its related information.
  40899. * @param parent defines the object to serialize in
  40900. * @returns the serialized object
  40901. */
  40902. serialize(parent: any): any;
  40903. }
  40904. }
  40905. declare module BABYLON {
  40906. /**
  40907. * This defines an action responsible to change the value of a property
  40908. * by interpolating between its current value and the newly set one once triggered.
  40909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40910. */
  40911. export class InterpolateValueAction extends Action {
  40912. /**
  40913. * Defines the path of the property where the value should be interpolated
  40914. */
  40915. propertyPath: string;
  40916. /**
  40917. * Defines the target value at the end of the interpolation.
  40918. */
  40919. value: any;
  40920. /**
  40921. * Defines the time it will take for the property to interpolate to the value.
  40922. */
  40923. duration: number;
  40924. /**
  40925. * Defines if the other scene animations should be stopped when the action has been triggered
  40926. */
  40927. stopOtherAnimations?: boolean;
  40928. /**
  40929. * Defines a callback raised once the interpolation animation has been done.
  40930. */
  40931. onInterpolationDone?: () => void;
  40932. /**
  40933. * Observable triggered once the interpolation animation has been done.
  40934. */
  40935. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40936. private _target;
  40937. private _effectiveTarget;
  40938. private _property;
  40939. /**
  40940. * Instantiate the action
  40941. * @param triggerOptions defines the trigger options
  40942. * @param target defines the object containing the value to interpolate
  40943. * @param propertyPath defines the path to the property in the target object
  40944. * @param value defines the target value at the end of the interpolation
  40945. * @param duration deines the time it will take for the property to interpolate to the value.
  40946. * @param condition defines the trigger related conditions
  40947. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40948. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40949. */
  40950. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40951. /** @hidden */
  40952. _prepare(): void;
  40953. /**
  40954. * Execute the action starts the value interpolation.
  40955. */
  40956. execute(): void;
  40957. /**
  40958. * Serializes the actions and its related information.
  40959. * @param parent defines the object to serialize in
  40960. * @returns the serialized object
  40961. */
  40962. serialize(parent: any): any;
  40963. }
  40964. }
  40965. declare module BABYLON {
  40966. /**
  40967. * Options allowed during the creation of a sound track.
  40968. */
  40969. export interface ISoundTrackOptions {
  40970. /**
  40971. * The volume the sound track should take during creation
  40972. */
  40973. volume?: number;
  40974. /**
  40975. * Define if the sound track is the main sound track of the scene
  40976. */
  40977. mainTrack?: boolean;
  40978. }
  40979. /**
  40980. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40981. * It will be also used in a future release to apply effects on a specific track.
  40982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40983. */
  40984. export class SoundTrack {
  40985. /**
  40986. * The unique identifier of the sound track in the scene.
  40987. */
  40988. id: number;
  40989. /**
  40990. * The list of sounds included in the sound track.
  40991. */
  40992. soundCollection: Array<Sound>;
  40993. private _outputAudioNode;
  40994. private _scene;
  40995. private _connectedAnalyser;
  40996. private _options;
  40997. private _isInitialized;
  40998. /**
  40999. * Creates a new sound track.
  41000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41001. * @param scene Define the scene the sound track belongs to
  41002. * @param options
  41003. */
  41004. constructor(scene: Scene, options?: ISoundTrackOptions);
  41005. private _initializeSoundTrackAudioGraph;
  41006. /**
  41007. * Release the sound track and its associated resources
  41008. */
  41009. dispose(): void;
  41010. /**
  41011. * Adds a sound to this sound track
  41012. * @param sound define the cound to add
  41013. * @ignoreNaming
  41014. */
  41015. AddSound(sound: Sound): void;
  41016. /**
  41017. * Removes a sound to this sound track
  41018. * @param sound define the cound to remove
  41019. * @ignoreNaming
  41020. */
  41021. RemoveSound(sound: Sound): void;
  41022. /**
  41023. * Set a global volume for the full sound track.
  41024. * @param newVolume Define the new volume of the sound track
  41025. */
  41026. setVolume(newVolume: number): void;
  41027. /**
  41028. * Switch the panning model to HRTF:
  41029. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41031. */
  41032. switchPanningModelToHRTF(): void;
  41033. /**
  41034. * Switch the panning model to Equal Power:
  41035. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41037. */
  41038. switchPanningModelToEqualPower(): void;
  41039. /**
  41040. * Connect the sound track to an audio analyser allowing some amazing
  41041. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41043. * @param analyser The analyser to connect to the engine
  41044. */
  41045. connectToAnalyser(analyser: Analyser): void;
  41046. }
  41047. }
  41048. declare module BABYLON {
  41049. interface AbstractScene {
  41050. /**
  41051. * The list of sounds used in the scene.
  41052. */
  41053. sounds: Nullable<Array<Sound>>;
  41054. }
  41055. interface Scene {
  41056. /**
  41057. * @hidden
  41058. * Backing field
  41059. */
  41060. _mainSoundTrack: SoundTrack;
  41061. /**
  41062. * The main sound track played by the scene.
  41063. * It cotains your primary collection of sounds.
  41064. */
  41065. mainSoundTrack: SoundTrack;
  41066. /**
  41067. * The list of sound tracks added to the scene
  41068. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41069. */
  41070. soundTracks: Nullable<Array<SoundTrack>>;
  41071. /**
  41072. * Gets a sound using a given name
  41073. * @param name defines the name to search for
  41074. * @return the found sound or null if not found at all.
  41075. */
  41076. getSoundByName(name: string): Nullable<Sound>;
  41077. /**
  41078. * Gets or sets if audio support is enabled
  41079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41080. */
  41081. audioEnabled: boolean;
  41082. /**
  41083. * Gets or sets if audio will be output to headphones
  41084. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41085. */
  41086. headphone: boolean;
  41087. /**
  41088. * Gets or sets custom audio listener position provider
  41089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41090. */
  41091. audioListenerPositionProvider: Nullable<() => Vector3>;
  41092. /**
  41093. * Gets or sets a refresh rate when using 3D audio positioning
  41094. */
  41095. audioPositioningRefreshRate: number;
  41096. }
  41097. /**
  41098. * Defines the sound scene component responsible to manage any sounds
  41099. * in a given scene.
  41100. */
  41101. export class AudioSceneComponent implements ISceneSerializableComponent {
  41102. /**
  41103. * The component name helpfull to identify the component in the list of scene components.
  41104. */
  41105. readonly name: string;
  41106. /**
  41107. * The scene the component belongs to.
  41108. */
  41109. scene: Scene;
  41110. private _audioEnabled;
  41111. /**
  41112. * Gets whether audio is enabled or not.
  41113. * Please use related enable/disable method to switch state.
  41114. */
  41115. get audioEnabled(): boolean;
  41116. private _headphone;
  41117. /**
  41118. * Gets whether audio is outputing to headphone or not.
  41119. * Please use the according Switch methods to change output.
  41120. */
  41121. get headphone(): boolean;
  41122. /**
  41123. * Gets or sets a refresh rate when using 3D audio positioning
  41124. */
  41125. audioPositioningRefreshRate: number;
  41126. private _audioListenerPositionProvider;
  41127. /**
  41128. * Gets the current audio listener position provider
  41129. */
  41130. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41131. /**
  41132. * Sets a custom listener position for all sounds in the scene
  41133. * By default, this is the position of the first active camera
  41134. */
  41135. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41136. /**
  41137. * Creates a new instance of the component for the given scene
  41138. * @param scene Defines the scene to register the component in
  41139. */
  41140. constructor(scene: Scene);
  41141. /**
  41142. * Registers the component in a given scene
  41143. */
  41144. register(): void;
  41145. /**
  41146. * Rebuilds the elements related to this component in case of
  41147. * context lost for instance.
  41148. */
  41149. rebuild(): void;
  41150. /**
  41151. * Serializes the component data to the specified json object
  41152. * @param serializationObject The object to serialize to
  41153. */
  41154. serialize(serializationObject: any): void;
  41155. /**
  41156. * Adds all the elements from the container to the scene
  41157. * @param container the container holding the elements
  41158. */
  41159. addFromContainer(container: AbstractScene): void;
  41160. /**
  41161. * Removes all the elements in the container from the scene
  41162. * @param container contains the elements to remove
  41163. * @param dispose if the removed element should be disposed (default: false)
  41164. */
  41165. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41166. /**
  41167. * Disposes the component and the associated ressources.
  41168. */
  41169. dispose(): void;
  41170. /**
  41171. * Disables audio in the associated scene.
  41172. */
  41173. disableAudio(): void;
  41174. /**
  41175. * Enables audio in the associated scene.
  41176. */
  41177. enableAudio(): void;
  41178. /**
  41179. * Switch audio to headphone output.
  41180. */
  41181. switchAudioModeForHeadphones(): void;
  41182. /**
  41183. * Switch audio to normal speakers.
  41184. */
  41185. switchAudioModeForNormalSpeakers(): void;
  41186. private _cachedCameraDirection;
  41187. private _cachedCameraPosition;
  41188. private _lastCheck;
  41189. private _afterRender;
  41190. }
  41191. }
  41192. declare module BABYLON {
  41193. /**
  41194. * Wraps one or more Sound objects and selects one with random weight for playback.
  41195. */
  41196. export class WeightedSound {
  41197. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41198. loop: boolean;
  41199. private _coneInnerAngle;
  41200. private _coneOuterAngle;
  41201. private _volume;
  41202. /** A Sound is currently playing. */
  41203. isPlaying: boolean;
  41204. /** A Sound is currently paused. */
  41205. isPaused: boolean;
  41206. private _sounds;
  41207. private _weights;
  41208. private _currentIndex?;
  41209. /**
  41210. * Creates a new WeightedSound from the list of sounds given.
  41211. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41212. * @param sounds Array of Sounds that will be selected from.
  41213. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41214. */
  41215. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41216. /**
  41217. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41218. */
  41219. get directionalConeInnerAngle(): number;
  41220. /**
  41221. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41222. */
  41223. set directionalConeInnerAngle(value: number);
  41224. /**
  41225. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41226. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41227. */
  41228. get directionalConeOuterAngle(): number;
  41229. /**
  41230. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41231. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41232. */
  41233. set directionalConeOuterAngle(value: number);
  41234. /**
  41235. * Playback volume.
  41236. */
  41237. get volume(): number;
  41238. /**
  41239. * Playback volume.
  41240. */
  41241. set volume(value: number);
  41242. private _onended;
  41243. /**
  41244. * Suspend playback
  41245. */
  41246. pause(): void;
  41247. /**
  41248. * Stop playback
  41249. */
  41250. stop(): void;
  41251. /**
  41252. * Start playback.
  41253. * @param startOffset Position the clip head at a specific time in seconds.
  41254. */
  41255. play(startOffset?: number): void;
  41256. }
  41257. }
  41258. declare module BABYLON {
  41259. /**
  41260. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41261. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41262. */
  41263. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41264. /**
  41265. * Gets the name of the behavior.
  41266. */
  41267. get name(): string;
  41268. /**
  41269. * The easing function used by animations
  41270. */
  41271. static EasingFunction: BackEase;
  41272. /**
  41273. * The easing mode used by animations
  41274. */
  41275. static EasingMode: number;
  41276. /**
  41277. * The duration of the animation, in milliseconds
  41278. */
  41279. transitionDuration: number;
  41280. /**
  41281. * Length of the distance animated by the transition when lower radius is reached
  41282. */
  41283. lowerRadiusTransitionRange: number;
  41284. /**
  41285. * Length of the distance animated by the transition when upper radius is reached
  41286. */
  41287. upperRadiusTransitionRange: number;
  41288. private _autoTransitionRange;
  41289. /**
  41290. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41291. */
  41292. get autoTransitionRange(): boolean;
  41293. /**
  41294. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41295. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41296. */
  41297. set autoTransitionRange(value: boolean);
  41298. private _attachedCamera;
  41299. private _onAfterCheckInputsObserver;
  41300. private _onMeshTargetChangedObserver;
  41301. /**
  41302. * Initializes the behavior.
  41303. */
  41304. init(): void;
  41305. /**
  41306. * Attaches the behavior to its arc rotate camera.
  41307. * @param camera Defines the camera to attach the behavior to
  41308. */
  41309. attach(camera: ArcRotateCamera): void;
  41310. /**
  41311. * Detaches the behavior from its current arc rotate camera.
  41312. */
  41313. detach(): void;
  41314. private _radiusIsAnimating;
  41315. private _radiusBounceTransition;
  41316. private _animatables;
  41317. private _cachedWheelPrecision;
  41318. /**
  41319. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41320. * @param radiusLimit The limit to check against.
  41321. * @return Bool to indicate if at limit.
  41322. */
  41323. private _isRadiusAtLimit;
  41324. /**
  41325. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41326. * @param radiusDelta The delta by which to animate to. Can be negative.
  41327. */
  41328. private _applyBoundRadiusAnimation;
  41329. /**
  41330. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41331. */
  41332. protected _clearAnimationLocks(): void;
  41333. /**
  41334. * Stops and removes all animations that have been applied to the camera
  41335. */
  41336. stopAllAnimations(): void;
  41337. }
  41338. }
  41339. declare module BABYLON {
  41340. /**
  41341. * 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.
  41342. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41343. */
  41344. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41345. /**
  41346. * Gets the name of the behavior.
  41347. */
  41348. get name(): string;
  41349. private _mode;
  41350. private _radiusScale;
  41351. private _positionScale;
  41352. private _defaultElevation;
  41353. private _elevationReturnTime;
  41354. private _elevationReturnWaitTime;
  41355. private _zoomStopsAnimation;
  41356. private _framingTime;
  41357. /**
  41358. * The easing function used by animations
  41359. */
  41360. static EasingFunction: ExponentialEase;
  41361. /**
  41362. * The easing mode used by animations
  41363. */
  41364. static EasingMode: number;
  41365. /**
  41366. * Sets the current mode used by the behavior
  41367. */
  41368. set mode(mode: number);
  41369. /**
  41370. * Gets current mode used by the behavior.
  41371. */
  41372. get mode(): number;
  41373. /**
  41374. * Sets the scale applied to the radius (1 by default)
  41375. */
  41376. set radiusScale(radius: number);
  41377. /**
  41378. * Gets the scale applied to the radius
  41379. */
  41380. get radiusScale(): number;
  41381. /**
  41382. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41383. */
  41384. set positionScale(scale: number);
  41385. /**
  41386. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41387. */
  41388. get positionScale(): number;
  41389. /**
  41390. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41391. * behaviour is triggered, in radians.
  41392. */
  41393. set defaultElevation(elevation: number);
  41394. /**
  41395. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41396. * behaviour is triggered, in radians.
  41397. */
  41398. get defaultElevation(): number;
  41399. /**
  41400. * Sets the time (in milliseconds) taken to return to the default beta position.
  41401. * Negative value indicates camera should not return to default.
  41402. */
  41403. set elevationReturnTime(speed: number);
  41404. /**
  41405. * Gets the time (in milliseconds) taken to return to the default beta position.
  41406. * Negative value indicates camera should not return to default.
  41407. */
  41408. get elevationReturnTime(): number;
  41409. /**
  41410. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41411. */
  41412. set elevationReturnWaitTime(time: number);
  41413. /**
  41414. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41415. */
  41416. get elevationReturnWaitTime(): number;
  41417. /**
  41418. * Sets the flag that indicates if user zooming should stop animation.
  41419. */
  41420. set zoomStopsAnimation(flag: boolean);
  41421. /**
  41422. * Gets the flag that indicates if user zooming should stop animation.
  41423. */
  41424. get zoomStopsAnimation(): boolean;
  41425. /**
  41426. * Sets the transition time when framing the mesh, in milliseconds
  41427. */
  41428. set framingTime(time: number);
  41429. /**
  41430. * Gets the transition time when framing the mesh, in milliseconds
  41431. */
  41432. get framingTime(): number;
  41433. /**
  41434. * Define if the behavior should automatically change the configured
  41435. * camera limits and sensibilities.
  41436. */
  41437. autoCorrectCameraLimitsAndSensibility: boolean;
  41438. private _onPrePointerObservableObserver;
  41439. private _onAfterCheckInputsObserver;
  41440. private _onMeshTargetChangedObserver;
  41441. private _attachedCamera;
  41442. private _isPointerDown;
  41443. private _lastInteractionTime;
  41444. /**
  41445. * Initializes the behavior.
  41446. */
  41447. init(): void;
  41448. /**
  41449. * Attaches the behavior to its arc rotate camera.
  41450. * @param camera Defines the camera to attach the behavior to
  41451. */
  41452. attach(camera: ArcRotateCamera): void;
  41453. /**
  41454. * Detaches the behavior from its current arc rotate camera.
  41455. */
  41456. detach(): void;
  41457. private _animatables;
  41458. private _betaIsAnimating;
  41459. private _betaTransition;
  41460. private _radiusTransition;
  41461. private _vectorTransition;
  41462. /**
  41463. * Targets the given mesh and updates zoom level accordingly.
  41464. * @param mesh The mesh to target.
  41465. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41466. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41467. */
  41468. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41469. /**
  41470. * Targets the given mesh with its children and updates zoom level accordingly.
  41471. * @param mesh The mesh to target.
  41472. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41473. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41474. */
  41475. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41476. /**
  41477. * Targets the given meshes with their children and updates zoom level accordingly.
  41478. * @param meshes The mesh to target.
  41479. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41480. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41481. */
  41482. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41483. /**
  41484. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41485. * @param minimumWorld Determines the smaller position of the bounding box extend
  41486. * @param maximumWorld Determines the bigger position of the bounding box extend
  41487. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41488. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41489. */
  41490. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41491. /**
  41492. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41493. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41494. * frustum width.
  41495. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41496. * to fully enclose the mesh in the viewing frustum.
  41497. */
  41498. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41499. /**
  41500. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41501. * is automatically returned to its default position (expected to be above ground plane).
  41502. */
  41503. private _maintainCameraAboveGround;
  41504. /**
  41505. * Returns the frustum slope based on the canvas ratio and camera FOV
  41506. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41507. */
  41508. private _getFrustumSlope;
  41509. /**
  41510. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41511. */
  41512. private _clearAnimationLocks;
  41513. /**
  41514. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41515. */
  41516. private _applyUserInteraction;
  41517. /**
  41518. * Stops and removes all animations that have been applied to the camera
  41519. */
  41520. stopAllAnimations(): void;
  41521. /**
  41522. * Gets a value indicating if the user is moving the camera
  41523. */
  41524. get isUserIsMoving(): boolean;
  41525. /**
  41526. * The camera can move all the way towards the mesh.
  41527. */
  41528. static IgnoreBoundsSizeMode: number;
  41529. /**
  41530. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41531. */
  41532. static FitFrustumSidesMode: number;
  41533. }
  41534. }
  41535. declare module BABYLON {
  41536. /**
  41537. * Base class for Camera Pointer Inputs.
  41538. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41539. * for example usage.
  41540. */
  41541. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41542. /**
  41543. * Defines the camera the input is attached to.
  41544. */
  41545. abstract camera: Camera;
  41546. /**
  41547. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41548. */
  41549. protected _altKey: boolean;
  41550. protected _ctrlKey: boolean;
  41551. protected _metaKey: boolean;
  41552. protected _shiftKey: boolean;
  41553. /**
  41554. * Which mouse buttons were pressed at time of last mouse event.
  41555. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41556. */
  41557. protected _buttonsPressed: number;
  41558. /**
  41559. * Defines the buttons associated with the input to handle camera move.
  41560. */
  41561. buttons: number[];
  41562. /**
  41563. * Attach the input controls to a specific dom element to get the input from.
  41564. * @param element Defines the element the controls should be listened from
  41565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41566. */
  41567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41568. /**
  41569. * Detach the current controls from the specified dom element.
  41570. * @param element Defines the element to stop listening the inputs from
  41571. */
  41572. detachControl(element: Nullable<HTMLElement>): void;
  41573. /**
  41574. * Gets the class name of the current input.
  41575. * @returns the class name
  41576. */
  41577. getClassName(): string;
  41578. /**
  41579. * Get the friendly name associated with the input class.
  41580. * @returns the input friendly name
  41581. */
  41582. getSimpleName(): string;
  41583. /**
  41584. * Called on pointer POINTERDOUBLETAP event.
  41585. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41586. */
  41587. protected onDoubleTap(type: string): void;
  41588. /**
  41589. * Called on pointer POINTERMOVE event if only a single touch is active.
  41590. * Override this method to provide functionality.
  41591. */
  41592. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41593. /**
  41594. * Called on pointer POINTERMOVE event if multiple touches are active.
  41595. * Override this method to provide functionality.
  41596. */
  41597. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41598. /**
  41599. * Called on JS contextmenu event.
  41600. * Override this method to provide functionality.
  41601. */
  41602. protected onContextMenu(evt: PointerEvent): void;
  41603. /**
  41604. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41605. * press.
  41606. * Override this method to provide functionality.
  41607. */
  41608. protected onButtonDown(evt: PointerEvent): void;
  41609. /**
  41610. * Called each time a new POINTERUP event occurs. Ie, for each button
  41611. * release.
  41612. * Override this method to provide functionality.
  41613. */
  41614. protected onButtonUp(evt: PointerEvent): void;
  41615. /**
  41616. * Called when window becomes inactive.
  41617. * Override this method to provide functionality.
  41618. */
  41619. protected onLostFocus(): void;
  41620. private _pointerInput;
  41621. private _observer;
  41622. private _onLostFocus;
  41623. private pointA;
  41624. private pointB;
  41625. }
  41626. }
  41627. declare module BABYLON {
  41628. /**
  41629. * Manage the pointers inputs to control an arc rotate camera.
  41630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41631. */
  41632. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41633. /**
  41634. * Defines the camera the input is attached to.
  41635. */
  41636. camera: ArcRotateCamera;
  41637. /**
  41638. * Gets the class name of the current input.
  41639. * @returns the class name
  41640. */
  41641. getClassName(): string;
  41642. /**
  41643. * Defines the buttons associated with the input to handle camera move.
  41644. */
  41645. buttons: number[];
  41646. /**
  41647. * Defines the pointer angular sensibility along the X axis or how fast is
  41648. * the camera rotating.
  41649. */
  41650. angularSensibilityX: number;
  41651. /**
  41652. * Defines the pointer angular sensibility along the Y axis or how fast is
  41653. * the camera rotating.
  41654. */
  41655. angularSensibilityY: number;
  41656. /**
  41657. * Defines the pointer pinch precision or how fast is the camera zooming.
  41658. */
  41659. pinchPrecision: number;
  41660. /**
  41661. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41662. * from 0.
  41663. * It defines the percentage of current camera.radius to use as delta when
  41664. * pinch zoom is used.
  41665. */
  41666. pinchDeltaPercentage: number;
  41667. /**
  41668. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41669. * that any object in the plane at the camera's target point will scale
  41670. * perfectly with finger motion.
  41671. * Overrides pinchDeltaPercentage and pinchPrecision.
  41672. */
  41673. useNaturalPinchZoom: boolean;
  41674. /**
  41675. * Defines the pointer panning sensibility or how fast is the camera moving.
  41676. */
  41677. panningSensibility: number;
  41678. /**
  41679. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41680. */
  41681. multiTouchPanning: boolean;
  41682. /**
  41683. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41684. * zoom (pinch) through multitouch.
  41685. */
  41686. multiTouchPanAndZoom: boolean;
  41687. /**
  41688. * Revers pinch action direction.
  41689. */
  41690. pinchInwards: boolean;
  41691. private _isPanClick;
  41692. private _twoFingerActivityCount;
  41693. private _isPinching;
  41694. /**
  41695. * Called on pointer POINTERMOVE event if only a single touch is active.
  41696. */
  41697. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41698. /**
  41699. * Called on pointer POINTERDOUBLETAP event.
  41700. */
  41701. protected onDoubleTap(type: string): void;
  41702. /**
  41703. * Called on pointer POINTERMOVE event if multiple touches are active.
  41704. */
  41705. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41706. /**
  41707. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41708. * press.
  41709. */
  41710. protected onButtonDown(evt: PointerEvent): void;
  41711. /**
  41712. * Called each time a new POINTERUP event occurs. Ie, for each button
  41713. * release.
  41714. */
  41715. protected onButtonUp(evt: PointerEvent): void;
  41716. /**
  41717. * Called when window becomes inactive.
  41718. */
  41719. protected onLostFocus(): void;
  41720. }
  41721. }
  41722. declare module BABYLON {
  41723. /**
  41724. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41726. */
  41727. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41728. /**
  41729. * Defines the camera the input is attached to.
  41730. */
  41731. camera: ArcRotateCamera;
  41732. /**
  41733. * Defines the list of key codes associated with the up action (increase alpha)
  41734. */
  41735. keysUp: number[];
  41736. /**
  41737. * Defines the list of key codes associated with the down action (decrease alpha)
  41738. */
  41739. keysDown: number[];
  41740. /**
  41741. * Defines the list of key codes associated with the left action (increase beta)
  41742. */
  41743. keysLeft: number[];
  41744. /**
  41745. * Defines the list of key codes associated with the right action (decrease beta)
  41746. */
  41747. keysRight: number[];
  41748. /**
  41749. * Defines the list of key codes associated with the reset action.
  41750. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41751. */
  41752. keysReset: number[];
  41753. /**
  41754. * Defines the panning sensibility of the inputs.
  41755. * (How fast is the camera panning)
  41756. */
  41757. panningSensibility: number;
  41758. /**
  41759. * Defines the zooming sensibility of the inputs.
  41760. * (How fast is the camera zooming)
  41761. */
  41762. zoomingSensibility: number;
  41763. /**
  41764. * Defines whether maintaining the alt key down switch the movement mode from
  41765. * orientation to zoom.
  41766. */
  41767. useAltToZoom: boolean;
  41768. /**
  41769. * Rotation speed of the camera
  41770. */
  41771. angularSpeed: number;
  41772. private _keys;
  41773. private _ctrlPressed;
  41774. private _altPressed;
  41775. private _onCanvasBlurObserver;
  41776. private _onKeyboardObserver;
  41777. private _engine;
  41778. private _scene;
  41779. /**
  41780. * Attach the input controls to a specific dom element to get the input from.
  41781. * @param element Defines the element the controls should be listened from
  41782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41783. */
  41784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41785. /**
  41786. * Detach the current controls from the specified dom element.
  41787. * @param element Defines the element to stop listening the inputs from
  41788. */
  41789. detachControl(element: Nullable<HTMLElement>): void;
  41790. /**
  41791. * Update the current camera state depending on the inputs that have been used this frame.
  41792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41793. */
  41794. checkInputs(): void;
  41795. /**
  41796. * Gets the class name of the current intput.
  41797. * @returns the class name
  41798. */
  41799. getClassName(): string;
  41800. /**
  41801. * Get the friendly name associated with the input class.
  41802. * @returns the input friendly name
  41803. */
  41804. getSimpleName(): string;
  41805. }
  41806. }
  41807. declare module BABYLON {
  41808. /**
  41809. * Manage the mouse wheel inputs to control an arc rotate camera.
  41810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41811. */
  41812. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41813. /**
  41814. * Defines the camera the input is attached to.
  41815. */
  41816. camera: ArcRotateCamera;
  41817. /**
  41818. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41819. */
  41820. wheelPrecision: number;
  41821. /**
  41822. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41823. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41824. */
  41825. wheelDeltaPercentage: number;
  41826. private _wheel;
  41827. private _observer;
  41828. private computeDeltaFromMouseWheelLegacyEvent;
  41829. /**
  41830. * Attach the input controls to a specific dom element to get the input from.
  41831. * @param element Defines the element the controls should be listened from
  41832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41833. */
  41834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41835. /**
  41836. * Detach the current controls from the specified dom element.
  41837. * @param element Defines the element to stop listening the inputs from
  41838. */
  41839. detachControl(element: Nullable<HTMLElement>): void;
  41840. /**
  41841. * Gets the class name of the current intput.
  41842. * @returns the class name
  41843. */
  41844. getClassName(): string;
  41845. /**
  41846. * Get the friendly name associated with the input class.
  41847. * @returns the input friendly name
  41848. */
  41849. getSimpleName(): string;
  41850. }
  41851. }
  41852. declare module BABYLON {
  41853. /**
  41854. * Default Inputs manager for the ArcRotateCamera.
  41855. * It groups all the default supported inputs for ease of use.
  41856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41857. */
  41858. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41859. /**
  41860. * Instantiates a new ArcRotateCameraInputsManager.
  41861. * @param camera Defines the camera the inputs belong to
  41862. */
  41863. constructor(camera: ArcRotateCamera);
  41864. /**
  41865. * Add mouse wheel input support to the input manager.
  41866. * @returns the current input manager
  41867. */
  41868. addMouseWheel(): ArcRotateCameraInputsManager;
  41869. /**
  41870. * Add pointers input support to the input manager.
  41871. * @returns the current input manager
  41872. */
  41873. addPointers(): ArcRotateCameraInputsManager;
  41874. /**
  41875. * Add keyboard input support to the input manager.
  41876. * @returns the current input manager
  41877. */
  41878. addKeyboard(): ArcRotateCameraInputsManager;
  41879. }
  41880. }
  41881. declare module BABYLON {
  41882. /**
  41883. * This represents an orbital type of camera.
  41884. *
  41885. * 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.
  41886. * 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.
  41887. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41888. */
  41889. export class ArcRotateCamera extends TargetCamera {
  41890. /**
  41891. * Defines the rotation angle of the camera along the longitudinal axis.
  41892. */
  41893. alpha: number;
  41894. /**
  41895. * Defines the rotation angle of the camera along the latitudinal axis.
  41896. */
  41897. beta: number;
  41898. /**
  41899. * Defines the radius of the camera from it s target point.
  41900. */
  41901. radius: number;
  41902. protected _target: Vector3;
  41903. protected _targetHost: Nullable<AbstractMesh>;
  41904. /**
  41905. * Defines the target point of the camera.
  41906. * The camera looks towards it form the radius distance.
  41907. */
  41908. get target(): Vector3;
  41909. set target(value: Vector3);
  41910. /**
  41911. * Define the current local position of the camera in the scene
  41912. */
  41913. get position(): Vector3;
  41914. set position(newPosition: Vector3);
  41915. protected _upVector: Vector3;
  41916. protected _upToYMatrix: Matrix;
  41917. protected _YToUpMatrix: Matrix;
  41918. /**
  41919. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41920. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41921. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41922. */
  41923. set upVector(vec: Vector3);
  41924. get upVector(): Vector3;
  41925. /**
  41926. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41927. */
  41928. setMatUp(): void;
  41929. /**
  41930. * Current inertia value on the longitudinal axis.
  41931. * The bigger this number the longer it will take for the camera to stop.
  41932. */
  41933. inertialAlphaOffset: number;
  41934. /**
  41935. * Current inertia value on the latitudinal axis.
  41936. * The bigger this number the longer it will take for the camera to stop.
  41937. */
  41938. inertialBetaOffset: number;
  41939. /**
  41940. * Current inertia value on the radius axis.
  41941. * The bigger this number the longer it will take for the camera to stop.
  41942. */
  41943. inertialRadiusOffset: number;
  41944. /**
  41945. * Minimum allowed angle on the longitudinal axis.
  41946. * This can help limiting how the Camera is able to move in the scene.
  41947. */
  41948. lowerAlphaLimit: Nullable<number>;
  41949. /**
  41950. * Maximum allowed angle on the longitudinal axis.
  41951. * This can help limiting how the Camera is able to move in the scene.
  41952. */
  41953. upperAlphaLimit: Nullable<number>;
  41954. /**
  41955. * Minimum allowed angle on the latitudinal axis.
  41956. * This can help limiting how the Camera is able to move in the scene.
  41957. */
  41958. lowerBetaLimit: number;
  41959. /**
  41960. * Maximum allowed angle on the latitudinal axis.
  41961. * This can help limiting how the Camera is able to move in the scene.
  41962. */
  41963. upperBetaLimit: number;
  41964. /**
  41965. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41966. * This can help limiting how the Camera is able to move in the scene.
  41967. */
  41968. lowerRadiusLimit: Nullable<number>;
  41969. /**
  41970. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41971. * This can help limiting how the Camera is able to move in the scene.
  41972. */
  41973. upperRadiusLimit: Nullable<number>;
  41974. /**
  41975. * Defines the current inertia value used during panning of the camera along the X axis.
  41976. */
  41977. inertialPanningX: number;
  41978. /**
  41979. * Defines the current inertia value used during panning of the camera along the Y axis.
  41980. */
  41981. inertialPanningY: number;
  41982. /**
  41983. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41984. * Basically if your fingers moves away from more than this distance you will be considered
  41985. * in pinch mode.
  41986. */
  41987. pinchToPanMaxDistance: number;
  41988. /**
  41989. * Defines the maximum distance the camera can pan.
  41990. * This could help keeping the cammera always in your scene.
  41991. */
  41992. panningDistanceLimit: Nullable<number>;
  41993. /**
  41994. * Defines the target of the camera before paning.
  41995. */
  41996. panningOriginTarget: Vector3;
  41997. /**
  41998. * Defines the value of the inertia used during panning.
  41999. * 0 would mean stop inertia and one would mean no decelleration at all.
  42000. */
  42001. panningInertia: number;
  42002. /**
  42003. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42004. */
  42005. get angularSensibilityX(): number;
  42006. set angularSensibilityX(value: number);
  42007. /**
  42008. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42009. */
  42010. get angularSensibilityY(): number;
  42011. set angularSensibilityY(value: number);
  42012. /**
  42013. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42014. */
  42015. get pinchPrecision(): number;
  42016. set pinchPrecision(value: number);
  42017. /**
  42018. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42019. * It will be used instead of pinchDeltaPrecision if different from 0.
  42020. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42021. */
  42022. get pinchDeltaPercentage(): number;
  42023. set pinchDeltaPercentage(value: number);
  42024. /**
  42025. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42026. * and pinch delta percentage.
  42027. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42028. * that any object in the plane at the camera's target point will scale
  42029. * perfectly with finger motion.
  42030. */
  42031. get useNaturalPinchZoom(): boolean;
  42032. set useNaturalPinchZoom(value: boolean);
  42033. /**
  42034. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42035. */
  42036. get panningSensibility(): number;
  42037. set panningSensibility(value: number);
  42038. /**
  42039. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42040. */
  42041. get keysUp(): number[];
  42042. set keysUp(value: number[]);
  42043. /**
  42044. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42045. */
  42046. get keysDown(): number[];
  42047. set keysDown(value: number[]);
  42048. /**
  42049. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42050. */
  42051. get keysLeft(): number[];
  42052. set keysLeft(value: number[]);
  42053. /**
  42054. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42055. */
  42056. get keysRight(): number[];
  42057. set keysRight(value: number[]);
  42058. /**
  42059. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42060. */
  42061. get wheelPrecision(): number;
  42062. set wheelPrecision(value: number);
  42063. /**
  42064. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42065. * It will be used instead of pinchDeltaPrecision if different from 0.
  42066. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42067. */
  42068. get wheelDeltaPercentage(): number;
  42069. set wheelDeltaPercentage(value: number);
  42070. /**
  42071. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42072. */
  42073. zoomOnFactor: number;
  42074. /**
  42075. * Defines a screen offset for the camera position.
  42076. */
  42077. targetScreenOffset: Vector2;
  42078. /**
  42079. * Allows the camera to be completely reversed.
  42080. * If false the camera can not arrive upside down.
  42081. */
  42082. allowUpsideDown: boolean;
  42083. /**
  42084. * Define if double tap/click is used to restore the previously saved state of the camera.
  42085. */
  42086. useInputToRestoreState: boolean;
  42087. /** @hidden */
  42088. _viewMatrix: Matrix;
  42089. /** @hidden */
  42090. _useCtrlForPanning: boolean;
  42091. /** @hidden */
  42092. _panningMouseButton: number;
  42093. /**
  42094. * Defines the input associated to the camera.
  42095. */
  42096. inputs: ArcRotateCameraInputsManager;
  42097. /** @hidden */
  42098. _reset: () => void;
  42099. /**
  42100. * Defines the allowed panning axis.
  42101. */
  42102. panningAxis: Vector3;
  42103. protected _localDirection: Vector3;
  42104. protected _transformedDirection: Vector3;
  42105. private _bouncingBehavior;
  42106. /**
  42107. * Gets the bouncing behavior of the camera if it has been enabled.
  42108. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42109. */
  42110. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42111. /**
  42112. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42113. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42114. */
  42115. get useBouncingBehavior(): boolean;
  42116. set useBouncingBehavior(value: boolean);
  42117. private _framingBehavior;
  42118. /**
  42119. * Gets the framing behavior of the camera if it has been enabled.
  42120. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42121. */
  42122. get framingBehavior(): Nullable<FramingBehavior>;
  42123. /**
  42124. * Defines if the framing behavior of the camera is enabled on the camera.
  42125. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42126. */
  42127. get useFramingBehavior(): boolean;
  42128. set useFramingBehavior(value: boolean);
  42129. private _autoRotationBehavior;
  42130. /**
  42131. * Gets the auto rotation behavior of the camera if it has been enabled.
  42132. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42133. */
  42134. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42135. /**
  42136. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42137. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42138. */
  42139. get useAutoRotationBehavior(): boolean;
  42140. set useAutoRotationBehavior(value: boolean);
  42141. /**
  42142. * Observable triggered when the mesh target has been changed on the camera.
  42143. */
  42144. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42145. /**
  42146. * Event raised when the camera is colliding with a mesh.
  42147. */
  42148. onCollide: (collidedMesh: AbstractMesh) => void;
  42149. /**
  42150. * Defines whether the camera should check collision with the objects oh the scene.
  42151. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42152. */
  42153. checkCollisions: boolean;
  42154. /**
  42155. * Defines the collision radius of the camera.
  42156. * This simulates a sphere around the camera.
  42157. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42158. */
  42159. collisionRadius: Vector3;
  42160. protected _collider: Collider;
  42161. protected _previousPosition: Vector3;
  42162. protected _collisionVelocity: Vector3;
  42163. protected _newPosition: Vector3;
  42164. protected _previousAlpha: number;
  42165. protected _previousBeta: number;
  42166. protected _previousRadius: number;
  42167. protected _collisionTriggered: boolean;
  42168. protected _targetBoundingCenter: Nullable<Vector3>;
  42169. private _computationVector;
  42170. /**
  42171. * Instantiates a new ArcRotateCamera in a given scene
  42172. * @param name Defines the name of the camera
  42173. * @param alpha Defines the camera rotation along the logitudinal axis
  42174. * @param beta Defines the camera rotation along the latitudinal axis
  42175. * @param radius Defines the camera distance from its target
  42176. * @param target Defines the camera target
  42177. * @param scene Defines the scene the camera belongs to
  42178. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42179. */
  42180. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42181. /** @hidden */
  42182. _initCache(): void;
  42183. /** @hidden */
  42184. _updateCache(ignoreParentClass?: boolean): void;
  42185. protected _getTargetPosition(): Vector3;
  42186. private _storedAlpha;
  42187. private _storedBeta;
  42188. private _storedRadius;
  42189. private _storedTarget;
  42190. private _storedTargetScreenOffset;
  42191. /**
  42192. * Stores the current state of the camera (alpha, beta, radius and target)
  42193. * @returns the camera itself
  42194. */
  42195. storeState(): Camera;
  42196. /**
  42197. * @hidden
  42198. * Restored camera state. You must call storeState() first
  42199. */
  42200. _restoreStateValues(): boolean;
  42201. /** @hidden */
  42202. _isSynchronizedViewMatrix(): boolean;
  42203. /**
  42204. * Attached controls to the current camera.
  42205. * @param element Defines the element the controls should be listened from
  42206. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42207. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42208. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42209. */
  42210. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42211. /**
  42212. * Detach the current controls from the camera.
  42213. * The camera will stop reacting to inputs.
  42214. * @param element Defines the element to stop listening the inputs from
  42215. */
  42216. detachControl(element: HTMLElement): void;
  42217. /** @hidden */
  42218. _checkInputs(): void;
  42219. protected _checkLimits(): void;
  42220. /**
  42221. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42222. */
  42223. rebuildAnglesAndRadius(): void;
  42224. /**
  42225. * Use a position to define the current camera related information like alpha, beta and radius
  42226. * @param position Defines the position to set the camera at
  42227. */
  42228. setPosition(position: Vector3): void;
  42229. /**
  42230. * Defines the target the camera should look at.
  42231. * This will automatically adapt alpha beta and radius to fit within the new target.
  42232. * @param target Defines the new target as a Vector or a mesh
  42233. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42234. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42235. */
  42236. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42237. /** @hidden */
  42238. _getViewMatrix(): Matrix;
  42239. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42240. /**
  42241. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42242. * @param meshes Defines the mesh to zoom on
  42243. * @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)
  42244. */
  42245. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42246. /**
  42247. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42248. * The target will be changed but the radius
  42249. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42250. * @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)
  42251. */
  42252. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42253. min: Vector3;
  42254. max: Vector3;
  42255. distance: number;
  42256. }, doNotUpdateMaxZ?: boolean): void;
  42257. /**
  42258. * @override
  42259. * Override Camera.createRigCamera
  42260. */
  42261. createRigCamera(name: string, cameraIndex: number): Camera;
  42262. /**
  42263. * @hidden
  42264. * @override
  42265. * Override Camera._updateRigCameras
  42266. */
  42267. _updateRigCameras(): void;
  42268. /**
  42269. * Destroy the camera and release the current resources hold by it.
  42270. */
  42271. dispose(): void;
  42272. /**
  42273. * Gets the current object class name.
  42274. * @return the class name
  42275. */
  42276. getClassName(): string;
  42277. }
  42278. }
  42279. declare module BABYLON {
  42280. /**
  42281. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42282. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42283. */
  42284. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42285. /**
  42286. * Gets the name of the behavior.
  42287. */
  42288. get name(): string;
  42289. private _zoomStopsAnimation;
  42290. private _idleRotationSpeed;
  42291. private _idleRotationWaitTime;
  42292. private _idleRotationSpinupTime;
  42293. /**
  42294. * Sets the flag that indicates if user zooming should stop animation.
  42295. */
  42296. set zoomStopsAnimation(flag: boolean);
  42297. /**
  42298. * Gets the flag that indicates if user zooming should stop animation.
  42299. */
  42300. get zoomStopsAnimation(): boolean;
  42301. /**
  42302. * Sets the default speed at which the camera rotates around the model.
  42303. */
  42304. set idleRotationSpeed(speed: number);
  42305. /**
  42306. * Gets the default speed at which the camera rotates around the model.
  42307. */
  42308. get idleRotationSpeed(): number;
  42309. /**
  42310. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42311. */
  42312. set idleRotationWaitTime(time: number);
  42313. /**
  42314. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42315. */
  42316. get idleRotationWaitTime(): number;
  42317. /**
  42318. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42319. */
  42320. set idleRotationSpinupTime(time: number);
  42321. /**
  42322. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42323. */
  42324. get idleRotationSpinupTime(): number;
  42325. /**
  42326. * Gets a value indicating if the camera is currently rotating because of this behavior
  42327. */
  42328. get rotationInProgress(): boolean;
  42329. private _onPrePointerObservableObserver;
  42330. private _onAfterCheckInputsObserver;
  42331. private _attachedCamera;
  42332. private _isPointerDown;
  42333. private _lastFrameTime;
  42334. private _lastInteractionTime;
  42335. private _cameraRotationSpeed;
  42336. /**
  42337. * Initializes the behavior.
  42338. */
  42339. init(): void;
  42340. /**
  42341. * Attaches the behavior to its arc rotate camera.
  42342. * @param camera Defines the camera to attach the behavior to
  42343. */
  42344. attach(camera: ArcRotateCamera): void;
  42345. /**
  42346. * Detaches the behavior from its current arc rotate camera.
  42347. */
  42348. detach(): void;
  42349. /**
  42350. * Returns true if user is scrolling.
  42351. * @return true if user is scrolling.
  42352. */
  42353. private _userIsZooming;
  42354. private _lastFrameRadius;
  42355. private _shouldAnimationStopForInteraction;
  42356. /**
  42357. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42358. */
  42359. private _applyUserInteraction;
  42360. private _userIsMoving;
  42361. }
  42362. }
  42363. declare module BABYLON {
  42364. /**
  42365. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42366. */
  42367. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42368. private ui;
  42369. /**
  42370. * The name of the behavior
  42371. */
  42372. name: string;
  42373. /**
  42374. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42375. */
  42376. distanceAwayFromFace: number;
  42377. /**
  42378. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42379. */
  42380. distanceAwayFromBottomOfFace: number;
  42381. private _faceVectors;
  42382. private _target;
  42383. private _scene;
  42384. private _onRenderObserver;
  42385. private _tmpMatrix;
  42386. private _tmpVector;
  42387. /**
  42388. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42389. * @param ui The transform node that should be attched to the mesh
  42390. */
  42391. constructor(ui: TransformNode);
  42392. /**
  42393. * Initializes the behavior
  42394. */
  42395. init(): void;
  42396. private _closestFace;
  42397. private _zeroVector;
  42398. private _lookAtTmpMatrix;
  42399. private _lookAtToRef;
  42400. /**
  42401. * Attaches the AttachToBoxBehavior to the passed in mesh
  42402. * @param target The mesh that the specified node will be attached to
  42403. */
  42404. attach(target: Mesh): void;
  42405. /**
  42406. * Detaches the behavior from the mesh
  42407. */
  42408. detach(): void;
  42409. }
  42410. }
  42411. declare module BABYLON {
  42412. /**
  42413. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42414. */
  42415. export class FadeInOutBehavior implements Behavior<Mesh> {
  42416. /**
  42417. * Time in milliseconds to delay before fading in (Default: 0)
  42418. */
  42419. delay: number;
  42420. /**
  42421. * Time in milliseconds for the mesh to fade in (Default: 300)
  42422. */
  42423. fadeInTime: number;
  42424. private _millisecondsPerFrame;
  42425. private _hovered;
  42426. private _hoverValue;
  42427. private _ownerNode;
  42428. /**
  42429. * Instatiates the FadeInOutBehavior
  42430. */
  42431. constructor();
  42432. /**
  42433. * The name of the behavior
  42434. */
  42435. get name(): string;
  42436. /**
  42437. * Initializes the behavior
  42438. */
  42439. init(): void;
  42440. /**
  42441. * Attaches the fade behavior on the passed in mesh
  42442. * @param ownerNode The mesh that will be faded in/out once attached
  42443. */
  42444. attach(ownerNode: Mesh): void;
  42445. /**
  42446. * Detaches the behavior from the mesh
  42447. */
  42448. detach(): void;
  42449. /**
  42450. * Triggers the mesh to begin fading in or out
  42451. * @param value if the object should fade in or out (true to fade in)
  42452. */
  42453. fadeIn(value: boolean): void;
  42454. private _update;
  42455. private _setAllVisibility;
  42456. }
  42457. }
  42458. declare module BABYLON {
  42459. /**
  42460. * Class containing a set of static utilities functions for managing Pivots
  42461. * @hidden
  42462. */
  42463. export class PivotTools {
  42464. private static _PivotCached;
  42465. private static _OldPivotPoint;
  42466. private static _PivotTranslation;
  42467. private static _PivotTmpVector;
  42468. /** @hidden */
  42469. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42470. /** @hidden */
  42471. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42472. }
  42473. }
  42474. declare module BABYLON {
  42475. /**
  42476. * Class containing static functions to help procedurally build meshes
  42477. */
  42478. export class PlaneBuilder {
  42479. /**
  42480. * Creates a plane mesh
  42481. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42482. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42483. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42485. * * 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
  42486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42487. * @param name defines the name of the mesh
  42488. * @param options defines the options used to create the mesh
  42489. * @param scene defines the hosting scene
  42490. * @returns the plane mesh
  42491. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42492. */
  42493. static CreatePlane(name: string, options: {
  42494. size?: number;
  42495. width?: number;
  42496. height?: number;
  42497. sideOrientation?: number;
  42498. frontUVs?: Vector4;
  42499. backUVs?: Vector4;
  42500. updatable?: boolean;
  42501. sourcePlane?: Plane;
  42502. }, scene?: Nullable<Scene>): Mesh;
  42503. }
  42504. }
  42505. declare module BABYLON {
  42506. /**
  42507. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42508. */
  42509. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42510. private static _AnyMouseID;
  42511. /**
  42512. * Abstract mesh the behavior is set on
  42513. */
  42514. attachedNode: AbstractMesh;
  42515. private _dragPlane;
  42516. private _scene;
  42517. private _pointerObserver;
  42518. private _beforeRenderObserver;
  42519. private static _planeScene;
  42520. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42521. /**
  42522. * 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)
  42523. */
  42524. maxDragAngle: number;
  42525. /**
  42526. * @hidden
  42527. */
  42528. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42529. /**
  42530. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42531. */
  42532. currentDraggingPointerID: number;
  42533. /**
  42534. * The last position where the pointer hit the drag plane in world space
  42535. */
  42536. lastDragPosition: Vector3;
  42537. /**
  42538. * If the behavior is currently in a dragging state
  42539. */
  42540. dragging: boolean;
  42541. /**
  42542. * 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)
  42543. */
  42544. dragDeltaRatio: number;
  42545. /**
  42546. * If the drag plane orientation should be updated during the dragging (Default: true)
  42547. */
  42548. updateDragPlane: boolean;
  42549. private _debugMode;
  42550. private _moving;
  42551. /**
  42552. * Fires each time the attached mesh is dragged with the pointer
  42553. * * delta between last drag position and current drag position in world space
  42554. * * dragDistance along the drag axis
  42555. * * dragPlaneNormal normal of the current drag plane used during the drag
  42556. * * dragPlanePoint in world space where the drag intersects the drag plane
  42557. */
  42558. onDragObservable: Observable<{
  42559. delta: Vector3;
  42560. dragPlanePoint: Vector3;
  42561. dragPlaneNormal: Vector3;
  42562. dragDistance: number;
  42563. pointerId: number;
  42564. }>;
  42565. /**
  42566. * Fires each time a drag begins (eg. mouse down on mesh)
  42567. */
  42568. onDragStartObservable: Observable<{
  42569. dragPlanePoint: Vector3;
  42570. pointerId: number;
  42571. }>;
  42572. /**
  42573. * Fires each time a drag ends (eg. mouse release after drag)
  42574. */
  42575. onDragEndObservable: Observable<{
  42576. dragPlanePoint: Vector3;
  42577. pointerId: number;
  42578. }>;
  42579. /**
  42580. * If the attached mesh should be moved when dragged
  42581. */
  42582. moveAttached: boolean;
  42583. /**
  42584. * If the drag behavior will react to drag events (Default: true)
  42585. */
  42586. enabled: boolean;
  42587. /**
  42588. * If pointer events should start and release the drag (Default: true)
  42589. */
  42590. startAndReleaseDragOnPointerEvents: boolean;
  42591. /**
  42592. * If camera controls should be detached during the drag
  42593. */
  42594. detachCameraControls: boolean;
  42595. /**
  42596. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42597. */
  42598. useObjectOrientationForDragging: boolean;
  42599. private _options;
  42600. /**
  42601. * Gets the options used by the behavior
  42602. */
  42603. get options(): {
  42604. dragAxis?: Vector3;
  42605. dragPlaneNormal?: Vector3;
  42606. };
  42607. /**
  42608. * Sets the options used by the behavior
  42609. */
  42610. set options(options: {
  42611. dragAxis?: Vector3;
  42612. dragPlaneNormal?: Vector3;
  42613. });
  42614. /**
  42615. * Creates a pointer drag behavior that can be attached to a mesh
  42616. * @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)
  42617. */
  42618. constructor(options?: {
  42619. dragAxis?: Vector3;
  42620. dragPlaneNormal?: Vector3;
  42621. });
  42622. /**
  42623. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42624. */
  42625. validateDrag: (targetPosition: Vector3) => boolean;
  42626. /**
  42627. * The name of the behavior
  42628. */
  42629. get name(): string;
  42630. /**
  42631. * Initializes the behavior
  42632. */
  42633. init(): void;
  42634. private _tmpVector;
  42635. private _alternatePickedPoint;
  42636. private _worldDragAxis;
  42637. private _targetPosition;
  42638. private _attachedElement;
  42639. /**
  42640. * Attaches the drag behavior the passed in mesh
  42641. * @param ownerNode The mesh that will be dragged around once attached
  42642. * @param predicate Predicate to use for pick filtering
  42643. */
  42644. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42645. /**
  42646. * Force relase the drag action by code.
  42647. */
  42648. releaseDrag(): void;
  42649. private _startDragRay;
  42650. private _lastPointerRay;
  42651. /**
  42652. * Simulates the start of a pointer drag event on the behavior
  42653. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42654. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42655. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42656. */
  42657. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42658. private _startDrag;
  42659. private _dragDelta;
  42660. private _moveDrag;
  42661. private _pickWithRayOnDragPlane;
  42662. private _pointA;
  42663. private _pointB;
  42664. private _pointC;
  42665. private _lineA;
  42666. private _lineB;
  42667. private _localAxis;
  42668. private _lookAt;
  42669. private _updateDragPlanePosition;
  42670. /**
  42671. * Detaches the behavior from the mesh
  42672. */
  42673. detach(): void;
  42674. }
  42675. }
  42676. declare module BABYLON {
  42677. /**
  42678. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42679. */
  42680. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42681. private _dragBehaviorA;
  42682. private _dragBehaviorB;
  42683. private _startDistance;
  42684. private _initialScale;
  42685. private _targetScale;
  42686. private _ownerNode;
  42687. private _sceneRenderObserver;
  42688. /**
  42689. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42690. */
  42691. constructor();
  42692. /**
  42693. * The name of the behavior
  42694. */
  42695. get name(): string;
  42696. /**
  42697. * Initializes the behavior
  42698. */
  42699. init(): void;
  42700. private _getCurrentDistance;
  42701. /**
  42702. * Attaches the scale behavior the passed in mesh
  42703. * @param ownerNode The mesh that will be scaled around once attached
  42704. */
  42705. attach(ownerNode: Mesh): void;
  42706. /**
  42707. * Detaches the behavior from the mesh
  42708. */
  42709. detach(): void;
  42710. }
  42711. }
  42712. declare module BABYLON {
  42713. /**
  42714. * 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
  42715. */
  42716. export class SixDofDragBehavior implements Behavior<Mesh> {
  42717. private static _virtualScene;
  42718. private _ownerNode;
  42719. private _sceneRenderObserver;
  42720. private _scene;
  42721. private _targetPosition;
  42722. private _virtualOriginMesh;
  42723. private _virtualDragMesh;
  42724. private _pointerObserver;
  42725. private _moving;
  42726. private _startingOrientation;
  42727. private _attachedElement;
  42728. /**
  42729. * 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)
  42730. */
  42731. private zDragFactor;
  42732. /**
  42733. * If the object should rotate to face the drag origin
  42734. */
  42735. rotateDraggedObject: boolean;
  42736. /**
  42737. * If the behavior is currently in a dragging state
  42738. */
  42739. dragging: boolean;
  42740. /**
  42741. * 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)
  42742. */
  42743. dragDeltaRatio: number;
  42744. /**
  42745. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42746. */
  42747. currentDraggingPointerID: number;
  42748. /**
  42749. * If camera controls should be detached during the drag
  42750. */
  42751. detachCameraControls: boolean;
  42752. /**
  42753. * Fires each time a drag starts
  42754. */
  42755. onDragStartObservable: Observable<{}>;
  42756. /**
  42757. * Fires each time a drag ends (eg. mouse release after drag)
  42758. */
  42759. onDragEndObservable: Observable<{}>;
  42760. /**
  42761. * 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
  42762. */
  42763. constructor();
  42764. /**
  42765. * The name of the behavior
  42766. */
  42767. get name(): string;
  42768. /**
  42769. * Initializes the behavior
  42770. */
  42771. init(): void;
  42772. /**
  42773. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42774. */
  42775. private get _pointerCamera();
  42776. /**
  42777. * Attaches the scale behavior the passed in mesh
  42778. * @param ownerNode The mesh that will be scaled around once attached
  42779. */
  42780. attach(ownerNode: Mesh): void;
  42781. /**
  42782. * Detaches the behavior from the mesh
  42783. */
  42784. detach(): void;
  42785. }
  42786. }
  42787. declare module BABYLON {
  42788. /**
  42789. * Class used to apply inverse kinematics to bones
  42790. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42791. */
  42792. export class BoneIKController {
  42793. private static _tmpVecs;
  42794. private static _tmpQuat;
  42795. private static _tmpMats;
  42796. /**
  42797. * Gets or sets the target mesh
  42798. */
  42799. targetMesh: AbstractMesh;
  42800. /** Gets or sets the mesh used as pole */
  42801. poleTargetMesh: AbstractMesh;
  42802. /**
  42803. * Gets or sets the bone used as pole
  42804. */
  42805. poleTargetBone: Nullable<Bone>;
  42806. /**
  42807. * Gets or sets the target position
  42808. */
  42809. targetPosition: Vector3;
  42810. /**
  42811. * Gets or sets the pole target position
  42812. */
  42813. poleTargetPosition: Vector3;
  42814. /**
  42815. * Gets or sets the pole target local offset
  42816. */
  42817. poleTargetLocalOffset: Vector3;
  42818. /**
  42819. * Gets or sets the pole angle
  42820. */
  42821. poleAngle: number;
  42822. /**
  42823. * Gets or sets the mesh associated with the controller
  42824. */
  42825. mesh: AbstractMesh;
  42826. /**
  42827. * 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)
  42828. */
  42829. slerpAmount: number;
  42830. private _bone1Quat;
  42831. private _bone1Mat;
  42832. private _bone2Ang;
  42833. private _bone1;
  42834. private _bone2;
  42835. private _bone1Length;
  42836. private _bone2Length;
  42837. private _maxAngle;
  42838. private _maxReach;
  42839. private _rightHandedSystem;
  42840. private _bendAxis;
  42841. private _slerping;
  42842. private _adjustRoll;
  42843. /**
  42844. * Gets or sets maximum allowed angle
  42845. */
  42846. get maxAngle(): number;
  42847. set maxAngle(value: number);
  42848. /**
  42849. * Creates a new BoneIKController
  42850. * @param mesh defines the mesh to control
  42851. * @param bone defines the bone to control
  42852. * @param options defines options to set up the controller
  42853. */
  42854. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42855. targetMesh?: AbstractMesh;
  42856. poleTargetMesh?: AbstractMesh;
  42857. poleTargetBone?: Bone;
  42858. poleTargetLocalOffset?: Vector3;
  42859. poleAngle?: number;
  42860. bendAxis?: Vector3;
  42861. maxAngle?: number;
  42862. slerpAmount?: number;
  42863. });
  42864. private _setMaxAngle;
  42865. /**
  42866. * Force the controller to update the bones
  42867. */
  42868. update(): void;
  42869. }
  42870. }
  42871. declare module BABYLON {
  42872. /**
  42873. * Class used to make a bone look toward a point in space
  42874. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42875. */
  42876. export class BoneLookController {
  42877. private static _tmpVecs;
  42878. private static _tmpQuat;
  42879. private static _tmpMats;
  42880. /**
  42881. * The target Vector3 that the bone will look at
  42882. */
  42883. target: Vector3;
  42884. /**
  42885. * The mesh that the bone is attached to
  42886. */
  42887. mesh: AbstractMesh;
  42888. /**
  42889. * The bone that will be looking to the target
  42890. */
  42891. bone: Bone;
  42892. /**
  42893. * The up axis of the coordinate system that is used when the bone is rotated
  42894. */
  42895. upAxis: Vector3;
  42896. /**
  42897. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42898. */
  42899. upAxisSpace: Space;
  42900. /**
  42901. * Used to make an adjustment to the yaw of the bone
  42902. */
  42903. adjustYaw: number;
  42904. /**
  42905. * Used to make an adjustment to the pitch of the bone
  42906. */
  42907. adjustPitch: number;
  42908. /**
  42909. * Used to make an adjustment to the roll of the bone
  42910. */
  42911. adjustRoll: number;
  42912. /**
  42913. * 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)
  42914. */
  42915. slerpAmount: number;
  42916. private _minYaw;
  42917. private _maxYaw;
  42918. private _minPitch;
  42919. private _maxPitch;
  42920. private _minYawSin;
  42921. private _minYawCos;
  42922. private _maxYawSin;
  42923. private _maxYawCos;
  42924. private _midYawConstraint;
  42925. private _minPitchTan;
  42926. private _maxPitchTan;
  42927. private _boneQuat;
  42928. private _slerping;
  42929. private _transformYawPitch;
  42930. private _transformYawPitchInv;
  42931. private _firstFrameSkipped;
  42932. private _yawRange;
  42933. private _fowardAxis;
  42934. /**
  42935. * Gets or sets the minimum yaw angle that the bone can look to
  42936. */
  42937. get minYaw(): number;
  42938. set minYaw(value: number);
  42939. /**
  42940. * Gets or sets the maximum yaw angle that the bone can look to
  42941. */
  42942. get maxYaw(): number;
  42943. set maxYaw(value: number);
  42944. /**
  42945. * Gets or sets the minimum pitch angle that the bone can look to
  42946. */
  42947. get minPitch(): number;
  42948. set minPitch(value: number);
  42949. /**
  42950. * Gets or sets the maximum pitch angle that the bone can look to
  42951. */
  42952. get maxPitch(): number;
  42953. set maxPitch(value: number);
  42954. /**
  42955. * Create a BoneLookController
  42956. * @param mesh the mesh that the bone belongs to
  42957. * @param bone the bone that will be looking to the target
  42958. * @param target the target Vector3 to look at
  42959. * @param options optional settings:
  42960. * * maxYaw: the maximum angle the bone will yaw to
  42961. * * minYaw: the minimum angle the bone will yaw to
  42962. * * maxPitch: the maximum angle the bone will pitch to
  42963. * * minPitch: the minimum angle the bone will yaw to
  42964. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42965. * * upAxis: the up axis of the coordinate system
  42966. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42967. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42968. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42969. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42970. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42971. * * adjustRoll: used to make an adjustment to the roll of the bone
  42972. **/
  42973. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42974. maxYaw?: number;
  42975. minYaw?: number;
  42976. maxPitch?: number;
  42977. minPitch?: number;
  42978. slerpAmount?: number;
  42979. upAxis?: Vector3;
  42980. upAxisSpace?: Space;
  42981. yawAxis?: Vector3;
  42982. pitchAxis?: Vector3;
  42983. adjustYaw?: number;
  42984. adjustPitch?: number;
  42985. adjustRoll?: number;
  42986. });
  42987. /**
  42988. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42989. */
  42990. update(): void;
  42991. private _getAngleDiff;
  42992. private _getAngleBetween;
  42993. private _isAngleBetween;
  42994. }
  42995. }
  42996. declare module BABYLON {
  42997. /**
  42998. * Manage the gamepad inputs to control an arc rotate camera.
  42999. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43000. */
  43001. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43002. /**
  43003. * Defines the camera the input is attached to.
  43004. */
  43005. camera: ArcRotateCamera;
  43006. /**
  43007. * Defines the gamepad the input is gathering event from.
  43008. */
  43009. gamepad: Nullable<Gamepad>;
  43010. /**
  43011. * Defines the gamepad rotation sensiblity.
  43012. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43013. */
  43014. gamepadRotationSensibility: number;
  43015. /**
  43016. * Defines the gamepad move sensiblity.
  43017. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43018. */
  43019. gamepadMoveSensibility: number;
  43020. private _yAxisScale;
  43021. /**
  43022. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43023. */
  43024. get invertYAxis(): boolean;
  43025. set invertYAxis(value: boolean);
  43026. private _onGamepadConnectedObserver;
  43027. private _onGamepadDisconnectedObserver;
  43028. /**
  43029. * Attach the input controls to a specific dom element to get the input from.
  43030. * @param element Defines the element the controls should be listened from
  43031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43032. */
  43033. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43034. /**
  43035. * Detach the current controls from the specified dom element.
  43036. * @param element Defines the element to stop listening the inputs from
  43037. */
  43038. detachControl(element: Nullable<HTMLElement>): void;
  43039. /**
  43040. * Update the current camera state depending on the inputs that have been used this frame.
  43041. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43042. */
  43043. checkInputs(): void;
  43044. /**
  43045. * Gets the class name of the current intput.
  43046. * @returns the class name
  43047. */
  43048. getClassName(): string;
  43049. /**
  43050. * Get the friendly name associated with the input class.
  43051. * @returns the input friendly name
  43052. */
  43053. getSimpleName(): string;
  43054. }
  43055. }
  43056. declare module BABYLON {
  43057. interface ArcRotateCameraInputsManager {
  43058. /**
  43059. * Add orientation input support to the input manager.
  43060. * @returns the current input manager
  43061. */
  43062. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43063. }
  43064. /**
  43065. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43066. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43067. */
  43068. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43069. /**
  43070. * Defines the camera the input is attached to.
  43071. */
  43072. camera: ArcRotateCamera;
  43073. /**
  43074. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43075. */
  43076. alphaCorrection: number;
  43077. /**
  43078. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43079. */
  43080. gammaCorrection: number;
  43081. private _alpha;
  43082. private _gamma;
  43083. private _dirty;
  43084. private _deviceOrientationHandler;
  43085. /**
  43086. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43087. */
  43088. constructor();
  43089. /**
  43090. * Attach the input controls to a specific dom element to get the input from.
  43091. * @param element Defines the element the controls should be listened from
  43092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43093. */
  43094. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43095. /** @hidden */
  43096. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43097. /**
  43098. * Update the current camera state depending on the inputs that have been used this frame.
  43099. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43100. */
  43101. checkInputs(): void;
  43102. /**
  43103. * Detach the current controls from the specified dom element.
  43104. * @param element Defines the element to stop listening the inputs from
  43105. */
  43106. detachControl(element: Nullable<HTMLElement>): void;
  43107. /**
  43108. * Gets the class name of the current intput.
  43109. * @returns the class name
  43110. */
  43111. getClassName(): string;
  43112. /**
  43113. * Get the friendly name associated with the input class.
  43114. * @returns the input friendly name
  43115. */
  43116. getSimpleName(): string;
  43117. }
  43118. }
  43119. declare module BABYLON {
  43120. /**
  43121. * Listen to mouse events to control the camera.
  43122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43123. */
  43124. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43125. /**
  43126. * Defines the camera the input is attached to.
  43127. */
  43128. camera: FlyCamera;
  43129. /**
  43130. * Defines if touch is enabled. (Default is true.)
  43131. */
  43132. touchEnabled: boolean;
  43133. /**
  43134. * Defines the buttons associated with the input to handle camera rotation.
  43135. */
  43136. buttons: number[];
  43137. /**
  43138. * Assign buttons for Yaw control.
  43139. */
  43140. buttonsYaw: number[];
  43141. /**
  43142. * Assign buttons for Pitch control.
  43143. */
  43144. buttonsPitch: number[];
  43145. /**
  43146. * Assign buttons for Roll control.
  43147. */
  43148. buttonsRoll: number[];
  43149. /**
  43150. * Detect if any button is being pressed while mouse is moved.
  43151. * -1 = Mouse locked.
  43152. * 0 = Left button.
  43153. * 1 = Middle Button.
  43154. * 2 = Right Button.
  43155. */
  43156. activeButton: number;
  43157. /**
  43158. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43159. * Higher values reduce its sensitivity.
  43160. */
  43161. angularSensibility: number;
  43162. private _mousemoveCallback;
  43163. private _observer;
  43164. private _rollObserver;
  43165. private previousPosition;
  43166. private noPreventDefault;
  43167. private element;
  43168. /**
  43169. * Listen to mouse events to control the camera.
  43170. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43172. */
  43173. constructor(touchEnabled?: boolean);
  43174. /**
  43175. * Attach the mouse control to the HTML DOM element.
  43176. * @param element Defines the element that listens to the input events.
  43177. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43178. */
  43179. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43180. /**
  43181. * Detach the current controls from the specified dom element.
  43182. * @param element Defines the element to stop listening the inputs from
  43183. */
  43184. detachControl(element: Nullable<HTMLElement>): void;
  43185. /**
  43186. * Gets the class name of the current input.
  43187. * @returns the class name.
  43188. */
  43189. getClassName(): string;
  43190. /**
  43191. * Get the friendly name associated with the input class.
  43192. * @returns the input's friendly name.
  43193. */
  43194. getSimpleName(): string;
  43195. private _pointerInput;
  43196. private _onMouseMove;
  43197. /**
  43198. * Rotate camera by mouse offset.
  43199. */
  43200. private rotateCamera;
  43201. }
  43202. }
  43203. declare module BABYLON {
  43204. /**
  43205. * Default Inputs manager for the FlyCamera.
  43206. * It groups all the default supported inputs for ease of use.
  43207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43208. */
  43209. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43210. /**
  43211. * Instantiates a new FlyCameraInputsManager.
  43212. * @param camera Defines the camera the inputs belong to.
  43213. */
  43214. constructor(camera: FlyCamera);
  43215. /**
  43216. * Add keyboard input support to the input manager.
  43217. * @returns the new FlyCameraKeyboardMoveInput().
  43218. */
  43219. addKeyboard(): FlyCameraInputsManager;
  43220. /**
  43221. * Add mouse input support to the input manager.
  43222. * @param touchEnabled Enable touch screen support.
  43223. * @returns the new FlyCameraMouseInput().
  43224. */
  43225. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43226. }
  43227. }
  43228. declare module BABYLON {
  43229. /**
  43230. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43231. * such as in a 3D Space Shooter or a Flight Simulator.
  43232. */
  43233. export class FlyCamera extends TargetCamera {
  43234. /**
  43235. * Define the collision ellipsoid of the camera.
  43236. * This is helpful for simulating a camera body, like a player's body.
  43237. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43238. */
  43239. ellipsoid: Vector3;
  43240. /**
  43241. * Define an offset for the position of the ellipsoid around the camera.
  43242. * This can be helpful if the camera is attached away from the player's body center,
  43243. * such as at its head.
  43244. */
  43245. ellipsoidOffset: Vector3;
  43246. /**
  43247. * Enable or disable collisions of the camera with the rest of the scene objects.
  43248. */
  43249. checkCollisions: boolean;
  43250. /**
  43251. * Enable or disable gravity on the camera.
  43252. */
  43253. applyGravity: boolean;
  43254. /**
  43255. * Define the current direction the camera is moving to.
  43256. */
  43257. cameraDirection: Vector3;
  43258. /**
  43259. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43260. * This overrides and empties cameraRotation.
  43261. */
  43262. rotationQuaternion: Quaternion;
  43263. /**
  43264. * Track Roll to maintain the wanted Rolling when looking around.
  43265. */
  43266. _trackRoll: number;
  43267. /**
  43268. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43269. */
  43270. rollCorrect: number;
  43271. /**
  43272. * Mimic a banked turn, Rolling the camera when Yawing.
  43273. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43274. */
  43275. bankedTurn: boolean;
  43276. /**
  43277. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43278. */
  43279. bankedTurnLimit: number;
  43280. /**
  43281. * Value of 0 disables the banked Roll.
  43282. * Value of 1 is equal to the Yaw angle in radians.
  43283. */
  43284. bankedTurnMultiplier: number;
  43285. /**
  43286. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43287. */
  43288. inputs: FlyCameraInputsManager;
  43289. /**
  43290. * Gets the input sensibility for mouse input.
  43291. * Higher values reduce sensitivity.
  43292. */
  43293. get angularSensibility(): number;
  43294. /**
  43295. * Sets the input sensibility for a mouse input.
  43296. * Higher values reduce sensitivity.
  43297. */
  43298. set angularSensibility(value: number);
  43299. /**
  43300. * Get the keys for camera movement forward.
  43301. */
  43302. get keysForward(): number[];
  43303. /**
  43304. * Set the keys for camera movement forward.
  43305. */
  43306. set keysForward(value: number[]);
  43307. /**
  43308. * Get the keys for camera movement backward.
  43309. */
  43310. get keysBackward(): number[];
  43311. set keysBackward(value: number[]);
  43312. /**
  43313. * Get the keys for camera movement up.
  43314. */
  43315. get keysUp(): number[];
  43316. /**
  43317. * Set the keys for camera movement up.
  43318. */
  43319. set keysUp(value: number[]);
  43320. /**
  43321. * Get the keys for camera movement down.
  43322. */
  43323. get keysDown(): number[];
  43324. /**
  43325. * Set the keys for camera movement down.
  43326. */
  43327. set keysDown(value: number[]);
  43328. /**
  43329. * Get the keys for camera movement left.
  43330. */
  43331. get keysLeft(): number[];
  43332. /**
  43333. * Set the keys for camera movement left.
  43334. */
  43335. set keysLeft(value: number[]);
  43336. /**
  43337. * Set the keys for camera movement right.
  43338. */
  43339. get keysRight(): number[];
  43340. /**
  43341. * Set the keys for camera movement right.
  43342. */
  43343. set keysRight(value: number[]);
  43344. /**
  43345. * Event raised when the camera collides with a mesh in the scene.
  43346. */
  43347. onCollide: (collidedMesh: AbstractMesh) => void;
  43348. private _collider;
  43349. private _needMoveForGravity;
  43350. private _oldPosition;
  43351. private _diffPosition;
  43352. private _newPosition;
  43353. /** @hidden */
  43354. _localDirection: Vector3;
  43355. /** @hidden */
  43356. _transformedDirection: Vector3;
  43357. /**
  43358. * Instantiates a FlyCamera.
  43359. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43360. * such as in a 3D Space Shooter or a Flight Simulator.
  43361. * @param name Define the name of the camera in the scene.
  43362. * @param position Define the starting position of the camera in the scene.
  43363. * @param scene Define the scene the camera belongs to.
  43364. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43365. */
  43366. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43367. /**
  43368. * Attach a control to the HTML DOM element.
  43369. * @param element Defines the element that listens to the input events.
  43370. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43371. */
  43372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43373. /**
  43374. * Detach a control from the HTML DOM element.
  43375. * The camera will stop reacting to that input.
  43376. * @param element Defines the element that listens to the input events.
  43377. */
  43378. detachControl(element: HTMLElement): void;
  43379. private _collisionMask;
  43380. /**
  43381. * Get the mask that the camera ignores in collision events.
  43382. */
  43383. get collisionMask(): number;
  43384. /**
  43385. * Set the mask that the camera ignores in collision events.
  43386. */
  43387. set collisionMask(mask: number);
  43388. /** @hidden */
  43389. _collideWithWorld(displacement: Vector3): void;
  43390. /** @hidden */
  43391. private _onCollisionPositionChange;
  43392. /** @hidden */
  43393. _checkInputs(): void;
  43394. /** @hidden */
  43395. _decideIfNeedsToMove(): boolean;
  43396. /** @hidden */
  43397. _updatePosition(): void;
  43398. /**
  43399. * Restore the Roll to its target value at the rate specified.
  43400. * @param rate - Higher means slower restoring.
  43401. * @hidden
  43402. */
  43403. restoreRoll(rate: number): void;
  43404. /**
  43405. * Destroy the camera and release the current resources held by it.
  43406. */
  43407. dispose(): void;
  43408. /**
  43409. * Get the current object class name.
  43410. * @returns the class name.
  43411. */
  43412. getClassName(): string;
  43413. }
  43414. }
  43415. declare module BABYLON {
  43416. /**
  43417. * Listen to keyboard events to control the camera.
  43418. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43419. */
  43420. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43421. /**
  43422. * Defines the camera the input is attached to.
  43423. */
  43424. camera: FlyCamera;
  43425. /**
  43426. * The list of keyboard keys used to control the forward move of the camera.
  43427. */
  43428. keysForward: number[];
  43429. /**
  43430. * The list of keyboard keys used to control the backward move of the camera.
  43431. */
  43432. keysBackward: number[];
  43433. /**
  43434. * The list of keyboard keys used to control the forward move of the camera.
  43435. */
  43436. keysUp: number[];
  43437. /**
  43438. * The list of keyboard keys used to control the backward move of the camera.
  43439. */
  43440. keysDown: number[];
  43441. /**
  43442. * The list of keyboard keys used to control the right strafe move of the camera.
  43443. */
  43444. keysRight: number[];
  43445. /**
  43446. * The list of keyboard keys used to control the left strafe move of the camera.
  43447. */
  43448. keysLeft: number[];
  43449. private _keys;
  43450. private _onCanvasBlurObserver;
  43451. private _onKeyboardObserver;
  43452. private _engine;
  43453. private _scene;
  43454. /**
  43455. * Attach the input controls to a specific dom element to get the input from.
  43456. * @param element Defines the element the controls should be listened from
  43457. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43458. */
  43459. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43460. /**
  43461. * Detach the current controls from the specified dom element.
  43462. * @param element Defines the element to stop listening the inputs from
  43463. */
  43464. detachControl(element: Nullable<HTMLElement>): void;
  43465. /**
  43466. * Gets the class name of the current intput.
  43467. * @returns the class name
  43468. */
  43469. getClassName(): string;
  43470. /** @hidden */
  43471. _onLostFocus(e: FocusEvent): void;
  43472. /**
  43473. * Get the friendly name associated with the input class.
  43474. * @returns the input friendly name
  43475. */
  43476. getSimpleName(): string;
  43477. /**
  43478. * Update the current camera state depending on the inputs that have been used this frame.
  43479. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43480. */
  43481. checkInputs(): void;
  43482. }
  43483. }
  43484. declare module BABYLON {
  43485. /**
  43486. * Manage the mouse wheel inputs to control a follow camera.
  43487. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43488. */
  43489. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43490. /**
  43491. * Defines the camera the input is attached to.
  43492. */
  43493. camera: FollowCamera;
  43494. /**
  43495. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43496. */
  43497. axisControlRadius: boolean;
  43498. /**
  43499. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43500. */
  43501. axisControlHeight: boolean;
  43502. /**
  43503. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43504. */
  43505. axisControlRotation: boolean;
  43506. /**
  43507. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43508. * relation to mouseWheel events.
  43509. */
  43510. wheelPrecision: number;
  43511. /**
  43512. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43513. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43514. */
  43515. wheelDeltaPercentage: number;
  43516. private _wheel;
  43517. private _observer;
  43518. /**
  43519. * Attach the input controls to a specific dom element to get the input from.
  43520. * @param element Defines the element the controls should be listened from
  43521. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43522. */
  43523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43524. /**
  43525. * Detach the current controls from the specified dom element.
  43526. * @param element Defines the element to stop listening the inputs from
  43527. */
  43528. detachControl(element: Nullable<HTMLElement>): void;
  43529. /**
  43530. * Gets the class name of the current intput.
  43531. * @returns the class name
  43532. */
  43533. getClassName(): string;
  43534. /**
  43535. * Get the friendly name associated with the input class.
  43536. * @returns the input friendly name
  43537. */
  43538. getSimpleName(): string;
  43539. }
  43540. }
  43541. declare module BABYLON {
  43542. /**
  43543. * Manage the pointers inputs to control an follow camera.
  43544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43545. */
  43546. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43547. /**
  43548. * Defines the camera the input is attached to.
  43549. */
  43550. camera: FollowCamera;
  43551. /**
  43552. * Gets the class name of the current input.
  43553. * @returns the class name
  43554. */
  43555. getClassName(): string;
  43556. /**
  43557. * Defines the pointer angular sensibility along the X axis or how fast is
  43558. * the camera rotating.
  43559. * A negative number will reverse the axis direction.
  43560. */
  43561. angularSensibilityX: number;
  43562. /**
  43563. * Defines the pointer angular sensibility along the Y axis or how fast is
  43564. * the camera rotating.
  43565. * A negative number will reverse the axis direction.
  43566. */
  43567. angularSensibilityY: number;
  43568. /**
  43569. * Defines the pointer pinch precision or how fast is the camera zooming.
  43570. * A negative number will reverse the axis direction.
  43571. */
  43572. pinchPrecision: number;
  43573. /**
  43574. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43575. * from 0.
  43576. * It defines the percentage of current camera.radius to use as delta when
  43577. * pinch zoom is used.
  43578. */
  43579. pinchDeltaPercentage: number;
  43580. /**
  43581. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43582. */
  43583. axisXControlRadius: boolean;
  43584. /**
  43585. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43586. */
  43587. axisXControlHeight: boolean;
  43588. /**
  43589. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43590. */
  43591. axisXControlRotation: boolean;
  43592. /**
  43593. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43594. */
  43595. axisYControlRadius: boolean;
  43596. /**
  43597. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43598. */
  43599. axisYControlHeight: boolean;
  43600. /**
  43601. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43602. */
  43603. axisYControlRotation: boolean;
  43604. /**
  43605. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43606. */
  43607. axisPinchControlRadius: boolean;
  43608. /**
  43609. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43610. */
  43611. axisPinchControlHeight: boolean;
  43612. /**
  43613. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43614. */
  43615. axisPinchControlRotation: boolean;
  43616. /**
  43617. * Log error messages if basic misconfiguration has occurred.
  43618. */
  43619. warningEnable: boolean;
  43620. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43621. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43622. private _warningCounter;
  43623. private _warning;
  43624. }
  43625. }
  43626. declare module BABYLON {
  43627. /**
  43628. * Default Inputs manager for the FollowCamera.
  43629. * It groups all the default supported inputs for ease of use.
  43630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43631. */
  43632. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43633. /**
  43634. * Instantiates a new FollowCameraInputsManager.
  43635. * @param camera Defines the camera the inputs belong to
  43636. */
  43637. constructor(camera: FollowCamera);
  43638. /**
  43639. * Add keyboard input support to the input manager.
  43640. * @returns the current input manager
  43641. */
  43642. addKeyboard(): FollowCameraInputsManager;
  43643. /**
  43644. * Add mouse wheel input support to the input manager.
  43645. * @returns the current input manager
  43646. */
  43647. addMouseWheel(): FollowCameraInputsManager;
  43648. /**
  43649. * Add pointers input support to the input manager.
  43650. * @returns the current input manager
  43651. */
  43652. addPointers(): FollowCameraInputsManager;
  43653. /**
  43654. * Add orientation input support to the input manager.
  43655. * @returns the current input manager
  43656. */
  43657. addVRDeviceOrientation(): FollowCameraInputsManager;
  43658. }
  43659. }
  43660. declare module BABYLON {
  43661. /**
  43662. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43663. * an arc rotate version arcFollowCamera are available.
  43664. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43665. */
  43666. export class FollowCamera extends TargetCamera {
  43667. /**
  43668. * Distance the follow camera should follow an object at
  43669. */
  43670. radius: number;
  43671. /**
  43672. * Minimum allowed distance of the camera to the axis of rotation
  43673. * (The camera can not get closer).
  43674. * This can help limiting how the Camera is able to move in the scene.
  43675. */
  43676. lowerRadiusLimit: Nullable<number>;
  43677. /**
  43678. * Maximum allowed distance of the camera to the axis of rotation
  43679. * (The camera can not get further).
  43680. * This can help limiting how the Camera is able to move in the scene.
  43681. */
  43682. upperRadiusLimit: Nullable<number>;
  43683. /**
  43684. * Define a rotation offset between the camera and the object it follows
  43685. */
  43686. rotationOffset: number;
  43687. /**
  43688. * Minimum allowed angle to camera position relative to target object.
  43689. * This can help limiting how the Camera is able to move in the scene.
  43690. */
  43691. lowerRotationOffsetLimit: Nullable<number>;
  43692. /**
  43693. * Maximum allowed angle to camera position relative to target object.
  43694. * This can help limiting how the Camera is able to move in the scene.
  43695. */
  43696. upperRotationOffsetLimit: Nullable<number>;
  43697. /**
  43698. * Define a height offset between the camera and the object it follows.
  43699. * It can help following an object from the top (like a car chaing a plane)
  43700. */
  43701. heightOffset: number;
  43702. /**
  43703. * Minimum allowed height of camera position relative to target object.
  43704. * This can help limiting how the Camera is able to move in the scene.
  43705. */
  43706. lowerHeightOffsetLimit: Nullable<number>;
  43707. /**
  43708. * Maximum allowed height of camera position relative to target object.
  43709. * This can help limiting how the Camera is able to move in the scene.
  43710. */
  43711. upperHeightOffsetLimit: Nullable<number>;
  43712. /**
  43713. * Define how fast the camera can accelerate to follow it s target.
  43714. */
  43715. cameraAcceleration: number;
  43716. /**
  43717. * Define the speed limit of the camera following an object.
  43718. */
  43719. maxCameraSpeed: number;
  43720. /**
  43721. * Define the target of the camera.
  43722. */
  43723. lockedTarget: Nullable<AbstractMesh>;
  43724. /**
  43725. * Defines the input associated with the camera.
  43726. */
  43727. inputs: FollowCameraInputsManager;
  43728. /**
  43729. * Instantiates the follow camera.
  43730. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43731. * @param name Define the name of the camera in the scene
  43732. * @param position Define the position of the camera
  43733. * @param scene Define the scene the camera belong to
  43734. * @param lockedTarget Define the target of the camera
  43735. */
  43736. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43737. private _follow;
  43738. /**
  43739. * Attached controls to the current camera.
  43740. * @param element Defines the element the controls should be listened from
  43741. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43742. */
  43743. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43744. /**
  43745. * Detach the current controls from the camera.
  43746. * The camera will stop reacting to inputs.
  43747. * @param element Defines the element to stop listening the inputs from
  43748. */
  43749. detachControl(element: HTMLElement): void;
  43750. /** @hidden */
  43751. _checkInputs(): void;
  43752. private _checkLimits;
  43753. /**
  43754. * Gets the camera class name.
  43755. * @returns the class name
  43756. */
  43757. getClassName(): string;
  43758. }
  43759. /**
  43760. * Arc Rotate version of the follow camera.
  43761. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43762. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43763. */
  43764. export class ArcFollowCamera extends TargetCamera {
  43765. /** The longitudinal angle of the camera */
  43766. alpha: number;
  43767. /** The latitudinal angle of the camera */
  43768. beta: number;
  43769. /** The radius of the camera from its target */
  43770. radius: number;
  43771. /** Define the camera target (the mesh it should follow) */
  43772. target: Nullable<AbstractMesh>;
  43773. private _cartesianCoordinates;
  43774. /**
  43775. * Instantiates a new ArcFollowCamera
  43776. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43777. * @param name Define the name of the camera
  43778. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43779. * @param beta Define the rotation angle of the camera around the elevation axis
  43780. * @param radius Define the radius of the camera from its target point
  43781. * @param target Define the target of the camera
  43782. * @param scene Define the scene the camera belongs to
  43783. */
  43784. constructor(name: string,
  43785. /** The longitudinal angle of the camera */
  43786. alpha: number,
  43787. /** The latitudinal angle of the camera */
  43788. beta: number,
  43789. /** The radius of the camera from its target */
  43790. radius: number,
  43791. /** Define the camera target (the mesh it should follow) */
  43792. target: Nullable<AbstractMesh>, scene: Scene);
  43793. private _follow;
  43794. /** @hidden */
  43795. _checkInputs(): void;
  43796. /**
  43797. * Returns the class name of the object.
  43798. * It is mostly used internally for serialization purposes.
  43799. */
  43800. getClassName(): string;
  43801. }
  43802. }
  43803. declare module BABYLON {
  43804. /**
  43805. * Manage the keyboard inputs to control the movement of a follow camera.
  43806. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43807. */
  43808. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43809. /**
  43810. * Defines the camera the input is attached to.
  43811. */
  43812. camera: FollowCamera;
  43813. /**
  43814. * Defines the list of key codes associated with the up action (increase heightOffset)
  43815. */
  43816. keysHeightOffsetIncr: number[];
  43817. /**
  43818. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43819. */
  43820. keysHeightOffsetDecr: number[];
  43821. /**
  43822. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43823. */
  43824. keysHeightOffsetModifierAlt: boolean;
  43825. /**
  43826. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43827. */
  43828. keysHeightOffsetModifierCtrl: boolean;
  43829. /**
  43830. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43831. */
  43832. keysHeightOffsetModifierShift: boolean;
  43833. /**
  43834. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43835. */
  43836. keysRotationOffsetIncr: number[];
  43837. /**
  43838. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43839. */
  43840. keysRotationOffsetDecr: number[];
  43841. /**
  43842. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43843. */
  43844. keysRotationOffsetModifierAlt: boolean;
  43845. /**
  43846. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43847. */
  43848. keysRotationOffsetModifierCtrl: boolean;
  43849. /**
  43850. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43851. */
  43852. keysRotationOffsetModifierShift: boolean;
  43853. /**
  43854. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43855. */
  43856. keysRadiusIncr: number[];
  43857. /**
  43858. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43859. */
  43860. keysRadiusDecr: number[];
  43861. /**
  43862. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43863. */
  43864. keysRadiusModifierAlt: boolean;
  43865. /**
  43866. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43867. */
  43868. keysRadiusModifierCtrl: boolean;
  43869. /**
  43870. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43871. */
  43872. keysRadiusModifierShift: boolean;
  43873. /**
  43874. * Defines the rate of change of heightOffset.
  43875. */
  43876. heightSensibility: number;
  43877. /**
  43878. * Defines the rate of change of rotationOffset.
  43879. */
  43880. rotationSensibility: number;
  43881. /**
  43882. * Defines the rate of change of radius.
  43883. */
  43884. radiusSensibility: number;
  43885. private _keys;
  43886. private _ctrlPressed;
  43887. private _altPressed;
  43888. private _shiftPressed;
  43889. private _onCanvasBlurObserver;
  43890. private _onKeyboardObserver;
  43891. private _engine;
  43892. private _scene;
  43893. /**
  43894. * Attach the input controls to a specific dom element to get the input from.
  43895. * @param element Defines the element the controls should be listened from
  43896. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43897. */
  43898. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43899. /**
  43900. * Detach the current controls from the specified dom element.
  43901. * @param element Defines the element to stop listening the inputs from
  43902. */
  43903. detachControl(element: Nullable<HTMLElement>): void;
  43904. /**
  43905. * Update the current camera state depending on the inputs that have been used this frame.
  43906. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43907. */
  43908. checkInputs(): void;
  43909. /**
  43910. * Gets the class name of the current input.
  43911. * @returns the class name
  43912. */
  43913. getClassName(): string;
  43914. /**
  43915. * Get the friendly name associated with the input class.
  43916. * @returns the input friendly name
  43917. */
  43918. getSimpleName(): string;
  43919. /**
  43920. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43921. * allow modification of the heightOffset value.
  43922. */
  43923. private _modifierHeightOffset;
  43924. /**
  43925. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43926. * allow modification of the rotationOffset value.
  43927. */
  43928. private _modifierRotationOffset;
  43929. /**
  43930. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43931. * allow modification of the radius value.
  43932. */
  43933. private _modifierRadius;
  43934. }
  43935. }
  43936. declare module BABYLON {
  43937. interface FreeCameraInputsManager {
  43938. /**
  43939. * @hidden
  43940. */
  43941. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43942. /**
  43943. * Add orientation input support to the input manager.
  43944. * @returns the current input manager
  43945. */
  43946. addDeviceOrientation(): FreeCameraInputsManager;
  43947. }
  43948. /**
  43949. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43950. * Screen rotation is taken into account.
  43951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43952. */
  43953. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43954. private _camera;
  43955. private _screenOrientationAngle;
  43956. private _constantTranform;
  43957. private _screenQuaternion;
  43958. private _alpha;
  43959. private _beta;
  43960. private _gamma;
  43961. /**
  43962. * Can be used to detect if a device orientation sensor is available on a device
  43963. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43964. * @returns a promise that will resolve on orientation change
  43965. */
  43966. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43967. /**
  43968. * @hidden
  43969. */
  43970. _onDeviceOrientationChangedObservable: Observable<void>;
  43971. /**
  43972. * Instantiates a new input
  43973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43974. */
  43975. constructor();
  43976. /**
  43977. * Define the camera controlled by the input.
  43978. */
  43979. get camera(): FreeCamera;
  43980. set camera(camera: FreeCamera);
  43981. /**
  43982. * Attach the input controls to a specific dom element to get the input from.
  43983. * @param element Defines the element the controls should be listened from
  43984. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43985. */
  43986. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43987. private _orientationChanged;
  43988. private _deviceOrientation;
  43989. /**
  43990. * Detach the current controls from the specified dom element.
  43991. * @param element Defines the element to stop listening the inputs from
  43992. */
  43993. detachControl(element: Nullable<HTMLElement>): void;
  43994. /**
  43995. * Update the current camera state depending on the inputs that have been used this frame.
  43996. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43997. */
  43998. checkInputs(): void;
  43999. /**
  44000. * Gets the class name of the current intput.
  44001. * @returns the class name
  44002. */
  44003. getClassName(): string;
  44004. /**
  44005. * Get the friendly name associated with the input class.
  44006. * @returns the input friendly name
  44007. */
  44008. getSimpleName(): string;
  44009. }
  44010. }
  44011. declare module BABYLON {
  44012. /**
  44013. * Manage the gamepad inputs to control a free camera.
  44014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44015. */
  44016. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44017. /**
  44018. * Define the camera the input is attached to.
  44019. */
  44020. camera: FreeCamera;
  44021. /**
  44022. * Define the Gamepad controlling the input
  44023. */
  44024. gamepad: Nullable<Gamepad>;
  44025. /**
  44026. * Defines the gamepad rotation sensiblity.
  44027. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44028. */
  44029. gamepadAngularSensibility: number;
  44030. /**
  44031. * Defines the gamepad move sensiblity.
  44032. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44033. */
  44034. gamepadMoveSensibility: number;
  44035. private _yAxisScale;
  44036. /**
  44037. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44038. */
  44039. get invertYAxis(): boolean;
  44040. set invertYAxis(value: boolean);
  44041. private _onGamepadConnectedObserver;
  44042. private _onGamepadDisconnectedObserver;
  44043. private _cameraTransform;
  44044. private _deltaTransform;
  44045. private _vector3;
  44046. private _vector2;
  44047. /**
  44048. * Attach the input controls to a specific dom element to get the input from.
  44049. * @param element Defines the element the controls should be listened from
  44050. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44051. */
  44052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44053. /**
  44054. * Detach the current controls from the specified dom element.
  44055. * @param element Defines the element to stop listening the inputs from
  44056. */
  44057. detachControl(element: Nullable<HTMLElement>): void;
  44058. /**
  44059. * Update the current camera state depending on the inputs that have been used this frame.
  44060. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44061. */
  44062. checkInputs(): void;
  44063. /**
  44064. * Gets the class name of the current intput.
  44065. * @returns the class name
  44066. */
  44067. getClassName(): string;
  44068. /**
  44069. * Get the friendly name associated with the input class.
  44070. * @returns the input friendly name
  44071. */
  44072. getSimpleName(): string;
  44073. }
  44074. }
  44075. declare module BABYLON {
  44076. /**
  44077. * Defines the potential axis of a Joystick
  44078. */
  44079. export enum JoystickAxis {
  44080. /** X axis */
  44081. X = 0,
  44082. /** Y axis */
  44083. Y = 1,
  44084. /** Z axis */
  44085. Z = 2
  44086. }
  44087. /**
  44088. * Class used to define virtual joystick (used in touch mode)
  44089. */
  44090. export class VirtualJoystick {
  44091. /**
  44092. * Gets or sets a boolean indicating that left and right values must be inverted
  44093. */
  44094. reverseLeftRight: boolean;
  44095. /**
  44096. * Gets or sets a boolean indicating that up and down values must be inverted
  44097. */
  44098. reverseUpDown: boolean;
  44099. /**
  44100. * Gets the offset value for the position (ie. the change of the position value)
  44101. */
  44102. deltaPosition: Vector3;
  44103. /**
  44104. * Gets a boolean indicating if the virtual joystick was pressed
  44105. */
  44106. pressed: boolean;
  44107. /**
  44108. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44109. */
  44110. static Canvas: Nullable<HTMLCanvasElement>;
  44111. private static _globalJoystickIndex;
  44112. private static vjCanvasContext;
  44113. private static vjCanvasWidth;
  44114. private static vjCanvasHeight;
  44115. private static halfWidth;
  44116. private _action;
  44117. private _axisTargetedByLeftAndRight;
  44118. private _axisTargetedByUpAndDown;
  44119. private _joystickSensibility;
  44120. private _inversedSensibility;
  44121. private _joystickPointerID;
  44122. private _joystickColor;
  44123. private _joystickPointerPos;
  44124. private _joystickPreviousPointerPos;
  44125. private _joystickPointerStartPos;
  44126. private _deltaJoystickVector;
  44127. private _leftJoystick;
  44128. private _touches;
  44129. private _onPointerDownHandlerRef;
  44130. private _onPointerMoveHandlerRef;
  44131. private _onPointerUpHandlerRef;
  44132. private _onResize;
  44133. /**
  44134. * Creates a new virtual joystick
  44135. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44136. */
  44137. constructor(leftJoystick?: boolean);
  44138. /**
  44139. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44140. * @param newJoystickSensibility defines the new sensibility
  44141. */
  44142. setJoystickSensibility(newJoystickSensibility: number): void;
  44143. private _onPointerDown;
  44144. private _onPointerMove;
  44145. private _onPointerUp;
  44146. /**
  44147. * Change the color of the virtual joystick
  44148. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44149. */
  44150. setJoystickColor(newColor: string): void;
  44151. /**
  44152. * Defines a callback to call when the joystick is touched
  44153. * @param action defines the callback
  44154. */
  44155. setActionOnTouch(action: () => any): void;
  44156. /**
  44157. * Defines which axis you'd like to control for left & right
  44158. * @param axis defines the axis to use
  44159. */
  44160. setAxisForLeftRight(axis: JoystickAxis): void;
  44161. /**
  44162. * Defines which axis you'd like to control for up & down
  44163. * @param axis defines the axis to use
  44164. */
  44165. setAxisForUpDown(axis: JoystickAxis): void;
  44166. private _drawVirtualJoystick;
  44167. /**
  44168. * Release internal HTML canvas
  44169. */
  44170. releaseCanvas(): void;
  44171. }
  44172. }
  44173. declare module BABYLON {
  44174. interface FreeCameraInputsManager {
  44175. /**
  44176. * Add virtual joystick input support to the input manager.
  44177. * @returns the current input manager
  44178. */
  44179. addVirtualJoystick(): FreeCameraInputsManager;
  44180. }
  44181. /**
  44182. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44183. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44184. */
  44185. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44186. /**
  44187. * Defines the camera the input is attached to.
  44188. */
  44189. camera: FreeCamera;
  44190. private _leftjoystick;
  44191. private _rightjoystick;
  44192. /**
  44193. * Gets the left stick of the virtual joystick.
  44194. * @returns The virtual Joystick
  44195. */
  44196. getLeftJoystick(): VirtualJoystick;
  44197. /**
  44198. * Gets the right stick of the virtual joystick.
  44199. * @returns The virtual Joystick
  44200. */
  44201. getRightJoystick(): VirtualJoystick;
  44202. /**
  44203. * Update the current camera state depending on the inputs that have been used this frame.
  44204. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44205. */
  44206. checkInputs(): void;
  44207. /**
  44208. * Attach the input controls to a specific dom element to get the input from.
  44209. * @param element Defines the element the controls should be listened from
  44210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44211. */
  44212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44213. /**
  44214. * Detach the current controls from the specified dom element.
  44215. * @param element Defines the element to stop listening the inputs from
  44216. */
  44217. detachControl(element: Nullable<HTMLElement>): void;
  44218. /**
  44219. * Gets the class name of the current intput.
  44220. * @returns the class name
  44221. */
  44222. getClassName(): string;
  44223. /**
  44224. * Get the friendly name associated with the input class.
  44225. * @returns the input friendly name
  44226. */
  44227. getSimpleName(): string;
  44228. }
  44229. }
  44230. declare module BABYLON {
  44231. /**
  44232. * This represents a FPS type of camera controlled by touch.
  44233. * This is like a universal camera minus the Gamepad controls.
  44234. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44235. */
  44236. export class TouchCamera extends FreeCamera {
  44237. /**
  44238. * Defines the touch sensibility for rotation.
  44239. * The higher the faster.
  44240. */
  44241. get touchAngularSensibility(): number;
  44242. set touchAngularSensibility(value: number);
  44243. /**
  44244. * Defines the touch sensibility for move.
  44245. * The higher the faster.
  44246. */
  44247. get touchMoveSensibility(): number;
  44248. set touchMoveSensibility(value: number);
  44249. /**
  44250. * Instantiates a new touch camera.
  44251. * This represents a FPS type of camera controlled by touch.
  44252. * This is like a universal camera minus the Gamepad controls.
  44253. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44254. * @param name Define the name of the camera in the scene
  44255. * @param position Define the start position of the camera in the scene
  44256. * @param scene Define the scene the camera belongs to
  44257. */
  44258. constructor(name: string, position: Vector3, scene: Scene);
  44259. /**
  44260. * Gets the current object class name.
  44261. * @return the class name
  44262. */
  44263. getClassName(): string;
  44264. /** @hidden */
  44265. _setupInputs(): void;
  44266. }
  44267. }
  44268. declare module BABYLON {
  44269. /**
  44270. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44271. * being tilted forward or back and left or right.
  44272. */
  44273. export class DeviceOrientationCamera extends FreeCamera {
  44274. private _initialQuaternion;
  44275. private _quaternionCache;
  44276. private _tmpDragQuaternion;
  44277. private _disablePointerInputWhenUsingDeviceOrientation;
  44278. /**
  44279. * Creates a new device orientation camera
  44280. * @param name The name of the camera
  44281. * @param position The start position camera
  44282. * @param scene The scene the camera belongs to
  44283. */
  44284. constructor(name: string, position: Vector3, scene: Scene);
  44285. /**
  44286. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44287. */
  44288. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44289. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44290. private _dragFactor;
  44291. /**
  44292. * Enabled turning on the y axis when the orientation sensor is active
  44293. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44294. */
  44295. enableHorizontalDragging(dragFactor?: number): void;
  44296. /**
  44297. * Gets the current instance class name ("DeviceOrientationCamera").
  44298. * This helps avoiding instanceof at run time.
  44299. * @returns the class name
  44300. */
  44301. getClassName(): string;
  44302. /**
  44303. * @hidden
  44304. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44305. */
  44306. _checkInputs(): void;
  44307. /**
  44308. * Reset the camera to its default orientation on the specified axis only.
  44309. * @param axis The axis to reset
  44310. */
  44311. resetToCurrentRotation(axis?: Axis): void;
  44312. }
  44313. }
  44314. declare module BABYLON {
  44315. /**
  44316. * Defines supported buttons for XBox360 compatible gamepads
  44317. */
  44318. export enum Xbox360Button {
  44319. /** A */
  44320. A = 0,
  44321. /** B */
  44322. B = 1,
  44323. /** X */
  44324. X = 2,
  44325. /** Y */
  44326. Y = 3,
  44327. /** Left button */
  44328. LB = 4,
  44329. /** Right button */
  44330. RB = 5,
  44331. /** Back */
  44332. Back = 8,
  44333. /** Start */
  44334. Start = 9,
  44335. /** Left stick */
  44336. LeftStick = 10,
  44337. /** Right stick */
  44338. RightStick = 11
  44339. }
  44340. /** Defines values for XBox360 DPad */
  44341. export enum Xbox360Dpad {
  44342. /** Up */
  44343. Up = 12,
  44344. /** Down */
  44345. Down = 13,
  44346. /** Left */
  44347. Left = 14,
  44348. /** Right */
  44349. Right = 15
  44350. }
  44351. /**
  44352. * Defines a XBox360 gamepad
  44353. */
  44354. export class Xbox360Pad extends Gamepad {
  44355. private _leftTrigger;
  44356. private _rightTrigger;
  44357. private _onlefttriggerchanged;
  44358. private _onrighttriggerchanged;
  44359. private _onbuttondown;
  44360. private _onbuttonup;
  44361. private _ondpaddown;
  44362. private _ondpadup;
  44363. /** Observable raised when a button is pressed */
  44364. onButtonDownObservable: Observable<Xbox360Button>;
  44365. /** Observable raised when a button is released */
  44366. onButtonUpObservable: Observable<Xbox360Button>;
  44367. /** Observable raised when a pad is pressed */
  44368. onPadDownObservable: Observable<Xbox360Dpad>;
  44369. /** Observable raised when a pad is released */
  44370. onPadUpObservable: Observable<Xbox360Dpad>;
  44371. private _buttonA;
  44372. private _buttonB;
  44373. private _buttonX;
  44374. private _buttonY;
  44375. private _buttonBack;
  44376. private _buttonStart;
  44377. private _buttonLB;
  44378. private _buttonRB;
  44379. private _buttonLeftStick;
  44380. private _buttonRightStick;
  44381. private _dPadUp;
  44382. private _dPadDown;
  44383. private _dPadLeft;
  44384. private _dPadRight;
  44385. private _isXboxOnePad;
  44386. /**
  44387. * Creates a new XBox360 gamepad object
  44388. * @param id defines the id of this gamepad
  44389. * @param index defines its index
  44390. * @param gamepad defines the internal HTML gamepad object
  44391. * @param xboxOne defines if it is a XBox One gamepad
  44392. */
  44393. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44394. /**
  44395. * Defines the callback to call when left trigger is pressed
  44396. * @param callback defines the callback to use
  44397. */
  44398. onlefttriggerchanged(callback: (value: number) => void): void;
  44399. /**
  44400. * Defines the callback to call when right trigger is pressed
  44401. * @param callback defines the callback to use
  44402. */
  44403. onrighttriggerchanged(callback: (value: number) => void): void;
  44404. /**
  44405. * Gets the left trigger value
  44406. */
  44407. get leftTrigger(): number;
  44408. /**
  44409. * Sets the left trigger value
  44410. */
  44411. set leftTrigger(newValue: number);
  44412. /**
  44413. * Gets the right trigger value
  44414. */
  44415. get rightTrigger(): number;
  44416. /**
  44417. * Sets the right trigger value
  44418. */
  44419. set rightTrigger(newValue: number);
  44420. /**
  44421. * Defines the callback to call when a button is pressed
  44422. * @param callback defines the callback to use
  44423. */
  44424. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44425. /**
  44426. * Defines the callback to call when a button is released
  44427. * @param callback defines the callback to use
  44428. */
  44429. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44430. /**
  44431. * Defines the callback to call when a pad is pressed
  44432. * @param callback defines the callback to use
  44433. */
  44434. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44435. /**
  44436. * Defines the callback to call when a pad is released
  44437. * @param callback defines the callback to use
  44438. */
  44439. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44440. private _setButtonValue;
  44441. private _setDPadValue;
  44442. /**
  44443. * Gets the value of the `A` button
  44444. */
  44445. get buttonA(): number;
  44446. /**
  44447. * Sets the value of the `A` button
  44448. */
  44449. set buttonA(value: number);
  44450. /**
  44451. * Gets the value of the `B` button
  44452. */
  44453. get buttonB(): number;
  44454. /**
  44455. * Sets the value of the `B` button
  44456. */
  44457. set buttonB(value: number);
  44458. /**
  44459. * Gets the value of the `X` button
  44460. */
  44461. get buttonX(): number;
  44462. /**
  44463. * Sets the value of the `X` button
  44464. */
  44465. set buttonX(value: number);
  44466. /**
  44467. * Gets the value of the `Y` button
  44468. */
  44469. get buttonY(): number;
  44470. /**
  44471. * Sets the value of the `Y` button
  44472. */
  44473. set buttonY(value: number);
  44474. /**
  44475. * Gets the value of the `Start` button
  44476. */
  44477. get buttonStart(): number;
  44478. /**
  44479. * Sets the value of the `Start` button
  44480. */
  44481. set buttonStart(value: number);
  44482. /**
  44483. * Gets the value of the `Back` button
  44484. */
  44485. get buttonBack(): number;
  44486. /**
  44487. * Sets the value of the `Back` button
  44488. */
  44489. set buttonBack(value: number);
  44490. /**
  44491. * Gets the value of the `Left` button
  44492. */
  44493. get buttonLB(): number;
  44494. /**
  44495. * Sets the value of the `Left` button
  44496. */
  44497. set buttonLB(value: number);
  44498. /**
  44499. * Gets the value of the `Right` button
  44500. */
  44501. get buttonRB(): number;
  44502. /**
  44503. * Sets the value of the `Right` button
  44504. */
  44505. set buttonRB(value: number);
  44506. /**
  44507. * Gets the value of the Left joystick
  44508. */
  44509. get buttonLeftStick(): number;
  44510. /**
  44511. * Sets the value of the Left joystick
  44512. */
  44513. set buttonLeftStick(value: number);
  44514. /**
  44515. * Gets the value of the Right joystick
  44516. */
  44517. get buttonRightStick(): number;
  44518. /**
  44519. * Sets the value of the Right joystick
  44520. */
  44521. set buttonRightStick(value: number);
  44522. /**
  44523. * Gets the value of D-pad up
  44524. */
  44525. get dPadUp(): number;
  44526. /**
  44527. * Sets the value of D-pad up
  44528. */
  44529. set dPadUp(value: number);
  44530. /**
  44531. * Gets the value of D-pad down
  44532. */
  44533. get dPadDown(): number;
  44534. /**
  44535. * Sets the value of D-pad down
  44536. */
  44537. set dPadDown(value: number);
  44538. /**
  44539. * Gets the value of D-pad left
  44540. */
  44541. get dPadLeft(): number;
  44542. /**
  44543. * Sets the value of D-pad left
  44544. */
  44545. set dPadLeft(value: number);
  44546. /**
  44547. * Gets the value of D-pad right
  44548. */
  44549. get dPadRight(): number;
  44550. /**
  44551. * Sets the value of D-pad right
  44552. */
  44553. set dPadRight(value: number);
  44554. /**
  44555. * Force the gamepad to synchronize with device values
  44556. */
  44557. update(): void;
  44558. /**
  44559. * Disposes the gamepad
  44560. */
  44561. dispose(): void;
  44562. }
  44563. }
  44564. declare module BABYLON {
  44565. /**
  44566. * Defines supported buttons for DualShock compatible gamepads
  44567. */
  44568. export enum DualShockButton {
  44569. /** Cross */
  44570. Cross = 0,
  44571. /** Circle */
  44572. Circle = 1,
  44573. /** Square */
  44574. Square = 2,
  44575. /** Triangle */
  44576. Triangle = 3,
  44577. /** L1 */
  44578. L1 = 4,
  44579. /** R1 */
  44580. R1 = 5,
  44581. /** Share */
  44582. Share = 8,
  44583. /** Options */
  44584. Options = 9,
  44585. /** Left stick */
  44586. LeftStick = 10,
  44587. /** Right stick */
  44588. RightStick = 11
  44589. }
  44590. /** Defines values for DualShock DPad */
  44591. export enum DualShockDpad {
  44592. /** Up */
  44593. Up = 12,
  44594. /** Down */
  44595. Down = 13,
  44596. /** Left */
  44597. Left = 14,
  44598. /** Right */
  44599. Right = 15
  44600. }
  44601. /**
  44602. * Defines a DualShock gamepad
  44603. */
  44604. export class DualShockPad extends Gamepad {
  44605. private _leftTrigger;
  44606. private _rightTrigger;
  44607. private _onlefttriggerchanged;
  44608. private _onrighttriggerchanged;
  44609. private _onbuttondown;
  44610. private _onbuttonup;
  44611. private _ondpaddown;
  44612. private _ondpadup;
  44613. /** Observable raised when a button is pressed */
  44614. onButtonDownObservable: Observable<DualShockButton>;
  44615. /** Observable raised when a button is released */
  44616. onButtonUpObservable: Observable<DualShockButton>;
  44617. /** Observable raised when a pad is pressed */
  44618. onPadDownObservable: Observable<DualShockDpad>;
  44619. /** Observable raised when a pad is released */
  44620. onPadUpObservable: Observable<DualShockDpad>;
  44621. private _buttonCross;
  44622. private _buttonCircle;
  44623. private _buttonSquare;
  44624. private _buttonTriangle;
  44625. private _buttonShare;
  44626. private _buttonOptions;
  44627. private _buttonL1;
  44628. private _buttonR1;
  44629. private _buttonLeftStick;
  44630. private _buttonRightStick;
  44631. private _dPadUp;
  44632. private _dPadDown;
  44633. private _dPadLeft;
  44634. private _dPadRight;
  44635. /**
  44636. * Creates a new DualShock gamepad object
  44637. * @param id defines the id of this gamepad
  44638. * @param index defines its index
  44639. * @param gamepad defines the internal HTML gamepad object
  44640. */
  44641. constructor(id: string, index: number, gamepad: any);
  44642. /**
  44643. * Defines the callback to call when left trigger is pressed
  44644. * @param callback defines the callback to use
  44645. */
  44646. onlefttriggerchanged(callback: (value: number) => void): void;
  44647. /**
  44648. * Defines the callback to call when right trigger is pressed
  44649. * @param callback defines the callback to use
  44650. */
  44651. onrighttriggerchanged(callback: (value: number) => void): void;
  44652. /**
  44653. * Gets the left trigger value
  44654. */
  44655. get leftTrigger(): number;
  44656. /**
  44657. * Sets the left trigger value
  44658. */
  44659. set leftTrigger(newValue: number);
  44660. /**
  44661. * Gets the right trigger value
  44662. */
  44663. get rightTrigger(): number;
  44664. /**
  44665. * Sets the right trigger value
  44666. */
  44667. set rightTrigger(newValue: number);
  44668. /**
  44669. * Defines the callback to call when a button is pressed
  44670. * @param callback defines the callback to use
  44671. */
  44672. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44673. /**
  44674. * Defines the callback to call when a button is released
  44675. * @param callback defines the callback to use
  44676. */
  44677. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44678. /**
  44679. * Defines the callback to call when a pad is pressed
  44680. * @param callback defines the callback to use
  44681. */
  44682. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44683. /**
  44684. * Defines the callback to call when a pad is released
  44685. * @param callback defines the callback to use
  44686. */
  44687. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44688. private _setButtonValue;
  44689. private _setDPadValue;
  44690. /**
  44691. * Gets the value of the `Cross` button
  44692. */
  44693. get buttonCross(): number;
  44694. /**
  44695. * Sets the value of the `Cross` button
  44696. */
  44697. set buttonCross(value: number);
  44698. /**
  44699. * Gets the value of the `Circle` button
  44700. */
  44701. get buttonCircle(): number;
  44702. /**
  44703. * Sets the value of the `Circle` button
  44704. */
  44705. set buttonCircle(value: number);
  44706. /**
  44707. * Gets the value of the `Square` button
  44708. */
  44709. get buttonSquare(): number;
  44710. /**
  44711. * Sets the value of the `Square` button
  44712. */
  44713. set buttonSquare(value: number);
  44714. /**
  44715. * Gets the value of the `Triangle` button
  44716. */
  44717. get buttonTriangle(): number;
  44718. /**
  44719. * Sets the value of the `Triangle` button
  44720. */
  44721. set buttonTriangle(value: number);
  44722. /**
  44723. * Gets the value of the `Options` button
  44724. */
  44725. get buttonOptions(): number;
  44726. /**
  44727. * Sets the value of the `Options` button
  44728. */
  44729. set buttonOptions(value: number);
  44730. /**
  44731. * Gets the value of the `Share` button
  44732. */
  44733. get buttonShare(): number;
  44734. /**
  44735. * Sets the value of the `Share` button
  44736. */
  44737. set buttonShare(value: number);
  44738. /**
  44739. * Gets the value of the `L1` button
  44740. */
  44741. get buttonL1(): number;
  44742. /**
  44743. * Sets the value of the `L1` button
  44744. */
  44745. set buttonL1(value: number);
  44746. /**
  44747. * Gets the value of the `R1` button
  44748. */
  44749. get buttonR1(): number;
  44750. /**
  44751. * Sets the value of the `R1` button
  44752. */
  44753. set buttonR1(value: number);
  44754. /**
  44755. * Gets the value of the Left joystick
  44756. */
  44757. get buttonLeftStick(): number;
  44758. /**
  44759. * Sets the value of the Left joystick
  44760. */
  44761. set buttonLeftStick(value: number);
  44762. /**
  44763. * Gets the value of the Right joystick
  44764. */
  44765. get buttonRightStick(): number;
  44766. /**
  44767. * Sets the value of the Right joystick
  44768. */
  44769. set buttonRightStick(value: number);
  44770. /**
  44771. * Gets the value of D-pad up
  44772. */
  44773. get dPadUp(): number;
  44774. /**
  44775. * Sets the value of D-pad up
  44776. */
  44777. set dPadUp(value: number);
  44778. /**
  44779. * Gets the value of D-pad down
  44780. */
  44781. get dPadDown(): number;
  44782. /**
  44783. * Sets the value of D-pad down
  44784. */
  44785. set dPadDown(value: number);
  44786. /**
  44787. * Gets the value of D-pad left
  44788. */
  44789. get dPadLeft(): number;
  44790. /**
  44791. * Sets the value of D-pad left
  44792. */
  44793. set dPadLeft(value: number);
  44794. /**
  44795. * Gets the value of D-pad right
  44796. */
  44797. get dPadRight(): number;
  44798. /**
  44799. * Sets the value of D-pad right
  44800. */
  44801. set dPadRight(value: number);
  44802. /**
  44803. * Force the gamepad to synchronize with device values
  44804. */
  44805. update(): void;
  44806. /**
  44807. * Disposes the gamepad
  44808. */
  44809. dispose(): void;
  44810. }
  44811. }
  44812. declare module BABYLON {
  44813. /**
  44814. * Manager for handling gamepads
  44815. */
  44816. export class GamepadManager {
  44817. private _scene?;
  44818. private _babylonGamepads;
  44819. private _oneGamepadConnected;
  44820. /** @hidden */
  44821. _isMonitoring: boolean;
  44822. private _gamepadEventSupported;
  44823. private _gamepadSupport?;
  44824. /**
  44825. * observable to be triggered when the gamepad controller has been connected
  44826. */
  44827. onGamepadConnectedObservable: Observable<Gamepad>;
  44828. /**
  44829. * observable to be triggered when the gamepad controller has been disconnected
  44830. */
  44831. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44832. private _onGamepadConnectedEvent;
  44833. private _onGamepadDisconnectedEvent;
  44834. /**
  44835. * Initializes the gamepad manager
  44836. * @param _scene BabylonJS scene
  44837. */
  44838. constructor(_scene?: Scene | undefined);
  44839. /**
  44840. * The gamepads in the game pad manager
  44841. */
  44842. get gamepads(): Gamepad[];
  44843. /**
  44844. * Get the gamepad controllers based on type
  44845. * @param type The type of gamepad controller
  44846. * @returns Nullable gamepad
  44847. */
  44848. getGamepadByType(type?: number): Nullable<Gamepad>;
  44849. /**
  44850. * Disposes the gamepad manager
  44851. */
  44852. dispose(): void;
  44853. private _addNewGamepad;
  44854. private _startMonitoringGamepads;
  44855. private _stopMonitoringGamepads;
  44856. /** @hidden */
  44857. _checkGamepadsStatus(): void;
  44858. private _updateGamepadObjects;
  44859. }
  44860. }
  44861. declare module BABYLON {
  44862. interface Scene {
  44863. /** @hidden */
  44864. _gamepadManager: Nullable<GamepadManager>;
  44865. /**
  44866. * Gets the gamepad manager associated with the scene
  44867. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44868. */
  44869. gamepadManager: GamepadManager;
  44870. }
  44871. /**
  44872. * Interface representing a free camera inputs manager
  44873. */
  44874. interface FreeCameraInputsManager {
  44875. /**
  44876. * Adds gamepad input support to the FreeCameraInputsManager.
  44877. * @returns the FreeCameraInputsManager
  44878. */
  44879. addGamepad(): FreeCameraInputsManager;
  44880. }
  44881. /**
  44882. * Interface representing an arc rotate camera inputs manager
  44883. */
  44884. interface ArcRotateCameraInputsManager {
  44885. /**
  44886. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44887. * @returns the camera inputs manager
  44888. */
  44889. addGamepad(): ArcRotateCameraInputsManager;
  44890. }
  44891. /**
  44892. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44893. */
  44894. export class GamepadSystemSceneComponent implements ISceneComponent {
  44895. /**
  44896. * The component name helpfull to identify the component in the list of scene components.
  44897. */
  44898. readonly name: string;
  44899. /**
  44900. * The scene the component belongs to.
  44901. */
  44902. scene: Scene;
  44903. /**
  44904. * Creates a new instance of the component for the given scene
  44905. * @param scene Defines the scene to register the component in
  44906. */
  44907. constructor(scene: Scene);
  44908. /**
  44909. * Registers the component in a given scene
  44910. */
  44911. register(): void;
  44912. /**
  44913. * Rebuilds the elements related to this component in case of
  44914. * context lost for instance.
  44915. */
  44916. rebuild(): void;
  44917. /**
  44918. * Disposes the component and the associated ressources
  44919. */
  44920. dispose(): void;
  44921. private _beforeCameraUpdate;
  44922. }
  44923. }
  44924. declare module BABYLON {
  44925. /**
  44926. * 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,
  44927. * which still works and will still be found in many Playgrounds.
  44928. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44929. */
  44930. export class UniversalCamera extends TouchCamera {
  44931. /**
  44932. * Defines the gamepad rotation sensiblity.
  44933. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44934. */
  44935. get gamepadAngularSensibility(): number;
  44936. set gamepadAngularSensibility(value: number);
  44937. /**
  44938. * Defines the gamepad move sensiblity.
  44939. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44940. */
  44941. get gamepadMoveSensibility(): number;
  44942. set gamepadMoveSensibility(value: number);
  44943. /**
  44944. * 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,
  44945. * which still works and will still be found in many Playgrounds.
  44946. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44947. * @param name Define the name of the camera in the scene
  44948. * @param position Define the start position of the camera in the scene
  44949. * @param scene Define the scene the camera belongs to
  44950. */
  44951. constructor(name: string, position: Vector3, scene: Scene);
  44952. /**
  44953. * Gets the current object class name.
  44954. * @return the class name
  44955. */
  44956. getClassName(): string;
  44957. }
  44958. }
  44959. declare module BABYLON {
  44960. /**
  44961. * This represents a FPS type of camera. This is only here for back compat purpose.
  44962. * Please use the UniversalCamera instead as both are identical.
  44963. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44964. */
  44965. export class GamepadCamera extends UniversalCamera {
  44966. /**
  44967. * Instantiates a new Gamepad Camera
  44968. * This represents a FPS type of camera. This is only here for back compat purpose.
  44969. * Please use the UniversalCamera instead as both are identical.
  44970. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44971. * @param name Define the name of the camera in the scene
  44972. * @param position Define the start position of the camera in the scene
  44973. * @param scene Define the scene the camera belongs to
  44974. */
  44975. constructor(name: string, position: Vector3, scene: Scene);
  44976. /**
  44977. * Gets the current object class name.
  44978. * @return the class name
  44979. */
  44980. getClassName(): string;
  44981. }
  44982. }
  44983. declare module BABYLON {
  44984. /** @hidden */
  44985. export var passPixelShader: {
  44986. name: string;
  44987. shader: string;
  44988. };
  44989. }
  44990. declare module BABYLON {
  44991. /** @hidden */
  44992. export var passCubePixelShader: {
  44993. name: string;
  44994. shader: string;
  44995. };
  44996. }
  44997. declare module BABYLON {
  44998. /**
  44999. * PassPostProcess which produces an output the same as it's input
  45000. */
  45001. export class PassPostProcess extends PostProcess {
  45002. /**
  45003. * Creates the PassPostProcess
  45004. * @param name The name of the effect.
  45005. * @param options The required width/height ratio to downsize to before computing the render pass.
  45006. * @param camera The camera to apply the render pass to.
  45007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45008. * @param engine The engine which the post process will be applied. (default: current engine)
  45009. * @param reusable If the post process can be reused on the same frame. (default: false)
  45010. * @param textureType The type of texture to be used when performing the post processing.
  45011. * @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)
  45012. */
  45013. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45014. }
  45015. /**
  45016. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45017. */
  45018. export class PassCubePostProcess extends PostProcess {
  45019. private _face;
  45020. /**
  45021. * Gets or sets the cube face to display.
  45022. * * 0 is +X
  45023. * * 1 is -X
  45024. * * 2 is +Y
  45025. * * 3 is -Y
  45026. * * 4 is +Z
  45027. * * 5 is -Z
  45028. */
  45029. get face(): number;
  45030. set face(value: number);
  45031. /**
  45032. * Creates the PassCubePostProcess
  45033. * @param name The name of the effect.
  45034. * @param options The required width/height ratio to downsize to before computing the render pass.
  45035. * @param camera The camera to apply the render pass to.
  45036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45037. * @param engine The engine which the post process will be applied. (default: current engine)
  45038. * @param reusable If the post process can be reused on the same frame. (default: false)
  45039. * @param textureType The type of texture to be used when performing the post processing.
  45040. * @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)
  45041. */
  45042. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45043. }
  45044. }
  45045. declare module BABYLON {
  45046. /** @hidden */
  45047. export var anaglyphPixelShader: {
  45048. name: string;
  45049. shader: string;
  45050. };
  45051. }
  45052. declare module BABYLON {
  45053. /**
  45054. * Postprocess used to generate anaglyphic rendering
  45055. */
  45056. export class AnaglyphPostProcess extends PostProcess {
  45057. private _passedProcess;
  45058. /**
  45059. * Creates a new AnaglyphPostProcess
  45060. * @param name defines postprocess name
  45061. * @param options defines creation options or target ratio scale
  45062. * @param rigCameras defines cameras using this postprocess
  45063. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45064. * @param engine defines hosting engine
  45065. * @param reusable defines if the postprocess will be reused multiple times per frame
  45066. */
  45067. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45068. }
  45069. }
  45070. declare module BABYLON {
  45071. /**
  45072. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45073. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45074. */
  45075. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45076. /**
  45077. * Creates a new AnaglyphArcRotateCamera
  45078. * @param name defines camera name
  45079. * @param alpha defines alpha angle (in radians)
  45080. * @param beta defines beta angle (in radians)
  45081. * @param radius defines radius
  45082. * @param target defines camera target
  45083. * @param interaxialDistance defines distance between each color axis
  45084. * @param scene defines the hosting scene
  45085. */
  45086. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45087. /**
  45088. * Gets camera class name
  45089. * @returns AnaglyphArcRotateCamera
  45090. */
  45091. getClassName(): string;
  45092. }
  45093. }
  45094. declare module BABYLON {
  45095. /**
  45096. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45097. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45098. */
  45099. export class AnaglyphFreeCamera extends FreeCamera {
  45100. /**
  45101. * Creates a new AnaglyphFreeCamera
  45102. * @param name defines camera name
  45103. * @param position defines initial position
  45104. * @param interaxialDistance defines distance between each color axis
  45105. * @param scene defines the hosting scene
  45106. */
  45107. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45108. /**
  45109. * Gets camera class name
  45110. * @returns AnaglyphFreeCamera
  45111. */
  45112. getClassName(): string;
  45113. }
  45114. }
  45115. declare module BABYLON {
  45116. /**
  45117. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45118. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45119. */
  45120. export class AnaglyphGamepadCamera extends GamepadCamera {
  45121. /**
  45122. * Creates a new AnaglyphGamepadCamera
  45123. * @param name defines camera name
  45124. * @param position defines initial position
  45125. * @param interaxialDistance defines distance between each color axis
  45126. * @param scene defines the hosting scene
  45127. */
  45128. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45129. /**
  45130. * Gets camera class name
  45131. * @returns AnaglyphGamepadCamera
  45132. */
  45133. getClassName(): string;
  45134. }
  45135. }
  45136. declare module BABYLON {
  45137. /**
  45138. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45139. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45140. */
  45141. export class AnaglyphUniversalCamera extends UniversalCamera {
  45142. /**
  45143. * Creates a new AnaglyphUniversalCamera
  45144. * @param name defines camera name
  45145. * @param position defines initial position
  45146. * @param interaxialDistance defines distance between each color axis
  45147. * @param scene defines the hosting scene
  45148. */
  45149. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45150. /**
  45151. * Gets camera class name
  45152. * @returns AnaglyphUniversalCamera
  45153. */
  45154. getClassName(): string;
  45155. }
  45156. }
  45157. declare module BABYLON {
  45158. /**
  45159. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  45160. * @see http://doc.babylonjs.com/features/cameras
  45161. */
  45162. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  45163. /**
  45164. * Creates a new StereoscopicArcRotateCamera
  45165. * @param name defines camera name
  45166. * @param alpha defines alpha angle (in radians)
  45167. * @param beta defines beta angle (in radians)
  45168. * @param radius defines radius
  45169. * @param target defines camera target
  45170. * @param interaxialDistance defines distance between each color axis
  45171. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45172. * @param scene defines the hosting scene
  45173. */
  45174. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45175. /**
  45176. * Gets camera class name
  45177. * @returns StereoscopicArcRotateCamera
  45178. */
  45179. getClassName(): string;
  45180. }
  45181. }
  45182. declare module BABYLON {
  45183. /**
  45184. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45185. * @see http://doc.babylonjs.com/features/cameras
  45186. */
  45187. export class StereoscopicFreeCamera extends FreeCamera {
  45188. /**
  45189. * Creates a new StereoscopicFreeCamera
  45190. * @param name defines camera name
  45191. * @param position defines initial position
  45192. * @param interaxialDistance defines distance between each color axis
  45193. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45194. * @param scene defines the hosting scene
  45195. */
  45196. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45197. /**
  45198. * Gets camera class name
  45199. * @returns StereoscopicFreeCamera
  45200. */
  45201. getClassName(): string;
  45202. }
  45203. }
  45204. declare module BABYLON {
  45205. /**
  45206. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45207. * @see http://doc.babylonjs.com/features/cameras
  45208. */
  45209. export class StereoscopicGamepadCamera extends GamepadCamera {
  45210. /**
  45211. * Creates a new StereoscopicGamepadCamera
  45212. * @param name defines camera name
  45213. * @param position defines initial position
  45214. * @param interaxialDistance defines distance between each color axis
  45215. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45216. * @param scene defines the hosting scene
  45217. */
  45218. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45219. /**
  45220. * Gets camera class name
  45221. * @returns StereoscopicGamepadCamera
  45222. */
  45223. getClassName(): string;
  45224. }
  45225. }
  45226. declare module BABYLON {
  45227. /**
  45228. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  45229. * @see http://doc.babylonjs.com/features/cameras
  45230. */
  45231. export class StereoscopicUniversalCamera extends UniversalCamera {
  45232. /**
  45233. * Creates a new StereoscopicUniversalCamera
  45234. * @param name defines camera name
  45235. * @param position defines initial position
  45236. * @param interaxialDistance defines distance between each color axis
  45237. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45238. * @param scene defines the hosting scene
  45239. */
  45240. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45241. /**
  45242. * Gets camera class name
  45243. * @returns StereoscopicUniversalCamera
  45244. */
  45245. getClassName(): string;
  45246. }
  45247. }
  45248. declare module BABYLON {
  45249. /**
  45250. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  45251. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45252. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45253. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45254. */
  45255. export class VirtualJoysticksCamera extends FreeCamera {
  45256. /**
  45257. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45258. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45259. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45260. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45261. * @param name Define the name of the camera in the scene
  45262. * @param position Define the start position of the camera in the scene
  45263. * @param scene Define the scene the camera belongs to
  45264. */
  45265. constructor(name: string, position: Vector3, scene: Scene);
  45266. /**
  45267. * Gets the current object class name.
  45268. * @return the class name
  45269. */
  45270. getClassName(): string;
  45271. }
  45272. }
  45273. declare module BABYLON {
  45274. /**
  45275. * This represents all the required metrics to create a VR camera.
  45276. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45277. */
  45278. export class VRCameraMetrics {
  45279. /**
  45280. * Define the horizontal resolution off the screen.
  45281. */
  45282. hResolution: number;
  45283. /**
  45284. * Define the vertical resolution off the screen.
  45285. */
  45286. vResolution: number;
  45287. /**
  45288. * Define the horizontal screen size.
  45289. */
  45290. hScreenSize: number;
  45291. /**
  45292. * Define the vertical screen size.
  45293. */
  45294. vScreenSize: number;
  45295. /**
  45296. * Define the vertical screen center position.
  45297. */
  45298. vScreenCenter: number;
  45299. /**
  45300. * Define the distance of the eyes to the screen.
  45301. */
  45302. eyeToScreenDistance: number;
  45303. /**
  45304. * Define the distance between both lenses
  45305. */
  45306. lensSeparationDistance: number;
  45307. /**
  45308. * Define the distance between both viewer's eyes.
  45309. */
  45310. interpupillaryDistance: number;
  45311. /**
  45312. * Define the distortion factor of the VR postprocess.
  45313. * Please, touch with care.
  45314. */
  45315. distortionK: number[];
  45316. /**
  45317. * Define the chromatic aberration correction factors for the VR post process.
  45318. */
  45319. chromaAbCorrection: number[];
  45320. /**
  45321. * Define the scale factor of the post process.
  45322. * The smaller the better but the slower.
  45323. */
  45324. postProcessScaleFactor: number;
  45325. /**
  45326. * Define an offset for the lens center.
  45327. */
  45328. lensCenterOffset: number;
  45329. /**
  45330. * Define if the current vr camera should compensate the distortion of the lense or not.
  45331. */
  45332. compensateDistortion: boolean;
  45333. /**
  45334. * Defines if multiview should be enabled when rendering (Default: false)
  45335. */
  45336. multiviewEnabled: boolean;
  45337. /**
  45338. * Gets the rendering aspect ratio based on the provided resolutions.
  45339. */
  45340. get aspectRatio(): number;
  45341. /**
  45342. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45343. */
  45344. get aspectRatioFov(): number;
  45345. /**
  45346. * @hidden
  45347. */
  45348. get leftHMatrix(): Matrix;
  45349. /**
  45350. * @hidden
  45351. */
  45352. get rightHMatrix(): Matrix;
  45353. /**
  45354. * @hidden
  45355. */
  45356. get leftPreViewMatrix(): Matrix;
  45357. /**
  45358. * @hidden
  45359. */
  45360. get rightPreViewMatrix(): Matrix;
  45361. /**
  45362. * Get the default VRMetrics based on the most generic setup.
  45363. * @returns the default vr metrics
  45364. */
  45365. static GetDefault(): VRCameraMetrics;
  45366. }
  45367. }
  45368. declare module BABYLON {
  45369. /** @hidden */
  45370. export var vrDistortionCorrectionPixelShader: {
  45371. name: string;
  45372. shader: string;
  45373. };
  45374. }
  45375. declare module BABYLON {
  45376. /**
  45377. * VRDistortionCorrectionPostProcess used for mobile VR
  45378. */
  45379. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45380. private _isRightEye;
  45381. private _distortionFactors;
  45382. private _postProcessScaleFactor;
  45383. private _lensCenterOffset;
  45384. private _scaleIn;
  45385. private _scaleFactor;
  45386. private _lensCenter;
  45387. /**
  45388. * Initializes the VRDistortionCorrectionPostProcess
  45389. * @param name The name of the effect.
  45390. * @param camera The camera to apply the render pass to.
  45391. * @param isRightEye If this is for the right eye distortion
  45392. * @param vrMetrics All the required metrics for the VR camera
  45393. */
  45394. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45395. }
  45396. }
  45397. declare module BABYLON {
  45398. /**
  45399. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45400. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45401. */
  45402. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45403. /**
  45404. * Creates a new VRDeviceOrientationArcRotateCamera
  45405. * @param name defines camera name
  45406. * @param alpha defines the camera rotation along the logitudinal axis
  45407. * @param beta defines the camera rotation along the latitudinal axis
  45408. * @param radius defines the camera distance from its target
  45409. * @param target defines the camera target
  45410. * @param scene defines the scene the camera belongs to
  45411. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45412. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45413. */
  45414. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45415. /**
  45416. * Gets camera class name
  45417. * @returns VRDeviceOrientationArcRotateCamera
  45418. */
  45419. getClassName(): string;
  45420. }
  45421. }
  45422. declare module BABYLON {
  45423. /**
  45424. * Camera used to simulate VR rendering (based on FreeCamera)
  45425. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45426. */
  45427. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45428. /**
  45429. * Creates a new VRDeviceOrientationFreeCamera
  45430. * @param name defines camera name
  45431. * @param position defines the start position of the camera
  45432. * @param scene defines the scene the camera belongs to
  45433. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45434. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45435. */
  45436. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45437. /**
  45438. * Gets camera class name
  45439. * @returns VRDeviceOrientationFreeCamera
  45440. */
  45441. getClassName(): string;
  45442. }
  45443. }
  45444. declare module BABYLON {
  45445. /**
  45446. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45447. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45448. */
  45449. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45450. /**
  45451. * Creates a new VRDeviceOrientationGamepadCamera
  45452. * @param name defines camera name
  45453. * @param position defines the start position of the camera
  45454. * @param scene defines the scene the camera belongs to
  45455. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45456. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45457. */
  45458. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45459. /**
  45460. * Gets camera class name
  45461. * @returns VRDeviceOrientationGamepadCamera
  45462. */
  45463. getClassName(): string;
  45464. }
  45465. }
  45466. declare module BABYLON {
  45467. /** @hidden */
  45468. export var imageProcessingPixelShader: {
  45469. name: string;
  45470. shader: string;
  45471. };
  45472. }
  45473. declare module BABYLON {
  45474. /**
  45475. * ImageProcessingPostProcess
  45476. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45477. */
  45478. export class ImageProcessingPostProcess extends PostProcess {
  45479. /**
  45480. * Default configuration related to image processing available in the PBR Material.
  45481. */
  45482. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45483. /**
  45484. * Gets the image processing configuration used either in this material.
  45485. */
  45486. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45487. /**
  45488. * Sets the Default image processing configuration used either in the this material.
  45489. *
  45490. * If sets to null, the scene one is in use.
  45491. */
  45492. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45493. /**
  45494. * Keep track of the image processing observer to allow dispose and replace.
  45495. */
  45496. private _imageProcessingObserver;
  45497. /**
  45498. * Attaches a new image processing configuration to the PBR Material.
  45499. * @param configuration
  45500. */
  45501. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45502. /**
  45503. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45504. */
  45505. get colorCurves(): Nullable<ColorCurves>;
  45506. /**
  45507. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45508. */
  45509. set colorCurves(value: Nullable<ColorCurves>);
  45510. /**
  45511. * Gets wether the color curves effect is enabled.
  45512. */
  45513. get colorCurvesEnabled(): boolean;
  45514. /**
  45515. * Sets wether the color curves effect is enabled.
  45516. */
  45517. set colorCurvesEnabled(value: boolean);
  45518. /**
  45519. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45520. */
  45521. get colorGradingTexture(): Nullable<BaseTexture>;
  45522. /**
  45523. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45524. */
  45525. set colorGradingTexture(value: Nullable<BaseTexture>);
  45526. /**
  45527. * Gets wether the color grading effect is enabled.
  45528. */
  45529. get colorGradingEnabled(): boolean;
  45530. /**
  45531. * Gets wether the color grading effect is enabled.
  45532. */
  45533. set colorGradingEnabled(value: boolean);
  45534. /**
  45535. * Gets exposure used in the effect.
  45536. */
  45537. get exposure(): number;
  45538. /**
  45539. * Sets exposure used in the effect.
  45540. */
  45541. set exposure(value: number);
  45542. /**
  45543. * Gets wether tonemapping is enabled or not.
  45544. */
  45545. get toneMappingEnabled(): boolean;
  45546. /**
  45547. * Sets wether tonemapping is enabled or not
  45548. */
  45549. set toneMappingEnabled(value: boolean);
  45550. /**
  45551. * Gets the type of tone mapping effect.
  45552. */
  45553. get toneMappingType(): number;
  45554. /**
  45555. * Sets the type of tone mapping effect.
  45556. */
  45557. set toneMappingType(value: number);
  45558. /**
  45559. * Gets contrast used in the effect.
  45560. */
  45561. get contrast(): number;
  45562. /**
  45563. * Sets contrast used in the effect.
  45564. */
  45565. set contrast(value: number);
  45566. /**
  45567. * Gets Vignette stretch size.
  45568. */
  45569. get vignetteStretch(): number;
  45570. /**
  45571. * Sets Vignette stretch size.
  45572. */
  45573. set vignetteStretch(value: number);
  45574. /**
  45575. * Gets Vignette centre X Offset.
  45576. */
  45577. get vignetteCentreX(): number;
  45578. /**
  45579. * Sets Vignette centre X Offset.
  45580. */
  45581. set vignetteCentreX(value: number);
  45582. /**
  45583. * Gets Vignette centre Y Offset.
  45584. */
  45585. get vignetteCentreY(): number;
  45586. /**
  45587. * Sets Vignette centre Y Offset.
  45588. */
  45589. set vignetteCentreY(value: number);
  45590. /**
  45591. * Gets Vignette weight or intensity of the vignette effect.
  45592. */
  45593. get vignetteWeight(): number;
  45594. /**
  45595. * Sets Vignette weight or intensity of the vignette effect.
  45596. */
  45597. set vignetteWeight(value: number);
  45598. /**
  45599. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45600. * if vignetteEnabled is set to true.
  45601. */
  45602. get vignetteColor(): Color4;
  45603. /**
  45604. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45605. * if vignetteEnabled is set to true.
  45606. */
  45607. set vignetteColor(value: Color4);
  45608. /**
  45609. * Gets Camera field of view used by the Vignette effect.
  45610. */
  45611. get vignetteCameraFov(): number;
  45612. /**
  45613. * Sets Camera field of view used by the Vignette effect.
  45614. */
  45615. set vignetteCameraFov(value: number);
  45616. /**
  45617. * Gets the vignette blend mode allowing different kind of effect.
  45618. */
  45619. get vignetteBlendMode(): number;
  45620. /**
  45621. * Sets the vignette blend mode allowing different kind of effect.
  45622. */
  45623. set vignetteBlendMode(value: number);
  45624. /**
  45625. * Gets wether the vignette effect is enabled.
  45626. */
  45627. get vignetteEnabled(): boolean;
  45628. /**
  45629. * Sets wether the vignette effect is enabled.
  45630. */
  45631. set vignetteEnabled(value: boolean);
  45632. private _fromLinearSpace;
  45633. /**
  45634. * Gets wether the input of the processing is in Gamma or Linear Space.
  45635. */
  45636. get fromLinearSpace(): boolean;
  45637. /**
  45638. * Sets wether the input of the processing is in Gamma or Linear Space.
  45639. */
  45640. set fromLinearSpace(value: boolean);
  45641. /**
  45642. * Defines cache preventing GC.
  45643. */
  45644. private _defines;
  45645. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45646. /**
  45647. * "ImageProcessingPostProcess"
  45648. * @returns "ImageProcessingPostProcess"
  45649. */
  45650. getClassName(): string;
  45651. protected _updateParameters(): void;
  45652. dispose(camera?: Camera): void;
  45653. }
  45654. }
  45655. declare module BABYLON {
  45656. /**
  45657. * Class containing static functions to help procedurally build meshes
  45658. */
  45659. export class GroundBuilder {
  45660. /**
  45661. * Creates a ground mesh
  45662. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45663. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45665. * @param name defines the name of the mesh
  45666. * @param options defines the options used to create the mesh
  45667. * @param scene defines the hosting scene
  45668. * @returns the ground mesh
  45669. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45670. */
  45671. static CreateGround(name: string, options: {
  45672. width?: number;
  45673. height?: number;
  45674. subdivisions?: number;
  45675. subdivisionsX?: number;
  45676. subdivisionsY?: number;
  45677. updatable?: boolean;
  45678. }, scene: any): Mesh;
  45679. /**
  45680. * Creates a tiled ground mesh
  45681. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45682. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45683. * * 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
  45684. * * 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
  45685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45686. * @param name defines the name of the mesh
  45687. * @param options defines the options used to create the mesh
  45688. * @param scene defines the hosting scene
  45689. * @returns the tiled ground mesh
  45690. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45691. */
  45692. static CreateTiledGround(name: string, options: {
  45693. xmin: number;
  45694. zmin: number;
  45695. xmax: number;
  45696. zmax: number;
  45697. subdivisions?: {
  45698. w: number;
  45699. h: number;
  45700. };
  45701. precision?: {
  45702. w: number;
  45703. h: number;
  45704. };
  45705. updatable?: boolean;
  45706. }, scene?: Nullable<Scene>): Mesh;
  45707. /**
  45708. * Creates a ground mesh from a height map
  45709. * * The parameter `url` sets the URL of the height map image resource.
  45710. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45711. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45712. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45713. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45714. * * 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.
  45715. * * 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).
  45716. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45718. * @param name defines the name of the mesh
  45719. * @param url defines the url to the height map
  45720. * @param options defines the options used to create the mesh
  45721. * @param scene defines the hosting scene
  45722. * @returns the ground mesh
  45723. * @see https://doc.babylonjs.com/babylon101/height_map
  45724. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45725. */
  45726. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45727. width?: number;
  45728. height?: number;
  45729. subdivisions?: number;
  45730. minHeight?: number;
  45731. maxHeight?: number;
  45732. colorFilter?: Color3;
  45733. alphaFilter?: number;
  45734. updatable?: boolean;
  45735. onReady?: (mesh: GroundMesh) => void;
  45736. }, scene?: Nullable<Scene>): GroundMesh;
  45737. }
  45738. }
  45739. declare module BABYLON {
  45740. /**
  45741. * Class containing static functions to help procedurally build meshes
  45742. */
  45743. export class TorusBuilder {
  45744. /**
  45745. * Creates a torus mesh
  45746. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45747. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45748. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45750. * * 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
  45751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45752. * @param name defines the name of the mesh
  45753. * @param options defines the options used to create the mesh
  45754. * @param scene defines the hosting scene
  45755. * @returns the torus mesh
  45756. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45757. */
  45758. static CreateTorus(name: string, options: {
  45759. diameter?: number;
  45760. thickness?: number;
  45761. tessellation?: number;
  45762. updatable?: boolean;
  45763. sideOrientation?: number;
  45764. frontUVs?: Vector4;
  45765. backUVs?: Vector4;
  45766. }, scene: any): Mesh;
  45767. }
  45768. }
  45769. declare module BABYLON {
  45770. /**
  45771. * Class containing static functions to help procedurally build meshes
  45772. */
  45773. export class CylinderBuilder {
  45774. /**
  45775. * Creates a cylinder or a cone mesh
  45776. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45777. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45778. * * 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.
  45779. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45780. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45781. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45782. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45783. * * 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).
  45784. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45785. * * 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).
  45786. * * 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
  45787. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45788. * * 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
  45789. * * 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.
  45790. * * If `enclose` is false, a ring surface is one element.
  45791. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45792. * * 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
  45793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45794. * * 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
  45795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45796. * @param name defines the name of the mesh
  45797. * @param options defines the options used to create the mesh
  45798. * @param scene defines the hosting scene
  45799. * @returns the cylinder mesh
  45800. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45801. */
  45802. static CreateCylinder(name: string, options: {
  45803. height?: number;
  45804. diameterTop?: number;
  45805. diameterBottom?: number;
  45806. diameter?: number;
  45807. tessellation?: number;
  45808. subdivisions?: number;
  45809. arc?: number;
  45810. faceColors?: Color4[];
  45811. faceUV?: Vector4[];
  45812. updatable?: boolean;
  45813. hasRings?: boolean;
  45814. enclose?: boolean;
  45815. cap?: number;
  45816. sideOrientation?: number;
  45817. frontUVs?: Vector4;
  45818. backUVs?: Vector4;
  45819. }, scene: any): Mesh;
  45820. }
  45821. }
  45822. declare module BABYLON {
  45823. /**
  45824. * States of the webXR experience
  45825. */
  45826. export enum WebXRState {
  45827. /**
  45828. * Transitioning to being in XR mode
  45829. */
  45830. ENTERING_XR = 0,
  45831. /**
  45832. * Transitioning to non XR mode
  45833. */
  45834. EXITING_XR = 1,
  45835. /**
  45836. * In XR mode and presenting
  45837. */
  45838. IN_XR = 2,
  45839. /**
  45840. * Not entered XR mode
  45841. */
  45842. NOT_IN_XR = 3
  45843. }
  45844. /**
  45845. * Abstraction of the XR render target
  45846. */
  45847. export interface WebXRRenderTarget extends IDisposable {
  45848. /**
  45849. * xrpresent context of the canvas which can be used to display/mirror xr content
  45850. */
  45851. canvasContext: WebGLRenderingContext;
  45852. /**
  45853. * xr layer for the canvas
  45854. */
  45855. xrLayer: Nullable<XRWebGLLayer>;
  45856. /**
  45857. * Initializes the xr layer for the session
  45858. * @param xrSession xr session
  45859. * @returns a promise that will resolve once the XR Layer has been created
  45860. */
  45861. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45862. }
  45863. }
  45864. declare module BABYLON {
  45865. /**
  45866. * COnfiguration object for WebXR output canvas
  45867. */
  45868. export class WebXRManagedOutputCanvasOptions {
  45869. /**
  45870. * An optional canvas in case you wish to create it yourself and provide it here.
  45871. * If not provided, a new canvas will be created
  45872. */
  45873. canvasElement?: HTMLCanvasElement;
  45874. /**
  45875. * Options for this XR Layer output
  45876. */
  45877. canvasOptions?: XRWebGLLayerOptions;
  45878. /**
  45879. * CSS styling for a newly created canvas (if not provided)
  45880. */
  45881. newCanvasCssStyle?: string;
  45882. /**
  45883. * Get the default values of the configuration object
  45884. * @returns default values of this configuration object
  45885. */
  45886. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45887. }
  45888. /**
  45889. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45890. */
  45891. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45892. private _options;
  45893. private _canvas;
  45894. private _engine;
  45895. /**
  45896. * Rendering context of the canvas which can be used to display/mirror xr content
  45897. */
  45898. canvasContext: WebGLRenderingContext;
  45899. /**
  45900. * xr layer for the canvas
  45901. */
  45902. xrLayer: Nullable<XRWebGLLayer>;
  45903. /**
  45904. * Initializes the canvas to be added/removed upon entering/exiting xr
  45905. * @param _xrSessionManager The XR Session manager
  45906. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45907. */
  45908. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45909. /**
  45910. * Disposes of the object
  45911. */
  45912. dispose(): void;
  45913. /**
  45914. * Initializes the xr layer for the session
  45915. * @param xrSession xr session
  45916. * @returns a promise that will resolve once the XR Layer has been created
  45917. */
  45918. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45919. private _addCanvas;
  45920. private _removeCanvas;
  45921. private _setManagedOutputCanvas;
  45922. }
  45923. }
  45924. declare module BABYLON {
  45925. /**
  45926. * Manages an XRSession to work with Babylon's engine
  45927. * @see https://doc.babylonjs.com/how_to/webxr
  45928. */
  45929. export class WebXRSessionManager implements IDisposable {
  45930. /** The scene which the session should be created for */
  45931. scene: Scene;
  45932. private _referenceSpace;
  45933. private _rttProvider;
  45934. private _sessionEnded;
  45935. private _xrNavigator;
  45936. private baseLayer;
  45937. /**
  45938. * The base reference space from which the session started. good if you want to reset your
  45939. * reference space
  45940. */
  45941. baseReferenceSpace: XRReferenceSpace;
  45942. /**
  45943. * Current XR frame
  45944. */
  45945. currentFrame: Nullable<XRFrame>;
  45946. /** WebXR timestamp updated every frame */
  45947. currentTimestamp: number;
  45948. /**
  45949. * Used just in case of a failure to initialize an immersive session.
  45950. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45951. */
  45952. defaultHeightCompensation: number;
  45953. /**
  45954. * Fires every time a new xrFrame arrives which can be used to update the camera
  45955. */
  45956. onXRFrameObservable: Observable<XRFrame>;
  45957. /**
  45958. * Fires when the reference space changed
  45959. */
  45960. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45961. /**
  45962. * Fires when the xr session is ended either by the device or manually done
  45963. */
  45964. onXRSessionEnded: Observable<any>;
  45965. /**
  45966. * Fires when the xr session is ended either by the device or manually done
  45967. */
  45968. onXRSessionInit: Observable<XRSession>;
  45969. /**
  45970. * Underlying xr session
  45971. */
  45972. session: XRSession;
  45973. /**
  45974. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45975. * or get the offset the player is currently at.
  45976. */
  45977. viewerReferenceSpace: XRReferenceSpace;
  45978. /**
  45979. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45980. * @param scene The scene which the session should be created for
  45981. */
  45982. constructor(
  45983. /** The scene which the session should be created for */
  45984. scene: Scene);
  45985. /**
  45986. * The current reference space used in this session. This reference space can constantly change!
  45987. * It is mainly used to offset the camera's position.
  45988. */
  45989. get referenceSpace(): XRReferenceSpace;
  45990. /**
  45991. * Set a new reference space and triggers the observable
  45992. */
  45993. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45994. /**
  45995. * Disposes of the session manager
  45996. */
  45997. dispose(): void;
  45998. /**
  45999. * Stops the xrSession and restores the render loop
  46000. * @returns Promise which resolves after it exits XR
  46001. */
  46002. exitXRAsync(): Promise<void>;
  46003. /**
  46004. * Gets the correct render target texture to be rendered this frame for this eye
  46005. * @param eye the eye for which to get the render target
  46006. * @returns the render target for the specified eye
  46007. */
  46008. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46009. /**
  46010. * Creates a WebXRRenderTarget object for the XR session
  46011. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46012. * @param options optional options to provide when creating a new render target
  46013. * @returns a WebXR render target to which the session can render
  46014. */
  46015. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46016. /**
  46017. * Initializes the manager
  46018. * After initialization enterXR can be called to start an XR session
  46019. * @returns Promise which resolves after it is initialized
  46020. */
  46021. initializeAsync(): Promise<void>;
  46022. /**
  46023. * Initializes an xr session
  46024. * @param xrSessionMode mode to initialize
  46025. * @param xrSessionInit defines optional and required values to pass to the session builder
  46026. * @returns a promise which will resolve once the session has been initialized
  46027. */
  46028. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46029. /**
  46030. * Checks if a session would be supported for the creation options specified
  46031. * @param sessionMode session mode to check if supported eg. immersive-vr
  46032. * @returns A Promise that resolves to true if supported and false if not
  46033. */
  46034. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46035. /**
  46036. * Resets the reference space to the one started the session
  46037. */
  46038. resetReferenceSpace(): void;
  46039. /**
  46040. * Starts rendering to the xr layer
  46041. */
  46042. runXRRenderLoop(): void;
  46043. /**
  46044. * Sets the reference space on the xr session
  46045. * @param referenceSpaceType space to set
  46046. * @returns a promise that will resolve once the reference space has been set
  46047. */
  46048. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46049. /**
  46050. * Updates the render state of the session
  46051. * @param state state to set
  46052. * @returns a promise that resolves once the render state has been updated
  46053. */
  46054. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46055. /**
  46056. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46057. * @param sessionMode defines the session to test
  46058. * @returns a promise with boolean as final value
  46059. */
  46060. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46061. private _createRenderTargetTexture;
  46062. }
  46063. }
  46064. declare module BABYLON {
  46065. /**
  46066. * WebXR Camera which holds the views for the xrSession
  46067. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46068. */
  46069. export class WebXRCamera extends FreeCamera {
  46070. private _xrSessionManager;
  46071. private _firstFrame;
  46072. private _referenceQuaternion;
  46073. private _referencedPosition;
  46074. private _xrInvPositionCache;
  46075. private _xrInvQuaternionCache;
  46076. /**
  46077. * Should position compensation execute on first frame.
  46078. * This is used when copying the position from a native (non XR) camera
  46079. */
  46080. compensateOnFirstFrame: boolean;
  46081. /**
  46082. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46083. * @param name the name of the camera
  46084. * @param scene the scene to add the camera to
  46085. * @param _xrSessionManager a constructed xr session manager
  46086. */
  46087. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46088. /**
  46089. * Return the user's height, unrelated to the current ground.
  46090. * This will be the y position of this camera, when ground level is 0.
  46091. */
  46092. get realWorldHeight(): number;
  46093. /** @hidden */
  46094. _updateForDualEyeDebugging(): void;
  46095. /**
  46096. * Sets this camera's transformation based on a non-vr camera
  46097. * @param otherCamera the non-vr camera to copy the transformation from
  46098. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46099. */
  46100. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46101. /**
  46102. * Gets the current instance class name ("WebXRCamera").
  46103. * @returns the class name
  46104. */
  46105. getClassName(): string;
  46106. /**
  46107. * Overriding the _getViewMatrix function, as it is computed by WebXR
  46108. */
  46109. _getViewMatrix(): Matrix;
  46110. private _updateFromXRSession;
  46111. private _updateNumberOfRigCameras;
  46112. private _updateReferenceSpace;
  46113. private _updateReferenceSpaceOffset;
  46114. }
  46115. }
  46116. declare module BABYLON {
  46117. /**
  46118. * Defining the interface required for a (webxr) feature
  46119. */
  46120. export interface IWebXRFeature extends IDisposable {
  46121. /**
  46122. * Is this feature attached
  46123. */
  46124. attached: boolean;
  46125. /**
  46126. * Should auto-attach be disabled?
  46127. */
  46128. disableAutoAttach: boolean;
  46129. /**
  46130. * Attach the feature to the session
  46131. * Will usually be called by the features manager
  46132. *
  46133. * @param force should attachment be forced (even when already attached)
  46134. * @returns true if successful.
  46135. */
  46136. attach(force?: boolean): boolean;
  46137. /**
  46138. * Detach the feature from the session
  46139. * Will usually be called by the features manager
  46140. *
  46141. * @returns true if successful.
  46142. */
  46143. detach(): boolean;
  46144. }
  46145. /**
  46146. * A list of the currently available features without referencing them
  46147. */
  46148. export class WebXRFeatureName {
  46149. /**
  46150. * The name of the anchor system feature
  46151. */
  46152. static ANCHOR_SYSTEM: string;
  46153. /**
  46154. * The name of the background remover feature
  46155. */
  46156. static BACKGROUND_REMOVER: string;
  46157. /**
  46158. * The name of the hit test feature
  46159. */
  46160. static HIT_TEST: string;
  46161. /**
  46162. * physics impostors for xr controllers feature
  46163. */
  46164. static PHYSICS_CONTROLLERS: string;
  46165. /**
  46166. * The name of the plane detection feature
  46167. */
  46168. static PLANE_DETECTION: string;
  46169. /**
  46170. * The name of the pointer selection feature
  46171. */
  46172. static POINTER_SELECTION: string;
  46173. /**
  46174. * The name of the teleportation feature
  46175. */
  46176. static TELEPORTATION: string;
  46177. }
  46178. /**
  46179. * Defining the constructor of a feature. Used to register the modules.
  46180. */
  46181. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  46182. /**
  46183. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46184. * It is mainly used in AR sessions.
  46185. *
  46186. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46187. */
  46188. export class WebXRFeaturesManager implements IDisposable {
  46189. private _xrSessionManager;
  46190. private static readonly _AvailableFeatures;
  46191. private _features;
  46192. /**
  46193. * constructs a new features manages.
  46194. *
  46195. * @param _xrSessionManager an instance of WebXRSessionManager
  46196. */
  46197. constructor(_xrSessionManager: WebXRSessionManager);
  46198. /**
  46199. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46200. * Mainly used internally.
  46201. *
  46202. * @param featureName the name of the feature to register
  46203. * @param constructorFunction the function used to construct the module
  46204. * @param version the (babylon) version of the module
  46205. * @param stable is that a stable version of this module
  46206. */
  46207. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46208. /**
  46209. * Returns a constructor of a specific feature.
  46210. *
  46211. * @param featureName the name of the feature to construct
  46212. * @param version the version of the feature to load
  46213. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46214. * @param options optional options provided to the module.
  46215. * @returns a function that, when called, will return a new instance of this feature
  46216. */
  46217. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  46218. /**
  46219. * Can be used to return the list of features currently registered
  46220. *
  46221. * @returns an Array of available features
  46222. */
  46223. static GetAvailableFeatures(): string[];
  46224. /**
  46225. * Gets the versions available for a specific feature
  46226. * @param featureName the name of the feature
  46227. * @returns an array with the available versions
  46228. */
  46229. static GetAvailableVersions(featureName: string): string[];
  46230. /**
  46231. * Return the latest unstable version of this feature
  46232. * @param featureName the name of the feature to search
  46233. * @returns the version number. if not found will return -1
  46234. */
  46235. static GetLatestVersionOfFeature(featureName: string): number;
  46236. /**
  46237. * Return the latest stable version of this feature
  46238. * @param featureName the name of the feature to search
  46239. * @returns the version number. if not found will return -1
  46240. */
  46241. static GetStableVersionOfFeature(featureName: string): number;
  46242. /**
  46243. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46244. * Can be used during a session to start a feature
  46245. * @param featureName the name of feature to attach
  46246. */
  46247. attachFeature(featureName: string): void;
  46248. /**
  46249. * Can be used inside a session or when the session ends to detach a specific feature
  46250. * @param featureName the name of the feature to detach
  46251. */
  46252. detachFeature(featureName: string): void;
  46253. /**
  46254. * Used to disable an already-enabled feature
  46255. * The feature will be disposed and will be recreated once enabled.
  46256. * @param featureName the feature to disable
  46257. * @returns true if disable was successful
  46258. */
  46259. disableFeature(featureName: string | {
  46260. Name: string;
  46261. }): boolean;
  46262. /**
  46263. * dispose this features manager
  46264. */
  46265. dispose(): void;
  46266. /**
  46267. * 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.
  46268. * 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.
  46269. *
  46270. * @param featureName the name of the feature to load or the class of the feature
  46271. * @param version optional version to load. if not provided the latest version will be enabled
  46272. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46273. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46274. * @returns a new constructed feature or throws an error if feature not found.
  46275. */
  46276. enableFeature(featureName: string | {
  46277. Name: string;
  46278. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46279. /**
  46280. * get the implementation of an enabled feature.
  46281. * @param featureName the name of the feature to load
  46282. * @returns the feature class, if found
  46283. */
  46284. getEnabledFeature(featureName: string): IWebXRFeature;
  46285. /**
  46286. * Get the list of enabled features
  46287. * @returns an array of enabled features
  46288. */
  46289. getEnabledFeatures(): string[];
  46290. }
  46291. }
  46292. declare module BABYLON {
  46293. /**
  46294. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46295. * @see https://doc.babylonjs.com/how_to/webxr
  46296. */
  46297. export class WebXRExperienceHelper implements IDisposable {
  46298. private scene;
  46299. private _nonVRCamera;
  46300. private _originalSceneAutoClear;
  46301. private _supported;
  46302. /**
  46303. * Camera used to render xr content
  46304. */
  46305. camera: WebXRCamera;
  46306. /** A features manager for this xr session */
  46307. featuresManager: WebXRFeaturesManager;
  46308. /**
  46309. * Observers registered here will be triggered after the camera's initial transformation is set
  46310. * This can be used to set a different ground level or an extra rotation.
  46311. *
  46312. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46313. * to the position set after this observable is done executing.
  46314. */
  46315. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46316. /**
  46317. * Fires when the state of the experience helper has changed
  46318. */
  46319. onStateChangedObservable: Observable<WebXRState>;
  46320. /** Session manager used to keep track of xr session */
  46321. sessionManager: WebXRSessionManager;
  46322. /**
  46323. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46324. */
  46325. state: WebXRState;
  46326. /**
  46327. * Creates a WebXRExperienceHelper
  46328. * @param scene The scene the helper should be created in
  46329. */
  46330. private constructor();
  46331. /**
  46332. * Creates the experience helper
  46333. * @param scene the scene to attach the experience helper to
  46334. * @returns a promise for the experience helper
  46335. */
  46336. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46337. /**
  46338. * Disposes of the experience helper
  46339. */
  46340. dispose(): void;
  46341. /**
  46342. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46343. * @param sessionMode options for the XR session
  46344. * @param referenceSpaceType frame of reference of the XR session
  46345. * @param renderTarget the output canvas that will be used to enter XR mode
  46346. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46347. * @returns promise that resolves after xr mode has entered
  46348. */
  46349. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46350. /**
  46351. * Exits XR mode and returns the scene to its original state
  46352. * @returns promise that resolves after xr mode has exited
  46353. */
  46354. exitXRAsync(): Promise<void>;
  46355. private _nonXRToXRCamera;
  46356. private _setState;
  46357. }
  46358. }
  46359. declare module BABYLON {
  46360. /**
  46361. * X-Y values for axes in WebXR
  46362. */
  46363. export interface IWebXRMotionControllerAxesValue {
  46364. /**
  46365. * The value of the x axis
  46366. */
  46367. x: number;
  46368. /**
  46369. * The value of the y-axis
  46370. */
  46371. y: number;
  46372. }
  46373. /**
  46374. * changed / previous values for the values of this component
  46375. */
  46376. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46377. /**
  46378. * current (this frame) value
  46379. */
  46380. current: T;
  46381. /**
  46382. * previous (last change) value
  46383. */
  46384. previous: T;
  46385. }
  46386. /**
  46387. * Represents changes in the component between current frame and last values recorded
  46388. */
  46389. export interface IWebXRMotionControllerComponentChanges {
  46390. /**
  46391. * will be populated with previous and current values if axes changed
  46392. */
  46393. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46394. /**
  46395. * will be populated with previous and current values if pressed changed
  46396. */
  46397. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46398. /**
  46399. * will be populated with previous and current values if touched changed
  46400. */
  46401. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46402. /**
  46403. * will be populated with previous and current values if value changed
  46404. */
  46405. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46406. }
  46407. /**
  46408. * This class represents a single component (for example button or thumbstick) of a motion controller
  46409. */
  46410. export class WebXRControllerComponent implements IDisposable {
  46411. /**
  46412. * the id of this component
  46413. */
  46414. id: string;
  46415. /**
  46416. * the type of the component
  46417. */
  46418. type: MotionControllerComponentType;
  46419. private _buttonIndex;
  46420. private _axesIndices;
  46421. private _axes;
  46422. private _changes;
  46423. private _currentValue;
  46424. private _hasChanges;
  46425. private _pressed;
  46426. private _touched;
  46427. /**
  46428. * button component type
  46429. */
  46430. static BUTTON_TYPE: MotionControllerComponentType;
  46431. /**
  46432. * squeeze component type
  46433. */
  46434. static SQUEEZE_TYPE: MotionControllerComponentType;
  46435. /**
  46436. * Thumbstick component type
  46437. */
  46438. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46439. /**
  46440. * Touchpad component type
  46441. */
  46442. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46443. /**
  46444. * trigger component type
  46445. */
  46446. static TRIGGER_TYPE: MotionControllerComponentType;
  46447. /**
  46448. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46449. * the axes data changes
  46450. */
  46451. onAxisValueChangedObservable: Observable<{
  46452. x: number;
  46453. y: number;
  46454. }>;
  46455. /**
  46456. * Observers registered here will be triggered when the state of a button changes
  46457. * State change is either pressed / touched / value
  46458. */
  46459. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46460. /**
  46461. * Creates a new component for a motion controller.
  46462. * It is created by the motion controller itself
  46463. *
  46464. * @param id the id of this component
  46465. * @param type the type of the component
  46466. * @param _buttonIndex index in the buttons array of the gamepad
  46467. * @param _axesIndices indices of the values in the axes array of the gamepad
  46468. */
  46469. constructor(
  46470. /**
  46471. * the id of this component
  46472. */
  46473. id: string,
  46474. /**
  46475. * the type of the component
  46476. */
  46477. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46478. /**
  46479. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46480. */
  46481. get axes(): IWebXRMotionControllerAxesValue;
  46482. /**
  46483. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46484. */
  46485. get changes(): IWebXRMotionControllerComponentChanges;
  46486. /**
  46487. * Return whether or not the component changed the last frame
  46488. */
  46489. get hasChanges(): boolean;
  46490. /**
  46491. * is the button currently pressed
  46492. */
  46493. get pressed(): boolean;
  46494. /**
  46495. * is the button currently touched
  46496. */
  46497. get touched(): boolean;
  46498. /**
  46499. * Get the current value of this component
  46500. */
  46501. get value(): number;
  46502. /**
  46503. * Dispose this component
  46504. */
  46505. dispose(): void;
  46506. /**
  46507. * Are there axes correlating to this component
  46508. * @return true is axes data is available
  46509. */
  46510. isAxes(): boolean;
  46511. /**
  46512. * Is this component a button (hence - pressable)
  46513. * @returns true if can be pressed
  46514. */
  46515. isButton(): boolean;
  46516. /**
  46517. * update this component using the gamepad object it is in. Called on every frame
  46518. * @param nativeController the native gamepad controller object
  46519. */
  46520. update(nativeController: IMinimalMotionControllerObject): void;
  46521. }
  46522. }
  46523. declare module BABYLON {
  46524. /**
  46525. * Class used to represent data loading progression
  46526. */
  46527. export class SceneLoaderProgressEvent {
  46528. /** defines if data length to load can be evaluated */
  46529. readonly lengthComputable: boolean;
  46530. /** defines the loaded data length */
  46531. readonly loaded: number;
  46532. /** defines the data length to load */
  46533. readonly total: number;
  46534. /**
  46535. * Create a new progress event
  46536. * @param lengthComputable defines if data length to load can be evaluated
  46537. * @param loaded defines the loaded data length
  46538. * @param total defines the data length to load
  46539. */
  46540. constructor(
  46541. /** defines if data length to load can be evaluated */
  46542. lengthComputable: boolean,
  46543. /** defines the loaded data length */
  46544. loaded: number,
  46545. /** defines the data length to load */
  46546. total: number);
  46547. /**
  46548. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46549. * @param event defines the source event
  46550. * @returns a new SceneLoaderProgressEvent
  46551. */
  46552. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46553. }
  46554. /**
  46555. * Interface used by SceneLoader plugins to define supported file extensions
  46556. */
  46557. export interface ISceneLoaderPluginExtensions {
  46558. /**
  46559. * Defines the list of supported extensions
  46560. */
  46561. [extension: string]: {
  46562. isBinary: boolean;
  46563. };
  46564. }
  46565. /**
  46566. * Interface used by SceneLoader plugin factory
  46567. */
  46568. export interface ISceneLoaderPluginFactory {
  46569. /**
  46570. * Defines the name of the factory
  46571. */
  46572. name: string;
  46573. /**
  46574. * Function called to create a new plugin
  46575. * @return the new plugin
  46576. */
  46577. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46578. /**
  46579. * The callback that returns true if the data can be directly loaded.
  46580. * @param data string containing the file data
  46581. * @returns if the data can be loaded directly
  46582. */
  46583. canDirectLoad?(data: string): boolean;
  46584. }
  46585. /**
  46586. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46587. */
  46588. export interface ISceneLoaderPluginBase {
  46589. /**
  46590. * The friendly name of this plugin.
  46591. */
  46592. name: string;
  46593. /**
  46594. * The file extensions supported by this plugin.
  46595. */
  46596. extensions: string | ISceneLoaderPluginExtensions;
  46597. /**
  46598. * The callback called when loading from a url.
  46599. * @param scene scene loading this url
  46600. * @param url url to load
  46601. * @param onSuccess callback called when the file successfully loads
  46602. * @param onProgress callback called while file is loading (if the server supports this mode)
  46603. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46604. * @param onError callback called when the file fails to load
  46605. * @returns a file request object
  46606. */
  46607. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46608. /**
  46609. * The callback called when loading from a file object.
  46610. * @param scene scene loading this file
  46611. * @param file defines the file to load
  46612. * @param onSuccess defines the callback to call when data is loaded
  46613. * @param onProgress defines the callback to call during loading process
  46614. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46615. * @param onError defines the callback to call when an error occurs
  46616. * @returns a file request object
  46617. */
  46618. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46619. /**
  46620. * The callback that returns true if the data can be directly loaded.
  46621. * @param data string containing the file data
  46622. * @returns if the data can be loaded directly
  46623. */
  46624. canDirectLoad?(data: string): boolean;
  46625. /**
  46626. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46627. * @param scene scene loading this data
  46628. * @param data string containing the data
  46629. * @returns data to pass to the plugin
  46630. */
  46631. directLoad?(scene: Scene, data: string): any;
  46632. /**
  46633. * The callback that allows custom handling of the root url based on the response url.
  46634. * @param rootUrl the original root url
  46635. * @param responseURL the response url if available
  46636. * @returns the new root url
  46637. */
  46638. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46639. }
  46640. /**
  46641. * Interface used to define a SceneLoader plugin
  46642. */
  46643. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46644. /**
  46645. * Import meshes into a scene.
  46646. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46647. * @param scene The scene to import into
  46648. * @param data The data to import
  46649. * @param rootUrl The root url for scene and resources
  46650. * @param meshes The meshes array to import into
  46651. * @param particleSystems The particle systems array to import into
  46652. * @param skeletons The skeletons array to import into
  46653. * @param onError The callback when import fails
  46654. * @returns True if successful or false otherwise
  46655. */
  46656. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46657. /**
  46658. * Load into a scene.
  46659. * @param scene The scene to load into
  46660. * @param data The data to import
  46661. * @param rootUrl The root url for scene and resources
  46662. * @param onError The callback when import fails
  46663. * @returns True if successful or false otherwise
  46664. */
  46665. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46666. /**
  46667. * Load into an asset container.
  46668. * @param scene The scene to load into
  46669. * @param data The data to import
  46670. * @param rootUrl The root url for scene and resources
  46671. * @param onError The callback when import fails
  46672. * @returns The loaded asset container
  46673. */
  46674. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46675. }
  46676. /**
  46677. * Interface used to define an async SceneLoader plugin
  46678. */
  46679. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46680. /**
  46681. * Import meshes into a scene.
  46682. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46683. * @param scene The scene to import into
  46684. * @param data The data to import
  46685. * @param rootUrl The root url for scene and resources
  46686. * @param onProgress The callback when the load progresses
  46687. * @param fileName Defines the name of the file to load
  46688. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46689. */
  46690. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46691. meshes: AbstractMesh[];
  46692. particleSystems: IParticleSystem[];
  46693. skeletons: Skeleton[];
  46694. animationGroups: AnimationGroup[];
  46695. }>;
  46696. /**
  46697. * Load into a scene.
  46698. * @param scene The scene to load into
  46699. * @param data The data to import
  46700. * @param rootUrl The root url for scene and resources
  46701. * @param onProgress The callback when the load progresses
  46702. * @param fileName Defines the name of the file to load
  46703. * @returns Nothing
  46704. */
  46705. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46706. /**
  46707. * Load into an asset container.
  46708. * @param scene The scene to load into
  46709. * @param data The data to import
  46710. * @param rootUrl The root url for scene and resources
  46711. * @param onProgress The callback when the load progresses
  46712. * @param fileName Defines the name of the file to load
  46713. * @returns The loaded asset container
  46714. */
  46715. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46716. }
  46717. /**
  46718. * Mode that determines how to handle old animation groups before loading new ones.
  46719. */
  46720. export enum SceneLoaderAnimationGroupLoadingMode {
  46721. /**
  46722. * Reset all old animations to initial state then dispose them.
  46723. */
  46724. Clean = 0,
  46725. /**
  46726. * Stop all old animations.
  46727. */
  46728. Stop = 1,
  46729. /**
  46730. * Restart old animations from first frame.
  46731. */
  46732. Sync = 2,
  46733. /**
  46734. * Old animations remains untouched.
  46735. */
  46736. NoSync = 3
  46737. }
  46738. /**
  46739. * Class used to load scene from various file formats using registered plugins
  46740. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46741. */
  46742. export class SceneLoader {
  46743. /**
  46744. * No logging while loading
  46745. */
  46746. static readonly NO_LOGGING: number;
  46747. /**
  46748. * Minimal logging while loading
  46749. */
  46750. static readonly MINIMAL_LOGGING: number;
  46751. /**
  46752. * Summary logging while loading
  46753. */
  46754. static readonly SUMMARY_LOGGING: number;
  46755. /**
  46756. * Detailled logging while loading
  46757. */
  46758. static readonly DETAILED_LOGGING: number;
  46759. /**
  46760. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46761. */
  46762. static get ForceFullSceneLoadingForIncremental(): boolean;
  46763. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46764. /**
  46765. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46766. */
  46767. static get ShowLoadingScreen(): boolean;
  46768. static set ShowLoadingScreen(value: boolean);
  46769. /**
  46770. * Defines the current logging level (while loading the scene)
  46771. * @ignorenaming
  46772. */
  46773. static get loggingLevel(): number;
  46774. static set loggingLevel(value: number);
  46775. /**
  46776. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46777. */
  46778. static get CleanBoneMatrixWeights(): boolean;
  46779. static set CleanBoneMatrixWeights(value: boolean);
  46780. /**
  46781. * Event raised when a plugin is used to load a scene
  46782. */
  46783. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46784. private static _registeredPlugins;
  46785. private static _getDefaultPlugin;
  46786. private static _getPluginForExtension;
  46787. private static _getPluginForDirectLoad;
  46788. private static _getPluginForFilename;
  46789. private static _getDirectLoad;
  46790. private static _loadData;
  46791. private static _getFileInfo;
  46792. /**
  46793. * Gets a plugin that can load the given extension
  46794. * @param extension defines the extension to load
  46795. * @returns a plugin or null if none works
  46796. */
  46797. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46798. /**
  46799. * Gets a boolean indicating that the given extension can be loaded
  46800. * @param extension defines the extension to load
  46801. * @returns true if the extension is supported
  46802. */
  46803. static IsPluginForExtensionAvailable(extension: string): boolean;
  46804. /**
  46805. * Adds a new plugin to the list of registered plugins
  46806. * @param plugin defines the plugin to add
  46807. */
  46808. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46809. /**
  46810. * Import meshes into a scene
  46811. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46812. * @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)
  46813. * @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)
  46814. * @param scene the instance of BABYLON.Scene to append to
  46815. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46816. * @param onProgress a callback with a progress event for each file being loaded
  46817. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46818. * @param pluginExtension the extension used to determine the plugin
  46819. * @returns The loaded plugin
  46820. */
  46821. 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>;
  46822. /**
  46823. * Import meshes into a scene
  46824. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46825. * @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)
  46826. * @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)
  46827. * @param scene the instance of BABYLON.Scene to append to
  46828. * @param onProgress a callback with a progress event for each file being loaded
  46829. * @param pluginExtension the extension used to determine the plugin
  46830. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46831. */
  46832. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46833. meshes: AbstractMesh[];
  46834. particleSystems: IParticleSystem[];
  46835. skeletons: Skeleton[];
  46836. animationGroups: AnimationGroup[];
  46837. }>;
  46838. /**
  46839. * Load a scene
  46840. * @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)
  46841. * @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)
  46842. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46843. * @param onSuccess a callback with the scene when import succeeds
  46844. * @param onProgress a callback with a progress event for each file being loaded
  46845. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46846. * @param pluginExtension the extension used to determine the plugin
  46847. * @returns The loaded plugin
  46848. */
  46849. 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>;
  46850. /**
  46851. * Load a scene
  46852. * @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)
  46853. * @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)
  46854. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46855. * @param onProgress a callback with a progress event for each file being loaded
  46856. * @param pluginExtension the extension used to determine the plugin
  46857. * @returns The loaded scene
  46858. */
  46859. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46860. /**
  46861. * Append a scene
  46862. * @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)
  46863. * @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)
  46864. * @param scene is the instance of BABYLON.Scene to append to
  46865. * @param onSuccess a callback with the scene when import succeeds
  46866. * @param onProgress a callback with a progress event for each file being loaded
  46867. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46868. * @param pluginExtension the extension used to determine the plugin
  46869. * @returns The loaded plugin
  46870. */
  46871. 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>;
  46872. /**
  46873. * Append a scene
  46874. * @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)
  46875. * @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)
  46876. * @param scene is the instance of BABYLON.Scene to append to
  46877. * @param onProgress a callback with a progress event for each file being loaded
  46878. * @param pluginExtension the extension used to determine the plugin
  46879. * @returns The given scene
  46880. */
  46881. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46882. /**
  46883. * Load a scene into an asset container
  46884. * @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)
  46885. * @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)
  46886. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46887. * @param onSuccess a callback with the scene when import succeeds
  46888. * @param onProgress a callback with a progress event for each file being loaded
  46889. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46890. * @param pluginExtension the extension used to determine the plugin
  46891. * @returns The loaded plugin
  46892. */
  46893. 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>;
  46894. /**
  46895. * Load a scene into an asset container
  46896. * @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)
  46897. * @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)
  46898. * @param scene is the instance of Scene to append to
  46899. * @param onProgress a callback with a progress event for each file being loaded
  46900. * @param pluginExtension the extension used to determine the plugin
  46901. * @returns The loaded asset container
  46902. */
  46903. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46904. /**
  46905. * Import animations from a file into a scene
  46906. * @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)
  46907. * @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)
  46908. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46909. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46910. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46911. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46912. * @param onSuccess a callback with the scene when import succeeds
  46913. * @param onProgress a callback with a progress event for each file being loaded
  46914. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46915. */
  46916. 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;
  46917. /**
  46918. * Import animations from a file into a scene
  46919. * @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)
  46920. * @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)
  46921. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46922. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46923. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46924. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46925. * @param onSuccess a callback with the scene when import succeeds
  46926. * @param onProgress a callback with a progress event for each file being loaded
  46927. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46928. * @returns the updated scene with imported animations
  46929. */
  46930. 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>;
  46931. }
  46932. }
  46933. declare module BABYLON {
  46934. /**
  46935. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46936. */
  46937. export type MotionControllerHandedness = "none" | "left" | "right";
  46938. /**
  46939. * The type of components available in motion controllers.
  46940. * This is not the name of the component.
  46941. */
  46942. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46943. /**
  46944. * The state of a controller component
  46945. */
  46946. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46947. /**
  46948. * The schema of motion controller layout.
  46949. * No object will be initialized using this interface
  46950. * This is used just to define the profile.
  46951. */
  46952. export interface IMotionControllerLayout {
  46953. /**
  46954. * Path to load the assets. Usually relative to the base path
  46955. */
  46956. assetPath: string;
  46957. /**
  46958. * Available components (unsorted)
  46959. */
  46960. components: {
  46961. /**
  46962. * A map of component Ids
  46963. */
  46964. [componentId: string]: {
  46965. /**
  46966. * The type of input the component outputs
  46967. */
  46968. type: MotionControllerComponentType;
  46969. /**
  46970. * The indices of this component in the gamepad object
  46971. */
  46972. gamepadIndices: {
  46973. /**
  46974. * Index of button
  46975. */
  46976. button?: number;
  46977. /**
  46978. * If available, index of x-axis
  46979. */
  46980. xAxis?: number;
  46981. /**
  46982. * If available, index of y-axis
  46983. */
  46984. yAxis?: number;
  46985. };
  46986. /**
  46987. * The mesh's root node name
  46988. */
  46989. rootNodeName: string;
  46990. /**
  46991. * Animation definitions for this model
  46992. */
  46993. visualResponses: {
  46994. [stateKey: string]: {
  46995. /**
  46996. * What property will be animated
  46997. */
  46998. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46999. /**
  47000. * What states influence this visual response
  47001. */
  47002. states: MotionControllerComponentStateType[];
  47003. /**
  47004. * Type of animation - movement or visibility
  47005. */
  47006. valueNodeProperty: "transform" | "visibility";
  47007. /**
  47008. * Base node name to move. Its position will be calculated according to the min and max nodes
  47009. */
  47010. valueNodeName?: string;
  47011. /**
  47012. * Minimum movement node
  47013. */
  47014. minNodeName?: string;
  47015. /**
  47016. * Max movement node
  47017. */
  47018. maxNodeName?: string;
  47019. };
  47020. };
  47021. /**
  47022. * If touch enabled, what is the name of node to display user feedback
  47023. */
  47024. touchPointNodeName?: string;
  47025. };
  47026. };
  47027. /**
  47028. * Is it xr standard mapping or not
  47029. */
  47030. gamepadMapping: "" | "xr-standard";
  47031. /**
  47032. * Base root node of this entire model
  47033. */
  47034. rootNodeName: string;
  47035. /**
  47036. * Defines the main button component id
  47037. */
  47038. selectComponentId: string;
  47039. }
  47040. /**
  47041. * A definition for the layout map in the input profile
  47042. */
  47043. export interface IMotionControllerLayoutMap {
  47044. /**
  47045. * Layouts with handedness type as a key
  47046. */
  47047. [handedness: string]: IMotionControllerLayout;
  47048. }
  47049. /**
  47050. * The XR Input profile schema
  47051. * Profiles can be found here:
  47052. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47053. */
  47054. export interface IMotionControllerProfile {
  47055. /**
  47056. * fallback profiles for this profileId
  47057. */
  47058. fallbackProfileIds: string[];
  47059. /**
  47060. * The layout map, with handedness as key
  47061. */
  47062. layouts: IMotionControllerLayoutMap;
  47063. /**
  47064. * The id of this profile
  47065. * correlates to the profile(s) in the xrInput.profiles array
  47066. */
  47067. profileId: string;
  47068. }
  47069. /**
  47070. * A helper-interface for the 3 meshes needed for controller button animation
  47071. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47072. */
  47073. export interface IMotionControllerButtonMeshMap {
  47074. /**
  47075. * the mesh that defines the pressed value mesh position.
  47076. * This is used to find the max-position of this button
  47077. */
  47078. pressedMesh: AbstractMesh;
  47079. /**
  47080. * the mesh that defines the unpressed value mesh position.
  47081. * This is used to find the min (or initial) position of this button
  47082. */
  47083. unpressedMesh: AbstractMesh;
  47084. /**
  47085. * The mesh that will be changed when value changes
  47086. */
  47087. valueMesh: AbstractMesh;
  47088. }
  47089. /**
  47090. * A helper-interface for the 3 meshes needed for controller axis animation.
  47091. * This will be expanded when touchpad animations are fully supported
  47092. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47093. */
  47094. export interface IMotionControllerMeshMap {
  47095. /**
  47096. * the mesh that defines the maximum value mesh position.
  47097. */
  47098. maxMesh?: AbstractMesh;
  47099. /**
  47100. * the mesh that defines the minimum value mesh position.
  47101. */
  47102. minMesh?: AbstractMesh;
  47103. /**
  47104. * The mesh that will be changed when axis value changes
  47105. */
  47106. valueMesh: AbstractMesh;
  47107. }
  47108. /**
  47109. * The elements needed for change-detection of the gamepad objects in motion controllers
  47110. */
  47111. export interface IMinimalMotionControllerObject {
  47112. /**
  47113. * Available axes of this controller
  47114. */
  47115. axes: number[];
  47116. /**
  47117. * An array of available buttons
  47118. */
  47119. buttons: Array<{
  47120. /**
  47121. * Value of the button/trigger
  47122. */
  47123. value: number;
  47124. /**
  47125. * If the button/trigger is currently touched
  47126. */
  47127. touched: boolean;
  47128. /**
  47129. * If the button/trigger is currently pressed
  47130. */
  47131. pressed: boolean;
  47132. }>;
  47133. /**
  47134. * EXPERIMENTAL haptic support.
  47135. */
  47136. hapticActuators?: Array<{
  47137. pulse: (value: number, duration: number) => Promise<boolean>;
  47138. }>;
  47139. }
  47140. /**
  47141. * An Abstract Motion controller
  47142. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47143. * Each component has an observable to check for changes in value and state
  47144. */
  47145. export abstract class WebXRAbstractMotionController implements IDisposable {
  47146. protected scene: Scene;
  47147. protected layout: IMotionControllerLayout;
  47148. /**
  47149. * The gamepad object correlating to this controller
  47150. */
  47151. gamepadObject: IMinimalMotionControllerObject;
  47152. /**
  47153. * handedness (left/right/none) of this controller
  47154. */
  47155. handedness: MotionControllerHandedness;
  47156. private _initComponent;
  47157. private _modelReady;
  47158. /**
  47159. * A map of components (WebXRControllerComponent) in this motion controller
  47160. * Components have a ComponentType and can also have both button and axis definitions
  47161. */
  47162. readonly components: {
  47163. [id: string]: WebXRControllerComponent;
  47164. };
  47165. /**
  47166. * Disable the model's animation. Can be set at any time.
  47167. */
  47168. disableAnimation: boolean;
  47169. /**
  47170. * Observers registered here will be triggered when the model of this controller is done loading
  47171. */
  47172. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47173. /**
  47174. * The profile id of this motion controller
  47175. */
  47176. abstract profileId: string;
  47177. /**
  47178. * The root mesh of the model. It is null if the model was not yet initialized
  47179. */
  47180. rootMesh: Nullable<AbstractMesh>;
  47181. /**
  47182. * constructs a new abstract motion controller
  47183. * @param scene the scene to which the model of the controller will be added
  47184. * @param layout The profile layout to load
  47185. * @param gamepadObject The gamepad object correlating to this controller
  47186. * @param handedness handedness (left/right/none) of this controller
  47187. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47188. */
  47189. constructor(scene: Scene, layout: IMotionControllerLayout,
  47190. /**
  47191. * The gamepad object correlating to this controller
  47192. */
  47193. gamepadObject: IMinimalMotionControllerObject,
  47194. /**
  47195. * handedness (left/right/none) of this controller
  47196. */
  47197. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47198. /**
  47199. * Dispose this controller, the model mesh and all its components
  47200. */
  47201. dispose(): void;
  47202. /**
  47203. * Returns all components of specific type
  47204. * @param type the type to search for
  47205. * @return an array of components with this type
  47206. */
  47207. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47208. /**
  47209. * get a component based an its component id as defined in layout.components
  47210. * @param id the id of the component
  47211. * @returns the component correlates to the id or undefined if not found
  47212. */
  47213. getComponent(id: string): WebXRControllerComponent;
  47214. /**
  47215. * Get the list of components available in this motion controller
  47216. * @returns an array of strings correlating to available components
  47217. */
  47218. getComponentIds(): string[];
  47219. /**
  47220. * Get the first component of specific type
  47221. * @param type type of component to find
  47222. * @return a controller component or null if not found
  47223. */
  47224. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47225. /**
  47226. * Get the main (Select) component of this controller as defined in the layout
  47227. * @returns the main component of this controller
  47228. */
  47229. getMainComponent(): WebXRControllerComponent;
  47230. /**
  47231. * Loads the model correlating to this controller
  47232. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47233. * @returns A promise fulfilled with the result of the model loading
  47234. */
  47235. loadModel(): Promise<boolean>;
  47236. /**
  47237. * Update this model using the current XRFrame
  47238. * @param xrFrame the current xr frame to use and update the model
  47239. */
  47240. updateFromXRFrame(xrFrame: XRFrame): void;
  47241. /**
  47242. * Backwards compatibility due to a deeply-integrated typo
  47243. */
  47244. get handness(): XREye;
  47245. /**
  47246. * Pulse (vibrate) this controller
  47247. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47248. * Consecutive calls to this function will cancel the last pulse call
  47249. *
  47250. * @param value the strength of the pulse in 0.0...1.0 range
  47251. * @param duration Duration of the pulse in milliseconds
  47252. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47253. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  47254. */
  47255. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47256. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47257. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47258. /**
  47259. * Moves the axis on the controller mesh based on its current state
  47260. * @param axis the index of the axis
  47261. * @param axisValue the value of the axis which determines the meshes new position
  47262. * @hidden
  47263. */
  47264. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47265. /**
  47266. * Update the model itself with the current frame data
  47267. * @param xrFrame the frame to use for updating the model mesh
  47268. */
  47269. protected updateModel(xrFrame: XRFrame): void;
  47270. /**
  47271. * Get the filename and path for this controller's model
  47272. * @returns a map of filename and path
  47273. */
  47274. protected abstract _getFilenameAndPath(): {
  47275. filename: string;
  47276. path: string;
  47277. };
  47278. /**
  47279. * This function is called before the mesh is loaded. It checks for loading constraints.
  47280. * For example, this function can check if the GLB loader is available
  47281. * If this function returns false, the generic controller will be loaded instead
  47282. * @returns Is the client ready to load the mesh
  47283. */
  47284. protected abstract _getModelLoadingConstraints(): boolean;
  47285. /**
  47286. * This function will be called after the model was successfully loaded and can be used
  47287. * for mesh transformations before it is available for the user
  47288. * @param meshes the loaded meshes
  47289. */
  47290. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47291. /**
  47292. * Set the root mesh for this controller. Important for the WebXR controller class
  47293. * @param meshes the loaded meshes
  47294. */
  47295. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47296. /**
  47297. * A function executed each frame that updates the mesh (if needed)
  47298. * @param xrFrame the current xrFrame
  47299. */
  47300. protected abstract _updateModel(xrFrame: XRFrame): void;
  47301. private _getGenericFilenameAndPath;
  47302. private _getGenericParentMesh;
  47303. }
  47304. }
  47305. declare module BABYLON {
  47306. /**
  47307. * A generic trigger-only motion controller for WebXR
  47308. */
  47309. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47310. /**
  47311. * Static version of the profile id of this controller
  47312. */
  47313. static ProfileId: string;
  47314. profileId: string;
  47315. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47316. protected _getFilenameAndPath(): {
  47317. filename: string;
  47318. path: string;
  47319. };
  47320. protected _getModelLoadingConstraints(): boolean;
  47321. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47322. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47323. protected _updateModel(): void;
  47324. }
  47325. }
  47326. declare module BABYLON {
  47327. /**
  47328. * Class containing static functions to help procedurally build meshes
  47329. */
  47330. export class SphereBuilder {
  47331. /**
  47332. * Creates a sphere mesh
  47333. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47334. * * 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`)
  47335. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47336. * * 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
  47337. * * 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)
  47338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47339. * * 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
  47340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47341. * @param name defines the name of the mesh
  47342. * @param options defines the options used to create the mesh
  47343. * @param scene defines the hosting scene
  47344. * @returns the sphere mesh
  47345. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47346. */
  47347. static CreateSphere(name: string, options: {
  47348. segments?: number;
  47349. diameter?: number;
  47350. diameterX?: number;
  47351. diameterY?: number;
  47352. diameterZ?: number;
  47353. arc?: number;
  47354. slice?: number;
  47355. sideOrientation?: number;
  47356. frontUVs?: Vector4;
  47357. backUVs?: Vector4;
  47358. updatable?: boolean;
  47359. }, scene?: Nullable<Scene>): Mesh;
  47360. }
  47361. }
  47362. declare module BABYLON {
  47363. /**
  47364. * A profiled motion controller has its profile loaded from an online repository.
  47365. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47366. */
  47367. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47368. private _repositoryUrl;
  47369. private _buttonMeshMapping;
  47370. private _touchDots;
  47371. /**
  47372. * The profile ID of this controller. Will be populated when the controller initializes.
  47373. */
  47374. profileId: string;
  47375. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47376. dispose(): void;
  47377. protected _getFilenameAndPath(): {
  47378. filename: string;
  47379. path: string;
  47380. };
  47381. protected _getModelLoadingConstraints(): boolean;
  47382. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47383. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47384. protected _updateModel(_xrFrame: XRFrame): void;
  47385. }
  47386. }
  47387. declare module BABYLON {
  47388. /**
  47389. * A construction function type to create a new controller based on an xrInput object
  47390. */
  47391. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47392. /**
  47393. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47394. *
  47395. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47396. * it should be replaced with auto-loaded controllers.
  47397. *
  47398. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47399. */
  47400. export class WebXRMotionControllerManager {
  47401. private static _AvailableControllers;
  47402. private static _Fallbacks;
  47403. private static _ProfileLoadingPromises;
  47404. private static _ProfilesList;
  47405. /**
  47406. * The base URL of the online controller repository. Can be changed at any time.
  47407. */
  47408. static BaseRepositoryUrl: string;
  47409. /**
  47410. * Which repository gets priority - local or online
  47411. */
  47412. static PrioritizeOnlineRepository: boolean;
  47413. /**
  47414. * Use the online repository, or use only locally-defined controllers
  47415. */
  47416. static UseOnlineRepository: boolean;
  47417. /**
  47418. * Clear the cache used for profile loading and reload when requested again
  47419. */
  47420. static ClearProfilesCache(): void;
  47421. /**
  47422. * Register the default fallbacks.
  47423. * This function is called automatically when this file is imported.
  47424. */
  47425. static DefaultFallbacks(): void;
  47426. /**
  47427. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47428. * @param profileId the profile to which a fallback needs to be found
  47429. * @return an array with corresponding fallback profiles
  47430. */
  47431. static FindFallbackWithProfileId(profileId: string): string[];
  47432. /**
  47433. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47434. * The order of search:
  47435. *
  47436. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47437. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47438. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47439. * 4) return the generic trigger controller if none were found
  47440. *
  47441. * @param xrInput the xrInput to which a new controller is initialized
  47442. * @param scene the scene to which the model will be added
  47443. * @param forceProfile force a certain profile for this controller
  47444. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47445. */
  47446. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47447. /**
  47448. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47449. *
  47450. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47451. *
  47452. * @param type the profile type to register
  47453. * @param constructFunction the function to be called when loading this profile
  47454. */
  47455. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47456. /**
  47457. * Register a fallback to a specific profile.
  47458. * @param profileId the profileId that will receive the fallbacks
  47459. * @param fallbacks A list of fallback profiles
  47460. */
  47461. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47462. /**
  47463. * Will update the list of profiles available in the repository
  47464. * @return a promise that resolves to a map of profiles available online
  47465. */
  47466. static UpdateProfilesList(): Promise<{
  47467. [profile: string]: string;
  47468. }>;
  47469. private static _LoadProfileFromRepository;
  47470. private static _LoadProfilesFromAvailableControllers;
  47471. }
  47472. }
  47473. declare module BABYLON {
  47474. /**
  47475. * Configuration options for the WebXR controller creation
  47476. */
  47477. export interface IWebXRControllerOptions {
  47478. /**
  47479. * Should the controller mesh be animated when a user interacts with it
  47480. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47481. */
  47482. disableMotionControllerAnimation?: boolean;
  47483. /**
  47484. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47485. */
  47486. doNotLoadControllerMesh?: boolean;
  47487. /**
  47488. * Force a specific controller type for this controller.
  47489. * This can be used when creating your own profile or when testing different controllers
  47490. */
  47491. forceControllerProfile?: string;
  47492. /**
  47493. * Defines a rendering group ID for meshes that will be loaded.
  47494. * This is for the default controllers only.
  47495. */
  47496. renderingGroupId?: number;
  47497. }
  47498. /**
  47499. * Represents an XR controller
  47500. */
  47501. export class WebXRInputSource {
  47502. private _scene;
  47503. /** The underlying input source for the controller */
  47504. inputSource: XRInputSource;
  47505. private _options;
  47506. private _tmpVector;
  47507. private _uniqueId;
  47508. /**
  47509. * 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
  47510. */
  47511. grip?: AbstractMesh;
  47512. /**
  47513. * If available, this is the gamepad object related to this controller.
  47514. * Using this object it is possible to get click events and trackpad changes of the
  47515. * webxr controller that is currently being used.
  47516. */
  47517. motionController?: WebXRAbstractMotionController;
  47518. /**
  47519. * Event that fires when the controller is removed/disposed.
  47520. * The object provided as event data is this controller, after associated assets were disposed.
  47521. * uniqueId is still available.
  47522. */
  47523. onDisposeObservable: Observable<WebXRInputSource>;
  47524. /**
  47525. * Will be triggered when the mesh associated with the motion controller is done loading.
  47526. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47527. * A shortened version of controller -> motion controller -> on mesh loaded.
  47528. */
  47529. onMeshLoadedObservable: Observable<AbstractMesh>;
  47530. /**
  47531. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47532. */
  47533. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47534. /**
  47535. * Pointer which can be used to select objects or attach a visible laser to
  47536. */
  47537. pointer: AbstractMesh;
  47538. /**
  47539. * Creates the controller
  47540. * @see https://doc.babylonjs.com/how_to/webxr
  47541. * @param _scene the scene which the controller should be associated to
  47542. * @param inputSource the underlying input source for the controller
  47543. * @param _options options for this controller creation
  47544. */
  47545. constructor(_scene: Scene,
  47546. /** The underlying input source for the controller */
  47547. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47548. /**
  47549. * Get this controllers unique id
  47550. */
  47551. get uniqueId(): string;
  47552. /**
  47553. * Disposes of the object
  47554. */
  47555. dispose(): void;
  47556. /**
  47557. * Gets a world space ray coming from the pointer or grip
  47558. * @param result the resulting ray
  47559. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47560. */
  47561. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47562. /**
  47563. * Updates the controller pose based on the given XRFrame
  47564. * @param xrFrame xr frame to update the pose with
  47565. * @param referenceSpace reference space to use
  47566. */
  47567. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47568. }
  47569. }
  47570. declare module BABYLON {
  47571. /**
  47572. * The schema for initialization options of the XR Input class
  47573. */
  47574. export interface IWebXRInputOptions {
  47575. /**
  47576. * If set to true no model will be automatically loaded
  47577. */
  47578. doNotLoadControllerMeshes?: boolean;
  47579. /**
  47580. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47581. * If not found, the xr input profile data will be used.
  47582. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47583. */
  47584. forceInputProfile?: string;
  47585. /**
  47586. * Do not send a request to the controller repository to load the profile.
  47587. *
  47588. * Instead, use the controllers available in babylon itself.
  47589. */
  47590. disableOnlineControllerRepository?: boolean;
  47591. /**
  47592. * A custom URL for the controllers repository
  47593. */
  47594. customControllersRepositoryURL?: string;
  47595. /**
  47596. * Should the controller model's components not move according to the user input
  47597. */
  47598. disableControllerAnimation?: boolean;
  47599. /**
  47600. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47601. */
  47602. controllerOptions?: IWebXRControllerOptions;
  47603. }
  47604. /**
  47605. * XR input used to track XR inputs such as controllers/rays
  47606. */
  47607. export class WebXRInput implements IDisposable {
  47608. /**
  47609. * the xr session manager for this session
  47610. */
  47611. xrSessionManager: WebXRSessionManager;
  47612. /**
  47613. * the WebXR camera for this session. Mainly used for teleportation
  47614. */
  47615. xrCamera: WebXRCamera;
  47616. private readonly options;
  47617. /**
  47618. * XR controllers being tracked
  47619. */
  47620. controllers: Array<WebXRInputSource>;
  47621. private _frameObserver;
  47622. private _sessionEndedObserver;
  47623. private _sessionInitObserver;
  47624. /**
  47625. * Event when a controller has been connected/added
  47626. */
  47627. onControllerAddedObservable: Observable<WebXRInputSource>;
  47628. /**
  47629. * Event when a controller has been removed/disconnected
  47630. */
  47631. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47632. /**
  47633. * Initializes the WebXRInput
  47634. * @param xrSessionManager the xr session manager for this session
  47635. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47636. * @param options = initialization options for this xr input
  47637. */
  47638. constructor(
  47639. /**
  47640. * the xr session manager for this session
  47641. */
  47642. xrSessionManager: WebXRSessionManager,
  47643. /**
  47644. * the WebXR camera for this session. Mainly used for teleportation
  47645. */
  47646. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47647. private _onInputSourcesChange;
  47648. private _addAndRemoveControllers;
  47649. /**
  47650. * Disposes of the object
  47651. */
  47652. dispose(): void;
  47653. }
  47654. }
  47655. declare module BABYLON {
  47656. /**
  47657. * This is the base class for all WebXR features.
  47658. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47659. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47660. */
  47661. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47662. protected _xrSessionManager: WebXRSessionManager;
  47663. private _attached;
  47664. private _removeOnDetach;
  47665. /**
  47666. * Should auto-attach be disabled?
  47667. */
  47668. disableAutoAttach: boolean;
  47669. /**
  47670. * Construct a new (abstract) WebXR feature
  47671. * @param _xrSessionManager the xr session manager for this feature
  47672. */
  47673. constructor(_xrSessionManager: WebXRSessionManager);
  47674. /**
  47675. * Is this feature attached
  47676. */
  47677. get attached(): boolean;
  47678. /**
  47679. * attach this feature
  47680. *
  47681. * @param force should attachment be forced (even when already attached)
  47682. * @returns true if successful, false is failed or already attached
  47683. */
  47684. attach(force?: boolean): boolean;
  47685. /**
  47686. * detach this feature.
  47687. *
  47688. * @returns true if successful, false if failed or already detached
  47689. */
  47690. detach(): boolean;
  47691. /**
  47692. * Dispose this feature and all of the resources attached
  47693. */
  47694. dispose(): void;
  47695. /**
  47696. * This is used to register callbacks that will automatically be removed when detach is called.
  47697. * @param observable the observable to which the observer will be attached
  47698. * @param callback the callback to register
  47699. */
  47700. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47701. /**
  47702. * Code in this function will be executed on each xrFrame received from the browser.
  47703. * This function will not execute after the feature is detached.
  47704. * @param _xrFrame the current frame
  47705. */
  47706. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47707. }
  47708. }
  47709. declare module BABYLON {
  47710. /**
  47711. * Renders a layer on top of an existing scene
  47712. */
  47713. export class UtilityLayerRenderer implements IDisposable {
  47714. /** the original scene that will be rendered on top of */
  47715. originalScene: Scene;
  47716. private _pointerCaptures;
  47717. private _lastPointerEvents;
  47718. private static _DefaultUtilityLayer;
  47719. private static _DefaultKeepDepthUtilityLayer;
  47720. private _sharedGizmoLight;
  47721. private _renderCamera;
  47722. /**
  47723. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47724. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47725. * @returns the camera that is used when rendering the utility layer
  47726. */
  47727. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47728. /**
  47729. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47730. * @param cam the camera that should be used when rendering the utility layer
  47731. */
  47732. setRenderCamera(cam: Nullable<Camera>): void;
  47733. /**
  47734. * @hidden
  47735. * Light which used by gizmos to get light shading
  47736. */
  47737. _getSharedGizmoLight(): HemisphericLight;
  47738. /**
  47739. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47740. */
  47741. pickUtilitySceneFirst: boolean;
  47742. /**
  47743. * 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)
  47744. */
  47745. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47746. /**
  47747. * 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)
  47748. */
  47749. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47750. /**
  47751. * The scene that is rendered on top of the original scene
  47752. */
  47753. utilityLayerScene: Scene;
  47754. /**
  47755. * If the utility layer should automatically be rendered on top of existing scene
  47756. */
  47757. shouldRender: boolean;
  47758. /**
  47759. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47760. */
  47761. onlyCheckPointerDownEvents: boolean;
  47762. /**
  47763. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47764. */
  47765. processAllEvents: boolean;
  47766. /**
  47767. * Observable raised when the pointer move from the utility layer scene to the main scene
  47768. */
  47769. onPointerOutObservable: Observable<number>;
  47770. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47771. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47772. private _afterRenderObserver;
  47773. private _sceneDisposeObserver;
  47774. private _originalPointerObserver;
  47775. /**
  47776. * Instantiates a UtilityLayerRenderer
  47777. * @param originalScene the original scene that will be rendered on top of
  47778. * @param handleEvents boolean indicating if the utility layer should handle events
  47779. */
  47780. constructor(
  47781. /** the original scene that will be rendered on top of */
  47782. originalScene: Scene, handleEvents?: boolean);
  47783. private _notifyObservers;
  47784. /**
  47785. * Renders the utility layers scene on top of the original scene
  47786. */
  47787. render(): void;
  47788. /**
  47789. * Disposes of the renderer
  47790. */
  47791. dispose(): void;
  47792. private _updateCamera;
  47793. }
  47794. }
  47795. declare module BABYLON {
  47796. /**
  47797. * Options interface for the pointer selection module
  47798. */
  47799. export interface IWebXRControllerPointerSelectionOptions {
  47800. /**
  47801. * if provided, this scene will be used to render meshes.
  47802. */
  47803. customUtilityLayerScene?: Scene;
  47804. /**
  47805. * 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)
  47806. * If not disabled, the last picked point will be used to execute a pointer up event
  47807. * If disabled, pointer up event will be triggered right after the pointer down event.
  47808. * Used in screen and gaze target ray mode only
  47809. */
  47810. disablePointerUpOnTouchOut: boolean;
  47811. /**
  47812. * For gaze mode (time to select instead of press)
  47813. */
  47814. forceGazeMode: boolean;
  47815. /**
  47816. * 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
  47817. * to start a new countdown to the pointer down event.
  47818. * Defaults to 1.
  47819. */
  47820. gazeModePointerMovedFactor?: number;
  47821. /**
  47822. * Different button type to use instead of the main component
  47823. */
  47824. overrideButtonId?: string;
  47825. /**
  47826. * use this rendering group id for the meshes (optional)
  47827. */
  47828. renderingGroupId?: number;
  47829. /**
  47830. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47831. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47832. * 3000 means 3 seconds between pointing at something and selecting it
  47833. */
  47834. timeToSelect?: number;
  47835. /**
  47836. * Should meshes created here be added to a utility layer or the main scene
  47837. */
  47838. useUtilityLayer?: boolean;
  47839. /**
  47840. * the xr input to use with this pointer selection
  47841. */
  47842. xrInput: WebXRInput;
  47843. }
  47844. /**
  47845. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47846. */
  47847. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47848. private readonly _options;
  47849. private static _idCounter;
  47850. private _attachController;
  47851. private _controllers;
  47852. private _scene;
  47853. private _tmpVectorForPickCompare;
  47854. /**
  47855. * The module's name
  47856. */
  47857. static readonly Name: string;
  47858. /**
  47859. * The (Babylon) version of this module.
  47860. * This is an integer representing the implementation version.
  47861. * This number does not correspond to the WebXR specs version
  47862. */
  47863. static readonly Version: number;
  47864. /**
  47865. * Disable lighting on the laser pointer (so it will always be visible)
  47866. */
  47867. disablePointerLighting: boolean;
  47868. /**
  47869. * Disable lighting on the selection mesh (so it will always be visible)
  47870. */
  47871. disableSelectionMeshLighting: boolean;
  47872. /**
  47873. * Should the laser pointer be displayed
  47874. */
  47875. displayLaserPointer: boolean;
  47876. /**
  47877. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47878. */
  47879. displaySelectionMesh: boolean;
  47880. /**
  47881. * This color will be set to the laser pointer when selection is triggered
  47882. */
  47883. laserPointerPickedColor: Color3;
  47884. /**
  47885. * Default color of the laser pointer
  47886. */
  47887. laserPointerDefaultColor: Color3;
  47888. /**
  47889. * default color of the selection ring
  47890. */
  47891. selectionMeshDefaultColor: Color3;
  47892. /**
  47893. * This color will be applied to the selection ring when selection is triggered
  47894. */
  47895. selectionMeshPickedColor: Color3;
  47896. /**
  47897. * Optional filter to be used for ray selection. This predicate shares behavior with
  47898. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47899. */
  47900. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47901. /**
  47902. * constructs a new background remover module
  47903. * @param _xrSessionManager the session manager for this module
  47904. * @param _options read-only options to be used in this module
  47905. */
  47906. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47907. /**
  47908. * attach this feature
  47909. * Will usually be called by the features manager
  47910. *
  47911. * @returns true if successful.
  47912. */
  47913. attach(): boolean;
  47914. /**
  47915. * detach this feature.
  47916. * Will usually be called by the features manager
  47917. *
  47918. * @returns true if successful.
  47919. */
  47920. detach(): boolean;
  47921. /**
  47922. * Will get the mesh under a specific pointer.
  47923. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47924. * @param controllerId the controllerId to check
  47925. * @returns The mesh under pointer or null if no mesh is under the pointer
  47926. */
  47927. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47928. /**
  47929. * Get the xr controller that correlates to the pointer id in the pointer event
  47930. *
  47931. * @param id the pointer id to search for
  47932. * @returns the controller that correlates to this id or null if not found
  47933. */
  47934. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47935. protected _onXRFrame(_xrFrame: XRFrame): void;
  47936. private _attachGazeMode;
  47937. private _attachScreenRayMode;
  47938. private _attachTrackedPointerRayMode;
  47939. private _convertNormalToDirectionOfRay;
  47940. private _detachController;
  47941. private _generateNewMeshPair;
  47942. private _pickingMoved;
  47943. private _updatePointerDistance;
  47944. /** @hidden */
  47945. get lasterPointerDefaultColor(): Color3;
  47946. }
  47947. }
  47948. declare module BABYLON {
  47949. /**
  47950. * Button which can be used to enter a different mode of XR
  47951. */
  47952. export class WebXREnterExitUIButton {
  47953. /** button element */
  47954. element: HTMLElement;
  47955. /** XR initialization options for the button */
  47956. sessionMode: XRSessionMode;
  47957. /** Reference space type */
  47958. referenceSpaceType: XRReferenceSpaceType;
  47959. /**
  47960. * Creates a WebXREnterExitUIButton
  47961. * @param element button element
  47962. * @param sessionMode XR initialization session mode
  47963. * @param referenceSpaceType the type of reference space to be used
  47964. */
  47965. constructor(
  47966. /** button element */
  47967. element: HTMLElement,
  47968. /** XR initialization options for the button */
  47969. sessionMode: XRSessionMode,
  47970. /** Reference space type */
  47971. referenceSpaceType: XRReferenceSpaceType);
  47972. /**
  47973. * Extendable function which can be used to update the button's visuals when the state changes
  47974. * @param activeButton the current active button in the UI
  47975. */
  47976. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47977. }
  47978. /**
  47979. * Options to create the webXR UI
  47980. */
  47981. export class WebXREnterExitUIOptions {
  47982. /**
  47983. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47984. */
  47985. customButtons?: Array<WebXREnterExitUIButton>;
  47986. /**
  47987. * A reference space type to use when creating the default button.
  47988. * Default is local-floor
  47989. */
  47990. referenceSpaceType?: XRReferenceSpaceType;
  47991. /**
  47992. * Context to enter xr with
  47993. */
  47994. renderTarget?: Nullable<WebXRRenderTarget>;
  47995. /**
  47996. * A session mode to use when creating the default button.
  47997. * Default is immersive-vr
  47998. */
  47999. sessionMode?: XRSessionMode;
  48000. /**
  48001. * A list of optional features to init the session with
  48002. */
  48003. optionalFeatures?: string[];
  48004. }
  48005. /**
  48006. * UI to allow the user to enter/exit XR mode
  48007. */
  48008. export class WebXREnterExitUI implements IDisposable {
  48009. private scene;
  48010. /** version of the options passed to this UI */
  48011. options: WebXREnterExitUIOptions;
  48012. private _activeButton;
  48013. private _buttons;
  48014. private _overlay;
  48015. /**
  48016. * Fired every time the active button is changed.
  48017. *
  48018. * When xr is entered via a button that launches xr that button will be the callback parameter
  48019. *
  48020. * When exiting xr the callback parameter will be null)
  48021. */
  48022. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48023. /**
  48024. *
  48025. * @param scene babylon scene object to use
  48026. * @param options (read-only) version of the options passed to this UI
  48027. */
  48028. private constructor();
  48029. /**
  48030. * Creates UI to allow the user to enter/exit XR mode
  48031. * @param scene the scene to add the ui to
  48032. * @param helper the xr experience helper to enter/exit xr with
  48033. * @param options options to configure the UI
  48034. * @returns the created ui
  48035. */
  48036. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48037. /**
  48038. * Disposes of the XR UI component
  48039. */
  48040. dispose(): void;
  48041. private _updateButtons;
  48042. }
  48043. }
  48044. declare module BABYLON {
  48045. /**
  48046. * Class containing static functions to help procedurally build meshes
  48047. */
  48048. export class LinesBuilder {
  48049. /**
  48050. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48051. * * 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
  48052. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48053. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48054. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48055. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48056. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48057. * * 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
  48058. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48061. * @param name defines the name of the new line system
  48062. * @param options defines the options used to create the line system
  48063. * @param scene defines the hosting scene
  48064. * @returns a new line system mesh
  48065. */
  48066. static CreateLineSystem(name: string, options: {
  48067. lines: Vector3[][];
  48068. updatable?: boolean;
  48069. instance?: Nullable<LinesMesh>;
  48070. colors?: Nullable<Color4[][]>;
  48071. useVertexAlpha?: boolean;
  48072. }, scene: Nullable<Scene>): LinesMesh;
  48073. /**
  48074. * Creates a line mesh
  48075. * 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
  48076. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48077. * * The parameter `points` is an array successive Vector3
  48078. * * 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
  48079. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48080. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48081. * * When updating an instance, remember that only point positions can change, not the number of points
  48082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48084. * @param name defines the name of the new line system
  48085. * @param options defines the options used to create the line system
  48086. * @param scene defines the hosting scene
  48087. * @returns a new line mesh
  48088. */
  48089. static CreateLines(name: string, options: {
  48090. points: Vector3[];
  48091. updatable?: boolean;
  48092. instance?: Nullable<LinesMesh>;
  48093. colors?: Color4[];
  48094. useVertexAlpha?: boolean;
  48095. }, scene?: Nullable<Scene>): LinesMesh;
  48096. /**
  48097. * Creates a dashed line mesh
  48098. * * 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
  48099. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48100. * * The parameter `points` is an array successive Vector3
  48101. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48102. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48103. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48104. * * 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
  48105. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48106. * * When updating an instance, remember that only point positions can change, not the number of points
  48107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48108. * @param name defines the name of the mesh
  48109. * @param options defines the options used to create the mesh
  48110. * @param scene defines the hosting scene
  48111. * @returns the dashed line mesh
  48112. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48113. */
  48114. static CreateDashedLines(name: string, options: {
  48115. points: Vector3[];
  48116. dashSize?: number;
  48117. gapSize?: number;
  48118. dashNb?: number;
  48119. updatable?: boolean;
  48120. instance?: LinesMesh;
  48121. useVertexAlpha?: boolean;
  48122. }, scene?: Nullable<Scene>): LinesMesh;
  48123. }
  48124. }
  48125. declare module BABYLON {
  48126. /**
  48127. * Construction options for a timer
  48128. */
  48129. export interface ITimerOptions<T> {
  48130. /**
  48131. * Time-to-end
  48132. */
  48133. timeout: number;
  48134. /**
  48135. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48136. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48137. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48138. */
  48139. contextObservable: Observable<T>;
  48140. /**
  48141. * Optional parameters when adding an observer to the observable
  48142. */
  48143. observableParameters?: {
  48144. mask?: number;
  48145. insertFirst?: boolean;
  48146. scope?: any;
  48147. };
  48148. /**
  48149. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48150. */
  48151. breakCondition?: (data?: ITimerData<T>) => boolean;
  48152. /**
  48153. * Will be triggered when the time condition has met
  48154. */
  48155. onEnded?: (data: ITimerData<any>) => void;
  48156. /**
  48157. * Will be triggered when the break condition has met (prematurely ended)
  48158. */
  48159. onAborted?: (data: ITimerData<any>) => void;
  48160. /**
  48161. * Optional function to execute on each tick (or count)
  48162. */
  48163. onTick?: (data: ITimerData<any>) => void;
  48164. }
  48165. /**
  48166. * An interface defining the data sent by the timer
  48167. */
  48168. export interface ITimerData<T> {
  48169. /**
  48170. * When did it start
  48171. */
  48172. startTime: number;
  48173. /**
  48174. * Time now
  48175. */
  48176. currentTime: number;
  48177. /**
  48178. * Time passed since started
  48179. */
  48180. deltaTime: number;
  48181. /**
  48182. * How much is completed, in [0.0...1.0].
  48183. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48184. */
  48185. completeRate: number;
  48186. /**
  48187. * What the registered observable sent in the last count
  48188. */
  48189. payload: T;
  48190. }
  48191. /**
  48192. * The current state of the timer
  48193. */
  48194. export enum TimerState {
  48195. /**
  48196. * Timer initialized, not yet started
  48197. */
  48198. INIT = 0,
  48199. /**
  48200. * Timer started and counting
  48201. */
  48202. STARTED = 1,
  48203. /**
  48204. * Timer ended (whether aborted or time reached)
  48205. */
  48206. ENDED = 2
  48207. }
  48208. /**
  48209. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48210. *
  48211. * @param options options with which to initialize this timer
  48212. */
  48213. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48214. /**
  48215. * An advanced implementation of a timer class
  48216. */
  48217. export class AdvancedTimer<T = any> implements IDisposable {
  48218. /**
  48219. * Will notify each time the timer calculates the remaining time
  48220. */
  48221. onEachCountObservable: Observable<ITimerData<T>>;
  48222. /**
  48223. * Will trigger when the timer was aborted due to the break condition
  48224. */
  48225. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48226. /**
  48227. * Will trigger when the timer ended successfully
  48228. */
  48229. onTimerEndedObservable: Observable<ITimerData<T>>;
  48230. /**
  48231. * Will trigger when the timer state has changed
  48232. */
  48233. onStateChangedObservable: Observable<TimerState>;
  48234. private _observer;
  48235. private _contextObservable;
  48236. private _observableParameters;
  48237. private _startTime;
  48238. private _timer;
  48239. private _state;
  48240. private _breakCondition;
  48241. private _timeToEnd;
  48242. private _breakOnNextTick;
  48243. /**
  48244. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48245. * @param options construction options for this advanced timer
  48246. */
  48247. constructor(options: ITimerOptions<T>);
  48248. /**
  48249. * set a breaking condition for this timer. Default is to never break during count
  48250. * @param predicate the new break condition. Returns true to break, false otherwise
  48251. */
  48252. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48253. /**
  48254. * Reset ALL associated observables in this advanced timer
  48255. */
  48256. clearObservables(): void;
  48257. /**
  48258. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48259. *
  48260. * @param timeToEnd how much time to measure until timer ended
  48261. */
  48262. start(timeToEnd?: number): void;
  48263. /**
  48264. * Will force a stop on the next tick.
  48265. */
  48266. stop(): void;
  48267. /**
  48268. * Dispose this timer, clearing all resources
  48269. */
  48270. dispose(): void;
  48271. private _setState;
  48272. private _tick;
  48273. private _stop;
  48274. }
  48275. }
  48276. declare module BABYLON {
  48277. /**
  48278. * The options container for the teleportation module
  48279. */
  48280. export interface IWebXRTeleportationOptions {
  48281. /**
  48282. * if provided, this scene will be used to render meshes.
  48283. */
  48284. customUtilityLayerScene?: Scene;
  48285. /**
  48286. * Values to configure the default target mesh
  48287. */
  48288. defaultTargetMeshOptions?: {
  48289. /**
  48290. * Fill color of the teleportation area
  48291. */
  48292. teleportationFillColor?: string;
  48293. /**
  48294. * Border color for the teleportation area
  48295. */
  48296. teleportationBorderColor?: string;
  48297. /**
  48298. * Disable the mesh's animation sequence
  48299. */
  48300. disableAnimation?: boolean;
  48301. /**
  48302. * Disable lighting on the material or the ring and arrow
  48303. */
  48304. disableLighting?: boolean;
  48305. /**
  48306. * Override the default material of the torus and arrow
  48307. */
  48308. torusArrowMaterial?: Material;
  48309. };
  48310. /**
  48311. * A list of meshes to use as floor meshes.
  48312. * Meshes can be added and removed after initializing the feature using the
  48313. * addFloorMesh and removeFloorMesh functions
  48314. * If empty, rotation will still work
  48315. */
  48316. floorMeshes?: AbstractMesh[];
  48317. /**
  48318. * use this rendering group id for the meshes (optional)
  48319. */
  48320. renderingGroupId?: number;
  48321. /**
  48322. * Should teleportation move only to snap points
  48323. */
  48324. snapPointsOnly?: boolean;
  48325. /**
  48326. * An array of points to which the teleportation will snap to.
  48327. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  48328. */
  48329. snapPositions?: Vector3[];
  48330. /**
  48331. * How close should the teleportation ray be in order to snap to position.
  48332. * Default to 0.8 units (meters)
  48333. */
  48334. snapToPositionRadius?: number;
  48335. /**
  48336. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  48337. * If you want to support rotation, make sure your mesh has a direction indicator.
  48338. *
  48339. * When left untouched, the default mesh will be initialized.
  48340. */
  48341. teleportationTargetMesh?: AbstractMesh;
  48342. /**
  48343. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  48344. */
  48345. timeToTeleport?: number;
  48346. /**
  48347. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  48348. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  48349. */
  48350. useMainComponentOnly?: boolean;
  48351. /**
  48352. * Should meshes created here be added to a utility layer or the main scene
  48353. */
  48354. useUtilityLayer?: boolean;
  48355. /**
  48356. * Babylon XR Input class for controller
  48357. */
  48358. xrInput: WebXRInput;
  48359. }
  48360. /**
  48361. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  48362. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  48363. * the input of the attached controllers.
  48364. */
  48365. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  48366. private _options;
  48367. private _controllers;
  48368. private _currentTeleportationControllerId;
  48369. private _floorMeshes;
  48370. private _quadraticBezierCurve;
  48371. private _selectionFeature;
  48372. private _snapToPositions;
  48373. private _snappedToPoint;
  48374. private _teleportationRingMaterial?;
  48375. private _tmpRay;
  48376. private _tmpVector;
  48377. /**
  48378. * The module's name
  48379. */
  48380. static readonly Name: string;
  48381. /**
  48382. * The (Babylon) version of this module.
  48383. * This is an integer representing the implementation version.
  48384. * This number does not correspond to the webxr specs version
  48385. */
  48386. static readonly Version: number;
  48387. /**
  48388. * Is movement backwards enabled
  48389. */
  48390. backwardsMovementEnabled: boolean;
  48391. /**
  48392. * Distance to travel when moving backwards
  48393. */
  48394. backwardsTeleportationDistance: number;
  48395. /**
  48396. * The distance from the user to the inspection point in the direction of the controller
  48397. * A higher number will allow the user to move further
  48398. * defaults to 5 (meters, in xr units)
  48399. */
  48400. parabolicCheckRadius: number;
  48401. /**
  48402. * Should the module support parabolic ray on top of direct ray
  48403. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48404. * Very helpful when moving between floors / different heights
  48405. */
  48406. parabolicRayEnabled: boolean;
  48407. /**
  48408. * How much rotation should be applied when rotating right and left
  48409. */
  48410. rotationAngle: number;
  48411. /**
  48412. * Is rotation enabled when moving forward?
  48413. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48414. */
  48415. rotationEnabled: boolean;
  48416. /**
  48417. * constructs a new anchor system
  48418. * @param _xrSessionManager an instance of WebXRSessionManager
  48419. * @param _options configuration object for this feature
  48420. */
  48421. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48422. /**
  48423. * Get the snapPointsOnly flag
  48424. */
  48425. get snapPointsOnly(): boolean;
  48426. /**
  48427. * Sets the snapPointsOnly flag
  48428. * @param snapToPoints should teleportation be exclusively to snap points
  48429. */
  48430. set snapPointsOnly(snapToPoints: boolean);
  48431. /**
  48432. * Add a new mesh to the floor meshes array
  48433. * @param mesh the mesh to use as floor mesh
  48434. */
  48435. addFloorMesh(mesh: AbstractMesh): void;
  48436. /**
  48437. * Add a new snap-to point to fix teleportation to this position
  48438. * @param newSnapPoint The new Snap-To point
  48439. */
  48440. addSnapPoint(newSnapPoint: Vector3): void;
  48441. attach(): boolean;
  48442. detach(): boolean;
  48443. dispose(): void;
  48444. /**
  48445. * Remove a mesh from the floor meshes array
  48446. * @param mesh the mesh to remove
  48447. */
  48448. removeFloorMesh(mesh: AbstractMesh): void;
  48449. /**
  48450. * Remove a mesh from the floor meshes array using its name
  48451. * @param name the mesh name to remove
  48452. */
  48453. removeFloorMeshByName(name: string): void;
  48454. /**
  48455. * 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
  48456. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48457. * @returns was the point found and removed or not
  48458. */
  48459. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48460. /**
  48461. * This function sets a selection feature that will be disabled when
  48462. * the forward ray is shown and will be reattached when hidden.
  48463. * This is used to remove the selection rays when moving.
  48464. * @param selectionFeature the feature to disable when forward movement is enabled
  48465. */
  48466. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48467. protected _onXRFrame(_xrFrame: XRFrame): void;
  48468. private _attachController;
  48469. private _createDefaultTargetMesh;
  48470. private _detachController;
  48471. private _findClosestSnapPointWithRadius;
  48472. private _setTargetMeshPosition;
  48473. private _setTargetMeshVisibility;
  48474. private _showParabolicPath;
  48475. private _teleportForward;
  48476. }
  48477. }
  48478. declare module BABYLON {
  48479. /**
  48480. * Options for the default xr helper
  48481. */
  48482. export class WebXRDefaultExperienceOptions {
  48483. /**
  48484. * Enable or disable default UI to enter XR
  48485. */
  48486. disableDefaultUI?: boolean;
  48487. /**
  48488. * Should teleportation not initialize. defaults to false.
  48489. */
  48490. disableTeleportation?: boolean;
  48491. /**
  48492. * Floor meshes that will be used for teleport
  48493. */
  48494. floorMeshes?: Array<AbstractMesh>;
  48495. /**
  48496. * If set to true, the first frame will not be used to reset position
  48497. * The first frame is mainly used when copying transformation from the old camera
  48498. * Mainly used in AR
  48499. */
  48500. ignoreNativeCameraTransformation?: boolean;
  48501. /**
  48502. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48503. */
  48504. inputOptions?: IWebXRInputOptions;
  48505. /**
  48506. * optional configuration for the output canvas
  48507. */
  48508. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48509. /**
  48510. * optional UI options. This can be used among other to change session mode and reference space type
  48511. */
  48512. uiOptions?: WebXREnterExitUIOptions;
  48513. /**
  48514. * When loading teleportation and pointer select, use stable versions instead of latest.
  48515. */
  48516. useStablePlugins?: boolean;
  48517. /**
  48518. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48519. */
  48520. renderingGroupId?: number;
  48521. /**
  48522. * A list of optional features to init the session with
  48523. * If set to true, all features we support will be added
  48524. */
  48525. optionalFeatures?: boolean | string[];
  48526. }
  48527. /**
  48528. * Default experience which provides a similar setup to the previous webVRExperience
  48529. */
  48530. export class WebXRDefaultExperience {
  48531. /**
  48532. * Base experience
  48533. */
  48534. baseExperience: WebXRExperienceHelper;
  48535. /**
  48536. * Enables ui for entering/exiting xr
  48537. */
  48538. enterExitUI: WebXREnterExitUI;
  48539. /**
  48540. * Input experience extension
  48541. */
  48542. input: WebXRInput;
  48543. /**
  48544. * Enables laser pointer and selection
  48545. */
  48546. pointerSelection: WebXRControllerPointerSelection;
  48547. /**
  48548. * Default target xr should render to
  48549. */
  48550. renderTarget: WebXRRenderTarget;
  48551. /**
  48552. * Enables teleportation
  48553. */
  48554. teleportation: WebXRMotionControllerTeleportation;
  48555. private constructor();
  48556. /**
  48557. * Creates the default xr experience
  48558. * @param scene scene
  48559. * @param options options for basic configuration
  48560. * @returns resulting WebXRDefaultExperience
  48561. */
  48562. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48563. /**
  48564. * DIsposes of the experience helper
  48565. */
  48566. dispose(): void;
  48567. }
  48568. }
  48569. declare module BABYLON {
  48570. /**
  48571. * Options to modify the vr teleportation behavior.
  48572. */
  48573. export interface VRTeleportationOptions {
  48574. /**
  48575. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48576. */
  48577. floorMeshName?: string;
  48578. /**
  48579. * A list of meshes to be used as the teleportation floor. (default: empty)
  48580. */
  48581. floorMeshes?: Mesh[];
  48582. /**
  48583. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48584. */
  48585. teleportationMode?: number;
  48586. /**
  48587. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48588. */
  48589. teleportationTime?: number;
  48590. /**
  48591. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48592. */
  48593. teleportationSpeed?: number;
  48594. /**
  48595. * The easing function used in the animation or null for Linear. (default CircleEase)
  48596. */
  48597. easingFunction?: EasingFunction;
  48598. }
  48599. /**
  48600. * Options to modify the vr experience helper's behavior.
  48601. */
  48602. export interface VRExperienceHelperOptions extends WebVROptions {
  48603. /**
  48604. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48605. */
  48606. createDeviceOrientationCamera?: boolean;
  48607. /**
  48608. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48609. */
  48610. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48611. /**
  48612. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48613. */
  48614. laserToggle?: boolean;
  48615. /**
  48616. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48617. */
  48618. floorMeshes?: Mesh[];
  48619. /**
  48620. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48621. */
  48622. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48623. /**
  48624. * Defines if WebXR should be used instead of WebVR (if available)
  48625. */
  48626. useXR?: boolean;
  48627. }
  48628. /**
  48629. * Event containing information after VR has been entered
  48630. */
  48631. export class OnAfterEnteringVRObservableEvent {
  48632. /**
  48633. * If entering vr was successful
  48634. */
  48635. success: boolean;
  48636. }
  48637. /**
  48638. * Helps to quickly add VR support to an existing scene.
  48639. * See http://doc.babylonjs.com/how_to/webvr_helper
  48640. */
  48641. export class VRExperienceHelper {
  48642. /** Options to modify the vr experience helper's behavior. */
  48643. webVROptions: VRExperienceHelperOptions;
  48644. private _scene;
  48645. private _position;
  48646. private _btnVR;
  48647. private _btnVRDisplayed;
  48648. private _webVRsupported;
  48649. private _webVRready;
  48650. private _webVRrequesting;
  48651. private _webVRpresenting;
  48652. private _hasEnteredVR;
  48653. private _fullscreenVRpresenting;
  48654. private _inputElement;
  48655. private _webVRCamera;
  48656. private _vrDeviceOrientationCamera;
  48657. private _deviceOrientationCamera;
  48658. private _existingCamera;
  48659. private _onKeyDown;
  48660. private _onVrDisplayPresentChange;
  48661. private _onVRDisplayChanged;
  48662. private _onVRRequestPresentStart;
  48663. private _onVRRequestPresentComplete;
  48664. /**
  48665. * 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)
  48666. */
  48667. enableGazeEvenWhenNoPointerLock: boolean;
  48668. /**
  48669. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48670. */
  48671. exitVROnDoubleTap: boolean;
  48672. /**
  48673. * Observable raised right before entering VR.
  48674. */
  48675. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48676. /**
  48677. * Observable raised when entering VR has completed.
  48678. */
  48679. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48680. /**
  48681. * Observable raised when exiting VR.
  48682. */
  48683. onExitingVRObservable: Observable<VRExperienceHelper>;
  48684. /**
  48685. * Observable raised when controller mesh is loaded.
  48686. */
  48687. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48688. /** Return this.onEnteringVRObservable
  48689. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48690. */
  48691. get onEnteringVR(): Observable<VRExperienceHelper>;
  48692. /** Return this.onExitingVRObservable
  48693. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48694. */
  48695. get onExitingVR(): Observable<VRExperienceHelper>;
  48696. /** Return this.onControllerMeshLoadedObservable
  48697. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48698. */
  48699. get onControllerMeshLoaded(): Observable<WebVRController>;
  48700. private _rayLength;
  48701. private _useCustomVRButton;
  48702. private _teleportationRequested;
  48703. private _teleportActive;
  48704. private _floorMeshName;
  48705. private _floorMeshesCollection;
  48706. private _teleportationMode;
  48707. private _teleportationTime;
  48708. private _teleportationSpeed;
  48709. private _teleportationEasing;
  48710. private _rotationAllowed;
  48711. private _teleportBackwardsVector;
  48712. private _teleportationTarget;
  48713. private _isDefaultTeleportationTarget;
  48714. private _postProcessMove;
  48715. private _teleportationFillColor;
  48716. private _teleportationBorderColor;
  48717. private _rotationAngle;
  48718. private _haloCenter;
  48719. private _cameraGazer;
  48720. private _padSensibilityUp;
  48721. private _padSensibilityDown;
  48722. private _leftController;
  48723. private _rightController;
  48724. private _gazeColor;
  48725. private _laserColor;
  48726. private _pickedLaserColor;
  48727. private _pickedGazeColor;
  48728. /**
  48729. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48730. */
  48731. onNewMeshSelected: Observable<AbstractMesh>;
  48732. /**
  48733. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48734. * This observable will provide the mesh and the controller used to select the mesh
  48735. */
  48736. onMeshSelectedWithController: Observable<{
  48737. mesh: AbstractMesh;
  48738. controller: WebVRController;
  48739. }>;
  48740. /**
  48741. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48742. */
  48743. onNewMeshPicked: Observable<PickingInfo>;
  48744. private _circleEase;
  48745. /**
  48746. * Observable raised before camera teleportation
  48747. */
  48748. onBeforeCameraTeleport: Observable<Vector3>;
  48749. /**
  48750. * Observable raised after camera teleportation
  48751. */
  48752. onAfterCameraTeleport: Observable<Vector3>;
  48753. /**
  48754. * Observable raised when current selected mesh gets unselected
  48755. */
  48756. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48757. private _raySelectionPredicate;
  48758. /**
  48759. * To be optionaly changed by user to define custom ray selection
  48760. */
  48761. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48762. /**
  48763. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48764. */
  48765. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48766. /**
  48767. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48768. */
  48769. teleportationEnabled: boolean;
  48770. private _defaultHeight;
  48771. private _teleportationInitialized;
  48772. private _interactionsEnabled;
  48773. private _interactionsRequested;
  48774. private _displayGaze;
  48775. private _displayLaserPointer;
  48776. /**
  48777. * The mesh used to display where the user is going to teleport.
  48778. */
  48779. get teleportationTarget(): Mesh;
  48780. /**
  48781. * Sets the mesh to be used to display where the user is going to teleport.
  48782. */
  48783. set teleportationTarget(value: Mesh);
  48784. /**
  48785. * 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
  48786. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48787. * See http://doc.babylonjs.com/resources/baking_transformations
  48788. */
  48789. get gazeTrackerMesh(): Mesh;
  48790. set gazeTrackerMesh(value: Mesh);
  48791. /**
  48792. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48793. */
  48794. updateGazeTrackerScale: boolean;
  48795. /**
  48796. * If the gaze trackers color should be updated when selecting meshes
  48797. */
  48798. updateGazeTrackerColor: boolean;
  48799. /**
  48800. * If the controller laser color should be updated when selecting meshes
  48801. */
  48802. updateControllerLaserColor: boolean;
  48803. /**
  48804. * The gaze tracking mesh corresponding to the left controller
  48805. */
  48806. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48807. /**
  48808. * The gaze tracking mesh corresponding to the right controller
  48809. */
  48810. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48811. /**
  48812. * If the ray of the gaze should be displayed.
  48813. */
  48814. get displayGaze(): boolean;
  48815. /**
  48816. * Sets if the ray of the gaze should be displayed.
  48817. */
  48818. set displayGaze(value: boolean);
  48819. /**
  48820. * If the ray of the LaserPointer should be displayed.
  48821. */
  48822. get displayLaserPointer(): boolean;
  48823. /**
  48824. * Sets if the ray of the LaserPointer should be displayed.
  48825. */
  48826. set displayLaserPointer(value: boolean);
  48827. /**
  48828. * The deviceOrientationCamera used as the camera when not in VR.
  48829. */
  48830. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48831. /**
  48832. * Based on the current WebVR support, returns the current VR camera used.
  48833. */
  48834. get currentVRCamera(): Nullable<Camera>;
  48835. /**
  48836. * The webVRCamera which is used when in VR.
  48837. */
  48838. get webVRCamera(): WebVRFreeCamera;
  48839. /**
  48840. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48841. */
  48842. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48843. /**
  48844. * The html button that is used to trigger entering into VR.
  48845. */
  48846. get vrButton(): Nullable<HTMLButtonElement>;
  48847. private get _teleportationRequestInitiated();
  48848. /**
  48849. * Defines whether or not Pointer lock should be requested when switching to
  48850. * full screen.
  48851. */
  48852. requestPointerLockOnFullScreen: boolean;
  48853. /**
  48854. * If asking to force XR, this will be populated with the default xr experience
  48855. */
  48856. xr: WebXRDefaultExperience;
  48857. /**
  48858. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48859. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48860. */
  48861. xrTestDone: boolean;
  48862. /**
  48863. * Instantiates a VRExperienceHelper.
  48864. * Helps to quickly add VR support to an existing scene.
  48865. * @param scene The scene the VRExperienceHelper belongs to.
  48866. * @param webVROptions Options to modify the vr experience helper's behavior.
  48867. */
  48868. constructor(scene: Scene,
  48869. /** Options to modify the vr experience helper's behavior. */
  48870. webVROptions?: VRExperienceHelperOptions);
  48871. private completeVRInit;
  48872. private _onDefaultMeshLoaded;
  48873. private _onResize;
  48874. private _onFullscreenChange;
  48875. /**
  48876. * Gets a value indicating if we are currently in VR mode.
  48877. */
  48878. get isInVRMode(): boolean;
  48879. private onVrDisplayPresentChange;
  48880. private onVRDisplayChanged;
  48881. private moveButtonToBottomRight;
  48882. private displayVRButton;
  48883. private updateButtonVisibility;
  48884. private _cachedAngularSensibility;
  48885. /**
  48886. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48887. * Otherwise, will use the fullscreen API.
  48888. */
  48889. enterVR(): void;
  48890. /**
  48891. * Attempt to exit VR, or fullscreen.
  48892. */
  48893. exitVR(): void;
  48894. /**
  48895. * The position of the vr experience helper.
  48896. */
  48897. get position(): Vector3;
  48898. /**
  48899. * Sets the position of the vr experience helper.
  48900. */
  48901. set position(value: Vector3);
  48902. /**
  48903. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48904. */
  48905. enableInteractions(): void;
  48906. private get _noControllerIsActive();
  48907. private beforeRender;
  48908. private _isTeleportationFloor;
  48909. /**
  48910. * Adds a floor mesh to be used for teleportation.
  48911. * @param floorMesh the mesh to be used for teleportation.
  48912. */
  48913. addFloorMesh(floorMesh: Mesh): void;
  48914. /**
  48915. * Removes a floor mesh from being used for teleportation.
  48916. * @param floorMesh the mesh to be removed.
  48917. */
  48918. removeFloorMesh(floorMesh: Mesh): void;
  48919. /**
  48920. * Enables interactions and teleportation using the VR controllers and gaze.
  48921. * @param vrTeleportationOptions options to modify teleportation behavior.
  48922. */
  48923. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48924. private _onNewGamepadConnected;
  48925. private _tryEnableInteractionOnController;
  48926. private _onNewGamepadDisconnected;
  48927. private _enableInteractionOnController;
  48928. private _checkTeleportWithRay;
  48929. private _checkRotate;
  48930. private _checkTeleportBackwards;
  48931. private _enableTeleportationOnController;
  48932. private _createTeleportationCircles;
  48933. private _displayTeleportationTarget;
  48934. private _hideTeleportationTarget;
  48935. private _rotateCamera;
  48936. private _moveTeleportationSelectorTo;
  48937. private _workingVector;
  48938. private _workingQuaternion;
  48939. private _workingMatrix;
  48940. /**
  48941. * Time Constant Teleportation Mode
  48942. */
  48943. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48944. /**
  48945. * Speed Constant Teleportation Mode
  48946. */
  48947. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48948. /**
  48949. * Teleports the users feet to the desired location
  48950. * @param location The location where the user's feet should be placed
  48951. */
  48952. teleportCamera(location: Vector3): void;
  48953. private _convertNormalToDirectionOfRay;
  48954. private _castRayAndSelectObject;
  48955. private _notifySelectedMeshUnselected;
  48956. /**
  48957. * Permanently set new colors for the laser pointer
  48958. * @param color the new laser color
  48959. * @param pickedColor the new laser color when picked mesh detected
  48960. */
  48961. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48962. /**
  48963. * Set lighting enabled / disabled on the laser pointer of both controllers
  48964. * @param enabled should the lighting be enabled on the laser pointer
  48965. */
  48966. setLaserLightingState(enabled?: boolean): void;
  48967. /**
  48968. * Permanently set new colors for the gaze pointer
  48969. * @param color the new gaze color
  48970. * @param pickedColor the new gaze color when picked mesh detected
  48971. */
  48972. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48973. /**
  48974. * Sets the color of the laser ray from the vr controllers.
  48975. * @param color new color for the ray.
  48976. */
  48977. changeLaserColor(color: Color3): void;
  48978. /**
  48979. * Sets the color of the ray from the vr headsets gaze.
  48980. * @param color new color for the ray.
  48981. */
  48982. changeGazeColor(color: Color3): void;
  48983. /**
  48984. * Exits VR and disposes of the vr experience helper
  48985. */
  48986. dispose(): void;
  48987. /**
  48988. * Gets the name of the VRExperienceHelper class
  48989. * @returns "VRExperienceHelper"
  48990. */
  48991. getClassName(): string;
  48992. }
  48993. }
  48994. declare module BABYLON {
  48995. /**
  48996. * Contains an array of blocks representing the octree
  48997. */
  48998. export interface IOctreeContainer<T> {
  48999. /**
  49000. * Blocks within the octree
  49001. */
  49002. blocks: Array<OctreeBlock<T>>;
  49003. }
  49004. /**
  49005. * Class used to store a cell in an octree
  49006. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49007. */
  49008. export class OctreeBlock<T> {
  49009. /**
  49010. * Gets the content of the current block
  49011. */
  49012. entries: T[];
  49013. /**
  49014. * Gets the list of block children
  49015. */
  49016. blocks: Array<OctreeBlock<T>>;
  49017. private _depth;
  49018. private _maxDepth;
  49019. private _capacity;
  49020. private _minPoint;
  49021. private _maxPoint;
  49022. private _boundingVectors;
  49023. private _creationFunc;
  49024. /**
  49025. * Creates a new block
  49026. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49027. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49028. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49029. * @param depth defines the current depth of this block in the octree
  49030. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49031. * @param creationFunc defines a callback to call when an element is added to the block
  49032. */
  49033. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49034. /**
  49035. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49036. */
  49037. get capacity(): number;
  49038. /**
  49039. * Gets the minimum vector (in world space) of the block's bounding box
  49040. */
  49041. get minPoint(): Vector3;
  49042. /**
  49043. * Gets the maximum vector (in world space) of the block's bounding box
  49044. */
  49045. get maxPoint(): Vector3;
  49046. /**
  49047. * Add a new element to this block
  49048. * @param entry defines the element to add
  49049. */
  49050. addEntry(entry: T): void;
  49051. /**
  49052. * Remove an element from this block
  49053. * @param entry defines the element to remove
  49054. */
  49055. removeEntry(entry: T): void;
  49056. /**
  49057. * Add an array of elements to this block
  49058. * @param entries defines the array of elements to add
  49059. */
  49060. addEntries(entries: T[]): void;
  49061. /**
  49062. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49063. * @param frustumPlanes defines the frustum planes to test
  49064. * @param selection defines the array to store current content if selection is positive
  49065. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49066. */
  49067. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49068. /**
  49069. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49070. * @param sphereCenter defines the bounding sphere center
  49071. * @param sphereRadius defines the bounding sphere radius
  49072. * @param selection defines the array to store current content if selection is positive
  49073. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49074. */
  49075. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49076. /**
  49077. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49078. * @param ray defines the ray to test with
  49079. * @param selection defines the array to store current content if selection is positive
  49080. */
  49081. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49082. /**
  49083. * Subdivide the content into child blocks (this block will then be empty)
  49084. */
  49085. createInnerBlocks(): void;
  49086. /**
  49087. * @hidden
  49088. */
  49089. 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;
  49090. }
  49091. }
  49092. declare module BABYLON {
  49093. /**
  49094. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49095. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49096. */
  49097. export class Octree<T> {
  49098. /** 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.) */
  49099. maxDepth: number;
  49100. /**
  49101. * Blocks within the octree containing objects
  49102. */
  49103. blocks: Array<OctreeBlock<T>>;
  49104. /**
  49105. * Content stored in the octree
  49106. */
  49107. dynamicContent: T[];
  49108. private _maxBlockCapacity;
  49109. private _selectionContent;
  49110. private _creationFunc;
  49111. /**
  49112. * Creates a octree
  49113. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49114. * @param creationFunc function to be used to instatiate the octree
  49115. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49116. * @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.)
  49117. */
  49118. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49119. /** 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.) */
  49120. maxDepth?: number);
  49121. /**
  49122. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49123. * @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);
  49124. * @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);
  49125. * @param entries meshes to be added to the octree blocks
  49126. */
  49127. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49128. /**
  49129. * Adds a mesh to the octree
  49130. * @param entry Mesh to add to the octree
  49131. */
  49132. addMesh(entry: T): void;
  49133. /**
  49134. * Remove an element from the octree
  49135. * @param entry defines the element to remove
  49136. */
  49137. removeMesh(entry: T): void;
  49138. /**
  49139. * Selects an array of meshes within the frustum
  49140. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49141. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49142. * @returns array of meshes within the frustum
  49143. */
  49144. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49145. /**
  49146. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49147. * @param sphereCenter defines the bounding sphere center
  49148. * @param sphereRadius defines the bounding sphere radius
  49149. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49150. * @returns an array of objects that intersect the sphere
  49151. */
  49152. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49153. /**
  49154. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49155. * @param ray defines the ray to test with
  49156. * @returns array of intersected objects
  49157. */
  49158. intersectsRay(ray: Ray): SmartArray<T>;
  49159. /**
  49160. * Adds a mesh into the octree block if it intersects the block
  49161. */
  49162. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49163. /**
  49164. * Adds a submesh into the octree block if it intersects the block
  49165. */
  49166. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49167. }
  49168. }
  49169. declare module BABYLON {
  49170. interface Scene {
  49171. /**
  49172. * @hidden
  49173. * Backing Filed
  49174. */
  49175. _selectionOctree: Octree<AbstractMesh>;
  49176. /**
  49177. * Gets the octree used to boost mesh selection (picking)
  49178. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49179. */
  49180. selectionOctree: Octree<AbstractMesh>;
  49181. /**
  49182. * Creates or updates the octree used to boost selection (picking)
  49183. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49184. * @param maxCapacity defines the maximum capacity per leaf
  49185. * @param maxDepth defines the maximum depth of the octree
  49186. * @returns an octree of AbstractMesh
  49187. */
  49188. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49189. }
  49190. interface AbstractMesh {
  49191. /**
  49192. * @hidden
  49193. * Backing Field
  49194. */
  49195. _submeshesOctree: Octree<SubMesh>;
  49196. /**
  49197. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49198. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49199. * @param maxCapacity defines the maximum size of each block (64 by default)
  49200. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49201. * @returns the new octree
  49202. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49203. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49204. */
  49205. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49206. }
  49207. /**
  49208. * Defines the octree scene component responsible to manage any octrees
  49209. * in a given scene.
  49210. */
  49211. export class OctreeSceneComponent {
  49212. /**
  49213. * The component name help to identify the component in the list of scene components.
  49214. */
  49215. readonly name: string;
  49216. /**
  49217. * The scene the component belongs to.
  49218. */
  49219. scene: Scene;
  49220. /**
  49221. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49222. */
  49223. readonly checksIsEnabled: boolean;
  49224. /**
  49225. * Creates a new instance of the component for the given scene
  49226. * @param scene Defines the scene to register the component in
  49227. */
  49228. constructor(scene: Scene);
  49229. /**
  49230. * Registers the component in a given scene
  49231. */
  49232. register(): void;
  49233. /**
  49234. * Return the list of active meshes
  49235. * @returns the list of active meshes
  49236. */
  49237. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49238. /**
  49239. * Return the list of active sub meshes
  49240. * @param mesh The mesh to get the candidates sub meshes from
  49241. * @returns the list of active sub meshes
  49242. */
  49243. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49244. private _tempRay;
  49245. /**
  49246. * Return the list of sub meshes intersecting with a given local ray
  49247. * @param mesh defines the mesh to find the submesh for
  49248. * @param localRay defines the ray in local space
  49249. * @returns the list of intersecting sub meshes
  49250. */
  49251. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49252. /**
  49253. * Return the list of sub meshes colliding with a collider
  49254. * @param mesh defines the mesh to find the submesh for
  49255. * @param collider defines the collider to evaluate the collision against
  49256. * @returns the list of colliding sub meshes
  49257. */
  49258. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49259. /**
  49260. * Rebuilds the elements related to this component in case of
  49261. * context lost for instance.
  49262. */
  49263. rebuild(): void;
  49264. /**
  49265. * Disposes the component and the associated ressources.
  49266. */
  49267. dispose(): void;
  49268. }
  49269. }
  49270. declare module BABYLON {
  49271. /**
  49272. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49273. */
  49274. export class Gizmo implements IDisposable {
  49275. /** The utility layer the gizmo will be added to */
  49276. gizmoLayer: UtilityLayerRenderer;
  49277. /**
  49278. * The root mesh of the gizmo
  49279. */
  49280. _rootMesh: Mesh;
  49281. private _attachedMesh;
  49282. /**
  49283. * Ratio for the scale of the gizmo (Default: 1)
  49284. */
  49285. scaleRatio: number;
  49286. /**
  49287. * If a custom mesh has been set (Default: false)
  49288. */
  49289. protected _customMeshSet: boolean;
  49290. /**
  49291. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49292. * * When set, interactions will be enabled
  49293. */
  49294. get attachedMesh(): Nullable<AbstractMesh>;
  49295. set attachedMesh(value: Nullable<AbstractMesh>);
  49296. /**
  49297. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49298. * @param mesh The mesh to replace the default mesh of the gizmo
  49299. */
  49300. setCustomMesh(mesh: Mesh): void;
  49301. /**
  49302. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49303. */
  49304. updateGizmoRotationToMatchAttachedMesh: boolean;
  49305. /**
  49306. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49307. */
  49308. updateGizmoPositionToMatchAttachedMesh: boolean;
  49309. /**
  49310. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49311. */
  49312. updateScale: boolean;
  49313. protected _interactionsEnabled: boolean;
  49314. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49315. private _beforeRenderObserver;
  49316. private _tempVector;
  49317. /**
  49318. * Creates a gizmo
  49319. * @param gizmoLayer The utility layer the gizmo will be added to
  49320. */
  49321. constructor(
  49322. /** The utility layer the gizmo will be added to */
  49323. gizmoLayer?: UtilityLayerRenderer);
  49324. /**
  49325. * Updates the gizmo to match the attached mesh's position/rotation
  49326. */
  49327. protected _update(): void;
  49328. /**
  49329. * Disposes of the gizmo
  49330. */
  49331. dispose(): void;
  49332. }
  49333. }
  49334. declare module BABYLON {
  49335. /**
  49336. * Single plane drag gizmo
  49337. */
  49338. export class PlaneDragGizmo extends Gizmo {
  49339. /**
  49340. * Drag behavior responsible for the gizmos dragging interactions
  49341. */
  49342. dragBehavior: PointerDragBehavior;
  49343. private _pointerObserver;
  49344. /**
  49345. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49346. */
  49347. snapDistance: number;
  49348. /**
  49349. * Event that fires each time the gizmo snaps to a new location.
  49350. * * snapDistance is the the change in distance
  49351. */
  49352. onSnapObservable: Observable<{
  49353. snapDistance: number;
  49354. }>;
  49355. private _plane;
  49356. private _coloredMaterial;
  49357. private _hoverMaterial;
  49358. private _isEnabled;
  49359. private _parent;
  49360. /** @hidden */
  49361. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  49362. /** @hidden */
  49363. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49364. /**
  49365. * Creates a PlaneDragGizmo
  49366. * @param gizmoLayer The utility layer the gizmo will be added to
  49367. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  49368. * @param color The color of the gizmo
  49369. */
  49370. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49371. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49372. /**
  49373. * If the gizmo is enabled
  49374. */
  49375. set isEnabled(value: boolean);
  49376. get isEnabled(): boolean;
  49377. /**
  49378. * Disposes of the gizmo
  49379. */
  49380. dispose(): void;
  49381. }
  49382. }
  49383. declare module BABYLON {
  49384. /**
  49385. * Gizmo that enables dragging a mesh along 3 axis
  49386. */
  49387. export class PositionGizmo extends Gizmo {
  49388. /**
  49389. * Internal gizmo used for interactions on the x axis
  49390. */
  49391. xGizmo: AxisDragGizmo;
  49392. /**
  49393. * Internal gizmo used for interactions on the y axis
  49394. */
  49395. yGizmo: AxisDragGizmo;
  49396. /**
  49397. * Internal gizmo used for interactions on the z axis
  49398. */
  49399. zGizmo: AxisDragGizmo;
  49400. /**
  49401. * Internal gizmo used for interactions on the yz plane
  49402. */
  49403. xPlaneGizmo: PlaneDragGizmo;
  49404. /**
  49405. * Internal gizmo used for interactions on the xz plane
  49406. */
  49407. yPlaneGizmo: PlaneDragGizmo;
  49408. /**
  49409. * Internal gizmo used for interactions on the xy plane
  49410. */
  49411. zPlaneGizmo: PlaneDragGizmo;
  49412. /**
  49413. * private variables
  49414. */
  49415. private _meshAttached;
  49416. private _updateGizmoRotationToMatchAttachedMesh;
  49417. private _snapDistance;
  49418. private _scaleRatio;
  49419. /** Fires an event when any of it's sub gizmos are dragged */
  49420. onDragStartObservable: Observable<unknown>;
  49421. /** Fires an event when any of it's sub gizmos are released from dragging */
  49422. onDragEndObservable: Observable<unknown>;
  49423. /**
  49424. * If set to true, planar drag is enabled
  49425. */
  49426. private _planarGizmoEnabled;
  49427. get attachedMesh(): Nullable<AbstractMesh>;
  49428. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49429. /**
  49430. * Creates a PositionGizmo
  49431. * @param gizmoLayer The utility layer the gizmo will be added to
  49432. */
  49433. constructor(gizmoLayer?: UtilityLayerRenderer);
  49434. /**
  49435. * If the planar drag gizmo is enabled
  49436. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49437. */
  49438. set planarGizmoEnabled(value: boolean);
  49439. get planarGizmoEnabled(): boolean;
  49440. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49441. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49442. /**
  49443. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49444. */
  49445. set snapDistance(value: number);
  49446. get snapDistance(): number;
  49447. /**
  49448. * Ratio for the scale of the gizmo (Default: 1)
  49449. */
  49450. set scaleRatio(value: number);
  49451. get scaleRatio(): number;
  49452. /**
  49453. * Disposes of the gizmo
  49454. */
  49455. dispose(): void;
  49456. /**
  49457. * CustomMeshes are not supported by this gizmo
  49458. * @param mesh The mesh to replace the default mesh of the gizmo
  49459. */
  49460. setCustomMesh(mesh: Mesh): void;
  49461. }
  49462. }
  49463. declare module BABYLON {
  49464. /**
  49465. * Single axis drag gizmo
  49466. */
  49467. export class AxisDragGizmo extends Gizmo {
  49468. /**
  49469. * Drag behavior responsible for the gizmos dragging interactions
  49470. */
  49471. dragBehavior: PointerDragBehavior;
  49472. private _pointerObserver;
  49473. /**
  49474. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49475. */
  49476. snapDistance: number;
  49477. /**
  49478. * Event that fires each time the gizmo snaps to a new location.
  49479. * * snapDistance is the the change in distance
  49480. */
  49481. onSnapObservable: Observable<{
  49482. snapDistance: number;
  49483. }>;
  49484. private _isEnabled;
  49485. private _parent;
  49486. private _arrow;
  49487. private _coloredMaterial;
  49488. private _hoverMaterial;
  49489. /** @hidden */
  49490. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49491. /** @hidden */
  49492. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49493. /**
  49494. * Creates an AxisDragGizmo
  49495. * @param gizmoLayer The utility layer the gizmo will be added to
  49496. * @param dragAxis The axis which the gizmo will be able to drag on
  49497. * @param color The color of the gizmo
  49498. */
  49499. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49500. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49501. /**
  49502. * If the gizmo is enabled
  49503. */
  49504. set isEnabled(value: boolean);
  49505. get isEnabled(): boolean;
  49506. /**
  49507. * Disposes of the gizmo
  49508. */
  49509. dispose(): void;
  49510. }
  49511. }
  49512. declare module BABYLON.Debug {
  49513. /**
  49514. * The Axes viewer will show 3 axes in a specific point in space
  49515. */
  49516. export class AxesViewer {
  49517. private _xAxis;
  49518. private _yAxis;
  49519. private _zAxis;
  49520. private _scaleLinesFactor;
  49521. private _instanced;
  49522. /**
  49523. * Gets the hosting scene
  49524. */
  49525. scene: Scene;
  49526. /**
  49527. * Gets or sets a number used to scale line length
  49528. */
  49529. scaleLines: number;
  49530. /** Gets the node hierarchy used to render x-axis */
  49531. get xAxis(): TransformNode;
  49532. /** Gets the node hierarchy used to render y-axis */
  49533. get yAxis(): TransformNode;
  49534. /** Gets the node hierarchy used to render z-axis */
  49535. get zAxis(): TransformNode;
  49536. /**
  49537. * Creates a new AxesViewer
  49538. * @param scene defines the hosting scene
  49539. * @param scaleLines defines a number used to scale line length (1 by default)
  49540. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49541. * @param xAxis defines the node hierarchy used to render the x-axis
  49542. * @param yAxis defines the node hierarchy used to render the y-axis
  49543. * @param zAxis defines the node hierarchy used to render the z-axis
  49544. */
  49545. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49546. /**
  49547. * Force the viewer to update
  49548. * @param position defines the position of the viewer
  49549. * @param xaxis defines the x axis of the viewer
  49550. * @param yaxis defines the y axis of the viewer
  49551. * @param zaxis defines the z axis of the viewer
  49552. */
  49553. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49554. /**
  49555. * Creates an instance of this axes viewer.
  49556. * @returns a new axes viewer with instanced meshes
  49557. */
  49558. createInstance(): AxesViewer;
  49559. /** Releases resources */
  49560. dispose(): void;
  49561. private static _SetRenderingGroupId;
  49562. }
  49563. }
  49564. declare module BABYLON.Debug {
  49565. /**
  49566. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49567. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49568. */
  49569. export class BoneAxesViewer extends AxesViewer {
  49570. /**
  49571. * Gets or sets the target mesh where to display the axes viewer
  49572. */
  49573. mesh: Nullable<Mesh>;
  49574. /**
  49575. * Gets or sets the target bone where to display the axes viewer
  49576. */
  49577. bone: Nullable<Bone>;
  49578. /** Gets current position */
  49579. pos: Vector3;
  49580. /** Gets direction of X axis */
  49581. xaxis: Vector3;
  49582. /** Gets direction of Y axis */
  49583. yaxis: Vector3;
  49584. /** Gets direction of Z axis */
  49585. zaxis: Vector3;
  49586. /**
  49587. * Creates a new BoneAxesViewer
  49588. * @param scene defines the hosting scene
  49589. * @param bone defines the target bone
  49590. * @param mesh defines the target mesh
  49591. * @param scaleLines defines a scaling factor for line length (1 by default)
  49592. */
  49593. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49594. /**
  49595. * Force the viewer to update
  49596. */
  49597. update(): void;
  49598. /** Releases resources */
  49599. dispose(): void;
  49600. }
  49601. }
  49602. declare module BABYLON {
  49603. /**
  49604. * Interface used to define scene explorer extensibility option
  49605. */
  49606. export interface IExplorerExtensibilityOption {
  49607. /**
  49608. * Define the option label
  49609. */
  49610. label: string;
  49611. /**
  49612. * Defines the action to execute on click
  49613. */
  49614. action: (entity: any) => void;
  49615. }
  49616. /**
  49617. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49618. */
  49619. export interface IExplorerExtensibilityGroup {
  49620. /**
  49621. * Defines a predicate to test if a given type mut be extended
  49622. */
  49623. predicate: (entity: any) => boolean;
  49624. /**
  49625. * Gets the list of options added to a type
  49626. */
  49627. entries: IExplorerExtensibilityOption[];
  49628. }
  49629. /**
  49630. * Interface used to define the options to use to create the Inspector
  49631. */
  49632. export interface IInspectorOptions {
  49633. /**
  49634. * Display in overlay mode (default: false)
  49635. */
  49636. overlay?: boolean;
  49637. /**
  49638. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49639. */
  49640. globalRoot?: HTMLElement;
  49641. /**
  49642. * Display the Scene explorer
  49643. */
  49644. showExplorer?: boolean;
  49645. /**
  49646. * Display the property inspector
  49647. */
  49648. showInspector?: boolean;
  49649. /**
  49650. * Display in embed mode (both panes on the right)
  49651. */
  49652. embedMode?: boolean;
  49653. /**
  49654. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49655. */
  49656. handleResize?: boolean;
  49657. /**
  49658. * Allow the panes to popup (default: true)
  49659. */
  49660. enablePopup?: boolean;
  49661. /**
  49662. * Allow the panes to be closed by users (default: true)
  49663. */
  49664. enableClose?: boolean;
  49665. /**
  49666. * Optional list of extensibility entries
  49667. */
  49668. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49669. /**
  49670. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49671. */
  49672. inspectorURL?: string;
  49673. /**
  49674. * Optional initial tab (default to DebugLayerTab.Properties)
  49675. */
  49676. initialTab?: DebugLayerTab;
  49677. }
  49678. interface Scene {
  49679. /**
  49680. * @hidden
  49681. * Backing field
  49682. */
  49683. _debugLayer: DebugLayer;
  49684. /**
  49685. * Gets the debug layer (aka Inspector) associated with the scene
  49686. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49687. */
  49688. debugLayer: DebugLayer;
  49689. }
  49690. /**
  49691. * Enum of inspector action tab
  49692. */
  49693. export enum DebugLayerTab {
  49694. /**
  49695. * Properties tag (default)
  49696. */
  49697. Properties = 0,
  49698. /**
  49699. * Debug tab
  49700. */
  49701. Debug = 1,
  49702. /**
  49703. * Statistics tab
  49704. */
  49705. Statistics = 2,
  49706. /**
  49707. * Tools tab
  49708. */
  49709. Tools = 3,
  49710. /**
  49711. * Settings tab
  49712. */
  49713. Settings = 4
  49714. }
  49715. /**
  49716. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49717. * what is happening in your scene
  49718. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49719. */
  49720. export class DebugLayer {
  49721. /**
  49722. * Define the url to get the inspector script from.
  49723. * By default it uses the babylonjs CDN.
  49724. * @ignoreNaming
  49725. */
  49726. static InspectorURL: string;
  49727. private _scene;
  49728. private BJSINSPECTOR;
  49729. private _onPropertyChangedObservable?;
  49730. /**
  49731. * Observable triggered when a property is changed through the inspector.
  49732. */
  49733. get onPropertyChangedObservable(): any;
  49734. /**
  49735. * Instantiates a new debug layer.
  49736. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49737. * what is happening in your scene
  49738. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49739. * @param scene Defines the scene to inspect
  49740. */
  49741. constructor(scene: Scene);
  49742. /** Creates the inspector window. */
  49743. private _createInspector;
  49744. /**
  49745. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49746. * @param entity defines the entity to select
  49747. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49748. */
  49749. select(entity: any, lineContainerTitles?: string | string[]): void;
  49750. /** Get the inspector from bundle or global */
  49751. private _getGlobalInspector;
  49752. /**
  49753. * Get if the inspector is visible or not.
  49754. * @returns true if visible otherwise, false
  49755. */
  49756. isVisible(): boolean;
  49757. /**
  49758. * Hide the inspector and close its window.
  49759. */
  49760. hide(): void;
  49761. /**
  49762. * Update the scene in the inspector
  49763. */
  49764. setAsActiveScene(): void;
  49765. /**
  49766. * Launch the debugLayer.
  49767. * @param config Define the configuration of the inspector
  49768. * @return a promise fulfilled when the debug layer is visible
  49769. */
  49770. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49771. }
  49772. }
  49773. declare module BABYLON {
  49774. /**
  49775. * Class containing static functions to help procedurally build meshes
  49776. */
  49777. export class BoxBuilder {
  49778. /**
  49779. * Creates a box mesh
  49780. * * The parameter `size` sets the size (float) of each box side (default 1)
  49781. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49782. * * 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)
  49783. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49785. * * 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
  49786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49787. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49788. * @param name defines the name of the mesh
  49789. * @param options defines the options used to create the mesh
  49790. * @param scene defines the hosting scene
  49791. * @returns the box mesh
  49792. */
  49793. static CreateBox(name: string, options: {
  49794. size?: number;
  49795. width?: number;
  49796. height?: number;
  49797. depth?: number;
  49798. faceUV?: Vector4[];
  49799. faceColors?: Color4[];
  49800. sideOrientation?: number;
  49801. frontUVs?: Vector4;
  49802. backUVs?: Vector4;
  49803. wrap?: boolean;
  49804. topBaseAt?: number;
  49805. bottomBaseAt?: number;
  49806. updatable?: boolean;
  49807. }, scene?: Nullable<Scene>): Mesh;
  49808. }
  49809. }
  49810. declare module BABYLON.Debug {
  49811. /**
  49812. * Used to show the physics impostor around the specific mesh
  49813. */
  49814. export class PhysicsViewer {
  49815. /** @hidden */
  49816. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49817. /** @hidden */
  49818. protected _meshes: Array<Nullable<AbstractMesh>>;
  49819. /** @hidden */
  49820. protected _scene: Nullable<Scene>;
  49821. /** @hidden */
  49822. protected _numMeshes: number;
  49823. /** @hidden */
  49824. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49825. private _renderFunction;
  49826. private _utilityLayer;
  49827. private _debugBoxMesh;
  49828. private _debugSphereMesh;
  49829. private _debugCylinderMesh;
  49830. private _debugMaterial;
  49831. private _debugMeshMeshes;
  49832. /**
  49833. * Creates a new PhysicsViewer
  49834. * @param scene defines the hosting scene
  49835. */
  49836. constructor(scene: Scene);
  49837. /** @hidden */
  49838. protected _updateDebugMeshes(): void;
  49839. /**
  49840. * Renders a specified physic impostor
  49841. * @param impostor defines the impostor to render
  49842. * @param targetMesh defines the mesh represented by the impostor
  49843. * @returns the new debug mesh used to render the impostor
  49844. */
  49845. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49846. /**
  49847. * Hides a specified physic impostor
  49848. * @param impostor defines the impostor to hide
  49849. */
  49850. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49851. private _getDebugMaterial;
  49852. private _getDebugBoxMesh;
  49853. private _getDebugSphereMesh;
  49854. private _getDebugCylinderMesh;
  49855. private _getDebugMeshMesh;
  49856. private _getDebugMesh;
  49857. /** Releases all resources */
  49858. dispose(): void;
  49859. }
  49860. }
  49861. declare module BABYLON {
  49862. /**
  49863. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49864. * in order to better appreciate the issue one might have.
  49865. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49866. */
  49867. export class RayHelper {
  49868. /**
  49869. * Defines the ray we are currently tryin to visualize.
  49870. */
  49871. ray: Nullable<Ray>;
  49872. private _renderPoints;
  49873. private _renderLine;
  49874. private _renderFunction;
  49875. private _scene;
  49876. private _updateToMeshFunction;
  49877. private _attachedToMesh;
  49878. private _meshSpaceDirection;
  49879. private _meshSpaceOrigin;
  49880. /**
  49881. * Helper function to create a colored helper in a scene in one line.
  49882. * @param ray Defines the ray we are currently tryin to visualize
  49883. * @param scene Defines the scene the ray is used in
  49884. * @param color Defines the color we want to see the ray in
  49885. * @returns The newly created ray helper.
  49886. */
  49887. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49888. /**
  49889. * Instantiate a new ray helper.
  49890. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49891. * in order to better appreciate the issue one might have.
  49892. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49893. * @param ray Defines the ray we are currently tryin to visualize
  49894. */
  49895. constructor(ray: Ray);
  49896. /**
  49897. * Shows the ray we are willing to debug.
  49898. * @param scene Defines the scene the ray needs to be rendered in
  49899. * @param color Defines the color the ray needs to be rendered in
  49900. */
  49901. show(scene: Scene, color?: Color3): void;
  49902. /**
  49903. * Hides the ray we are debugging.
  49904. */
  49905. hide(): void;
  49906. private _render;
  49907. /**
  49908. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49909. * @param mesh Defines the mesh we want the helper attached to
  49910. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49911. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49912. * @param length Defines the length of the ray
  49913. */
  49914. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49915. /**
  49916. * Detach the ray helper from the mesh it has previously been attached to.
  49917. */
  49918. detachFromMesh(): void;
  49919. private _updateToMesh;
  49920. /**
  49921. * Dispose the helper and release its associated resources.
  49922. */
  49923. dispose(): void;
  49924. }
  49925. }
  49926. declare module BABYLON.Debug {
  49927. /**
  49928. * Class used to render a debug view of a given skeleton
  49929. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49930. */
  49931. export class SkeletonViewer {
  49932. /** defines the skeleton to render */
  49933. skeleton: Skeleton;
  49934. /** defines the mesh attached to the skeleton */
  49935. mesh: AbstractMesh;
  49936. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49937. autoUpdateBonesMatrices: boolean;
  49938. /** defines the rendering group id to use with the viewer */
  49939. renderingGroupId: number;
  49940. /** Gets or sets the color used to render the skeleton */
  49941. color: Color3;
  49942. private _scene;
  49943. private _debugLines;
  49944. private _debugMesh;
  49945. private _isEnabled;
  49946. private _renderFunction;
  49947. private _utilityLayer;
  49948. /**
  49949. * Returns the mesh used to render the bones
  49950. */
  49951. get debugMesh(): Nullable<LinesMesh>;
  49952. /**
  49953. * Creates a new SkeletonViewer
  49954. * @param skeleton defines the skeleton to render
  49955. * @param mesh defines the mesh attached to the skeleton
  49956. * @param scene defines the hosting scene
  49957. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49958. * @param renderingGroupId defines the rendering group id to use with the viewer
  49959. */
  49960. constructor(
  49961. /** defines the skeleton to render */
  49962. skeleton: Skeleton,
  49963. /** defines the mesh attached to the skeleton */
  49964. mesh: AbstractMesh, scene: Scene,
  49965. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49966. autoUpdateBonesMatrices?: boolean,
  49967. /** defines the rendering group id to use with the viewer */
  49968. renderingGroupId?: number);
  49969. /** Gets or sets a boolean indicating if the viewer is enabled */
  49970. set isEnabled(value: boolean);
  49971. get isEnabled(): boolean;
  49972. private _getBonePosition;
  49973. private _getLinesForBonesWithLength;
  49974. private _getLinesForBonesNoLength;
  49975. /** Update the viewer to sync with current skeleton state */
  49976. update(): void;
  49977. /** Release associated resources */
  49978. dispose(): void;
  49979. }
  49980. }
  49981. declare module BABYLON {
  49982. /**
  49983. * Enum for Device Types
  49984. */
  49985. export enum DeviceType {
  49986. /** Generic */
  49987. Generic = 0,
  49988. /** Keyboard */
  49989. Keyboard = 1,
  49990. /** Mouse */
  49991. Mouse = 2,
  49992. /** Touch Pointers */
  49993. Touch = 3,
  49994. /** PS4 Dual Shock */
  49995. DualShock = 4,
  49996. /** Xbox */
  49997. Xbox = 5,
  49998. /** Switch Controller */
  49999. Switch = 6
  50000. }
  50001. /**
  50002. * Enum for All Pointers (Touch/Mouse)
  50003. */
  50004. export enum PointerInput {
  50005. /** Horizontal Axis */
  50006. Horizontal = 0,
  50007. /** Vertical Axis */
  50008. Vertical = 1,
  50009. /** Left Click or Touch */
  50010. LeftClick = 2,
  50011. /** Middle Click */
  50012. MiddleClick = 3,
  50013. /** Right Click */
  50014. RightClick = 4,
  50015. /** Browser Back */
  50016. BrowserBack = 5,
  50017. /** Browser Forward */
  50018. BrowserForward = 6
  50019. }
  50020. /**
  50021. * Enum for Dual Shock Gamepad
  50022. */
  50023. export enum DualShockInput {
  50024. /** Cross */
  50025. Cross = 0,
  50026. /** Circle */
  50027. Circle = 1,
  50028. /** Square */
  50029. Square = 2,
  50030. /** Triangle */
  50031. Triangle = 3,
  50032. /** L1 */
  50033. L1 = 4,
  50034. /** R1 */
  50035. R1 = 5,
  50036. /** L2 */
  50037. L2 = 6,
  50038. /** R2 */
  50039. R2 = 7,
  50040. /** Share */
  50041. Share = 8,
  50042. /** Options */
  50043. Options = 9,
  50044. /** L3 */
  50045. L3 = 10,
  50046. /** R3 */
  50047. R3 = 11,
  50048. /** DPadUp */
  50049. DPadUp = 12,
  50050. /** DPadDown */
  50051. DPadDown = 13,
  50052. /** DPadLeft */
  50053. DPadLeft = 14,
  50054. /** DRight */
  50055. DPadRight = 15,
  50056. /** Home */
  50057. Home = 16,
  50058. /** TouchPad */
  50059. TouchPad = 17,
  50060. /** LStickXAxis */
  50061. LStickXAxis = 18,
  50062. /** LStickYAxis */
  50063. LStickYAxis = 19,
  50064. /** RStickXAxis */
  50065. RStickXAxis = 20,
  50066. /** RStickYAxis */
  50067. RStickYAxis = 21
  50068. }
  50069. /**
  50070. * Enum for Xbox Gamepad
  50071. */
  50072. export enum XboxInput {
  50073. /** A */
  50074. A = 0,
  50075. /** B */
  50076. B = 1,
  50077. /** X */
  50078. X = 2,
  50079. /** Y */
  50080. Y = 3,
  50081. /** LB */
  50082. LB = 4,
  50083. /** RB */
  50084. RB = 5,
  50085. /** LT */
  50086. LT = 6,
  50087. /** RT */
  50088. RT = 7,
  50089. /** Back */
  50090. Back = 8,
  50091. /** Start */
  50092. Start = 9,
  50093. /** LS */
  50094. LS = 10,
  50095. /** RS */
  50096. RS = 11,
  50097. /** DPadUp */
  50098. DPadUp = 12,
  50099. /** DPadDown */
  50100. DPadDown = 13,
  50101. /** DPadLeft */
  50102. DPadLeft = 14,
  50103. /** DRight */
  50104. DPadRight = 15,
  50105. /** Home */
  50106. Home = 16,
  50107. /** LStickXAxis */
  50108. LStickXAxis = 17,
  50109. /** LStickYAxis */
  50110. LStickYAxis = 18,
  50111. /** RStickXAxis */
  50112. RStickXAxis = 19,
  50113. /** RStickYAxis */
  50114. RStickYAxis = 20
  50115. }
  50116. /**
  50117. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50118. */
  50119. export enum SwitchInput {
  50120. /** B */
  50121. B = 0,
  50122. /** A */
  50123. A = 1,
  50124. /** Y */
  50125. Y = 2,
  50126. /** X */
  50127. X = 3,
  50128. /** L */
  50129. L = 4,
  50130. /** R */
  50131. R = 5,
  50132. /** ZL */
  50133. ZL = 6,
  50134. /** ZR */
  50135. ZR = 7,
  50136. /** Minus */
  50137. Minus = 8,
  50138. /** Plus */
  50139. Plus = 9,
  50140. /** LS */
  50141. LS = 10,
  50142. /** RS */
  50143. RS = 11,
  50144. /** DPadUp */
  50145. DPadUp = 12,
  50146. /** DPadDown */
  50147. DPadDown = 13,
  50148. /** DPadLeft */
  50149. DPadLeft = 14,
  50150. /** DRight */
  50151. DPadRight = 15,
  50152. /** Home */
  50153. Home = 16,
  50154. /** Capture */
  50155. Capture = 17,
  50156. /** LStickXAxis */
  50157. LStickXAxis = 18,
  50158. /** LStickYAxis */
  50159. LStickYAxis = 19,
  50160. /** RStickXAxis */
  50161. RStickXAxis = 20,
  50162. /** RStickYAxis */
  50163. RStickYAxis = 21
  50164. }
  50165. }
  50166. declare module BABYLON {
  50167. /**
  50168. * This class will take all inputs from Keyboard, Pointer, and
  50169. * any Gamepads and provide a polling system that all devices
  50170. * will use. This class assumes that there will only be one
  50171. * pointer device and one keyboard.
  50172. */
  50173. export class DeviceInputSystem implements IDisposable {
  50174. /**
  50175. * Callback to be triggered when a device is connected
  50176. */
  50177. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50178. /**
  50179. * Callback to be triggered when a device is disconnected
  50180. */
  50181. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50182. /**
  50183. * Callback to be triggered when event driven input is updated
  50184. */
  50185. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50186. private _inputs;
  50187. private _gamepads;
  50188. private _keyboardActive;
  50189. private _pointerActive;
  50190. private _elementToAttachTo;
  50191. private _keyboardDownEvent;
  50192. private _keyboardUpEvent;
  50193. private _pointerMoveEvent;
  50194. private _pointerDownEvent;
  50195. private _pointerUpEvent;
  50196. private _gamepadConnectedEvent;
  50197. private _gamepadDisconnectedEvent;
  50198. private static _MAX_KEYCODES;
  50199. private static _MAX_POINTER_INPUTS;
  50200. private constructor();
  50201. /**
  50202. * Creates a new DeviceInputSystem instance
  50203. * @param engine Engine to pull input element from
  50204. * @returns The new instance
  50205. */
  50206. static Create(engine: Engine): DeviceInputSystem;
  50207. /**
  50208. * Checks for current device input value, given an id and input index
  50209. * @param deviceName Id of connected device
  50210. * @param inputIndex Index of device input
  50211. * @returns Current value of input
  50212. */
  50213. /**
  50214. * Checks for current device input value, given an id and input index
  50215. * @param deviceType Enum specifiying device type
  50216. * @param deviceSlot "Slot" or index that device is referenced in
  50217. * @param inputIndex Id of input to be checked
  50218. * @returns Current value of input
  50219. */
  50220. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50221. /**
  50222. * Dispose of all the eventlisteners
  50223. */
  50224. dispose(): void;
  50225. /**
  50226. * Add device and inputs to device array
  50227. * @param deviceType Enum specifiying device type
  50228. * @param deviceSlot "Slot" or index that device is referenced in
  50229. * @param numberOfInputs Number of input entries to create for given device
  50230. */
  50231. private _registerDevice;
  50232. /**
  50233. * Given a specific device name, remove that device from the device map
  50234. * @param deviceType Enum specifiying device type
  50235. * @param deviceSlot "Slot" or index that device is referenced in
  50236. */
  50237. private _unregisterDevice;
  50238. /**
  50239. * Handle all actions that come from keyboard interaction
  50240. */
  50241. private _handleKeyActions;
  50242. /**
  50243. * Handle all actions that come from pointer interaction
  50244. */
  50245. private _handlePointerActions;
  50246. /**
  50247. * Handle all actions that come from gamepad interaction
  50248. */
  50249. private _handleGamepadActions;
  50250. /**
  50251. * Update all non-event based devices with each frame
  50252. * @param deviceType Enum specifiying device type
  50253. * @param deviceSlot "Slot" or index that device is referenced in
  50254. * @param inputIndex Id of input to be checked
  50255. */
  50256. private _updateDevice;
  50257. /**
  50258. * Gets DeviceType from the device name
  50259. * @param deviceName Name of Device from DeviceInputSystem
  50260. * @returns DeviceType enum value
  50261. */
  50262. private _getGamepadDeviceType;
  50263. }
  50264. }
  50265. declare module BABYLON {
  50266. /**
  50267. * Type to handle enforcement of inputs
  50268. */
  50269. export type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : never;
  50270. }
  50271. declare module BABYLON {
  50272. /**
  50273. * Class that handles all input for a specific device
  50274. */
  50275. export class DeviceSource<T extends DeviceType> {
  50276. /** Type of device */
  50277. readonly deviceType: DeviceType;
  50278. /** "Slot" or index that device is referenced in */
  50279. readonly deviceSlot: number;
  50280. /**
  50281. * Observable to handle device input changes per device
  50282. */
  50283. readonly onInputChangedObservable: Observable<{
  50284. inputIndex: DeviceInput<T>;
  50285. previousState: Nullable<number>;
  50286. currentState: Nullable<number>;
  50287. }>;
  50288. private readonly _deviceInputSystem;
  50289. /**
  50290. * Default Constructor
  50291. * @param deviceInputSystem Reference to DeviceInputSystem
  50292. * @param deviceType Type of device
  50293. * @param deviceSlot "Slot" or index that device is referenced in
  50294. */
  50295. constructor(deviceInputSystem: DeviceInputSystem,
  50296. /** Type of device */
  50297. deviceType: DeviceType,
  50298. /** "Slot" or index that device is referenced in */
  50299. deviceSlot?: number);
  50300. /**
  50301. * Get input for specific input
  50302. * @param inputIndex index of specific input on device
  50303. * @returns Input value from DeviceInputSystem
  50304. */
  50305. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50306. }
  50307. /**
  50308. * Class to keep track of devices
  50309. */
  50310. export class DeviceSourceManager implements IDisposable {
  50311. /**
  50312. * Observable to be triggered when before a device is connected
  50313. */
  50314. readonly onBeforeDeviceConnectedObservable: Observable<{
  50315. deviceType: DeviceType;
  50316. deviceSlot: number;
  50317. }>;
  50318. /**
  50319. * Observable to be triggered when before a device is disconnected
  50320. */
  50321. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  50322. deviceType: DeviceType;
  50323. deviceSlot: number;
  50324. }>;
  50325. /**
  50326. * Observable to be triggered when after a device is connected
  50327. */
  50328. readonly onAfterDeviceConnectedObservable: Observable<{
  50329. deviceType: DeviceType;
  50330. deviceSlot: number;
  50331. }>;
  50332. /**
  50333. * Observable to be triggered when after a device is disconnected
  50334. */
  50335. readonly onAfterDeviceDisconnectedObservable: Observable<{
  50336. deviceType: DeviceType;
  50337. deviceSlot: number;
  50338. }>;
  50339. private readonly _devices;
  50340. private readonly _firstDevice;
  50341. private readonly _deviceInputSystem;
  50342. /**
  50343. * Default Constructor
  50344. * @param engine engine to pull input element from
  50345. */
  50346. constructor(engine: Engine);
  50347. /**
  50348. * Gets a DeviceSource, given a type and slot
  50349. * @param deviceType Enum specifying device type
  50350. * @param deviceSlot "Slot" or index that device is referenced in
  50351. * @returns DeviceSource object
  50352. */
  50353. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  50354. /**
  50355. * Gets an array of DeviceSource objects for a given device type
  50356. * @param deviceType Enum specifying device type
  50357. * @returns Array of DeviceSource objects
  50358. */
  50359. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  50360. /**
  50361. * Dispose of DeviceInputSystem and other parts
  50362. */
  50363. dispose(): void;
  50364. /**
  50365. * Function to add device name to device list
  50366. * @param deviceType Enum specifying device type
  50367. * @param deviceSlot "Slot" or index that device is referenced in
  50368. */
  50369. private _addDevice;
  50370. /**
  50371. * Function to remove device name to device list
  50372. * @param deviceType Enum specifying device type
  50373. * @param deviceSlot "Slot" or index that device is referenced in
  50374. */
  50375. private _removeDevice;
  50376. /**
  50377. * Updates array storing first connected device of each type
  50378. * @param type Type of Device
  50379. */
  50380. private _updateFirstDevices;
  50381. }
  50382. }
  50383. declare module BABYLON {
  50384. /**
  50385. * Options to create the null engine
  50386. */
  50387. export class NullEngineOptions {
  50388. /**
  50389. * Render width (Default: 512)
  50390. */
  50391. renderWidth: number;
  50392. /**
  50393. * Render height (Default: 256)
  50394. */
  50395. renderHeight: number;
  50396. /**
  50397. * Texture size (Default: 512)
  50398. */
  50399. textureSize: number;
  50400. /**
  50401. * If delta time between frames should be constant
  50402. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50403. */
  50404. deterministicLockstep: boolean;
  50405. /**
  50406. * Maximum about of steps between frames (Default: 4)
  50407. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50408. */
  50409. lockstepMaxSteps: number;
  50410. }
  50411. /**
  50412. * The null engine class provides support for headless version of babylon.js.
  50413. * This can be used in server side scenario or for testing purposes
  50414. */
  50415. export class NullEngine extends Engine {
  50416. private _options;
  50417. /**
  50418. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50419. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50420. * @returns true if engine is in deterministic lock step mode
  50421. */
  50422. isDeterministicLockStep(): boolean;
  50423. /**
  50424. * Gets the max steps when engine is running in deterministic lock step
  50425. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50426. * @returns the max steps
  50427. */
  50428. getLockstepMaxSteps(): number;
  50429. /**
  50430. * Gets the current hardware scaling level.
  50431. * By default the hardware scaling level is computed from the window device ratio.
  50432. * 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.
  50433. * @returns a number indicating the current hardware scaling level
  50434. */
  50435. getHardwareScalingLevel(): number;
  50436. constructor(options?: NullEngineOptions);
  50437. /**
  50438. * Creates a vertex buffer
  50439. * @param vertices the data for the vertex buffer
  50440. * @returns the new WebGL static buffer
  50441. */
  50442. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50443. /**
  50444. * Creates a new index buffer
  50445. * @param indices defines the content of the index buffer
  50446. * @param updatable defines if the index buffer must be updatable
  50447. * @returns a new webGL buffer
  50448. */
  50449. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50450. /**
  50451. * Clear the current render buffer or the current render target (if any is set up)
  50452. * @param color defines the color to use
  50453. * @param backBuffer defines if the back buffer must be cleared
  50454. * @param depth defines if the depth buffer must be cleared
  50455. * @param stencil defines if the stencil buffer must be cleared
  50456. */
  50457. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50458. /**
  50459. * Gets the current render width
  50460. * @param useScreen defines if screen size must be used (or the current render target if any)
  50461. * @returns a number defining the current render width
  50462. */
  50463. getRenderWidth(useScreen?: boolean): number;
  50464. /**
  50465. * Gets the current render height
  50466. * @param useScreen defines if screen size must be used (or the current render target if any)
  50467. * @returns a number defining the current render height
  50468. */
  50469. getRenderHeight(useScreen?: boolean): number;
  50470. /**
  50471. * Set the WebGL's viewport
  50472. * @param viewport defines the viewport element to be used
  50473. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50474. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50475. */
  50476. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50477. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50478. /**
  50479. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50480. * @param pipelineContext defines the pipeline context to use
  50481. * @param uniformsNames defines the list of uniform names
  50482. * @returns an array of webGL uniform locations
  50483. */
  50484. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50485. /**
  50486. * Gets the lsit of active attributes for a given webGL program
  50487. * @param pipelineContext defines the pipeline context to use
  50488. * @param attributesNames defines the list of attribute names to get
  50489. * @returns an array of indices indicating the offset of each attribute
  50490. */
  50491. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50492. /**
  50493. * Binds an effect to the webGL context
  50494. * @param effect defines the effect to bind
  50495. */
  50496. bindSamplers(effect: Effect): void;
  50497. /**
  50498. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50499. * @param effect defines the effect to activate
  50500. */
  50501. enableEffect(effect: Effect): void;
  50502. /**
  50503. * Set various states to the webGL context
  50504. * @param culling defines backface culling state
  50505. * @param zOffset defines the value to apply to zOffset (0 by default)
  50506. * @param force defines if states must be applied even if cache is up to date
  50507. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50508. */
  50509. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50510. /**
  50511. * Set the value of an uniform to an array of int32
  50512. * @param uniform defines the webGL uniform location where to store the value
  50513. * @param array defines the array of int32 to store
  50514. */
  50515. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50516. /**
  50517. * Set the value of an uniform to an array of int32 (stored as vec2)
  50518. * @param uniform defines the webGL uniform location where to store the value
  50519. * @param array defines the array of int32 to store
  50520. */
  50521. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50522. /**
  50523. * Set the value of an uniform to an array of int32 (stored as vec3)
  50524. * @param uniform defines the webGL uniform location where to store the value
  50525. * @param array defines the array of int32 to store
  50526. */
  50527. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50528. /**
  50529. * Set the value of an uniform to an array of int32 (stored as vec4)
  50530. * @param uniform defines the webGL uniform location where to store the value
  50531. * @param array defines the array of int32 to store
  50532. */
  50533. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50534. /**
  50535. * Set the value of an uniform to an array of float32
  50536. * @param uniform defines the webGL uniform location where to store the value
  50537. * @param array defines the array of float32 to store
  50538. */
  50539. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50540. /**
  50541. * Set the value of an uniform to an array of float32 (stored as vec2)
  50542. * @param uniform defines the webGL uniform location where to store the value
  50543. * @param array defines the array of float32 to store
  50544. */
  50545. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50546. /**
  50547. * Set the value of an uniform to an array of float32 (stored as vec3)
  50548. * @param uniform defines the webGL uniform location where to store the value
  50549. * @param array defines the array of float32 to store
  50550. */
  50551. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50552. /**
  50553. * Set the value of an uniform to an array of float32 (stored as vec4)
  50554. * @param uniform defines the webGL uniform location where to store the value
  50555. * @param array defines the array of float32 to store
  50556. */
  50557. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50558. /**
  50559. * Set the value of an uniform to an array of number
  50560. * @param uniform defines the webGL uniform location where to store the value
  50561. * @param array defines the array of number to store
  50562. */
  50563. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50564. /**
  50565. * Set the value of an uniform to an array of number (stored as vec2)
  50566. * @param uniform defines the webGL uniform location where to store the value
  50567. * @param array defines the array of number to store
  50568. */
  50569. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50570. /**
  50571. * Set the value of an uniform to an array of number (stored as vec3)
  50572. * @param uniform defines the webGL uniform location where to store the value
  50573. * @param array defines the array of number to store
  50574. */
  50575. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50576. /**
  50577. * Set the value of an uniform to an array of number (stored as vec4)
  50578. * @param uniform defines the webGL uniform location where to store the value
  50579. * @param array defines the array of number to store
  50580. */
  50581. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50582. /**
  50583. * Set the value of an uniform to an array of float32 (stored as matrices)
  50584. * @param uniform defines the webGL uniform location where to store the value
  50585. * @param matrices defines the array of float32 to store
  50586. */
  50587. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50588. /**
  50589. * Set the value of an uniform to a matrix (3x3)
  50590. * @param uniform defines the webGL uniform location where to store the value
  50591. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50592. */
  50593. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50594. /**
  50595. * Set the value of an uniform to a matrix (2x2)
  50596. * @param uniform defines the webGL uniform location where to store the value
  50597. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50598. */
  50599. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50600. /**
  50601. * Set the value of an uniform to a number (float)
  50602. * @param uniform defines the webGL uniform location where to store the value
  50603. * @param value defines the float number to store
  50604. */
  50605. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50606. /**
  50607. * Set the value of an uniform to a vec2
  50608. * @param uniform defines the webGL uniform location where to store the value
  50609. * @param x defines the 1st component of the value
  50610. * @param y defines the 2nd component of the value
  50611. */
  50612. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50613. /**
  50614. * Set the value of an uniform to a vec3
  50615. * @param uniform defines the webGL uniform location where to store the value
  50616. * @param x defines the 1st component of the value
  50617. * @param y defines the 2nd component of the value
  50618. * @param z defines the 3rd component of the value
  50619. */
  50620. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50621. /**
  50622. * Set the value of an uniform to a boolean
  50623. * @param uniform defines the webGL uniform location where to store the value
  50624. * @param bool defines the boolean to store
  50625. */
  50626. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50627. /**
  50628. * Set the value of an uniform to a vec4
  50629. * @param uniform defines the webGL uniform location where to store the value
  50630. * @param x defines the 1st component of the value
  50631. * @param y defines the 2nd component of the value
  50632. * @param z defines the 3rd component of the value
  50633. * @param w defines the 4th component of the value
  50634. */
  50635. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50636. /**
  50637. * Sets the current alpha mode
  50638. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50639. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50640. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50641. */
  50642. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50643. /**
  50644. * Bind webGl buffers directly to the webGL context
  50645. * @param vertexBuffers defines the vertex buffer to bind
  50646. * @param indexBuffer defines the index buffer to bind
  50647. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50648. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50649. * @param effect defines the effect associated with the vertex buffer
  50650. */
  50651. bindBuffers(vertexBuffers: {
  50652. [key: string]: VertexBuffer;
  50653. }, indexBuffer: DataBuffer, effect: Effect): void;
  50654. /**
  50655. * Force the entire cache to be cleared
  50656. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50657. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50658. */
  50659. wipeCaches(bruteForce?: boolean): void;
  50660. /**
  50661. * Send a draw order
  50662. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50663. * @param indexStart defines the starting index
  50664. * @param indexCount defines the number of index to draw
  50665. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50666. */
  50667. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50668. /**
  50669. * Draw a list of indexed primitives
  50670. * @param fillMode defines the primitive to use
  50671. * @param indexStart defines the starting index
  50672. * @param indexCount defines the number of index to draw
  50673. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50674. */
  50675. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50676. /**
  50677. * Draw a list of unindexed primitives
  50678. * @param fillMode defines the primitive to use
  50679. * @param verticesStart defines the index of first vertex to draw
  50680. * @param verticesCount defines the count of vertices to draw
  50681. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50682. */
  50683. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50684. /** @hidden */
  50685. _createTexture(): WebGLTexture;
  50686. /** @hidden */
  50687. _releaseTexture(texture: InternalTexture): void;
  50688. /**
  50689. * Usually called from Texture.ts.
  50690. * Passed information to create a WebGLTexture
  50691. * @param urlArg defines a value which contains one of the following:
  50692. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50693. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50694. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50695. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50696. * @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)
  50697. * @param scene needed for loading to the correct scene
  50698. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50699. * @param onLoad optional callback to be called upon successful completion
  50700. * @param onError optional callback to be called upon failure
  50701. * @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
  50702. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50703. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50704. * @param forcedExtension defines the extension to use to pick the right loader
  50705. * @param mimeType defines an optional mime type
  50706. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50707. */
  50708. 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;
  50709. /**
  50710. * Creates a new render target texture
  50711. * @param size defines the size of the texture
  50712. * @param options defines the options used to create the texture
  50713. * @returns a new render target texture stored in an InternalTexture
  50714. */
  50715. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50716. /**
  50717. * Update the sampling mode of a given texture
  50718. * @param samplingMode defines the required sampling mode
  50719. * @param texture defines the texture to update
  50720. */
  50721. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50722. /**
  50723. * Binds the frame buffer to the specified texture.
  50724. * @param texture The texture to render to or null for the default canvas
  50725. * @param faceIndex The face of the texture to render to in case of cube texture
  50726. * @param requiredWidth The width of the target to render to
  50727. * @param requiredHeight The height of the target to render to
  50728. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50729. * @param lodLevel defines le lod level to bind to the frame buffer
  50730. */
  50731. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50732. /**
  50733. * Unbind the current render target texture from the webGL context
  50734. * @param texture defines the render target texture to unbind
  50735. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50736. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50737. */
  50738. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50739. /**
  50740. * Creates a dynamic vertex buffer
  50741. * @param vertices the data for the dynamic vertex buffer
  50742. * @returns the new WebGL dynamic buffer
  50743. */
  50744. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50745. /**
  50746. * Update the content of a dynamic texture
  50747. * @param texture defines the texture to update
  50748. * @param canvas defines the canvas containing the source
  50749. * @param invertY defines if data must be stored with Y axis inverted
  50750. * @param premulAlpha defines if alpha is stored as premultiplied
  50751. * @param format defines the format of the data
  50752. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50753. */
  50754. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50755. /**
  50756. * Gets a boolean indicating if all created effects are ready
  50757. * @returns true if all effects are ready
  50758. */
  50759. areAllEffectsReady(): boolean;
  50760. /**
  50761. * @hidden
  50762. * Get the current error code of the webGL context
  50763. * @returns the error code
  50764. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50765. */
  50766. getError(): number;
  50767. /** @hidden */
  50768. _getUnpackAlignement(): number;
  50769. /** @hidden */
  50770. _unpackFlipY(value: boolean): void;
  50771. /**
  50772. * Update a dynamic index buffer
  50773. * @param indexBuffer defines the target index buffer
  50774. * @param indices defines the data to update
  50775. * @param offset defines the offset in the target index buffer where update should start
  50776. */
  50777. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50778. /**
  50779. * Updates a dynamic vertex buffer.
  50780. * @param vertexBuffer the vertex buffer to update
  50781. * @param vertices the data used to update the vertex buffer
  50782. * @param byteOffset the byte offset of the data (optional)
  50783. * @param byteLength the byte length of the data (optional)
  50784. */
  50785. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50786. /** @hidden */
  50787. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50788. /** @hidden */
  50789. _bindTexture(channel: number, texture: InternalTexture): void;
  50790. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50791. /**
  50792. * 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
  50793. */
  50794. releaseEffects(): void;
  50795. displayLoadingUI(): void;
  50796. hideLoadingUI(): void;
  50797. /** @hidden */
  50798. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50799. /** @hidden */
  50800. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50801. /** @hidden */
  50802. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50803. /** @hidden */
  50804. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50805. }
  50806. }
  50807. declare module BABYLON {
  50808. /**
  50809. * @hidden
  50810. **/
  50811. export class _TimeToken {
  50812. _startTimeQuery: Nullable<WebGLQuery>;
  50813. _endTimeQuery: Nullable<WebGLQuery>;
  50814. _timeElapsedQuery: Nullable<WebGLQuery>;
  50815. _timeElapsedQueryEnded: boolean;
  50816. }
  50817. }
  50818. declare module BABYLON {
  50819. /** @hidden */
  50820. export class _OcclusionDataStorage {
  50821. /** @hidden */
  50822. occlusionInternalRetryCounter: number;
  50823. /** @hidden */
  50824. isOcclusionQueryInProgress: boolean;
  50825. /** @hidden */
  50826. isOccluded: boolean;
  50827. /** @hidden */
  50828. occlusionRetryCount: number;
  50829. /** @hidden */
  50830. occlusionType: number;
  50831. /** @hidden */
  50832. occlusionQueryAlgorithmType: number;
  50833. }
  50834. interface Engine {
  50835. /**
  50836. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50837. * @return the new query
  50838. */
  50839. createQuery(): WebGLQuery;
  50840. /**
  50841. * Delete and release a webGL query
  50842. * @param query defines the query to delete
  50843. * @return the current engine
  50844. */
  50845. deleteQuery(query: WebGLQuery): Engine;
  50846. /**
  50847. * Check if a given query has resolved and got its value
  50848. * @param query defines the query to check
  50849. * @returns true if the query got its value
  50850. */
  50851. isQueryResultAvailable(query: WebGLQuery): boolean;
  50852. /**
  50853. * Gets the value of a given query
  50854. * @param query defines the query to check
  50855. * @returns the value of the query
  50856. */
  50857. getQueryResult(query: WebGLQuery): number;
  50858. /**
  50859. * Initiates an occlusion query
  50860. * @param algorithmType defines the algorithm to use
  50861. * @param query defines the query to use
  50862. * @returns the current engine
  50863. * @see http://doc.babylonjs.com/features/occlusionquery
  50864. */
  50865. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50866. /**
  50867. * Ends an occlusion query
  50868. * @see http://doc.babylonjs.com/features/occlusionquery
  50869. * @param algorithmType defines the algorithm to use
  50870. * @returns the current engine
  50871. */
  50872. endOcclusionQuery(algorithmType: number): Engine;
  50873. /**
  50874. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50875. * Please note that only one query can be issued at a time
  50876. * @returns a time token used to track the time span
  50877. */
  50878. startTimeQuery(): Nullable<_TimeToken>;
  50879. /**
  50880. * Ends a time query
  50881. * @param token defines the token used to measure the time span
  50882. * @returns the time spent (in ns)
  50883. */
  50884. endTimeQuery(token: _TimeToken): int;
  50885. /** @hidden */
  50886. _currentNonTimestampToken: Nullable<_TimeToken>;
  50887. /** @hidden */
  50888. _createTimeQuery(): WebGLQuery;
  50889. /** @hidden */
  50890. _deleteTimeQuery(query: WebGLQuery): void;
  50891. /** @hidden */
  50892. _getGlAlgorithmType(algorithmType: number): number;
  50893. /** @hidden */
  50894. _getTimeQueryResult(query: WebGLQuery): any;
  50895. /** @hidden */
  50896. _getTimeQueryAvailability(query: WebGLQuery): any;
  50897. }
  50898. interface AbstractMesh {
  50899. /**
  50900. * Backing filed
  50901. * @hidden
  50902. */
  50903. __occlusionDataStorage: _OcclusionDataStorage;
  50904. /**
  50905. * Access property
  50906. * @hidden
  50907. */
  50908. _occlusionDataStorage: _OcclusionDataStorage;
  50909. /**
  50910. * 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.
  50911. * The default value is -1 which means don't break the query and wait till the result
  50912. * @see http://doc.babylonjs.com/features/occlusionquery
  50913. */
  50914. occlusionRetryCount: number;
  50915. /**
  50916. * 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:
  50917. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50918. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50919. * * 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.
  50920. * @see http://doc.babylonjs.com/features/occlusionquery
  50921. */
  50922. occlusionType: number;
  50923. /**
  50924. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50925. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50926. * * 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.
  50927. * @see http://doc.babylonjs.com/features/occlusionquery
  50928. */
  50929. occlusionQueryAlgorithmType: number;
  50930. /**
  50931. * 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
  50932. * @see http://doc.babylonjs.com/features/occlusionquery
  50933. */
  50934. isOccluded: boolean;
  50935. /**
  50936. * Flag to check the progress status of the query
  50937. * @see http://doc.babylonjs.com/features/occlusionquery
  50938. */
  50939. isOcclusionQueryInProgress: boolean;
  50940. }
  50941. }
  50942. declare module BABYLON {
  50943. /** @hidden */
  50944. export var _forceTransformFeedbackToBundle: boolean;
  50945. interface Engine {
  50946. /**
  50947. * Creates a webGL transform feedback object
  50948. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50949. * @returns the webGL transform feedback object
  50950. */
  50951. createTransformFeedback(): WebGLTransformFeedback;
  50952. /**
  50953. * Delete a webGL transform feedback object
  50954. * @param value defines the webGL transform feedback object to delete
  50955. */
  50956. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50957. /**
  50958. * Bind a webGL transform feedback object to the webgl context
  50959. * @param value defines the webGL transform feedback object to bind
  50960. */
  50961. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50962. /**
  50963. * Begins a transform feedback operation
  50964. * @param usePoints defines if points or triangles must be used
  50965. */
  50966. beginTransformFeedback(usePoints: boolean): void;
  50967. /**
  50968. * Ends a transform feedback operation
  50969. */
  50970. endTransformFeedback(): void;
  50971. /**
  50972. * Specify the varyings to use with transform feedback
  50973. * @param program defines the associated webGL program
  50974. * @param value defines the list of strings representing the varying names
  50975. */
  50976. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50977. /**
  50978. * Bind a webGL buffer for a transform feedback operation
  50979. * @param value defines the webGL buffer to bind
  50980. */
  50981. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50982. }
  50983. }
  50984. declare module BABYLON {
  50985. /**
  50986. * Creation options of the multi render target texture.
  50987. */
  50988. export interface IMultiRenderTargetOptions {
  50989. /**
  50990. * Define if the texture needs to create mip maps after render.
  50991. */
  50992. generateMipMaps?: boolean;
  50993. /**
  50994. * Define the types of all the draw buffers we want to create
  50995. */
  50996. types?: number[];
  50997. /**
  50998. * Define the sampling modes of all the draw buffers we want to create
  50999. */
  51000. samplingModes?: number[];
  51001. /**
  51002. * Define if a depth buffer is required
  51003. */
  51004. generateDepthBuffer?: boolean;
  51005. /**
  51006. * Define if a stencil buffer is required
  51007. */
  51008. generateStencilBuffer?: boolean;
  51009. /**
  51010. * Define if a depth texture is required instead of a depth buffer
  51011. */
  51012. generateDepthTexture?: boolean;
  51013. /**
  51014. * Define the number of desired draw buffers
  51015. */
  51016. textureCount?: number;
  51017. /**
  51018. * Define if aspect ratio should be adapted to the texture or stay the scene one
  51019. */
  51020. doNotChangeAspectRatio?: boolean;
  51021. /**
  51022. * Define the default type of the buffers we are creating
  51023. */
  51024. defaultType?: number;
  51025. }
  51026. /**
  51027. * A multi render target, like a render target provides the ability to render to a texture.
  51028. * Unlike the render target, it can render to several draw buffers in one draw.
  51029. * This is specially interesting in deferred rendering or for any effects requiring more than
  51030. * just one color from a single pass.
  51031. */
  51032. export class MultiRenderTarget extends RenderTargetTexture {
  51033. private _internalTextures;
  51034. private _textures;
  51035. private _multiRenderTargetOptions;
  51036. /**
  51037. * Get if draw buffers are currently supported by the used hardware and browser.
  51038. */
  51039. get isSupported(): boolean;
  51040. /**
  51041. * Get the list of textures generated by the multi render target.
  51042. */
  51043. get textures(): Texture[];
  51044. /**
  51045. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  51046. */
  51047. get depthTexture(): Texture;
  51048. /**
  51049. * Set the wrapping mode on U of all the textures we are rendering to.
  51050. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51051. */
  51052. set wrapU(wrap: number);
  51053. /**
  51054. * Set the wrapping mode on V of all the textures we are rendering to.
  51055. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51056. */
  51057. set wrapV(wrap: number);
  51058. /**
  51059. * Instantiate a new multi render target texture.
  51060. * A multi render target, like a render target provides the ability to render to a texture.
  51061. * Unlike the render target, it can render to several draw buffers in one draw.
  51062. * This is specially interesting in deferred rendering or for any effects requiring more than
  51063. * just one color from a single pass.
  51064. * @param name Define the name of the texture
  51065. * @param size Define the size of the buffers to render to
  51066. * @param count Define the number of target we are rendering into
  51067. * @param scene Define the scene the texture belongs to
  51068. * @param options Define the options used to create the multi render target
  51069. */
  51070. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  51071. /** @hidden */
  51072. _rebuild(): void;
  51073. private _createInternalTextures;
  51074. private _createTextures;
  51075. /**
  51076. * Define the number of samples used if MSAA is enabled.
  51077. */
  51078. get samples(): number;
  51079. set samples(value: number);
  51080. /**
  51081. * Resize all the textures in the multi render target.
  51082. * Be carrefull as it will recreate all the data in the new texture.
  51083. * @param size Define the new size
  51084. */
  51085. resize(size: any): void;
  51086. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  51087. /**
  51088. * Dispose the render targets and their associated resources
  51089. */
  51090. dispose(): void;
  51091. /**
  51092. * Release all the underlying texture used as draw buffers.
  51093. */
  51094. releaseInternalTextures(): void;
  51095. }
  51096. }
  51097. declare module BABYLON {
  51098. interface ThinEngine {
  51099. /**
  51100. * Unbind a list of render target textures from the webGL context
  51101. * This is used only when drawBuffer extension or webGL2 are active
  51102. * @param textures defines the render target textures to unbind
  51103. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51104. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51105. */
  51106. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  51107. /**
  51108. * Create a multi render target texture
  51109. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  51110. * @param size defines the size of the texture
  51111. * @param options defines the creation options
  51112. * @returns the cube texture as an InternalTexture
  51113. */
  51114. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  51115. /**
  51116. * Update the sample count for a given multiple render target texture
  51117. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  51118. * @param textures defines the textures to update
  51119. * @param samples defines the sample count to set
  51120. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  51121. */
  51122. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  51123. }
  51124. }
  51125. declare module BABYLON {
  51126. /**
  51127. * Class used to define an additional view for the engine
  51128. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51129. */
  51130. export class EngineView {
  51131. /** Defines the canvas where to render the view */
  51132. target: HTMLCanvasElement;
  51133. /** Defines an optional camera used to render the view (will use active camera else) */
  51134. camera?: Camera;
  51135. }
  51136. interface Engine {
  51137. /**
  51138. * Gets or sets the HTML element to use for attaching events
  51139. */
  51140. inputElement: Nullable<HTMLElement>;
  51141. /**
  51142. * Gets the current engine view
  51143. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51144. */
  51145. activeView: Nullable<EngineView>;
  51146. /** Gets or sets the list of views */
  51147. views: EngineView[];
  51148. /**
  51149. * Register a new child canvas
  51150. * @param canvas defines the canvas to register
  51151. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51152. * @returns the associated view
  51153. */
  51154. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51155. /**
  51156. * Remove a registered child canvas
  51157. * @param canvas defines the canvas to remove
  51158. * @returns the current engine
  51159. */
  51160. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51161. }
  51162. }
  51163. declare module BABYLON {
  51164. interface Engine {
  51165. /** @hidden */
  51166. _excludedCompressedTextures: string[];
  51167. /** @hidden */
  51168. _textureFormatInUse: string;
  51169. /**
  51170. * Gets the list of texture formats supported
  51171. */
  51172. readonly texturesSupported: Array<string>;
  51173. /**
  51174. * Gets the texture format in use
  51175. */
  51176. readonly textureFormatInUse: Nullable<string>;
  51177. /**
  51178. * Set the compressed texture extensions or file names to skip.
  51179. *
  51180. * @param skippedFiles defines the list of those texture files you want to skip
  51181. * Example: [".dds", ".env", "myfile.png"]
  51182. */
  51183. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51184. /**
  51185. * Set the compressed texture format to use, based on the formats you have, and the formats
  51186. * supported by the hardware / browser.
  51187. *
  51188. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51189. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51190. * to API arguments needed to compressed textures. This puts the burden on the container
  51191. * generator to house the arcane code for determining these for current & future formats.
  51192. *
  51193. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51194. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51195. *
  51196. * Note: The result of this call is not taken into account when a texture is base64.
  51197. *
  51198. * @param formatsAvailable defines the list of those format families you have created
  51199. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51200. *
  51201. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51202. * @returns The extension selected.
  51203. */
  51204. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51205. }
  51206. }
  51207. declare module BABYLON {
  51208. /**
  51209. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51210. */
  51211. export interface CubeMapInfo {
  51212. /**
  51213. * The pixel array for the front face.
  51214. * This is stored in format, left to right, up to down format.
  51215. */
  51216. front: Nullable<ArrayBufferView>;
  51217. /**
  51218. * The pixel array for the back face.
  51219. * This is stored in format, left to right, up to down format.
  51220. */
  51221. back: Nullable<ArrayBufferView>;
  51222. /**
  51223. * The pixel array for the left face.
  51224. * This is stored in format, left to right, up to down format.
  51225. */
  51226. left: Nullable<ArrayBufferView>;
  51227. /**
  51228. * The pixel array for the right face.
  51229. * This is stored in format, left to right, up to down format.
  51230. */
  51231. right: Nullable<ArrayBufferView>;
  51232. /**
  51233. * The pixel array for the up face.
  51234. * This is stored in format, left to right, up to down format.
  51235. */
  51236. up: Nullable<ArrayBufferView>;
  51237. /**
  51238. * The pixel array for the down face.
  51239. * This is stored in format, left to right, up to down format.
  51240. */
  51241. down: Nullable<ArrayBufferView>;
  51242. /**
  51243. * The size of the cubemap stored.
  51244. *
  51245. * Each faces will be size * size pixels.
  51246. */
  51247. size: number;
  51248. /**
  51249. * The format of the texture.
  51250. *
  51251. * RGBA, RGB.
  51252. */
  51253. format: number;
  51254. /**
  51255. * The type of the texture data.
  51256. *
  51257. * UNSIGNED_INT, FLOAT.
  51258. */
  51259. type: number;
  51260. /**
  51261. * Specifies whether the texture is in gamma space.
  51262. */
  51263. gammaSpace: boolean;
  51264. }
  51265. /**
  51266. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51267. */
  51268. export class PanoramaToCubeMapTools {
  51269. private static FACE_LEFT;
  51270. private static FACE_RIGHT;
  51271. private static FACE_FRONT;
  51272. private static FACE_BACK;
  51273. private static FACE_DOWN;
  51274. private static FACE_UP;
  51275. /**
  51276. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51277. *
  51278. * @param float32Array The source data.
  51279. * @param inputWidth The width of the input panorama.
  51280. * @param inputHeight The height of the input panorama.
  51281. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51282. * @return The cubemap data
  51283. */
  51284. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51285. private static CreateCubemapTexture;
  51286. private static CalcProjectionSpherical;
  51287. }
  51288. }
  51289. declare module BABYLON {
  51290. /**
  51291. * Helper class dealing with the extraction of spherical polynomial dataArray
  51292. * from a cube map.
  51293. */
  51294. export class CubeMapToSphericalPolynomialTools {
  51295. private static FileFaces;
  51296. /**
  51297. * Converts a texture to the according Spherical Polynomial data.
  51298. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51299. *
  51300. * @param texture The texture to extract the information from.
  51301. * @return The Spherical Polynomial data.
  51302. */
  51303. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51304. /**
  51305. * Converts a cubemap to the according Spherical Polynomial data.
  51306. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51307. *
  51308. * @param cubeInfo The Cube map to extract the information from.
  51309. * @return The Spherical Polynomial data.
  51310. */
  51311. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51312. }
  51313. }
  51314. declare module BABYLON {
  51315. interface BaseTexture {
  51316. /**
  51317. * Get the polynomial representation of the texture data.
  51318. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51319. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51320. */
  51321. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51322. }
  51323. }
  51324. declare module BABYLON {
  51325. /** @hidden */
  51326. export var rgbdEncodePixelShader: {
  51327. name: string;
  51328. shader: string;
  51329. };
  51330. }
  51331. declare module BABYLON {
  51332. /** @hidden */
  51333. export var rgbdDecodePixelShader: {
  51334. name: string;
  51335. shader: string;
  51336. };
  51337. }
  51338. declare module BABYLON {
  51339. /**
  51340. * Raw texture data and descriptor sufficient for WebGL texture upload
  51341. */
  51342. export interface EnvironmentTextureInfo {
  51343. /**
  51344. * Version of the environment map
  51345. */
  51346. version: number;
  51347. /**
  51348. * Width of image
  51349. */
  51350. width: number;
  51351. /**
  51352. * Irradiance information stored in the file.
  51353. */
  51354. irradiance: any;
  51355. /**
  51356. * Specular information stored in the file.
  51357. */
  51358. specular: any;
  51359. }
  51360. /**
  51361. * Defines One Image in the file. It requires only the position in the file
  51362. * as well as the length.
  51363. */
  51364. interface BufferImageData {
  51365. /**
  51366. * Length of the image data.
  51367. */
  51368. length: number;
  51369. /**
  51370. * Position of the data from the null terminator delimiting the end of the JSON.
  51371. */
  51372. position: number;
  51373. }
  51374. /**
  51375. * Defines the specular data enclosed in the file.
  51376. * This corresponds to the version 1 of the data.
  51377. */
  51378. export interface EnvironmentTextureSpecularInfoV1 {
  51379. /**
  51380. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51381. */
  51382. specularDataPosition?: number;
  51383. /**
  51384. * This contains all the images data needed to reconstruct the cubemap.
  51385. */
  51386. mipmaps: Array<BufferImageData>;
  51387. /**
  51388. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51389. */
  51390. lodGenerationScale: number;
  51391. }
  51392. /**
  51393. * Sets of helpers addressing the serialization and deserialization of environment texture
  51394. * stored in a BabylonJS env file.
  51395. * Those files are usually stored as .env files.
  51396. */
  51397. export class EnvironmentTextureTools {
  51398. /**
  51399. * Magic number identifying the env file.
  51400. */
  51401. private static _MagicBytes;
  51402. /**
  51403. * Gets the environment info from an env file.
  51404. * @param data The array buffer containing the .env bytes.
  51405. * @returns the environment file info (the json header) if successfully parsed.
  51406. */
  51407. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51408. /**
  51409. * Creates an environment texture from a loaded cube texture.
  51410. * @param texture defines the cube texture to convert in env file
  51411. * @return a promise containing the environment data if succesfull.
  51412. */
  51413. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51414. /**
  51415. * Creates a JSON representation of the spherical data.
  51416. * @param texture defines the texture containing the polynomials
  51417. * @return the JSON representation of the spherical info
  51418. */
  51419. private static _CreateEnvTextureIrradiance;
  51420. /**
  51421. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51422. * @param data the image data
  51423. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51424. * @return the views described by info providing access to the underlying buffer
  51425. */
  51426. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51427. /**
  51428. * Uploads the texture info contained in the env file to the GPU.
  51429. * @param texture defines the internal texture to upload to
  51430. * @param data defines the data to load
  51431. * @param info defines the texture info retrieved through the GetEnvInfo method
  51432. * @returns a promise
  51433. */
  51434. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51435. private static _OnImageReadyAsync;
  51436. /**
  51437. * Uploads the levels of image data to the GPU.
  51438. * @param texture defines the internal texture to upload to
  51439. * @param imageData defines the array buffer views of image data [mipmap][face]
  51440. * @returns a promise
  51441. */
  51442. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51443. /**
  51444. * Uploads spherical polynomials information to the texture.
  51445. * @param texture defines the texture we are trying to upload the information to
  51446. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51447. */
  51448. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51449. /** @hidden */
  51450. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51451. }
  51452. }
  51453. declare module BABYLON {
  51454. /**
  51455. * Class used to inline functions in shader code
  51456. */
  51457. export class ShaderCodeInliner {
  51458. private static readonly _RegexpFindFunctionNameAndType;
  51459. private _sourceCode;
  51460. private _functionDescr;
  51461. private _numMaxIterations;
  51462. /** Gets or sets the token used to mark the functions to inline */
  51463. inlineToken: string;
  51464. /** Gets or sets the debug mode */
  51465. debug: boolean;
  51466. /** Gets the code after the inlining process */
  51467. get code(): string;
  51468. /**
  51469. * Initializes the inliner
  51470. * @param sourceCode shader code source to inline
  51471. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51472. */
  51473. constructor(sourceCode: string, numMaxIterations?: number);
  51474. /**
  51475. * Start the processing of the shader code
  51476. */
  51477. processCode(): void;
  51478. private _collectFunctions;
  51479. private _processInlining;
  51480. private _extractBetweenMarkers;
  51481. private _skipWhitespaces;
  51482. private _removeComments;
  51483. private _replaceFunctionCallsByCode;
  51484. private _findBackward;
  51485. private _escapeRegExp;
  51486. private _replaceNames;
  51487. }
  51488. }
  51489. declare module BABYLON {
  51490. /**
  51491. * Container for accessors for natively-stored mesh data buffers.
  51492. */
  51493. class NativeDataBuffer extends DataBuffer {
  51494. /**
  51495. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51496. */
  51497. nativeIndexBuffer?: any;
  51498. /**
  51499. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51500. */
  51501. nativeVertexBuffer?: any;
  51502. }
  51503. /** @hidden */
  51504. class NativeTexture extends InternalTexture {
  51505. getInternalTexture(): InternalTexture;
  51506. getViewCount(): number;
  51507. }
  51508. /** @hidden */
  51509. export class NativeEngine extends Engine {
  51510. private readonly _native;
  51511. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51512. private readonly INVALID_HANDLE;
  51513. getHardwareScalingLevel(): number;
  51514. constructor();
  51515. dispose(): void;
  51516. /**
  51517. * Can be used to override the current requestAnimationFrame requester.
  51518. * @hidden
  51519. */
  51520. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51521. /**
  51522. * Override default engine behavior.
  51523. * @param color
  51524. * @param backBuffer
  51525. * @param depth
  51526. * @param stencil
  51527. */
  51528. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51529. /**
  51530. * Gets host document
  51531. * @returns the host document object
  51532. */
  51533. getHostDocument(): Nullable<Document>;
  51534. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51535. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51536. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51537. recordVertexArrayObject(vertexBuffers: {
  51538. [key: string]: VertexBuffer;
  51539. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51540. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51541. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51542. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51543. /**
  51544. * Draw a list of indexed primitives
  51545. * @param fillMode defines the primitive to use
  51546. * @param indexStart defines the starting index
  51547. * @param indexCount defines the number of index to draw
  51548. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51549. */
  51550. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51551. /**
  51552. * Draw a list of unindexed primitives
  51553. * @param fillMode defines the primitive to use
  51554. * @param verticesStart defines the index of first vertex to draw
  51555. * @param verticesCount defines the count of vertices to draw
  51556. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51557. */
  51558. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51559. createPipelineContext(): IPipelineContext;
  51560. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51561. /** @hidden */
  51562. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51563. /** @hidden */
  51564. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51565. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51566. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51567. protected _setProgram(program: WebGLProgram): void;
  51568. _releaseEffect(effect: Effect): void;
  51569. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51570. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51571. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51572. bindSamplers(effect: Effect): void;
  51573. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51574. getRenderWidth(useScreen?: boolean): number;
  51575. getRenderHeight(useScreen?: boolean): number;
  51576. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51577. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51578. /**
  51579. * Set the z offset to apply to current rendering
  51580. * @param value defines the offset to apply
  51581. */
  51582. setZOffset(value: number): void;
  51583. /**
  51584. * Gets the current value of the zOffset
  51585. * @returns the current zOffset state
  51586. */
  51587. getZOffset(): number;
  51588. /**
  51589. * Enable or disable depth buffering
  51590. * @param enable defines the state to set
  51591. */
  51592. setDepthBuffer(enable: boolean): void;
  51593. /**
  51594. * Gets a boolean indicating if depth writing is enabled
  51595. * @returns the current depth writing state
  51596. */
  51597. getDepthWrite(): boolean;
  51598. /**
  51599. * Enable or disable depth writing
  51600. * @param enable defines the state to set
  51601. */
  51602. setDepthWrite(enable: boolean): void;
  51603. /**
  51604. * Enable or disable color writing
  51605. * @param enable defines the state to set
  51606. */
  51607. setColorWrite(enable: boolean): void;
  51608. /**
  51609. * Gets a boolean indicating if color writing is enabled
  51610. * @returns the current color writing state
  51611. */
  51612. getColorWrite(): boolean;
  51613. /**
  51614. * Sets alpha constants used by some alpha blending modes
  51615. * @param r defines the red component
  51616. * @param g defines the green component
  51617. * @param b defines the blue component
  51618. * @param a defines the alpha component
  51619. */
  51620. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51621. /**
  51622. * Sets the current alpha mode
  51623. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51624. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51625. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51626. */
  51627. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51628. /**
  51629. * Gets the current alpha mode
  51630. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51631. * @returns the current alpha mode
  51632. */
  51633. getAlphaMode(): number;
  51634. setInt(uniform: WebGLUniformLocation, int: number): void;
  51635. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51636. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51637. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51638. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51639. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51640. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51641. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51642. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51643. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51644. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51645. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51646. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51647. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51648. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51649. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51650. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51651. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51652. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51653. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51654. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51655. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51656. wipeCaches(bruteForce?: boolean): void;
  51657. _createTexture(): WebGLTexture;
  51658. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51659. /**
  51660. * Usually called from Texture.ts.
  51661. * Passed information to create a WebGLTexture
  51662. * @param url defines a value which contains one of the following:
  51663. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51664. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51665. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51666. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51667. * @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)
  51668. * @param scene needed for loading to the correct scene
  51669. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51670. * @param onLoad optional callback to be called upon successful completion
  51671. * @param onError optional callback to be called upon failure
  51672. * @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
  51673. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51674. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51675. * @param forcedExtension defines the extension to use to pick the right loader
  51676. * @param mimeType defines an optional mime type
  51677. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51678. */
  51679. createTexture(url: 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;
  51680. /**
  51681. * Creates a cube texture
  51682. * @param rootUrl defines the url where the files to load is located
  51683. * @param scene defines the current scene
  51684. * @param files defines the list of files to load (1 per face)
  51685. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51686. * @param onLoad defines an optional callback raised when the texture is loaded
  51687. * @param onError defines an optional callback raised if there is an issue to load the texture
  51688. * @param format defines the format of the data
  51689. * @param forcedExtension defines the extension to use to pick the right loader
  51690. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51691. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51692. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51693. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51694. * @returns the cube texture as an InternalTexture
  51695. */
  51696. 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;
  51697. private _getSamplingFilter;
  51698. private static _GetNativeTextureFormat;
  51699. createRenderTargetTexture(size: number | {
  51700. width: number;
  51701. height: number;
  51702. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51703. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51704. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51705. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51706. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51707. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51708. /**
  51709. * Updates a dynamic vertex buffer.
  51710. * @param vertexBuffer the vertex buffer to update
  51711. * @param data the data used to update the vertex buffer
  51712. * @param byteOffset the byte offset of the data (optional)
  51713. * @param byteLength the byte length of the data (optional)
  51714. */
  51715. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51716. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51717. private _updateAnisotropicLevel;
  51718. private _getAddressMode;
  51719. /** @hidden */
  51720. _bindTexture(channel: number, texture: InternalTexture): void;
  51721. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51722. releaseEffects(): void;
  51723. /** @hidden */
  51724. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51725. /** @hidden */
  51726. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51727. /** @hidden */
  51728. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51729. /** @hidden */
  51730. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51731. }
  51732. }
  51733. declare module BABYLON {
  51734. /**
  51735. * Gather the list of clipboard event types as constants.
  51736. */
  51737. export class ClipboardEventTypes {
  51738. /**
  51739. * The clipboard event is fired when a copy command is active (pressed).
  51740. */
  51741. static readonly COPY: number;
  51742. /**
  51743. * The clipboard event is fired when a cut command is active (pressed).
  51744. */
  51745. static readonly CUT: number;
  51746. /**
  51747. * The clipboard event is fired when a paste command is active (pressed).
  51748. */
  51749. static readonly PASTE: number;
  51750. }
  51751. /**
  51752. * This class is used to store clipboard related info for the onClipboardObservable event.
  51753. */
  51754. export class ClipboardInfo {
  51755. /**
  51756. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51757. */
  51758. type: number;
  51759. /**
  51760. * Defines the related dom event
  51761. */
  51762. event: ClipboardEvent;
  51763. /**
  51764. *Creates an instance of ClipboardInfo.
  51765. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51766. * @param event Defines the related dom event
  51767. */
  51768. constructor(
  51769. /**
  51770. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51771. */
  51772. type: number,
  51773. /**
  51774. * Defines the related dom event
  51775. */
  51776. event: ClipboardEvent);
  51777. /**
  51778. * Get the clipboard event's type from the keycode.
  51779. * @param keyCode Defines the keyCode for the current keyboard event.
  51780. * @return {number}
  51781. */
  51782. static GetTypeFromCharacter(keyCode: number): number;
  51783. }
  51784. }
  51785. declare module BABYLON {
  51786. /**
  51787. * Google Daydream controller
  51788. */
  51789. export class DaydreamController extends WebVRController {
  51790. /**
  51791. * Base Url for the controller model.
  51792. */
  51793. static MODEL_BASE_URL: string;
  51794. /**
  51795. * File name for the controller model.
  51796. */
  51797. static MODEL_FILENAME: string;
  51798. /**
  51799. * Gamepad Id prefix used to identify Daydream Controller.
  51800. */
  51801. static readonly GAMEPAD_ID_PREFIX: string;
  51802. /**
  51803. * Creates a new DaydreamController from a gamepad
  51804. * @param vrGamepad the gamepad that the controller should be created from
  51805. */
  51806. constructor(vrGamepad: any);
  51807. /**
  51808. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51809. * @param scene scene in which to add meshes
  51810. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51811. */
  51812. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51813. /**
  51814. * Called once for each button that changed state since the last frame
  51815. * @param buttonIdx Which button index changed
  51816. * @param state New state of the button
  51817. * @param changes Which properties on the state changed since last frame
  51818. */
  51819. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51820. }
  51821. }
  51822. declare module BABYLON {
  51823. /**
  51824. * Gear VR Controller
  51825. */
  51826. export class GearVRController extends WebVRController {
  51827. /**
  51828. * Base Url for the controller model.
  51829. */
  51830. static MODEL_BASE_URL: string;
  51831. /**
  51832. * File name for the controller model.
  51833. */
  51834. static MODEL_FILENAME: string;
  51835. /**
  51836. * Gamepad Id prefix used to identify this controller.
  51837. */
  51838. static readonly GAMEPAD_ID_PREFIX: string;
  51839. private readonly _buttonIndexToObservableNameMap;
  51840. /**
  51841. * Creates a new GearVRController from a gamepad
  51842. * @param vrGamepad the gamepad that the controller should be created from
  51843. */
  51844. constructor(vrGamepad: any);
  51845. /**
  51846. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51847. * @param scene scene in which to add meshes
  51848. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51849. */
  51850. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51851. /**
  51852. * Called once for each button that changed state since the last frame
  51853. * @param buttonIdx Which button index changed
  51854. * @param state New state of the button
  51855. * @param changes Which properties on the state changed since last frame
  51856. */
  51857. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51858. }
  51859. }
  51860. declare module BABYLON {
  51861. /**
  51862. * Generic Controller
  51863. */
  51864. export class GenericController extends WebVRController {
  51865. /**
  51866. * Base Url for the controller model.
  51867. */
  51868. static readonly MODEL_BASE_URL: string;
  51869. /**
  51870. * File name for the controller model.
  51871. */
  51872. static readonly MODEL_FILENAME: string;
  51873. /**
  51874. * Creates a new GenericController from a gamepad
  51875. * @param vrGamepad the gamepad that the controller should be created from
  51876. */
  51877. constructor(vrGamepad: any);
  51878. /**
  51879. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51880. * @param scene scene in which to add meshes
  51881. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51882. */
  51883. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51884. /**
  51885. * Called once for each button that changed state since the last frame
  51886. * @param buttonIdx Which button index changed
  51887. * @param state New state of the button
  51888. * @param changes Which properties on the state changed since last frame
  51889. */
  51890. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51891. }
  51892. }
  51893. declare module BABYLON {
  51894. /**
  51895. * Oculus Touch Controller
  51896. */
  51897. export class OculusTouchController extends WebVRController {
  51898. /**
  51899. * Base Url for the controller model.
  51900. */
  51901. static MODEL_BASE_URL: string;
  51902. /**
  51903. * File name for the left controller model.
  51904. */
  51905. static MODEL_LEFT_FILENAME: string;
  51906. /**
  51907. * File name for the right controller model.
  51908. */
  51909. static MODEL_RIGHT_FILENAME: string;
  51910. /**
  51911. * Base Url for the Quest controller model.
  51912. */
  51913. static QUEST_MODEL_BASE_URL: string;
  51914. /**
  51915. * @hidden
  51916. * If the controllers are running on a device that needs the updated Quest controller models
  51917. */
  51918. static _IsQuest: boolean;
  51919. /**
  51920. * Fired when the secondary trigger on this controller is modified
  51921. */
  51922. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51923. /**
  51924. * Fired when the thumb rest on this controller is modified
  51925. */
  51926. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51927. /**
  51928. * Creates a new OculusTouchController from a gamepad
  51929. * @param vrGamepad the gamepad that the controller should be created from
  51930. */
  51931. constructor(vrGamepad: any);
  51932. /**
  51933. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51934. * @param scene scene in which to add meshes
  51935. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51936. */
  51937. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51938. /**
  51939. * Fired when the A button on this controller is modified
  51940. */
  51941. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51942. /**
  51943. * Fired when the B button on this controller is modified
  51944. */
  51945. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51946. /**
  51947. * Fired when the X button on this controller is modified
  51948. */
  51949. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51950. /**
  51951. * Fired when the Y button on this controller is modified
  51952. */
  51953. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51954. /**
  51955. * Called once for each button that changed state since the last frame
  51956. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51957. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51958. * 2) secondary trigger (same)
  51959. * 3) A (right) X (left), touch, pressed = value
  51960. * 4) B / Y
  51961. * 5) thumb rest
  51962. * @param buttonIdx Which button index changed
  51963. * @param state New state of the button
  51964. * @param changes Which properties on the state changed since last frame
  51965. */
  51966. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51967. }
  51968. }
  51969. declare module BABYLON {
  51970. /**
  51971. * Vive Controller
  51972. */
  51973. export class ViveController extends WebVRController {
  51974. /**
  51975. * Base Url for the controller model.
  51976. */
  51977. static MODEL_BASE_URL: string;
  51978. /**
  51979. * File name for the controller model.
  51980. */
  51981. static MODEL_FILENAME: string;
  51982. /**
  51983. * Creates a new ViveController from a gamepad
  51984. * @param vrGamepad the gamepad that the controller should be created from
  51985. */
  51986. constructor(vrGamepad: any);
  51987. /**
  51988. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51989. * @param scene scene in which to add meshes
  51990. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51991. */
  51992. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51993. /**
  51994. * Fired when the left button on this controller is modified
  51995. */
  51996. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51997. /**
  51998. * Fired when the right button on this controller is modified
  51999. */
  52000. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52001. /**
  52002. * Fired when the menu button on this controller is modified
  52003. */
  52004. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52005. /**
  52006. * Called once for each button that changed state since the last frame
  52007. * Vive mapping:
  52008. * 0: touchpad
  52009. * 1: trigger
  52010. * 2: left AND right buttons
  52011. * 3: menu button
  52012. * @param buttonIdx Which button index changed
  52013. * @param state New state of the button
  52014. * @param changes Which properties on the state changed since last frame
  52015. */
  52016. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52017. }
  52018. }
  52019. declare module BABYLON {
  52020. /**
  52021. * Defines the WindowsMotionController object that the state of the windows motion controller
  52022. */
  52023. export class WindowsMotionController extends WebVRController {
  52024. /**
  52025. * The base url used to load the left and right controller models
  52026. */
  52027. static MODEL_BASE_URL: string;
  52028. /**
  52029. * The name of the left controller model file
  52030. */
  52031. static MODEL_LEFT_FILENAME: string;
  52032. /**
  52033. * The name of the right controller model file
  52034. */
  52035. static MODEL_RIGHT_FILENAME: string;
  52036. /**
  52037. * The controller name prefix for this controller type
  52038. */
  52039. static readonly GAMEPAD_ID_PREFIX: string;
  52040. /**
  52041. * The controller id pattern for this controller type
  52042. */
  52043. private static readonly GAMEPAD_ID_PATTERN;
  52044. private _loadedMeshInfo;
  52045. protected readonly _mapping: {
  52046. buttons: string[];
  52047. buttonMeshNames: {
  52048. trigger: string;
  52049. menu: string;
  52050. grip: string;
  52051. thumbstick: string;
  52052. trackpad: string;
  52053. };
  52054. buttonObservableNames: {
  52055. trigger: string;
  52056. menu: string;
  52057. grip: string;
  52058. thumbstick: string;
  52059. trackpad: string;
  52060. };
  52061. axisMeshNames: string[];
  52062. pointingPoseMeshName: string;
  52063. };
  52064. /**
  52065. * Fired when the trackpad on this controller is clicked
  52066. */
  52067. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52068. /**
  52069. * Fired when the trackpad on this controller is modified
  52070. */
  52071. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52072. /**
  52073. * The current x and y values of this controller's trackpad
  52074. */
  52075. trackpad: StickValues;
  52076. /**
  52077. * Creates a new WindowsMotionController from a gamepad
  52078. * @param vrGamepad the gamepad that the controller should be created from
  52079. */
  52080. constructor(vrGamepad: any);
  52081. /**
  52082. * Fired when the trigger on this controller is modified
  52083. */
  52084. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52085. /**
  52086. * Fired when the menu button on this controller is modified
  52087. */
  52088. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52089. /**
  52090. * Fired when the grip button on this controller is modified
  52091. */
  52092. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52093. /**
  52094. * Fired when the thumbstick button on this controller is modified
  52095. */
  52096. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52097. /**
  52098. * Fired when the touchpad button on this controller is modified
  52099. */
  52100. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52101. /**
  52102. * Fired when the touchpad values on this controller are modified
  52103. */
  52104. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52105. protected _updateTrackpad(): void;
  52106. /**
  52107. * Called once per frame by the engine.
  52108. */
  52109. update(): void;
  52110. /**
  52111. * Called once for each button that changed state since the last frame
  52112. * @param buttonIdx Which button index changed
  52113. * @param state New state of the button
  52114. * @param changes Which properties on the state changed since last frame
  52115. */
  52116. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52117. /**
  52118. * Moves the buttons on the controller mesh based on their current state
  52119. * @param buttonName the name of the button to move
  52120. * @param buttonValue the value of the button which determines the buttons new position
  52121. */
  52122. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52123. /**
  52124. * Moves the axis on the controller mesh based on its current state
  52125. * @param axis the index of the axis
  52126. * @param axisValue the value of the axis which determines the meshes new position
  52127. * @hidden
  52128. */
  52129. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52130. /**
  52131. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52132. * @param scene scene in which to add meshes
  52133. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52134. */
  52135. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52136. /**
  52137. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52138. * can be transformed by button presses and axes values, based on this._mapping.
  52139. *
  52140. * @param scene scene in which the meshes exist
  52141. * @param meshes list of meshes that make up the controller model to process
  52142. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52143. */
  52144. private processModel;
  52145. private createMeshInfo;
  52146. /**
  52147. * Gets the ray of the controller in the direction the controller is pointing
  52148. * @param length the length the resulting ray should be
  52149. * @returns a ray in the direction the controller is pointing
  52150. */
  52151. getForwardRay(length?: number): Ray;
  52152. /**
  52153. * Disposes of the controller
  52154. */
  52155. dispose(): void;
  52156. }
  52157. /**
  52158. * This class represents a new windows motion controller in XR.
  52159. */
  52160. export class XRWindowsMotionController extends WindowsMotionController {
  52161. /**
  52162. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52163. */
  52164. protected readonly _mapping: {
  52165. buttons: string[];
  52166. buttonMeshNames: {
  52167. trigger: string;
  52168. menu: string;
  52169. grip: string;
  52170. thumbstick: string;
  52171. trackpad: string;
  52172. };
  52173. buttonObservableNames: {
  52174. trigger: string;
  52175. menu: string;
  52176. grip: string;
  52177. thumbstick: string;
  52178. trackpad: string;
  52179. };
  52180. axisMeshNames: string[];
  52181. pointingPoseMeshName: string;
  52182. };
  52183. /**
  52184. * Construct a new XR-Based windows motion controller
  52185. *
  52186. * @param gamepadInfo the gamepad object from the browser
  52187. */
  52188. constructor(gamepadInfo: any);
  52189. /**
  52190. * holds the thumbstick values (X,Y)
  52191. */
  52192. thumbstickValues: StickValues;
  52193. /**
  52194. * Fired when the thumbstick on this controller is clicked
  52195. */
  52196. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52197. /**
  52198. * Fired when the thumbstick on this controller is modified
  52199. */
  52200. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52201. /**
  52202. * Fired when the touchpad button on this controller is modified
  52203. */
  52204. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52205. /**
  52206. * Fired when the touchpad values on this controller are modified
  52207. */
  52208. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52209. /**
  52210. * Fired when the thumbstick button on this controller is modified
  52211. * here to prevent breaking changes
  52212. */
  52213. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52214. /**
  52215. * updating the thumbstick(!) and not the trackpad.
  52216. * This is named this way due to the difference between WebVR and XR and to avoid
  52217. * changing the parent class.
  52218. */
  52219. protected _updateTrackpad(): void;
  52220. /**
  52221. * Disposes the class with joy
  52222. */
  52223. dispose(): void;
  52224. }
  52225. }
  52226. declare module BABYLON {
  52227. /**
  52228. * Class containing static functions to help procedurally build meshes
  52229. */
  52230. export class PolyhedronBuilder {
  52231. /**
  52232. * Creates a polyhedron mesh
  52233. * * 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
  52234. * * The parameter `size` (positive float, default 1) sets the polygon size
  52235. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52236. * * 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`
  52237. * * 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
  52238. * * 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)`)
  52239. * * 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
  52240. * * 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
  52241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52242. * * 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
  52243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52244. * @param name defines the name of the mesh
  52245. * @param options defines the options used to create the mesh
  52246. * @param scene defines the hosting scene
  52247. * @returns the polyhedron mesh
  52248. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52249. */
  52250. static CreatePolyhedron(name: string, options: {
  52251. type?: number;
  52252. size?: number;
  52253. sizeX?: number;
  52254. sizeY?: number;
  52255. sizeZ?: number;
  52256. custom?: any;
  52257. faceUV?: Vector4[];
  52258. faceColors?: Color4[];
  52259. flat?: boolean;
  52260. updatable?: boolean;
  52261. sideOrientation?: number;
  52262. frontUVs?: Vector4;
  52263. backUVs?: Vector4;
  52264. }, scene?: Nullable<Scene>): Mesh;
  52265. }
  52266. }
  52267. declare module BABYLON {
  52268. /**
  52269. * Gizmo that enables scaling a mesh along 3 axis
  52270. */
  52271. export class ScaleGizmo extends Gizmo {
  52272. /**
  52273. * Internal gizmo used for interactions on the x axis
  52274. */
  52275. xGizmo: AxisScaleGizmo;
  52276. /**
  52277. * Internal gizmo used for interactions on the y axis
  52278. */
  52279. yGizmo: AxisScaleGizmo;
  52280. /**
  52281. * Internal gizmo used for interactions on the z axis
  52282. */
  52283. zGizmo: AxisScaleGizmo;
  52284. /**
  52285. * Internal gizmo used to scale all axis equally
  52286. */
  52287. uniformScaleGizmo: AxisScaleGizmo;
  52288. private _meshAttached;
  52289. private _updateGizmoRotationToMatchAttachedMesh;
  52290. private _snapDistance;
  52291. private _scaleRatio;
  52292. private _uniformScalingMesh;
  52293. private _octahedron;
  52294. private _sensitivity;
  52295. /** Fires an event when any of it's sub gizmos are dragged */
  52296. onDragStartObservable: Observable<unknown>;
  52297. /** Fires an event when any of it's sub gizmos are released from dragging */
  52298. onDragEndObservable: Observable<unknown>;
  52299. get attachedMesh(): Nullable<AbstractMesh>;
  52300. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52301. /**
  52302. * Creates a ScaleGizmo
  52303. * @param gizmoLayer The utility layer the gizmo will be added to
  52304. */
  52305. constructor(gizmoLayer?: UtilityLayerRenderer);
  52306. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52307. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52308. /**
  52309. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52310. */
  52311. set snapDistance(value: number);
  52312. get snapDistance(): number;
  52313. /**
  52314. * Ratio for the scale of the gizmo (Default: 1)
  52315. */
  52316. set scaleRatio(value: number);
  52317. get scaleRatio(): number;
  52318. /**
  52319. * Sensitivity factor for dragging (Default: 1)
  52320. */
  52321. set sensitivity(value: number);
  52322. get sensitivity(): number;
  52323. /**
  52324. * Disposes of the gizmo
  52325. */
  52326. dispose(): void;
  52327. }
  52328. }
  52329. declare module BABYLON {
  52330. /**
  52331. * Single axis scale gizmo
  52332. */
  52333. export class AxisScaleGizmo extends Gizmo {
  52334. /**
  52335. * Drag behavior responsible for the gizmos dragging interactions
  52336. */
  52337. dragBehavior: PointerDragBehavior;
  52338. private _pointerObserver;
  52339. /**
  52340. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52341. */
  52342. snapDistance: number;
  52343. /**
  52344. * Event that fires each time the gizmo snaps to a new location.
  52345. * * snapDistance is the the change in distance
  52346. */
  52347. onSnapObservable: Observable<{
  52348. snapDistance: number;
  52349. }>;
  52350. /**
  52351. * If the scaling operation should be done on all axis (default: false)
  52352. */
  52353. uniformScaling: boolean;
  52354. /**
  52355. * Custom sensitivity value for the drag strength
  52356. */
  52357. sensitivity: number;
  52358. private _isEnabled;
  52359. private _parent;
  52360. private _arrow;
  52361. private _coloredMaterial;
  52362. private _hoverMaterial;
  52363. /**
  52364. * Creates an AxisScaleGizmo
  52365. * @param gizmoLayer The utility layer the gizmo will be added to
  52366. * @param dragAxis The axis which the gizmo will be able to scale on
  52367. * @param color The color of the gizmo
  52368. */
  52369. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52370. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52371. /**
  52372. * If the gizmo is enabled
  52373. */
  52374. set isEnabled(value: boolean);
  52375. get isEnabled(): boolean;
  52376. /**
  52377. * Disposes of the gizmo
  52378. */
  52379. dispose(): void;
  52380. /**
  52381. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52382. * @param mesh The mesh to replace the default mesh of the gizmo
  52383. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52384. */
  52385. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52386. }
  52387. }
  52388. declare module BABYLON {
  52389. /**
  52390. * Bounding box gizmo
  52391. */
  52392. export class BoundingBoxGizmo extends Gizmo {
  52393. private _lineBoundingBox;
  52394. private _rotateSpheresParent;
  52395. private _scaleBoxesParent;
  52396. private _boundingDimensions;
  52397. private _renderObserver;
  52398. private _pointerObserver;
  52399. private _scaleDragSpeed;
  52400. private _tmpQuaternion;
  52401. private _tmpVector;
  52402. private _tmpRotationMatrix;
  52403. /**
  52404. * 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)
  52405. */
  52406. ignoreChildren: boolean;
  52407. /**
  52408. * 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)
  52409. */
  52410. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52411. /**
  52412. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52413. */
  52414. rotationSphereSize: number;
  52415. /**
  52416. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52417. */
  52418. scaleBoxSize: number;
  52419. /**
  52420. * 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)
  52421. */
  52422. fixedDragMeshScreenSize: boolean;
  52423. /**
  52424. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52425. */
  52426. fixedDragMeshScreenSizeDistanceFactor: number;
  52427. /**
  52428. * Fired when a rotation sphere or scale box is dragged
  52429. */
  52430. onDragStartObservable: Observable<{}>;
  52431. /**
  52432. * Fired when a scale box is dragged
  52433. */
  52434. onScaleBoxDragObservable: Observable<{}>;
  52435. /**
  52436. * Fired when a scale box drag is ended
  52437. */
  52438. onScaleBoxDragEndObservable: Observable<{}>;
  52439. /**
  52440. * Fired when a rotation sphere is dragged
  52441. */
  52442. onRotationSphereDragObservable: Observable<{}>;
  52443. /**
  52444. * Fired when a rotation sphere drag is ended
  52445. */
  52446. onRotationSphereDragEndObservable: Observable<{}>;
  52447. /**
  52448. * 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)
  52449. */
  52450. scalePivot: Nullable<Vector3>;
  52451. /**
  52452. * Mesh used as a pivot to rotate the attached mesh
  52453. */
  52454. private _anchorMesh;
  52455. private _existingMeshScale;
  52456. private _dragMesh;
  52457. private pointerDragBehavior;
  52458. private coloredMaterial;
  52459. private hoverColoredMaterial;
  52460. /**
  52461. * Sets the color of the bounding box gizmo
  52462. * @param color the color to set
  52463. */
  52464. setColor(color: Color3): void;
  52465. /**
  52466. * Creates an BoundingBoxGizmo
  52467. * @param gizmoLayer The utility layer the gizmo will be added to
  52468. * @param color The color of the gizmo
  52469. */
  52470. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52471. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52472. private _selectNode;
  52473. /**
  52474. * Updates the bounding box information for the Gizmo
  52475. */
  52476. updateBoundingBox(): void;
  52477. private _updateRotationSpheres;
  52478. private _updateScaleBoxes;
  52479. /**
  52480. * Enables rotation on the specified axis and disables rotation on the others
  52481. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52482. */
  52483. setEnabledRotationAxis(axis: string): void;
  52484. /**
  52485. * Enables/disables scaling
  52486. * @param enable if scaling should be enabled
  52487. * @param homogeneousScaling defines if scaling should only be homogeneous
  52488. */
  52489. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52490. private _updateDummy;
  52491. /**
  52492. * Enables a pointer drag behavior on the bounding box of the gizmo
  52493. */
  52494. enableDragBehavior(): void;
  52495. /**
  52496. * Disposes of the gizmo
  52497. */
  52498. dispose(): void;
  52499. /**
  52500. * 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)
  52501. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52502. * @returns the bounding box mesh with the passed in mesh as a child
  52503. */
  52504. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52505. /**
  52506. * CustomMeshes are not supported by this gizmo
  52507. * @param mesh The mesh to replace the default mesh of the gizmo
  52508. */
  52509. setCustomMesh(mesh: Mesh): void;
  52510. }
  52511. }
  52512. declare module BABYLON {
  52513. /**
  52514. * Single plane rotation gizmo
  52515. */
  52516. export class PlaneRotationGizmo extends Gizmo {
  52517. /**
  52518. * Drag behavior responsible for the gizmos dragging interactions
  52519. */
  52520. dragBehavior: PointerDragBehavior;
  52521. private _pointerObserver;
  52522. /**
  52523. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52524. */
  52525. snapDistance: number;
  52526. /**
  52527. * Event that fires each time the gizmo snaps to a new location.
  52528. * * snapDistance is the the change in distance
  52529. */
  52530. onSnapObservable: Observable<{
  52531. snapDistance: number;
  52532. }>;
  52533. private _isEnabled;
  52534. private _parent;
  52535. /**
  52536. * Creates a PlaneRotationGizmo
  52537. * @param gizmoLayer The utility layer the gizmo will be added to
  52538. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52539. * @param color The color of the gizmo
  52540. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52541. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52542. */
  52543. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52544. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52545. /**
  52546. * If the gizmo is enabled
  52547. */
  52548. set isEnabled(value: boolean);
  52549. get isEnabled(): boolean;
  52550. /**
  52551. * Disposes of the gizmo
  52552. */
  52553. dispose(): void;
  52554. }
  52555. }
  52556. declare module BABYLON {
  52557. /**
  52558. * Gizmo that enables rotating a mesh along 3 axis
  52559. */
  52560. export class RotationGizmo extends Gizmo {
  52561. /**
  52562. * Internal gizmo used for interactions on the x axis
  52563. */
  52564. xGizmo: PlaneRotationGizmo;
  52565. /**
  52566. * Internal gizmo used for interactions on the y axis
  52567. */
  52568. yGizmo: PlaneRotationGizmo;
  52569. /**
  52570. * Internal gizmo used for interactions on the z axis
  52571. */
  52572. zGizmo: PlaneRotationGizmo;
  52573. /** Fires an event when any of it's sub gizmos are dragged */
  52574. onDragStartObservable: Observable<unknown>;
  52575. /** Fires an event when any of it's sub gizmos are released from dragging */
  52576. onDragEndObservable: Observable<unknown>;
  52577. private _meshAttached;
  52578. get attachedMesh(): Nullable<AbstractMesh>;
  52579. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52580. /**
  52581. * Creates a RotationGizmo
  52582. * @param gizmoLayer The utility layer the gizmo will be added to
  52583. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52584. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52585. */
  52586. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52587. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52588. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52589. /**
  52590. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52591. */
  52592. set snapDistance(value: number);
  52593. get snapDistance(): number;
  52594. /**
  52595. * Ratio for the scale of the gizmo (Default: 1)
  52596. */
  52597. set scaleRatio(value: number);
  52598. get scaleRatio(): number;
  52599. /**
  52600. * Disposes of the gizmo
  52601. */
  52602. dispose(): void;
  52603. /**
  52604. * CustomMeshes are not supported by this gizmo
  52605. * @param mesh The mesh to replace the default mesh of the gizmo
  52606. */
  52607. setCustomMesh(mesh: Mesh): void;
  52608. }
  52609. }
  52610. declare module BABYLON {
  52611. /**
  52612. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52613. */
  52614. export class GizmoManager implements IDisposable {
  52615. private scene;
  52616. /**
  52617. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52618. */
  52619. gizmos: {
  52620. positionGizmo: Nullable<PositionGizmo>;
  52621. rotationGizmo: Nullable<RotationGizmo>;
  52622. scaleGizmo: Nullable<ScaleGizmo>;
  52623. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52624. };
  52625. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52626. clearGizmoOnEmptyPointerEvent: boolean;
  52627. /** Fires an event when the manager is attached to a mesh */
  52628. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52629. private _gizmosEnabled;
  52630. private _pointerObserver;
  52631. private _attachedMesh;
  52632. private _boundingBoxColor;
  52633. private _defaultUtilityLayer;
  52634. private _defaultKeepDepthUtilityLayer;
  52635. /**
  52636. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52637. */
  52638. boundingBoxDragBehavior: SixDofDragBehavior;
  52639. /**
  52640. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52641. */
  52642. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52643. /**
  52644. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52645. */
  52646. usePointerToAttachGizmos: boolean;
  52647. /**
  52648. * Utility layer that the bounding box gizmo belongs to
  52649. */
  52650. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52651. /**
  52652. * Utility layer that all gizmos besides bounding box belong to
  52653. */
  52654. get utilityLayer(): UtilityLayerRenderer;
  52655. /**
  52656. * Instatiates a gizmo manager
  52657. * @param scene the scene to overlay the gizmos on top of
  52658. */
  52659. constructor(scene: Scene);
  52660. /**
  52661. * Attaches a set of gizmos to the specified mesh
  52662. * @param mesh The mesh the gizmo's should be attached to
  52663. */
  52664. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52665. /**
  52666. * If the position gizmo is enabled
  52667. */
  52668. set positionGizmoEnabled(value: boolean);
  52669. get positionGizmoEnabled(): boolean;
  52670. /**
  52671. * If the rotation gizmo is enabled
  52672. */
  52673. set rotationGizmoEnabled(value: boolean);
  52674. get rotationGizmoEnabled(): boolean;
  52675. /**
  52676. * If the scale gizmo is enabled
  52677. */
  52678. set scaleGizmoEnabled(value: boolean);
  52679. get scaleGizmoEnabled(): boolean;
  52680. /**
  52681. * If the boundingBox gizmo is enabled
  52682. */
  52683. set boundingBoxGizmoEnabled(value: boolean);
  52684. get boundingBoxGizmoEnabled(): boolean;
  52685. /**
  52686. * Disposes of the gizmo manager
  52687. */
  52688. dispose(): void;
  52689. }
  52690. }
  52691. declare module BABYLON {
  52692. /**
  52693. * A directional light is defined by a direction (what a surprise!).
  52694. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52695. * 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.
  52696. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52697. */
  52698. export class DirectionalLight extends ShadowLight {
  52699. private _shadowFrustumSize;
  52700. /**
  52701. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52702. */
  52703. get shadowFrustumSize(): number;
  52704. /**
  52705. * Specifies a fix frustum size for the shadow generation.
  52706. */
  52707. set shadowFrustumSize(value: number);
  52708. private _shadowOrthoScale;
  52709. /**
  52710. * Gets the shadow projection scale against the optimal computed one.
  52711. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52712. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52713. */
  52714. get shadowOrthoScale(): number;
  52715. /**
  52716. * Sets the shadow projection scale against the optimal computed one.
  52717. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52718. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52719. */
  52720. set shadowOrthoScale(value: number);
  52721. /**
  52722. * Automatically compute the projection matrix to best fit (including all the casters)
  52723. * on each frame.
  52724. */
  52725. autoUpdateExtends: boolean;
  52726. /**
  52727. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52728. * on each frame. autoUpdateExtends must be set to true for this to work
  52729. */
  52730. autoCalcShadowZBounds: boolean;
  52731. private _orthoLeft;
  52732. private _orthoRight;
  52733. private _orthoTop;
  52734. private _orthoBottom;
  52735. /**
  52736. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52737. * The directional light is emitted from everywhere in the given direction.
  52738. * It can cast shadows.
  52739. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52740. * @param name The friendly name of the light
  52741. * @param direction The direction of the light
  52742. * @param scene The scene the light belongs to
  52743. */
  52744. constructor(name: string, direction: Vector3, scene: Scene);
  52745. /**
  52746. * Returns the string "DirectionalLight".
  52747. * @return The class name
  52748. */
  52749. getClassName(): string;
  52750. /**
  52751. * Returns the integer 1.
  52752. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52753. */
  52754. getTypeID(): number;
  52755. /**
  52756. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52757. * Returns the DirectionalLight Shadow projection matrix.
  52758. */
  52759. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52760. /**
  52761. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52762. * Returns the DirectionalLight Shadow projection matrix.
  52763. */
  52764. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52765. /**
  52766. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52767. * Returns the DirectionalLight Shadow projection matrix.
  52768. */
  52769. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52770. protected _buildUniformLayout(): void;
  52771. /**
  52772. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52773. * @param effect The effect to update
  52774. * @param lightIndex The index of the light in the effect to update
  52775. * @returns The directional light
  52776. */
  52777. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52778. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52779. /**
  52780. * Gets the minZ used for shadow according to both the scene and the light.
  52781. *
  52782. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52783. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52784. * @param activeCamera The camera we are returning the min for
  52785. * @returns the depth min z
  52786. */
  52787. getDepthMinZ(activeCamera: Camera): number;
  52788. /**
  52789. * Gets the maxZ used for shadow according to both the scene and the light.
  52790. *
  52791. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52792. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52793. * @param activeCamera The camera we are returning the max for
  52794. * @returns the depth max z
  52795. */
  52796. getDepthMaxZ(activeCamera: Camera): number;
  52797. /**
  52798. * Prepares the list of defines specific to the light type.
  52799. * @param defines the list of defines
  52800. * @param lightIndex defines the index of the light for the effect
  52801. */
  52802. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52803. }
  52804. }
  52805. declare module BABYLON {
  52806. /**
  52807. * Class containing static functions to help procedurally build meshes
  52808. */
  52809. export class HemisphereBuilder {
  52810. /**
  52811. * Creates a hemisphere mesh
  52812. * @param name defines the name of the mesh
  52813. * @param options defines the options used to create the mesh
  52814. * @param scene defines the hosting scene
  52815. * @returns the hemisphere mesh
  52816. */
  52817. static CreateHemisphere(name: string, options: {
  52818. segments?: number;
  52819. diameter?: number;
  52820. sideOrientation?: number;
  52821. }, scene: any): Mesh;
  52822. }
  52823. }
  52824. declare module BABYLON {
  52825. /**
  52826. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52827. * These values define a cone of light starting from the position, emitting toward the direction.
  52828. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52829. * and the exponent defines the speed of the decay of the light with distance (reach).
  52830. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52831. */
  52832. export class SpotLight extends ShadowLight {
  52833. private _angle;
  52834. private _innerAngle;
  52835. private _cosHalfAngle;
  52836. private _lightAngleScale;
  52837. private _lightAngleOffset;
  52838. /**
  52839. * Gets the cone angle of the spot light in Radians.
  52840. */
  52841. get angle(): number;
  52842. /**
  52843. * Sets the cone angle of the spot light in Radians.
  52844. */
  52845. set angle(value: number);
  52846. /**
  52847. * Only used in gltf falloff mode, this defines the angle where
  52848. * the directional falloff will start before cutting at angle which could be seen
  52849. * as outer angle.
  52850. */
  52851. get innerAngle(): number;
  52852. /**
  52853. * Only used in gltf falloff mode, this defines the angle where
  52854. * the directional falloff will start before cutting at angle which could be seen
  52855. * as outer angle.
  52856. */
  52857. set innerAngle(value: number);
  52858. private _shadowAngleScale;
  52859. /**
  52860. * Allows scaling the angle of the light for shadow generation only.
  52861. */
  52862. get shadowAngleScale(): number;
  52863. /**
  52864. * Allows scaling the angle of the light for shadow generation only.
  52865. */
  52866. set shadowAngleScale(value: number);
  52867. /**
  52868. * The light decay speed with the distance from the emission spot.
  52869. */
  52870. exponent: number;
  52871. private _projectionTextureMatrix;
  52872. /**
  52873. * Allows reading the projecton texture
  52874. */
  52875. get projectionTextureMatrix(): Matrix;
  52876. protected _projectionTextureLightNear: number;
  52877. /**
  52878. * Gets the near clip of the Spotlight for texture projection.
  52879. */
  52880. get projectionTextureLightNear(): number;
  52881. /**
  52882. * Sets the near clip of the Spotlight for texture projection.
  52883. */
  52884. set projectionTextureLightNear(value: number);
  52885. protected _projectionTextureLightFar: number;
  52886. /**
  52887. * Gets the far clip of the Spotlight for texture projection.
  52888. */
  52889. get projectionTextureLightFar(): number;
  52890. /**
  52891. * Sets the far clip of the Spotlight for texture projection.
  52892. */
  52893. set projectionTextureLightFar(value: number);
  52894. protected _projectionTextureUpDirection: Vector3;
  52895. /**
  52896. * Gets the Up vector of the Spotlight for texture projection.
  52897. */
  52898. get projectionTextureUpDirection(): Vector3;
  52899. /**
  52900. * Sets the Up vector of the Spotlight for texture projection.
  52901. */
  52902. set projectionTextureUpDirection(value: Vector3);
  52903. private _projectionTexture;
  52904. /**
  52905. * Gets the projection texture of the light.
  52906. */
  52907. get projectionTexture(): Nullable<BaseTexture>;
  52908. /**
  52909. * Sets the projection texture of the light.
  52910. */
  52911. set projectionTexture(value: Nullable<BaseTexture>);
  52912. private _projectionTextureViewLightDirty;
  52913. private _projectionTextureProjectionLightDirty;
  52914. private _projectionTextureDirty;
  52915. private _projectionTextureViewTargetVector;
  52916. private _projectionTextureViewLightMatrix;
  52917. private _projectionTextureProjectionLightMatrix;
  52918. private _projectionTextureScalingMatrix;
  52919. /**
  52920. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52921. * It can cast shadows.
  52922. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52923. * @param name The light friendly name
  52924. * @param position The position of the spot light in the scene
  52925. * @param direction The direction of the light in the scene
  52926. * @param angle The cone angle of the light in Radians
  52927. * @param exponent The light decay speed with the distance from the emission spot
  52928. * @param scene The scene the lights belongs to
  52929. */
  52930. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52931. /**
  52932. * Returns the string "SpotLight".
  52933. * @returns the class name
  52934. */
  52935. getClassName(): string;
  52936. /**
  52937. * Returns the integer 2.
  52938. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52939. */
  52940. getTypeID(): number;
  52941. /**
  52942. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52943. */
  52944. protected _setDirection(value: Vector3): void;
  52945. /**
  52946. * Overrides the position setter to recompute the projection texture view light Matrix.
  52947. */
  52948. protected _setPosition(value: Vector3): void;
  52949. /**
  52950. * 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.
  52951. * Returns the SpotLight.
  52952. */
  52953. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52954. protected _computeProjectionTextureViewLightMatrix(): void;
  52955. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52956. /**
  52957. * Main function for light texture projection matrix computing.
  52958. */
  52959. protected _computeProjectionTextureMatrix(): void;
  52960. protected _buildUniformLayout(): void;
  52961. private _computeAngleValues;
  52962. /**
  52963. * Sets the passed Effect "effect" with the Light textures.
  52964. * @param effect The effect to update
  52965. * @param lightIndex The index of the light in the effect to update
  52966. * @returns The light
  52967. */
  52968. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52969. /**
  52970. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52971. * @param effect The effect to update
  52972. * @param lightIndex The index of the light in the effect to update
  52973. * @returns The spot light
  52974. */
  52975. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52976. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52977. /**
  52978. * Disposes the light and the associated resources.
  52979. */
  52980. dispose(): void;
  52981. /**
  52982. * Prepares the list of defines specific to the light type.
  52983. * @param defines the list of defines
  52984. * @param lightIndex defines the index of the light for the effect
  52985. */
  52986. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52987. }
  52988. }
  52989. declare module BABYLON {
  52990. /**
  52991. * Gizmo that enables viewing a light
  52992. */
  52993. export class LightGizmo extends Gizmo {
  52994. private _lightMesh;
  52995. private _material;
  52996. private _cachedPosition;
  52997. private _cachedForward;
  52998. private _attachedMeshParent;
  52999. /**
  53000. * Creates a LightGizmo
  53001. * @param gizmoLayer The utility layer the gizmo will be added to
  53002. */
  53003. constructor(gizmoLayer?: UtilityLayerRenderer);
  53004. private _light;
  53005. /**
  53006. * The light that the gizmo is attached to
  53007. */
  53008. set light(light: Nullable<Light>);
  53009. get light(): Nullable<Light>;
  53010. /**
  53011. * Gets the material used to render the light gizmo
  53012. */
  53013. get material(): StandardMaterial;
  53014. /**
  53015. * @hidden
  53016. * Updates the gizmo to match the attached mesh's position/rotation
  53017. */
  53018. protected _update(): void;
  53019. private static _Scale;
  53020. /**
  53021. * Creates the lines for a light mesh
  53022. */
  53023. private static _CreateLightLines;
  53024. /**
  53025. * Disposes of the light gizmo
  53026. */
  53027. dispose(): void;
  53028. private static _CreateHemisphericLightMesh;
  53029. private static _CreatePointLightMesh;
  53030. private static _CreateSpotLightMesh;
  53031. private static _CreateDirectionalLightMesh;
  53032. }
  53033. }
  53034. declare module BABYLON {
  53035. /** @hidden */
  53036. export var backgroundFragmentDeclaration: {
  53037. name: string;
  53038. shader: string;
  53039. };
  53040. }
  53041. declare module BABYLON {
  53042. /** @hidden */
  53043. export var backgroundUboDeclaration: {
  53044. name: string;
  53045. shader: string;
  53046. };
  53047. }
  53048. declare module BABYLON {
  53049. /** @hidden */
  53050. export var backgroundPixelShader: {
  53051. name: string;
  53052. shader: string;
  53053. };
  53054. }
  53055. declare module BABYLON {
  53056. /** @hidden */
  53057. export var backgroundVertexDeclaration: {
  53058. name: string;
  53059. shader: string;
  53060. };
  53061. }
  53062. declare module BABYLON {
  53063. /** @hidden */
  53064. export var backgroundVertexShader: {
  53065. name: string;
  53066. shader: string;
  53067. };
  53068. }
  53069. declare module BABYLON {
  53070. /**
  53071. * Background material used to create an efficient environement around your scene.
  53072. */
  53073. export class BackgroundMaterial extends PushMaterial {
  53074. /**
  53075. * Standard reflectance value at parallel view angle.
  53076. */
  53077. static StandardReflectance0: number;
  53078. /**
  53079. * Standard reflectance value at grazing angle.
  53080. */
  53081. static StandardReflectance90: number;
  53082. protected _primaryColor: Color3;
  53083. /**
  53084. * Key light Color (multiply against the environement texture)
  53085. */
  53086. primaryColor: Color3;
  53087. protected __perceptualColor: Nullable<Color3>;
  53088. /**
  53089. * Experimental Internal Use Only.
  53090. *
  53091. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53092. * This acts as a helper to set the primary color to a more "human friendly" value.
  53093. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53094. * output color as close as possible from the chosen value.
  53095. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53096. * part of lighting setup.)
  53097. */
  53098. get _perceptualColor(): Nullable<Color3>;
  53099. set _perceptualColor(value: Nullable<Color3>);
  53100. protected _primaryColorShadowLevel: float;
  53101. /**
  53102. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53103. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53104. */
  53105. get primaryColorShadowLevel(): float;
  53106. set primaryColorShadowLevel(value: float);
  53107. protected _primaryColorHighlightLevel: float;
  53108. /**
  53109. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53110. * The primary color is used at the level chosen to define what the white area would look.
  53111. */
  53112. get primaryColorHighlightLevel(): float;
  53113. set primaryColorHighlightLevel(value: float);
  53114. protected _reflectionTexture: Nullable<BaseTexture>;
  53115. /**
  53116. * Reflection Texture used in the material.
  53117. * Should be author in a specific way for the best result (refer to the documentation).
  53118. */
  53119. reflectionTexture: Nullable<BaseTexture>;
  53120. protected _reflectionBlur: float;
  53121. /**
  53122. * Reflection Texture level of blur.
  53123. *
  53124. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53125. * texture twice.
  53126. */
  53127. reflectionBlur: float;
  53128. protected _diffuseTexture: Nullable<BaseTexture>;
  53129. /**
  53130. * Diffuse Texture used in the material.
  53131. * Should be author in a specific way for the best result (refer to the documentation).
  53132. */
  53133. diffuseTexture: Nullable<BaseTexture>;
  53134. protected _shadowLights: Nullable<IShadowLight[]>;
  53135. /**
  53136. * Specify the list of lights casting shadow on the material.
  53137. * All scene shadow lights will be included if null.
  53138. */
  53139. shadowLights: Nullable<IShadowLight[]>;
  53140. protected _shadowLevel: float;
  53141. /**
  53142. * Helps adjusting the shadow to a softer level if required.
  53143. * 0 means black shadows and 1 means no shadows.
  53144. */
  53145. shadowLevel: float;
  53146. protected _sceneCenter: Vector3;
  53147. /**
  53148. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53149. * It is usually zero but might be interesting to modify according to your setup.
  53150. */
  53151. sceneCenter: Vector3;
  53152. protected _opacityFresnel: boolean;
  53153. /**
  53154. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53155. * This helps ensuring a nice transition when the camera goes under the ground.
  53156. */
  53157. opacityFresnel: boolean;
  53158. protected _reflectionFresnel: boolean;
  53159. /**
  53160. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53161. * This helps adding a mirror texture on the ground.
  53162. */
  53163. reflectionFresnel: boolean;
  53164. protected _reflectionFalloffDistance: number;
  53165. /**
  53166. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53167. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53168. */
  53169. reflectionFalloffDistance: number;
  53170. protected _reflectionAmount: number;
  53171. /**
  53172. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53173. */
  53174. reflectionAmount: number;
  53175. protected _reflectionReflectance0: number;
  53176. /**
  53177. * This specifies the weight of the reflection at grazing angle.
  53178. */
  53179. reflectionReflectance0: number;
  53180. protected _reflectionReflectance90: number;
  53181. /**
  53182. * This specifies the weight of the reflection at a perpendicular point of view.
  53183. */
  53184. reflectionReflectance90: number;
  53185. /**
  53186. * Sets the reflection reflectance fresnel values according to the default standard
  53187. * empirically know to work well :-)
  53188. */
  53189. set reflectionStandardFresnelWeight(value: number);
  53190. protected _useRGBColor: boolean;
  53191. /**
  53192. * Helps to directly use the maps channels instead of their level.
  53193. */
  53194. useRGBColor: boolean;
  53195. protected _enableNoise: boolean;
  53196. /**
  53197. * This helps reducing the banding effect that could occur on the background.
  53198. */
  53199. enableNoise: boolean;
  53200. /**
  53201. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53202. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53203. * Recommended to be keep at 1.0 except for special cases.
  53204. */
  53205. get fovMultiplier(): number;
  53206. set fovMultiplier(value: number);
  53207. private _fovMultiplier;
  53208. /**
  53209. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53210. */
  53211. useEquirectangularFOV: boolean;
  53212. private _maxSimultaneousLights;
  53213. /**
  53214. * Number of Simultaneous lights allowed on the material.
  53215. */
  53216. maxSimultaneousLights: int;
  53217. /**
  53218. * Default configuration related to image processing available in the Background Material.
  53219. */
  53220. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53221. /**
  53222. * Keep track of the image processing observer to allow dispose and replace.
  53223. */
  53224. private _imageProcessingObserver;
  53225. /**
  53226. * Attaches a new image processing configuration to the PBR Material.
  53227. * @param configuration (if null the scene configuration will be use)
  53228. */
  53229. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53230. /**
  53231. * Gets the image processing configuration used either in this material.
  53232. */
  53233. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53234. /**
  53235. * Sets the Default image processing configuration used either in the this material.
  53236. *
  53237. * If sets to null, the scene one is in use.
  53238. */
  53239. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53240. /**
  53241. * Gets wether the color curves effect is enabled.
  53242. */
  53243. get cameraColorCurvesEnabled(): boolean;
  53244. /**
  53245. * Sets wether the color curves effect is enabled.
  53246. */
  53247. set cameraColorCurvesEnabled(value: boolean);
  53248. /**
  53249. * Gets wether the color grading effect is enabled.
  53250. */
  53251. get cameraColorGradingEnabled(): boolean;
  53252. /**
  53253. * Gets wether the color grading effect is enabled.
  53254. */
  53255. set cameraColorGradingEnabled(value: boolean);
  53256. /**
  53257. * Gets wether tonemapping is enabled or not.
  53258. */
  53259. get cameraToneMappingEnabled(): boolean;
  53260. /**
  53261. * Sets wether tonemapping is enabled or not
  53262. */
  53263. set cameraToneMappingEnabled(value: boolean);
  53264. /**
  53265. * The camera exposure used on this material.
  53266. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53267. * This corresponds to a photographic exposure.
  53268. */
  53269. get cameraExposure(): float;
  53270. /**
  53271. * The camera exposure used on this material.
  53272. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53273. * This corresponds to a photographic exposure.
  53274. */
  53275. set cameraExposure(value: float);
  53276. /**
  53277. * Gets The camera contrast used on this material.
  53278. */
  53279. get cameraContrast(): float;
  53280. /**
  53281. * Sets The camera contrast used on this material.
  53282. */
  53283. set cameraContrast(value: float);
  53284. /**
  53285. * Gets the Color Grading 2D Lookup Texture.
  53286. */
  53287. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53288. /**
  53289. * Sets the Color Grading 2D Lookup Texture.
  53290. */
  53291. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53292. /**
  53293. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53294. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53295. * 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;
  53296. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53297. */
  53298. get cameraColorCurves(): Nullable<ColorCurves>;
  53299. /**
  53300. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53301. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53302. * 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;
  53303. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53304. */
  53305. set cameraColorCurves(value: Nullable<ColorCurves>);
  53306. /**
  53307. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53308. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53309. */
  53310. switchToBGR: boolean;
  53311. private _renderTargets;
  53312. private _reflectionControls;
  53313. private _white;
  53314. private _primaryShadowColor;
  53315. private _primaryHighlightColor;
  53316. /**
  53317. * Instantiates a Background Material in the given scene
  53318. * @param name The friendly name of the material
  53319. * @param scene The scene to add the material to
  53320. */
  53321. constructor(name: string, scene: Scene);
  53322. /**
  53323. * Gets a boolean indicating that current material needs to register RTT
  53324. */
  53325. get hasRenderTargetTextures(): boolean;
  53326. /**
  53327. * The entire material has been created in order to prevent overdraw.
  53328. * @returns false
  53329. */
  53330. needAlphaTesting(): boolean;
  53331. /**
  53332. * The entire material has been created in order to prevent overdraw.
  53333. * @returns true if blending is enable
  53334. */
  53335. needAlphaBlending(): boolean;
  53336. /**
  53337. * Checks wether the material is ready to be rendered for a given mesh.
  53338. * @param mesh The mesh to render
  53339. * @param subMesh The submesh to check against
  53340. * @param useInstances Specify wether or not the material is used with instances
  53341. * @returns true if all the dependencies are ready (Textures, Effects...)
  53342. */
  53343. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53344. /**
  53345. * Compute the primary color according to the chosen perceptual color.
  53346. */
  53347. private _computePrimaryColorFromPerceptualColor;
  53348. /**
  53349. * Compute the highlights and shadow colors according to their chosen levels.
  53350. */
  53351. private _computePrimaryColors;
  53352. /**
  53353. * Build the uniform buffer used in the material.
  53354. */
  53355. buildUniformLayout(): void;
  53356. /**
  53357. * Unbind the material.
  53358. */
  53359. unbind(): void;
  53360. /**
  53361. * Bind only the world matrix to the material.
  53362. * @param world The world matrix to bind.
  53363. */
  53364. bindOnlyWorldMatrix(world: Matrix): void;
  53365. /**
  53366. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53367. * @param world The world matrix to bind.
  53368. * @param subMesh The submesh to bind for.
  53369. */
  53370. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53371. /**
  53372. * Checks to see if a texture is used in the material.
  53373. * @param texture - Base texture to use.
  53374. * @returns - Boolean specifying if a texture is used in the material.
  53375. */
  53376. hasTexture(texture: BaseTexture): boolean;
  53377. /**
  53378. * Dispose the material.
  53379. * @param forceDisposeEffect Force disposal of the associated effect.
  53380. * @param forceDisposeTextures Force disposal of the associated textures.
  53381. */
  53382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53383. /**
  53384. * Clones the material.
  53385. * @param name The cloned name.
  53386. * @returns The cloned material.
  53387. */
  53388. clone(name: string): BackgroundMaterial;
  53389. /**
  53390. * Serializes the current material to its JSON representation.
  53391. * @returns The JSON representation.
  53392. */
  53393. serialize(): any;
  53394. /**
  53395. * Gets the class name of the material
  53396. * @returns "BackgroundMaterial"
  53397. */
  53398. getClassName(): string;
  53399. /**
  53400. * Parse a JSON input to create back a background material.
  53401. * @param source The JSON data to parse
  53402. * @param scene The scene to create the parsed material in
  53403. * @param rootUrl The root url of the assets the material depends upon
  53404. * @returns the instantiated BackgroundMaterial.
  53405. */
  53406. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53407. }
  53408. }
  53409. declare module BABYLON {
  53410. /**
  53411. * Represents the different options available during the creation of
  53412. * a Environment helper.
  53413. *
  53414. * This can control the default ground, skybox and image processing setup of your scene.
  53415. */
  53416. export interface IEnvironmentHelperOptions {
  53417. /**
  53418. * Specifies whether or not to create a ground.
  53419. * True by default.
  53420. */
  53421. createGround: boolean;
  53422. /**
  53423. * Specifies the ground size.
  53424. * 15 by default.
  53425. */
  53426. groundSize: number;
  53427. /**
  53428. * The texture used on the ground for the main color.
  53429. * Comes from the BabylonJS CDN by default.
  53430. *
  53431. * Remarks: Can be either a texture or a url.
  53432. */
  53433. groundTexture: string | BaseTexture;
  53434. /**
  53435. * The color mixed in the ground texture by default.
  53436. * BabylonJS clearColor by default.
  53437. */
  53438. groundColor: Color3;
  53439. /**
  53440. * Specifies the ground opacity.
  53441. * 1 by default.
  53442. */
  53443. groundOpacity: number;
  53444. /**
  53445. * Enables the ground to receive shadows.
  53446. * True by default.
  53447. */
  53448. enableGroundShadow: boolean;
  53449. /**
  53450. * Helps preventing the shadow to be fully black on the ground.
  53451. * 0.5 by default.
  53452. */
  53453. groundShadowLevel: number;
  53454. /**
  53455. * Creates a mirror texture attach to the ground.
  53456. * false by default.
  53457. */
  53458. enableGroundMirror: boolean;
  53459. /**
  53460. * Specifies the ground mirror size ratio.
  53461. * 0.3 by default as the default kernel is 64.
  53462. */
  53463. groundMirrorSizeRatio: number;
  53464. /**
  53465. * Specifies the ground mirror blur kernel size.
  53466. * 64 by default.
  53467. */
  53468. groundMirrorBlurKernel: number;
  53469. /**
  53470. * Specifies the ground mirror visibility amount.
  53471. * 1 by default
  53472. */
  53473. groundMirrorAmount: number;
  53474. /**
  53475. * Specifies the ground mirror reflectance weight.
  53476. * This uses the standard weight of the background material to setup the fresnel effect
  53477. * of the mirror.
  53478. * 1 by default.
  53479. */
  53480. groundMirrorFresnelWeight: number;
  53481. /**
  53482. * Specifies the ground mirror Falloff distance.
  53483. * This can helps reducing the size of the reflection.
  53484. * 0 by Default.
  53485. */
  53486. groundMirrorFallOffDistance: number;
  53487. /**
  53488. * Specifies the ground mirror texture type.
  53489. * Unsigned Int by Default.
  53490. */
  53491. groundMirrorTextureType: number;
  53492. /**
  53493. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53494. * the shown objects.
  53495. */
  53496. groundYBias: number;
  53497. /**
  53498. * Specifies whether or not to create a skybox.
  53499. * True by default.
  53500. */
  53501. createSkybox: boolean;
  53502. /**
  53503. * Specifies the skybox size.
  53504. * 20 by default.
  53505. */
  53506. skyboxSize: number;
  53507. /**
  53508. * The texture used on the skybox for the main color.
  53509. * Comes from the BabylonJS CDN by default.
  53510. *
  53511. * Remarks: Can be either a texture or a url.
  53512. */
  53513. skyboxTexture: string | BaseTexture;
  53514. /**
  53515. * The color mixed in the skybox texture by default.
  53516. * BabylonJS clearColor by default.
  53517. */
  53518. skyboxColor: Color3;
  53519. /**
  53520. * The background rotation around the Y axis of the scene.
  53521. * This helps aligning the key lights of your scene with the background.
  53522. * 0 by default.
  53523. */
  53524. backgroundYRotation: number;
  53525. /**
  53526. * Compute automatically the size of the elements to best fit with the scene.
  53527. */
  53528. sizeAuto: boolean;
  53529. /**
  53530. * Default position of the rootMesh if autoSize is not true.
  53531. */
  53532. rootPosition: Vector3;
  53533. /**
  53534. * Sets up the image processing in the scene.
  53535. * true by default.
  53536. */
  53537. setupImageProcessing: boolean;
  53538. /**
  53539. * The texture used as your environment texture in the scene.
  53540. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53541. *
  53542. * Remarks: Can be either a texture or a url.
  53543. */
  53544. environmentTexture: string | BaseTexture;
  53545. /**
  53546. * The value of the exposure to apply to the scene.
  53547. * 0.6 by default if setupImageProcessing is true.
  53548. */
  53549. cameraExposure: number;
  53550. /**
  53551. * The value of the contrast to apply to the scene.
  53552. * 1.6 by default if setupImageProcessing is true.
  53553. */
  53554. cameraContrast: number;
  53555. /**
  53556. * Specifies whether or not tonemapping should be enabled in the scene.
  53557. * true by default if setupImageProcessing is true.
  53558. */
  53559. toneMappingEnabled: boolean;
  53560. }
  53561. /**
  53562. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53563. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53564. * It also helps with the default setup of your imageProcessing configuration.
  53565. */
  53566. export class EnvironmentHelper {
  53567. /**
  53568. * Default ground texture URL.
  53569. */
  53570. private static _groundTextureCDNUrl;
  53571. /**
  53572. * Default skybox texture URL.
  53573. */
  53574. private static _skyboxTextureCDNUrl;
  53575. /**
  53576. * Default environment texture URL.
  53577. */
  53578. private static _environmentTextureCDNUrl;
  53579. /**
  53580. * Creates the default options for the helper.
  53581. */
  53582. private static _getDefaultOptions;
  53583. private _rootMesh;
  53584. /**
  53585. * Gets the root mesh created by the helper.
  53586. */
  53587. get rootMesh(): Mesh;
  53588. private _skybox;
  53589. /**
  53590. * Gets the skybox created by the helper.
  53591. */
  53592. get skybox(): Nullable<Mesh>;
  53593. private _skyboxTexture;
  53594. /**
  53595. * Gets the skybox texture created by the helper.
  53596. */
  53597. get skyboxTexture(): Nullable<BaseTexture>;
  53598. private _skyboxMaterial;
  53599. /**
  53600. * Gets the skybox material created by the helper.
  53601. */
  53602. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53603. private _ground;
  53604. /**
  53605. * Gets the ground mesh created by the helper.
  53606. */
  53607. get ground(): Nullable<Mesh>;
  53608. private _groundTexture;
  53609. /**
  53610. * Gets the ground texture created by the helper.
  53611. */
  53612. get groundTexture(): Nullable<BaseTexture>;
  53613. private _groundMirror;
  53614. /**
  53615. * Gets the ground mirror created by the helper.
  53616. */
  53617. get groundMirror(): Nullable<MirrorTexture>;
  53618. /**
  53619. * Gets the ground mirror render list to helps pushing the meshes
  53620. * you wish in the ground reflection.
  53621. */
  53622. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53623. private _groundMaterial;
  53624. /**
  53625. * Gets the ground material created by the helper.
  53626. */
  53627. get groundMaterial(): Nullable<BackgroundMaterial>;
  53628. /**
  53629. * Stores the creation options.
  53630. */
  53631. private readonly _scene;
  53632. private _options;
  53633. /**
  53634. * This observable will be notified with any error during the creation of the environment,
  53635. * mainly texture creation errors.
  53636. */
  53637. onErrorObservable: Observable<{
  53638. message?: string;
  53639. exception?: any;
  53640. }>;
  53641. /**
  53642. * constructor
  53643. * @param options Defines the options we want to customize the helper
  53644. * @param scene The scene to add the material to
  53645. */
  53646. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53647. /**
  53648. * Updates the background according to the new options
  53649. * @param options
  53650. */
  53651. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53652. /**
  53653. * Sets the primary color of all the available elements.
  53654. * @param color the main color to affect to the ground and the background
  53655. */
  53656. setMainColor(color: Color3): void;
  53657. /**
  53658. * Setup the image processing according to the specified options.
  53659. */
  53660. private _setupImageProcessing;
  53661. /**
  53662. * Setup the environment texture according to the specified options.
  53663. */
  53664. private _setupEnvironmentTexture;
  53665. /**
  53666. * Setup the background according to the specified options.
  53667. */
  53668. private _setupBackground;
  53669. /**
  53670. * Get the scene sizes according to the setup.
  53671. */
  53672. private _getSceneSize;
  53673. /**
  53674. * Setup the ground according to the specified options.
  53675. */
  53676. private _setupGround;
  53677. /**
  53678. * Setup the ground material according to the specified options.
  53679. */
  53680. private _setupGroundMaterial;
  53681. /**
  53682. * Setup the ground diffuse texture according to the specified options.
  53683. */
  53684. private _setupGroundDiffuseTexture;
  53685. /**
  53686. * Setup the ground mirror texture according to the specified options.
  53687. */
  53688. private _setupGroundMirrorTexture;
  53689. /**
  53690. * Setup the ground to receive the mirror texture.
  53691. */
  53692. private _setupMirrorInGroundMaterial;
  53693. /**
  53694. * Setup the skybox according to the specified options.
  53695. */
  53696. private _setupSkybox;
  53697. /**
  53698. * Setup the skybox material according to the specified options.
  53699. */
  53700. private _setupSkyboxMaterial;
  53701. /**
  53702. * Setup the skybox reflection texture according to the specified options.
  53703. */
  53704. private _setupSkyboxReflectionTexture;
  53705. private _errorHandler;
  53706. /**
  53707. * Dispose all the elements created by the Helper.
  53708. */
  53709. dispose(): void;
  53710. }
  53711. }
  53712. declare module BABYLON {
  53713. /**
  53714. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53715. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53716. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53717. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53718. */
  53719. export class PhotoDome extends TransformNode {
  53720. /**
  53721. * Define the image as a Monoscopic panoramic 360 image.
  53722. */
  53723. static readonly MODE_MONOSCOPIC: number;
  53724. /**
  53725. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53726. */
  53727. static readonly MODE_TOPBOTTOM: number;
  53728. /**
  53729. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53730. */
  53731. static readonly MODE_SIDEBYSIDE: number;
  53732. private _useDirectMapping;
  53733. /**
  53734. * The texture being displayed on the sphere
  53735. */
  53736. protected _photoTexture: Texture;
  53737. /**
  53738. * Gets or sets the texture being displayed on the sphere
  53739. */
  53740. get photoTexture(): Texture;
  53741. set photoTexture(value: Texture);
  53742. /**
  53743. * Observable raised when an error occured while loading the 360 image
  53744. */
  53745. onLoadErrorObservable: Observable<string>;
  53746. /**
  53747. * The skybox material
  53748. */
  53749. protected _material: BackgroundMaterial;
  53750. /**
  53751. * The surface used for the skybox
  53752. */
  53753. protected _mesh: Mesh;
  53754. /**
  53755. * Gets the mesh used for the skybox.
  53756. */
  53757. get mesh(): Mesh;
  53758. /**
  53759. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53760. * Also see the options.resolution property.
  53761. */
  53762. get fovMultiplier(): number;
  53763. set fovMultiplier(value: number);
  53764. private _imageMode;
  53765. /**
  53766. * Gets or set the current video mode for the video. It can be:
  53767. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53768. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53769. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53770. */
  53771. get imageMode(): number;
  53772. set imageMode(value: number);
  53773. /**
  53774. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53775. * @param name Element's name, child elements will append suffixes for their own names.
  53776. * @param urlsOfPhoto defines the url of the photo to display
  53777. * @param options defines an object containing optional or exposed sub element properties
  53778. * @param onError defines a callback called when an error occured while loading the texture
  53779. */
  53780. constructor(name: string, urlOfPhoto: string, options: {
  53781. resolution?: number;
  53782. size?: number;
  53783. useDirectMapping?: boolean;
  53784. faceForward?: boolean;
  53785. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53786. private _onBeforeCameraRenderObserver;
  53787. private _changeImageMode;
  53788. /**
  53789. * Releases resources associated with this node.
  53790. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53791. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53792. */
  53793. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53794. }
  53795. }
  53796. declare module BABYLON {
  53797. /**
  53798. * Class used to host RGBD texture specific utilities
  53799. */
  53800. export class RGBDTextureTools {
  53801. /**
  53802. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53803. * @param texture the texture to expand.
  53804. */
  53805. static ExpandRGBDTexture(texture: Texture): void;
  53806. }
  53807. }
  53808. declare module BABYLON {
  53809. /**
  53810. * Class used to host texture specific utilities
  53811. */
  53812. export class BRDFTextureTools {
  53813. /**
  53814. * Prevents texture cache collision
  53815. */
  53816. private static _instanceNumber;
  53817. /**
  53818. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53819. * @param scene defines the hosting scene
  53820. * @returns the environment BRDF texture
  53821. */
  53822. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53823. private static _environmentBRDFBase64Texture;
  53824. }
  53825. }
  53826. declare module BABYLON {
  53827. /**
  53828. * @hidden
  53829. */
  53830. export interface IMaterialClearCoatDefines {
  53831. CLEARCOAT: boolean;
  53832. CLEARCOAT_DEFAULTIOR: boolean;
  53833. CLEARCOAT_TEXTURE: boolean;
  53834. CLEARCOAT_TEXTUREDIRECTUV: number;
  53835. CLEARCOAT_BUMP: boolean;
  53836. CLEARCOAT_BUMPDIRECTUV: number;
  53837. CLEARCOAT_TINT: boolean;
  53838. CLEARCOAT_TINT_TEXTURE: boolean;
  53839. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53840. /** @hidden */
  53841. _areTexturesDirty: boolean;
  53842. }
  53843. /**
  53844. * Define the code related to the clear coat parameters of the pbr material.
  53845. */
  53846. export class PBRClearCoatConfiguration {
  53847. /**
  53848. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53849. * The default fits with a polyurethane material.
  53850. */
  53851. private static readonly _DefaultIndexOfRefraction;
  53852. private _isEnabled;
  53853. /**
  53854. * Defines if the clear coat is enabled in the material.
  53855. */
  53856. isEnabled: boolean;
  53857. /**
  53858. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53859. */
  53860. intensity: number;
  53861. /**
  53862. * Defines the clear coat layer roughness.
  53863. */
  53864. roughness: number;
  53865. private _indexOfRefraction;
  53866. /**
  53867. * Defines the index of refraction of the clear coat.
  53868. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53869. * The default fits with a polyurethane material.
  53870. * Changing the default value is more performance intensive.
  53871. */
  53872. indexOfRefraction: number;
  53873. private _texture;
  53874. /**
  53875. * Stores the clear coat values in a texture.
  53876. */
  53877. texture: Nullable<BaseTexture>;
  53878. private _bumpTexture;
  53879. /**
  53880. * Define the clear coat specific bump texture.
  53881. */
  53882. bumpTexture: Nullable<BaseTexture>;
  53883. private _isTintEnabled;
  53884. /**
  53885. * Defines if the clear coat tint is enabled in the material.
  53886. */
  53887. isTintEnabled: boolean;
  53888. /**
  53889. * Defines the clear coat tint of the material.
  53890. * This is only use if tint is enabled
  53891. */
  53892. tintColor: Color3;
  53893. /**
  53894. * Defines the distance at which the tint color should be found in the
  53895. * clear coat media.
  53896. * This is only use if tint is enabled
  53897. */
  53898. tintColorAtDistance: number;
  53899. /**
  53900. * Defines the clear coat layer thickness.
  53901. * This is only use if tint is enabled
  53902. */
  53903. tintThickness: number;
  53904. private _tintTexture;
  53905. /**
  53906. * Stores the clear tint values in a texture.
  53907. * rgb is tint
  53908. * a is a thickness factor
  53909. */
  53910. tintTexture: Nullable<BaseTexture>;
  53911. /** @hidden */
  53912. private _internalMarkAllSubMeshesAsTexturesDirty;
  53913. /** @hidden */
  53914. _markAllSubMeshesAsTexturesDirty(): void;
  53915. /**
  53916. * Instantiate a new istance of clear coat configuration.
  53917. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53918. */
  53919. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53920. /**
  53921. * Gets wehter the submesh is ready to be used or not.
  53922. * @param defines the list of "defines" to update.
  53923. * @param scene defines the scene the material belongs to.
  53924. * @param engine defines the engine the material belongs to.
  53925. * @param disableBumpMap defines wether the material disables bump or not.
  53926. * @returns - boolean indicating that the submesh is ready or not.
  53927. */
  53928. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53929. /**
  53930. * Checks to see if a texture is used in the material.
  53931. * @param defines the list of "defines" to update.
  53932. * @param scene defines the scene to the material belongs to.
  53933. */
  53934. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53935. /**
  53936. * Binds the material data.
  53937. * @param uniformBuffer defines the Uniform buffer to fill in.
  53938. * @param scene defines the scene the material belongs to.
  53939. * @param engine defines the engine the material belongs to.
  53940. * @param disableBumpMap defines wether the material disables bump or not.
  53941. * @param isFrozen defines wether the material is frozen or not.
  53942. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53943. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53944. */
  53945. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53946. /**
  53947. * Checks to see if a texture is used in the material.
  53948. * @param texture - Base texture to use.
  53949. * @returns - Boolean specifying if a texture is used in the material.
  53950. */
  53951. hasTexture(texture: BaseTexture): boolean;
  53952. /**
  53953. * Returns an array of the actively used textures.
  53954. * @param activeTextures Array of BaseTextures
  53955. */
  53956. getActiveTextures(activeTextures: BaseTexture[]): void;
  53957. /**
  53958. * Returns the animatable textures.
  53959. * @param animatables Array of animatable textures.
  53960. */
  53961. getAnimatables(animatables: IAnimatable[]): void;
  53962. /**
  53963. * Disposes the resources of the material.
  53964. * @param forceDisposeTextures - Forces the disposal of all textures.
  53965. */
  53966. dispose(forceDisposeTextures?: boolean): void;
  53967. /**
  53968. * Get the current class name of the texture useful for serialization or dynamic coding.
  53969. * @returns "PBRClearCoatConfiguration"
  53970. */
  53971. getClassName(): string;
  53972. /**
  53973. * Add fallbacks to the effect fallbacks list.
  53974. * @param defines defines the Base texture to use.
  53975. * @param fallbacks defines the current fallback list.
  53976. * @param currentRank defines the current fallback rank.
  53977. * @returns the new fallback rank.
  53978. */
  53979. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53980. /**
  53981. * Add the required uniforms to the current list.
  53982. * @param uniforms defines the current uniform list.
  53983. */
  53984. static AddUniforms(uniforms: string[]): void;
  53985. /**
  53986. * Add the required samplers to the current list.
  53987. * @param samplers defines the current sampler list.
  53988. */
  53989. static AddSamplers(samplers: string[]): void;
  53990. /**
  53991. * Add the required uniforms to the current buffer.
  53992. * @param uniformBuffer defines the current uniform buffer.
  53993. */
  53994. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53995. /**
  53996. * Makes a duplicate of the current configuration into another one.
  53997. * @param clearCoatConfiguration define the config where to copy the info
  53998. */
  53999. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54000. /**
  54001. * Serializes this clear coat configuration.
  54002. * @returns - An object with the serialized config.
  54003. */
  54004. serialize(): any;
  54005. /**
  54006. * Parses a anisotropy Configuration from a serialized object.
  54007. * @param source - Serialized object.
  54008. * @param scene Defines the scene we are parsing for
  54009. * @param rootUrl Defines the rootUrl to load from
  54010. */
  54011. parse(source: any, scene: Scene, rootUrl: string): void;
  54012. }
  54013. }
  54014. declare module BABYLON {
  54015. /**
  54016. * @hidden
  54017. */
  54018. export interface IMaterialAnisotropicDefines {
  54019. ANISOTROPIC: boolean;
  54020. ANISOTROPIC_TEXTURE: boolean;
  54021. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54022. MAINUV1: boolean;
  54023. _areTexturesDirty: boolean;
  54024. _needUVs: boolean;
  54025. }
  54026. /**
  54027. * Define the code related to the anisotropic parameters of the pbr material.
  54028. */
  54029. export class PBRAnisotropicConfiguration {
  54030. private _isEnabled;
  54031. /**
  54032. * Defines if the anisotropy is enabled in the material.
  54033. */
  54034. isEnabled: boolean;
  54035. /**
  54036. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54037. */
  54038. intensity: number;
  54039. /**
  54040. * Defines if the effect is along the tangents, bitangents or in between.
  54041. * By default, the effect is "strectching" the highlights along the tangents.
  54042. */
  54043. direction: Vector2;
  54044. private _texture;
  54045. /**
  54046. * Stores the anisotropy values in a texture.
  54047. * rg is direction (like normal from -1 to 1)
  54048. * b is a intensity
  54049. */
  54050. texture: Nullable<BaseTexture>;
  54051. /** @hidden */
  54052. private _internalMarkAllSubMeshesAsTexturesDirty;
  54053. /** @hidden */
  54054. _markAllSubMeshesAsTexturesDirty(): void;
  54055. /**
  54056. * Instantiate a new istance of anisotropy configuration.
  54057. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54058. */
  54059. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54060. /**
  54061. * Specifies that the submesh is ready to be used.
  54062. * @param defines the list of "defines" to update.
  54063. * @param scene defines the scene the material belongs to.
  54064. * @returns - boolean indicating that the submesh is ready or not.
  54065. */
  54066. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54067. /**
  54068. * Checks to see if a texture is used in the material.
  54069. * @param defines the list of "defines" to update.
  54070. * @param mesh the mesh we are preparing the defines for.
  54071. * @param scene defines the scene the material belongs to.
  54072. */
  54073. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54074. /**
  54075. * Binds the material data.
  54076. * @param uniformBuffer defines the Uniform buffer to fill in.
  54077. * @param scene defines the scene the material belongs to.
  54078. * @param isFrozen defines wether the material is frozen or not.
  54079. */
  54080. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54081. /**
  54082. * Checks to see if a texture is used in the material.
  54083. * @param texture - Base texture to use.
  54084. * @returns - Boolean specifying if a texture is used in the material.
  54085. */
  54086. hasTexture(texture: BaseTexture): boolean;
  54087. /**
  54088. * Returns an array of the actively used textures.
  54089. * @param activeTextures Array of BaseTextures
  54090. */
  54091. getActiveTextures(activeTextures: BaseTexture[]): void;
  54092. /**
  54093. * Returns the animatable textures.
  54094. * @param animatables Array of animatable textures.
  54095. */
  54096. getAnimatables(animatables: IAnimatable[]): void;
  54097. /**
  54098. * Disposes the resources of the material.
  54099. * @param forceDisposeTextures - Forces the disposal of all textures.
  54100. */
  54101. dispose(forceDisposeTextures?: boolean): void;
  54102. /**
  54103. * Get the current class name of the texture useful for serialization or dynamic coding.
  54104. * @returns "PBRAnisotropicConfiguration"
  54105. */
  54106. getClassName(): string;
  54107. /**
  54108. * Add fallbacks to the effect fallbacks list.
  54109. * @param defines defines the Base texture to use.
  54110. * @param fallbacks defines the current fallback list.
  54111. * @param currentRank defines the current fallback rank.
  54112. * @returns the new fallback rank.
  54113. */
  54114. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54115. /**
  54116. * Add the required uniforms to the current list.
  54117. * @param uniforms defines the current uniform list.
  54118. */
  54119. static AddUniforms(uniforms: string[]): void;
  54120. /**
  54121. * Add the required uniforms to the current buffer.
  54122. * @param uniformBuffer defines the current uniform buffer.
  54123. */
  54124. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54125. /**
  54126. * Add the required samplers to the current list.
  54127. * @param samplers defines the current sampler list.
  54128. */
  54129. static AddSamplers(samplers: string[]): void;
  54130. /**
  54131. * Makes a duplicate of the current configuration into another one.
  54132. * @param anisotropicConfiguration define the config where to copy the info
  54133. */
  54134. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54135. /**
  54136. * Serializes this anisotropy configuration.
  54137. * @returns - An object with the serialized config.
  54138. */
  54139. serialize(): any;
  54140. /**
  54141. * Parses a anisotropy Configuration from a serialized object.
  54142. * @param source - Serialized object.
  54143. * @param scene Defines the scene we are parsing for
  54144. * @param rootUrl Defines the rootUrl to load from
  54145. */
  54146. parse(source: any, scene: Scene, rootUrl: string): void;
  54147. }
  54148. }
  54149. declare module BABYLON {
  54150. /**
  54151. * @hidden
  54152. */
  54153. export interface IMaterialBRDFDefines {
  54154. BRDF_V_HEIGHT_CORRELATED: boolean;
  54155. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54156. SPHERICAL_HARMONICS: boolean;
  54157. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54158. /** @hidden */
  54159. _areMiscDirty: boolean;
  54160. }
  54161. /**
  54162. * Define the code related to the BRDF parameters of the pbr material.
  54163. */
  54164. export class PBRBRDFConfiguration {
  54165. /**
  54166. * Default value used for the energy conservation.
  54167. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54168. */
  54169. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54170. /**
  54171. * Default value used for the Smith Visibility Height Correlated mode.
  54172. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54173. */
  54174. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54175. /**
  54176. * Default value used for the IBL diffuse part.
  54177. * This can help switching back to the polynomials mode globally which is a tiny bit
  54178. * less GPU intensive at the drawback of a lower quality.
  54179. */
  54180. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54181. /**
  54182. * Default value used for activating energy conservation for the specular workflow.
  54183. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54184. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54185. */
  54186. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54187. private _useEnergyConservation;
  54188. /**
  54189. * Defines if the material uses energy conservation.
  54190. */
  54191. useEnergyConservation: boolean;
  54192. private _useSmithVisibilityHeightCorrelated;
  54193. /**
  54194. * LEGACY Mode set to false
  54195. * Defines if the material uses height smith correlated visibility term.
  54196. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54197. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54198. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54199. * Not relying on height correlated will also disable energy conservation.
  54200. */
  54201. useSmithVisibilityHeightCorrelated: boolean;
  54202. private _useSphericalHarmonics;
  54203. /**
  54204. * LEGACY Mode set to false
  54205. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54206. * diffuse part of the IBL.
  54207. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54208. * to the ground truth.
  54209. */
  54210. useSphericalHarmonics: boolean;
  54211. private _useSpecularGlossinessInputEnergyConservation;
  54212. /**
  54213. * Defines if the material uses energy conservation, when the specular workflow is active.
  54214. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54215. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54216. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54217. */
  54218. useSpecularGlossinessInputEnergyConservation: boolean;
  54219. /** @hidden */
  54220. private _internalMarkAllSubMeshesAsMiscDirty;
  54221. /** @hidden */
  54222. _markAllSubMeshesAsMiscDirty(): void;
  54223. /**
  54224. * Instantiate a new istance of clear coat configuration.
  54225. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54226. */
  54227. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54228. /**
  54229. * Checks to see if a texture is used in the material.
  54230. * @param defines the list of "defines" to update.
  54231. */
  54232. prepareDefines(defines: IMaterialBRDFDefines): void;
  54233. /**
  54234. * Get the current class name of the texture useful for serialization or dynamic coding.
  54235. * @returns "PBRClearCoatConfiguration"
  54236. */
  54237. getClassName(): string;
  54238. /**
  54239. * Makes a duplicate of the current configuration into another one.
  54240. * @param brdfConfiguration define the config where to copy the info
  54241. */
  54242. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54243. /**
  54244. * Serializes this BRDF configuration.
  54245. * @returns - An object with the serialized config.
  54246. */
  54247. serialize(): any;
  54248. /**
  54249. * Parses a anisotropy Configuration from a serialized object.
  54250. * @param source - Serialized object.
  54251. * @param scene Defines the scene we are parsing for
  54252. * @param rootUrl Defines the rootUrl to load from
  54253. */
  54254. parse(source: any, scene: Scene, rootUrl: string): void;
  54255. }
  54256. }
  54257. declare module BABYLON {
  54258. /**
  54259. * @hidden
  54260. */
  54261. export interface IMaterialSheenDefines {
  54262. SHEEN: boolean;
  54263. SHEEN_TEXTURE: boolean;
  54264. SHEEN_TEXTUREDIRECTUV: number;
  54265. SHEEN_LINKWITHALBEDO: boolean;
  54266. SHEEN_ROUGHNESS: boolean;
  54267. SHEEN_ALBEDOSCALING: boolean;
  54268. /** @hidden */
  54269. _areTexturesDirty: boolean;
  54270. }
  54271. /**
  54272. * Define the code related to the Sheen parameters of the pbr material.
  54273. */
  54274. export class PBRSheenConfiguration {
  54275. private _isEnabled;
  54276. /**
  54277. * Defines if the material uses sheen.
  54278. */
  54279. isEnabled: boolean;
  54280. private _linkSheenWithAlbedo;
  54281. /**
  54282. * Defines if the sheen is linked to the sheen color.
  54283. */
  54284. linkSheenWithAlbedo: boolean;
  54285. /**
  54286. * Defines the sheen intensity.
  54287. */
  54288. intensity: number;
  54289. /**
  54290. * Defines the sheen color.
  54291. */
  54292. color: Color3;
  54293. private _texture;
  54294. /**
  54295. * Stores the sheen tint values in a texture.
  54296. * rgb is tint
  54297. * a is a intensity
  54298. */
  54299. texture: Nullable<BaseTexture>;
  54300. private _roughness;
  54301. /**
  54302. * Defines the sheen roughness.
  54303. * It is not taken into account if linkSheenWithAlbedo is true.
  54304. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54305. */
  54306. roughness: Nullable<number>;
  54307. private _albedoScaling;
  54308. /**
  54309. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54310. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54311. * making it easier to setup and tweak the effect
  54312. */
  54313. albedoScaling: boolean;
  54314. /** @hidden */
  54315. private _internalMarkAllSubMeshesAsTexturesDirty;
  54316. /** @hidden */
  54317. _markAllSubMeshesAsTexturesDirty(): void;
  54318. /**
  54319. * Instantiate a new istance of clear coat configuration.
  54320. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54321. */
  54322. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54323. /**
  54324. * Specifies that the submesh is ready to be used.
  54325. * @param defines the list of "defines" to update.
  54326. * @param scene defines the scene the material belongs to.
  54327. * @returns - boolean indicating that the submesh is ready or not.
  54328. */
  54329. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54330. /**
  54331. * Checks to see if a texture is used in the material.
  54332. * @param defines the list of "defines" to update.
  54333. * @param scene defines the scene the material belongs to.
  54334. */
  54335. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54336. /**
  54337. * Binds the material data.
  54338. * @param uniformBuffer defines the Uniform buffer to fill in.
  54339. * @param scene defines the scene the material belongs to.
  54340. * @param isFrozen defines wether the material is frozen or not.
  54341. */
  54342. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54343. /**
  54344. * Checks to see if a texture is used in the material.
  54345. * @param texture - Base texture to use.
  54346. * @returns - Boolean specifying if a texture is used in the material.
  54347. */
  54348. hasTexture(texture: BaseTexture): boolean;
  54349. /**
  54350. * Returns an array of the actively used textures.
  54351. * @param activeTextures Array of BaseTextures
  54352. */
  54353. getActiveTextures(activeTextures: BaseTexture[]): void;
  54354. /**
  54355. * Returns the animatable textures.
  54356. * @param animatables Array of animatable textures.
  54357. */
  54358. getAnimatables(animatables: IAnimatable[]): void;
  54359. /**
  54360. * Disposes the resources of the material.
  54361. * @param forceDisposeTextures - Forces the disposal of all textures.
  54362. */
  54363. dispose(forceDisposeTextures?: boolean): void;
  54364. /**
  54365. * Get the current class name of the texture useful for serialization or dynamic coding.
  54366. * @returns "PBRSheenConfiguration"
  54367. */
  54368. getClassName(): string;
  54369. /**
  54370. * Add fallbacks to the effect fallbacks list.
  54371. * @param defines defines the Base texture to use.
  54372. * @param fallbacks defines the current fallback list.
  54373. * @param currentRank defines the current fallback rank.
  54374. * @returns the new fallback rank.
  54375. */
  54376. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54377. /**
  54378. * Add the required uniforms to the current list.
  54379. * @param uniforms defines the current uniform list.
  54380. */
  54381. static AddUniforms(uniforms: string[]): void;
  54382. /**
  54383. * Add the required uniforms to the current buffer.
  54384. * @param uniformBuffer defines the current uniform buffer.
  54385. */
  54386. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54387. /**
  54388. * Add the required samplers to the current list.
  54389. * @param samplers defines the current sampler list.
  54390. */
  54391. static AddSamplers(samplers: string[]): void;
  54392. /**
  54393. * Makes a duplicate of the current configuration into another one.
  54394. * @param sheenConfiguration define the config where to copy the info
  54395. */
  54396. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54397. /**
  54398. * Serializes this BRDF configuration.
  54399. * @returns - An object with the serialized config.
  54400. */
  54401. serialize(): any;
  54402. /**
  54403. * Parses a anisotropy Configuration from a serialized object.
  54404. * @param source - Serialized object.
  54405. * @param scene Defines the scene we are parsing for
  54406. * @param rootUrl Defines the rootUrl to load from
  54407. */
  54408. parse(source: any, scene: Scene, rootUrl: string): void;
  54409. }
  54410. }
  54411. declare module BABYLON {
  54412. /**
  54413. * @hidden
  54414. */
  54415. export interface IMaterialSubSurfaceDefines {
  54416. SUBSURFACE: boolean;
  54417. SS_REFRACTION: boolean;
  54418. SS_TRANSLUCENCY: boolean;
  54419. SS_SCATTERING: boolean;
  54420. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54421. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54422. SS_REFRACTIONMAP_3D: boolean;
  54423. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54424. SS_LODINREFRACTIONALPHA: boolean;
  54425. SS_GAMMAREFRACTION: boolean;
  54426. SS_RGBDREFRACTION: boolean;
  54427. SS_LINEARSPECULARREFRACTION: boolean;
  54428. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54429. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54430. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54431. /** @hidden */
  54432. _areTexturesDirty: boolean;
  54433. }
  54434. /**
  54435. * Define the code related to the sub surface parameters of the pbr material.
  54436. */
  54437. export class PBRSubSurfaceConfiguration {
  54438. private _isRefractionEnabled;
  54439. /**
  54440. * Defines if the refraction is enabled in the material.
  54441. */
  54442. isRefractionEnabled: boolean;
  54443. private _isTranslucencyEnabled;
  54444. /**
  54445. * Defines if the translucency is enabled in the material.
  54446. */
  54447. isTranslucencyEnabled: boolean;
  54448. private _isScatteringEnabled;
  54449. /**
  54450. * Defines the refraction intensity of the material.
  54451. * The refraction when enabled replaces the Diffuse part of the material.
  54452. * The intensity helps transitionning between diffuse and refraction.
  54453. */
  54454. refractionIntensity: number;
  54455. /**
  54456. * Defines the translucency intensity of the material.
  54457. * When translucency has been enabled, this defines how much of the "translucency"
  54458. * is addded to the diffuse part of the material.
  54459. */
  54460. translucencyIntensity: number;
  54461. /**
  54462. * Defines the scattering intensity of the material.
  54463. * When scattering has been enabled, this defines how much of the "scattered light"
  54464. * is addded to the diffuse part of the material.
  54465. */
  54466. scatteringIntensity: number;
  54467. /**
  54468. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54469. */
  54470. useAlbedoToTintRefraction: boolean;
  54471. private _thicknessTexture;
  54472. /**
  54473. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54474. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54475. * 0 would mean minimumThickness
  54476. * 1 would mean maximumThickness
  54477. * The other channels might be use as a mask to vary the different effects intensity.
  54478. */
  54479. thicknessTexture: Nullable<BaseTexture>;
  54480. private _refractionTexture;
  54481. /**
  54482. * Defines the texture to use for refraction.
  54483. */
  54484. refractionTexture: Nullable<BaseTexture>;
  54485. private _indexOfRefraction;
  54486. /**
  54487. * Index of refraction of the material base layer.
  54488. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54489. *
  54490. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54491. *
  54492. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54493. */
  54494. indexOfRefraction: number;
  54495. private _volumeIndexOfRefraction;
  54496. /**
  54497. * Index of refraction of the material's volume.
  54498. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54499. *
  54500. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54501. * the volume will use the same IOR as the surface.
  54502. */
  54503. get volumeIndexOfRefraction(): number;
  54504. set volumeIndexOfRefraction(value: number);
  54505. private _invertRefractionY;
  54506. /**
  54507. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54508. */
  54509. invertRefractionY: boolean;
  54510. private _linkRefractionWithTransparency;
  54511. /**
  54512. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54513. * Materials half opaque for instance using refraction could benefit from this control.
  54514. */
  54515. linkRefractionWithTransparency: boolean;
  54516. /**
  54517. * Defines the minimum thickness stored in the thickness map.
  54518. * If no thickness map is defined, this value will be used to simulate thickness.
  54519. */
  54520. minimumThickness: number;
  54521. /**
  54522. * Defines the maximum thickness stored in the thickness map.
  54523. */
  54524. maximumThickness: number;
  54525. /**
  54526. * Defines the volume tint of the material.
  54527. * This is used for both translucency and scattering.
  54528. */
  54529. tintColor: Color3;
  54530. /**
  54531. * Defines the distance at which the tint color should be found in the media.
  54532. * This is used for refraction only.
  54533. */
  54534. tintColorAtDistance: number;
  54535. /**
  54536. * Defines how far each channel transmit through the media.
  54537. * It is defined as a color to simplify it selection.
  54538. */
  54539. diffusionDistance: Color3;
  54540. private _useMaskFromThicknessTexture;
  54541. /**
  54542. * Stores the intensity of the different subsurface effects in the thickness texture.
  54543. * * the green channel is the translucency intensity.
  54544. * * the blue channel is the scattering intensity.
  54545. * * the alpha channel is the refraction intensity.
  54546. */
  54547. useMaskFromThicknessTexture: boolean;
  54548. /** @hidden */
  54549. private _internalMarkAllSubMeshesAsTexturesDirty;
  54550. /** @hidden */
  54551. _markAllSubMeshesAsTexturesDirty(): void;
  54552. /**
  54553. * Instantiate a new istance of sub surface configuration.
  54554. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54555. */
  54556. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54557. /**
  54558. * Gets wehter the submesh is ready to be used or not.
  54559. * @param defines the list of "defines" to update.
  54560. * @param scene defines the scene the material belongs to.
  54561. * @returns - boolean indicating that the submesh is ready or not.
  54562. */
  54563. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54564. /**
  54565. * Checks to see if a texture is used in the material.
  54566. * @param defines the list of "defines" to update.
  54567. * @param scene defines the scene to the material belongs to.
  54568. */
  54569. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54570. /**
  54571. * Binds the material data.
  54572. * @param uniformBuffer defines the Uniform buffer to fill in.
  54573. * @param scene defines the scene the material belongs to.
  54574. * @param engine defines the engine the material belongs to.
  54575. * @param isFrozen defines whether the material is frozen or not.
  54576. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54577. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54578. */
  54579. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54580. /**
  54581. * Unbinds the material from the mesh.
  54582. * @param activeEffect defines the effect that should be unbound from.
  54583. * @returns true if unbound, otherwise false
  54584. */
  54585. unbind(activeEffect: Effect): boolean;
  54586. /**
  54587. * Returns the texture used for refraction or null if none is used.
  54588. * @param scene defines the scene the material belongs to.
  54589. * @returns - Refraction texture if present. If no refraction texture and refraction
  54590. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54591. */
  54592. private _getRefractionTexture;
  54593. /**
  54594. * Returns true if alpha blending should be disabled.
  54595. */
  54596. get disableAlphaBlending(): boolean;
  54597. /**
  54598. * Fills the list of render target textures.
  54599. * @param renderTargets the list of render targets to update
  54600. */
  54601. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54602. /**
  54603. * Checks to see if a texture is used in the material.
  54604. * @param texture - Base texture to use.
  54605. * @returns - Boolean specifying if a texture is used in the material.
  54606. */
  54607. hasTexture(texture: BaseTexture): boolean;
  54608. /**
  54609. * Gets a boolean indicating that current material needs to register RTT
  54610. * @returns true if this uses a render target otherwise false.
  54611. */
  54612. hasRenderTargetTextures(): boolean;
  54613. /**
  54614. * Returns an array of the actively used textures.
  54615. * @param activeTextures Array of BaseTextures
  54616. */
  54617. getActiveTextures(activeTextures: BaseTexture[]): void;
  54618. /**
  54619. * Returns the animatable textures.
  54620. * @param animatables Array of animatable textures.
  54621. */
  54622. getAnimatables(animatables: IAnimatable[]): void;
  54623. /**
  54624. * Disposes the resources of the material.
  54625. * @param forceDisposeTextures - Forces the disposal of all textures.
  54626. */
  54627. dispose(forceDisposeTextures?: boolean): void;
  54628. /**
  54629. * Get the current class name of the texture useful for serialization or dynamic coding.
  54630. * @returns "PBRSubSurfaceConfiguration"
  54631. */
  54632. getClassName(): string;
  54633. /**
  54634. * Add fallbacks to the effect fallbacks list.
  54635. * @param defines defines the Base texture to use.
  54636. * @param fallbacks defines the current fallback list.
  54637. * @param currentRank defines the current fallback rank.
  54638. * @returns the new fallback rank.
  54639. */
  54640. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54641. /**
  54642. * Add the required uniforms to the current list.
  54643. * @param uniforms defines the current uniform list.
  54644. */
  54645. static AddUniforms(uniforms: string[]): void;
  54646. /**
  54647. * Add the required samplers to the current list.
  54648. * @param samplers defines the current sampler list.
  54649. */
  54650. static AddSamplers(samplers: string[]): void;
  54651. /**
  54652. * Add the required uniforms to the current buffer.
  54653. * @param uniformBuffer defines the current uniform buffer.
  54654. */
  54655. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54656. /**
  54657. * Makes a duplicate of the current configuration into another one.
  54658. * @param configuration define the config where to copy the info
  54659. */
  54660. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54661. /**
  54662. * Serializes this Sub Surface configuration.
  54663. * @returns - An object with the serialized config.
  54664. */
  54665. serialize(): any;
  54666. /**
  54667. * Parses a anisotropy Configuration from a serialized object.
  54668. * @param source - Serialized object.
  54669. * @param scene Defines the scene we are parsing for
  54670. * @param rootUrl Defines the rootUrl to load from
  54671. */
  54672. parse(source: any, scene: Scene, rootUrl: string): void;
  54673. }
  54674. }
  54675. declare module BABYLON {
  54676. /** @hidden */
  54677. export var pbrFragmentDeclaration: {
  54678. name: string;
  54679. shader: string;
  54680. };
  54681. }
  54682. declare module BABYLON {
  54683. /** @hidden */
  54684. export var pbrUboDeclaration: {
  54685. name: string;
  54686. shader: string;
  54687. };
  54688. }
  54689. declare module BABYLON {
  54690. /** @hidden */
  54691. export var pbrFragmentExtraDeclaration: {
  54692. name: string;
  54693. shader: string;
  54694. };
  54695. }
  54696. declare module BABYLON {
  54697. /** @hidden */
  54698. export var pbrFragmentSamplersDeclaration: {
  54699. name: string;
  54700. shader: string;
  54701. };
  54702. }
  54703. declare module BABYLON {
  54704. /** @hidden */
  54705. export var importanceSampling: {
  54706. name: string;
  54707. shader: string;
  54708. };
  54709. }
  54710. declare module BABYLON {
  54711. /** @hidden */
  54712. export var pbrHelperFunctions: {
  54713. name: string;
  54714. shader: string;
  54715. };
  54716. }
  54717. declare module BABYLON {
  54718. /** @hidden */
  54719. export var harmonicsFunctions: {
  54720. name: string;
  54721. shader: string;
  54722. };
  54723. }
  54724. declare module BABYLON {
  54725. /** @hidden */
  54726. export var pbrDirectLightingSetupFunctions: {
  54727. name: string;
  54728. shader: string;
  54729. };
  54730. }
  54731. declare module BABYLON {
  54732. /** @hidden */
  54733. export var pbrDirectLightingFalloffFunctions: {
  54734. name: string;
  54735. shader: string;
  54736. };
  54737. }
  54738. declare module BABYLON {
  54739. /** @hidden */
  54740. export var pbrBRDFFunctions: {
  54741. name: string;
  54742. shader: string;
  54743. };
  54744. }
  54745. declare module BABYLON {
  54746. /** @hidden */
  54747. export var hdrFilteringFunctions: {
  54748. name: string;
  54749. shader: string;
  54750. };
  54751. }
  54752. declare module BABYLON {
  54753. /** @hidden */
  54754. export var pbrDirectLightingFunctions: {
  54755. name: string;
  54756. shader: string;
  54757. };
  54758. }
  54759. declare module BABYLON {
  54760. /** @hidden */
  54761. export var pbrIBLFunctions: {
  54762. name: string;
  54763. shader: string;
  54764. };
  54765. }
  54766. declare module BABYLON {
  54767. /** @hidden */
  54768. export var pbrBlockAlbedoOpacity: {
  54769. name: string;
  54770. shader: string;
  54771. };
  54772. }
  54773. declare module BABYLON {
  54774. /** @hidden */
  54775. export var pbrBlockReflectivity: {
  54776. name: string;
  54777. shader: string;
  54778. };
  54779. }
  54780. declare module BABYLON {
  54781. /** @hidden */
  54782. export var pbrBlockAmbientOcclusion: {
  54783. name: string;
  54784. shader: string;
  54785. };
  54786. }
  54787. declare module BABYLON {
  54788. /** @hidden */
  54789. export var pbrBlockAlphaFresnel: {
  54790. name: string;
  54791. shader: string;
  54792. };
  54793. }
  54794. declare module BABYLON {
  54795. /** @hidden */
  54796. export var pbrBlockAnisotropic: {
  54797. name: string;
  54798. shader: string;
  54799. };
  54800. }
  54801. declare module BABYLON {
  54802. /** @hidden */
  54803. export var pbrBlockReflection: {
  54804. name: string;
  54805. shader: string;
  54806. };
  54807. }
  54808. declare module BABYLON {
  54809. /** @hidden */
  54810. export var pbrBlockSheen: {
  54811. name: string;
  54812. shader: string;
  54813. };
  54814. }
  54815. declare module BABYLON {
  54816. /** @hidden */
  54817. export var pbrBlockClearcoat: {
  54818. name: string;
  54819. shader: string;
  54820. };
  54821. }
  54822. declare module BABYLON {
  54823. /** @hidden */
  54824. export var pbrBlockSubSurface: {
  54825. name: string;
  54826. shader: string;
  54827. };
  54828. }
  54829. declare module BABYLON {
  54830. /** @hidden */
  54831. export var pbrBlockNormalGeometric: {
  54832. name: string;
  54833. shader: string;
  54834. };
  54835. }
  54836. declare module BABYLON {
  54837. /** @hidden */
  54838. export var pbrBlockNormalFinal: {
  54839. name: string;
  54840. shader: string;
  54841. };
  54842. }
  54843. declare module BABYLON {
  54844. /** @hidden */
  54845. export var pbrBlockGeometryInfo: {
  54846. name: string;
  54847. shader: string;
  54848. };
  54849. }
  54850. declare module BABYLON {
  54851. /** @hidden */
  54852. export var pbrBlockReflectance0: {
  54853. name: string;
  54854. shader: string;
  54855. };
  54856. }
  54857. declare module BABYLON {
  54858. /** @hidden */
  54859. export var pbrBlockReflectance: {
  54860. name: string;
  54861. shader: string;
  54862. };
  54863. }
  54864. declare module BABYLON {
  54865. /** @hidden */
  54866. export var pbrBlockDirectLighting: {
  54867. name: string;
  54868. shader: string;
  54869. };
  54870. }
  54871. declare module BABYLON {
  54872. /** @hidden */
  54873. export var pbrBlockFinalLitComponents: {
  54874. name: string;
  54875. shader: string;
  54876. };
  54877. }
  54878. declare module BABYLON {
  54879. /** @hidden */
  54880. export var pbrBlockFinalUnlitComponents: {
  54881. name: string;
  54882. shader: string;
  54883. };
  54884. }
  54885. declare module BABYLON {
  54886. /** @hidden */
  54887. export var pbrBlockFinalColorComposition: {
  54888. name: string;
  54889. shader: string;
  54890. };
  54891. }
  54892. declare module BABYLON {
  54893. /** @hidden */
  54894. export var pbrBlockImageProcessing: {
  54895. name: string;
  54896. shader: string;
  54897. };
  54898. }
  54899. declare module BABYLON {
  54900. /** @hidden */
  54901. export var pbrDebug: {
  54902. name: string;
  54903. shader: string;
  54904. };
  54905. }
  54906. declare module BABYLON {
  54907. /** @hidden */
  54908. export var pbrPixelShader: {
  54909. name: string;
  54910. shader: string;
  54911. };
  54912. }
  54913. declare module BABYLON {
  54914. /** @hidden */
  54915. export var pbrVertexDeclaration: {
  54916. name: string;
  54917. shader: string;
  54918. };
  54919. }
  54920. declare module BABYLON {
  54921. /** @hidden */
  54922. export var pbrVertexShader: {
  54923. name: string;
  54924. shader: string;
  54925. };
  54926. }
  54927. declare module BABYLON {
  54928. /**
  54929. * Manages the defines for the PBR Material.
  54930. * @hidden
  54931. */
  54932. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  54933. PBR: boolean;
  54934. NUM_SAMPLES: string;
  54935. REALTIME_FILTERING: boolean;
  54936. MAINUV1: boolean;
  54937. MAINUV2: boolean;
  54938. UV1: boolean;
  54939. UV2: boolean;
  54940. ALBEDO: boolean;
  54941. GAMMAALBEDO: boolean;
  54942. ALBEDODIRECTUV: number;
  54943. VERTEXCOLOR: boolean;
  54944. DETAIL: boolean;
  54945. DETAILDIRECTUV: number;
  54946. DETAIL_NORMALBLENDMETHOD: number;
  54947. AMBIENT: boolean;
  54948. AMBIENTDIRECTUV: number;
  54949. AMBIENTINGRAYSCALE: boolean;
  54950. OPACITY: boolean;
  54951. VERTEXALPHA: boolean;
  54952. OPACITYDIRECTUV: number;
  54953. OPACITYRGB: boolean;
  54954. ALPHATEST: boolean;
  54955. DEPTHPREPASS: boolean;
  54956. ALPHABLEND: boolean;
  54957. ALPHAFROMALBEDO: boolean;
  54958. ALPHATESTVALUE: string;
  54959. SPECULAROVERALPHA: boolean;
  54960. RADIANCEOVERALPHA: boolean;
  54961. ALPHAFRESNEL: boolean;
  54962. LINEARALPHAFRESNEL: boolean;
  54963. PREMULTIPLYALPHA: boolean;
  54964. EMISSIVE: boolean;
  54965. EMISSIVEDIRECTUV: number;
  54966. REFLECTIVITY: boolean;
  54967. REFLECTIVITYDIRECTUV: number;
  54968. SPECULARTERM: boolean;
  54969. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54970. MICROSURFACEAUTOMATIC: boolean;
  54971. LODBASEDMICROSFURACE: boolean;
  54972. MICROSURFACEMAP: boolean;
  54973. MICROSURFACEMAPDIRECTUV: number;
  54974. METALLICWORKFLOW: boolean;
  54975. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54976. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54977. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54978. AOSTOREINMETALMAPRED: boolean;
  54979. METALLIC_REFLECTANCE: boolean;
  54980. METALLIC_REFLECTANCEDIRECTUV: number;
  54981. ENVIRONMENTBRDF: boolean;
  54982. ENVIRONMENTBRDF_RGBD: boolean;
  54983. NORMAL: boolean;
  54984. TANGENT: boolean;
  54985. BUMP: boolean;
  54986. BUMPDIRECTUV: number;
  54987. OBJECTSPACE_NORMALMAP: boolean;
  54988. PARALLAX: boolean;
  54989. PARALLAXOCCLUSION: boolean;
  54990. NORMALXYSCALE: boolean;
  54991. LIGHTMAP: boolean;
  54992. LIGHTMAPDIRECTUV: number;
  54993. USELIGHTMAPASSHADOWMAP: boolean;
  54994. GAMMALIGHTMAP: boolean;
  54995. RGBDLIGHTMAP: boolean;
  54996. REFLECTION: boolean;
  54997. REFLECTIONMAP_3D: boolean;
  54998. REFLECTIONMAP_SPHERICAL: boolean;
  54999. REFLECTIONMAP_PLANAR: boolean;
  55000. REFLECTIONMAP_CUBIC: boolean;
  55001. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55002. REFLECTIONMAP_PROJECTION: boolean;
  55003. REFLECTIONMAP_SKYBOX: boolean;
  55004. REFLECTIONMAP_EXPLICIT: boolean;
  55005. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55006. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55007. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55008. INVERTCUBICMAP: boolean;
  55009. USESPHERICALFROMREFLECTIONMAP: boolean;
  55010. USEIRRADIANCEMAP: boolean;
  55011. SPHERICAL_HARMONICS: boolean;
  55012. USESPHERICALINVERTEX: boolean;
  55013. REFLECTIONMAP_OPPOSITEZ: boolean;
  55014. LODINREFLECTIONALPHA: boolean;
  55015. GAMMAREFLECTION: boolean;
  55016. RGBDREFLECTION: boolean;
  55017. LINEARSPECULARREFLECTION: boolean;
  55018. RADIANCEOCCLUSION: boolean;
  55019. HORIZONOCCLUSION: boolean;
  55020. INSTANCES: boolean;
  55021. THIN_INSTANCES: boolean;
  55022. NUM_BONE_INFLUENCERS: number;
  55023. BonesPerMesh: number;
  55024. BONETEXTURE: boolean;
  55025. NONUNIFORMSCALING: boolean;
  55026. MORPHTARGETS: boolean;
  55027. MORPHTARGETS_NORMAL: boolean;
  55028. MORPHTARGETS_TANGENT: boolean;
  55029. MORPHTARGETS_UV: boolean;
  55030. NUM_MORPH_INFLUENCERS: number;
  55031. IMAGEPROCESSING: boolean;
  55032. VIGNETTE: boolean;
  55033. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55034. VIGNETTEBLENDMODEOPAQUE: boolean;
  55035. TONEMAPPING: boolean;
  55036. TONEMAPPING_ACES: boolean;
  55037. CONTRAST: boolean;
  55038. COLORCURVES: boolean;
  55039. COLORGRADING: boolean;
  55040. COLORGRADING3D: boolean;
  55041. SAMPLER3DGREENDEPTH: boolean;
  55042. SAMPLER3DBGRMAP: boolean;
  55043. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55044. EXPOSURE: boolean;
  55045. MULTIVIEW: boolean;
  55046. USEPHYSICALLIGHTFALLOFF: boolean;
  55047. USEGLTFLIGHTFALLOFF: boolean;
  55048. TWOSIDEDLIGHTING: boolean;
  55049. SHADOWFLOAT: boolean;
  55050. CLIPPLANE: boolean;
  55051. CLIPPLANE2: boolean;
  55052. CLIPPLANE3: boolean;
  55053. CLIPPLANE4: boolean;
  55054. CLIPPLANE5: boolean;
  55055. CLIPPLANE6: boolean;
  55056. POINTSIZE: boolean;
  55057. FOG: boolean;
  55058. LOGARITHMICDEPTH: boolean;
  55059. FORCENORMALFORWARD: boolean;
  55060. SPECULARAA: boolean;
  55061. CLEARCOAT: boolean;
  55062. CLEARCOAT_DEFAULTIOR: boolean;
  55063. CLEARCOAT_TEXTURE: boolean;
  55064. CLEARCOAT_TEXTUREDIRECTUV: number;
  55065. CLEARCOAT_BUMP: boolean;
  55066. CLEARCOAT_BUMPDIRECTUV: number;
  55067. CLEARCOAT_TINT: boolean;
  55068. CLEARCOAT_TINT_TEXTURE: boolean;
  55069. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55070. ANISOTROPIC: boolean;
  55071. ANISOTROPIC_TEXTURE: boolean;
  55072. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55073. BRDF_V_HEIGHT_CORRELATED: boolean;
  55074. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55075. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55076. SHEEN: boolean;
  55077. SHEEN_TEXTURE: boolean;
  55078. SHEEN_TEXTUREDIRECTUV: number;
  55079. SHEEN_LINKWITHALBEDO: boolean;
  55080. SHEEN_ROUGHNESS: boolean;
  55081. SHEEN_ALBEDOSCALING: boolean;
  55082. SUBSURFACE: boolean;
  55083. SS_REFRACTION: boolean;
  55084. SS_TRANSLUCENCY: boolean;
  55085. SS_SCATTERING: boolean;
  55086. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55087. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55088. SS_REFRACTIONMAP_3D: boolean;
  55089. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55090. SS_LODINREFRACTIONALPHA: boolean;
  55091. SS_GAMMAREFRACTION: boolean;
  55092. SS_RGBDREFRACTION: boolean;
  55093. SS_LINEARSPECULARREFRACTION: boolean;
  55094. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55095. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55096. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55097. UNLIT: boolean;
  55098. DEBUGMODE: number;
  55099. /**
  55100. * Initializes the PBR Material defines.
  55101. */
  55102. constructor();
  55103. /**
  55104. * Resets the PBR Material defines.
  55105. */
  55106. reset(): void;
  55107. }
  55108. /**
  55109. * The Physically based material base class of BJS.
  55110. *
  55111. * This offers the main features of a standard PBR material.
  55112. * For more information, please refer to the documentation :
  55113. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55114. */
  55115. export abstract class PBRBaseMaterial extends PushMaterial {
  55116. /**
  55117. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55118. */
  55119. static readonly PBRMATERIAL_OPAQUE: number;
  55120. /**
  55121. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55122. */
  55123. static readonly PBRMATERIAL_ALPHATEST: number;
  55124. /**
  55125. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55126. */
  55127. static readonly PBRMATERIAL_ALPHABLEND: number;
  55128. /**
  55129. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55130. * They are also discarded below the alpha cutoff threshold to improve performances.
  55131. */
  55132. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55133. /**
  55134. * Defines the default value of how much AO map is occluding the analytical lights
  55135. * (point spot...).
  55136. */
  55137. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55138. /**
  55139. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55140. */
  55141. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55142. /**
  55143. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55144. * to enhance interoperability with other engines.
  55145. */
  55146. static readonly LIGHTFALLOFF_GLTF: number;
  55147. /**
  55148. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55149. * to enhance interoperability with other materials.
  55150. */
  55151. static readonly LIGHTFALLOFF_STANDARD: number;
  55152. /**
  55153. * Intensity of the direct lights e.g. the four lights available in your scene.
  55154. * This impacts both the direct diffuse and specular highlights.
  55155. */
  55156. protected _directIntensity: number;
  55157. /**
  55158. * Intensity of the emissive part of the material.
  55159. * This helps controlling the emissive effect without modifying the emissive color.
  55160. */
  55161. protected _emissiveIntensity: number;
  55162. /**
  55163. * Intensity of the environment e.g. how much the environment will light the object
  55164. * either through harmonics for rough material or through the refelction for shiny ones.
  55165. */
  55166. protected _environmentIntensity: number;
  55167. /**
  55168. * This is a special control allowing the reduction of the specular highlights coming from the
  55169. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55170. */
  55171. protected _specularIntensity: number;
  55172. /**
  55173. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55174. */
  55175. private _lightingInfos;
  55176. /**
  55177. * Debug Control allowing disabling the bump map on this material.
  55178. */
  55179. protected _disableBumpMap: boolean;
  55180. /**
  55181. * AKA Diffuse Texture in standard nomenclature.
  55182. */
  55183. protected _albedoTexture: Nullable<BaseTexture>;
  55184. /**
  55185. * AKA Occlusion Texture in other nomenclature.
  55186. */
  55187. protected _ambientTexture: Nullable<BaseTexture>;
  55188. /**
  55189. * AKA Occlusion Texture Intensity in other nomenclature.
  55190. */
  55191. protected _ambientTextureStrength: number;
  55192. /**
  55193. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55194. * 1 means it completely occludes it
  55195. * 0 mean it has no impact
  55196. */
  55197. protected _ambientTextureImpactOnAnalyticalLights: number;
  55198. /**
  55199. * Stores the alpha values in a texture.
  55200. */
  55201. protected _opacityTexture: Nullable<BaseTexture>;
  55202. /**
  55203. * Stores the reflection values in a texture.
  55204. */
  55205. protected _reflectionTexture: Nullable<BaseTexture>;
  55206. /**
  55207. * Stores the emissive values in a texture.
  55208. */
  55209. protected _emissiveTexture: Nullable<BaseTexture>;
  55210. /**
  55211. * AKA Specular texture in other nomenclature.
  55212. */
  55213. protected _reflectivityTexture: Nullable<BaseTexture>;
  55214. /**
  55215. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55216. */
  55217. protected _metallicTexture: Nullable<BaseTexture>;
  55218. /**
  55219. * Specifies the metallic scalar of the metallic/roughness workflow.
  55220. * Can also be used to scale the metalness values of the metallic texture.
  55221. */
  55222. protected _metallic: Nullable<number>;
  55223. /**
  55224. * Specifies the roughness scalar of the metallic/roughness workflow.
  55225. * Can also be used to scale the roughness values of the metallic texture.
  55226. */
  55227. protected _roughness: Nullable<number>;
  55228. /**
  55229. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55230. * By default the indexOfrefraction is used to compute F0;
  55231. *
  55232. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55233. *
  55234. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55235. * F90 = metallicReflectanceColor;
  55236. */
  55237. protected _metallicF0Factor: number;
  55238. /**
  55239. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55240. * By default the F90 is always 1;
  55241. *
  55242. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55243. *
  55244. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55245. * F90 = metallicReflectanceColor;
  55246. */
  55247. protected _metallicReflectanceColor: Color3;
  55248. /**
  55249. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55250. * This is multiply against the scalar values defined in the material.
  55251. */
  55252. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55253. /**
  55254. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55255. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55256. */
  55257. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55258. /**
  55259. * Stores surface normal data used to displace a mesh in a texture.
  55260. */
  55261. protected _bumpTexture: Nullable<BaseTexture>;
  55262. /**
  55263. * Stores the pre-calculated light information of a mesh in a texture.
  55264. */
  55265. protected _lightmapTexture: Nullable<BaseTexture>;
  55266. /**
  55267. * The color of a material in ambient lighting.
  55268. */
  55269. protected _ambientColor: Color3;
  55270. /**
  55271. * AKA Diffuse Color in other nomenclature.
  55272. */
  55273. protected _albedoColor: Color3;
  55274. /**
  55275. * AKA Specular Color in other nomenclature.
  55276. */
  55277. protected _reflectivityColor: Color3;
  55278. /**
  55279. * The color applied when light is reflected from a material.
  55280. */
  55281. protected _reflectionColor: Color3;
  55282. /**
  55283. * The color applied when light is emitted from a material.
  55284. */
  55285. protected _emissiveColor: Color3;
  55286. /**
  55287. * AKA Glossiness in other nomenclature.
  55288. */
  55289. protected _microSurface: number;
  55290. /**
  55291. * Specifies that the material will use the light map as a show map.
  55292. */
  55293. protected _useLightmapAsShadowmap: boolean;
  55294. /**
  55295. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55296. * makes the reflect vector face the model (under horizon).
  55297. */
  55298. protected _useHorizonOcclusion: boolean;
  55299. /**
  55300. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55301. * too much the area relying on ambient texture to define their ambient occlusion.
  55302. */
  55303. protected _useRadianceOcclusion: boolean;
  55304. /**
  55305. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55306. */
  55307. protected _useAlphaFromAlbedoTexture: boolean;
  55308. /**
  55309. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55310. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55311. */
  55312. protected _useSpecularOverAlpha: boolean;
  55313. /**
  55314. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55315. */
  55316. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55317. /**
  55318. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55319. */
  55320. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55321. /**
  55322. * Specifies if the metallic texture contains the roughness information in its green channel.
  55323. */
  55324. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55325. /**
  55326. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55327. */
  55328. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55329. /**
  55330. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55331. */
  55332. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55333. /**
  55334. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55335. */
  55336. protected _useAmbientInGrayScale: boolean;
  55337. /**
  55338. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55339. * The material will try to infer what glossiness each pixel should be.
  55340. */
  55341. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55342. /**
  55343. * Defines the falloff type used in this material.
  55344. * It by default is Physical.
  55345. */
  55346. protected _lightFalloff: number;
  55347. /**
  55348. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55349. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55350. */
  55351. protected _useRadianceOverAlpha: boolean;
  55352. /**
  55353. * Allows using an object space normal map (instead of tangent space).
  55354. */
  55355. protected _useObjectSpaceNormalMap: boolean;
  55356. /**
  55357. * Allows using the bump map in parallax mode.
  55358. */
  55359. protected _useParallax: boolean;
  55360. /**
  55361. * Allows using the bump map in parallax occlusion mode.
  55362. */
  55363. protected _useParallaxOcclusion: boolean;
  55364. /**
  55365. * Controls the scale bias of the parallax mode.
  55366. */
  55367. protected _parallaxScaleBias: number;
  55368. /**
  55369. * If sets to true, disables all the lights affecting the material.
  55370. */
  55371. protected _disableLighting: boolean;
  55372. /**
  55373. * Number of Simultaneous lights allowed on the material.
  55374. */
  55375. protected _maxSimultaneousLights: number;
  55376. /**
  55377. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55378. */
  55379. protected _invertNormalMapX: boolean;
  55380. /**
  55381. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55382. */
  55383. protected _invertNormalMapY: boolean;
  55384. /**
  55385. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55386. */
  55387. protected _twoSidedLighting: boolean;
  55388. /**
  55389. * Defines the alpha limits in alpha test mode.
  55390. */
  55391. protected _alphaCutOff: number;
  55392. /**
  55393. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55394. */
  55395. protected _forceAlphaTest: boolean;
  55396. /**
  55397. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55398. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55399. */
  55400. protected _useAlphaFresnel: boolean;
  55401. /**
  55402. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55403. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55404. */
  55405. protected _useLinearAlphaFresnel: boolean;
  55406. /**
  55407. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55408. * from cos thetav and roughness:
  55409. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55410. */
  55411. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55412. /**
  55413. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55414. */
  55415. protected _forceIrradianceInFragment: boolean;
  55416. private _realTimeFiltering;
  55417. /**
  55418. * Enables realtime filtering on the texture.
  55419. */
  55420. get realTimeFiltering(): boolean;
  55421. set realTimeFiltering(b: boolean);
  55422. private _realTimeFilteringQuality;
  55423. /**
  55424. * Quality switch for realtime filtering
  55425. */
  55426. get realTimeFilteringQuality(): number;
  55427. set realTimeFilteringQuality(n: number);
  55428. /**
  55429. * Force normal to face away from face.
  55430. */
  55431. protected _forceNormalForward: boolean;
  55432. /**
  55433. * Enables specular anti aliasing in the PBR shader.
  55434. * It will both interacts on the Geometry for analytical and IBL lighting.
  55435. * It also prefilter the roughness map based on the bump values.
  55436. */
  55437. protected _enableSpecularAntiAliasing: boolean;
  55438. /**
  55439. * Default configuration related to image processing available in the PBR Material.
  55440. */
  55441. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55442. /**
  55443. * Keep track of the image processing observer to allow dispose and replace.
  55444. */
  55445. private _imageProcessingObserver;
  55446. /**
  55447. * Attaches a new image processing configuration to the PBR Material.
  55448. * @param configuration
  55449. */
  55450. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55451. /**
  55452. * Stores the available render targets.
  55453. */
  55454. private _renderTargets;
  55455. /**
  55456. * Sets the global ambient color for the material used in lighting calculations.
  55457. */
  55458. private _globalAmbientColor;
  55459. /**
  55460. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55461. */
  55462. private _useLogarithmicDepth;
  55463. /**
  55464. * If set to true, no lighting calculations will be applied.
  55465. */
  55466. private _unlit;
  55467. private _debugMode;
  55468. /**
  55469. * @hidden
  55470. * This is reserved for the inspector.
  55471. * Defines the material debug mode.
  55472. * It helps seeing only some components of the material while troubleshooting.
  55473. */
  55474. debugMode: number;
  55475. /**
  55476. * @hidden
  55477. * This is reserved for the inspector.
  55478. * Specify from where on screen the debug mode should start.
  55479. * The value goes from -1 (full screen) to 1 (not visible)
  55480. * It helps with side by side comparison against the final render
  55481. * This defaults to -1
  55482. */
  55483. private debugLimit;
  55484. /**
  55485. * @hidden
  55486. * This is reserved for the inspector.
  55487. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55488. * You can use the factor to better multiply the final value.
  55489. */
  55490. private debugFactor;
  55491. /**
  55492. * Defines the clear coat layer parameters for the material.
  55493. */
  55494. readonly clearCoat: PBRClearCoatConfiguration;
  55495. /**
  55496. * Defines the anisotropic parameters for the material.
  55497. */
  55498. readonly anisotropy: PBRAnisotropicConfiguration;
  55499. /**
  55500. * Defines the BRDF parameters for the material.
  55501. */
  55502. readonly brdf: PBRBRDFConfiguration;
  55503. /**
  55504. * Defines the Sheen parameters for the material.
  55505. */
  55506. readonly sheen: PBRSheenConfiguration;
  55507. /**
  55508. * Defines the SubSurface parameters for the material.
  55509. */
  55510. readonly subSurface: PBRSubSurfaceConfiguration;
  55511. /**
  55512. * Defines the detail map parameters for the material.
  55513. */
  55514. readonly detailMap: DetailMapConfiguration;
  55515. protected _rebuildInParallel: boolean;
  55516. /**
  55517. * Instantiates a new PBRMaterial instance.
  55518. *
  55519. * @param name The material name
  55520. * @param scene The scene the material will be use in.
  55521. */
  55522. constructor(name: string, scene: Scene);
  55523. /**
  55524. * Gets a boolean indicating that current material needs to register RTT
  55525. */
  55526. get hasRenderTargetTextures(): boolean;
  55527. /**
  55528. * Gets the name of the material class.
  55529. */
  55530. getClassName(): string;
  55531. /**
  55532. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55533. */
  55534. get useLogarithmicDepth(): boolean;
  55535. /**
  55536. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55537. */
  55538. set useLogarithmicDepth(value: boolean);
  55539. /**
  55540. * Returns true if alpha blending should be disabled.
  55541. */
  55542. protected get _disableAlphaBlending(): boolean;
  55543. /**
  55544. * Specifies whether or not this material should be rendered in alpha blend mode.
  55545. */
  55546. needAlphaBlending(): boolean;
  55547. /**
  55548. * Specifies whether or not this material should be rendered in alpha test mode.
  55549. */
  55550. needAlphaTesting(): boolean;
  55551. /**
  55552. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55553. */
  55554. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55555. /**
  55556. * Gets the texture used for the alpha test.
  55557. */
  55558. getAlphaTestTexture(): Nullable<BaseTexture>;
  55559. /**
  55560. * Specifies that the submesh is ready to be used.
  55561. * @param mesh - BJS mesh.
  55562. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55563. * @param useInstances - Specifies that instances should be used.
  55564. * @returns - boolean indicating that the submesh is ready or not.
  55565. */
  55566. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55567. /**
  55568. * Specifies if the material uses metallic roughness workflow.
  55569. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55570. */
  55571. isMetallicWorkflow(): boolean;
  55572. private _prepareEffect;
  55573. private _prepareDefines;
  55574. /**
  55575. * Force shader compilation
  55576. */
  55577. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55578. /**
  55579. * Initializes the uniform buffer layout for the shader.
  55580. */
  55581. buildUniformLayout(): void;
  55582. /**
  55583. * Unbinds the material from the mesh
  55584. */
  55585. unbind(): void;
  55586. /**
  55587. * Binds the submesh data.
  55588. * @param world - The world matrix.
  55589. * @param mesh - The BJS mesh.
  55590. * @param subMesh - A submesh of the BJS mesh.
  55591. */
  55592. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55593. /**
  55594. * Returns the animatable textures.
  55595. * @returns - Array of animatable textures.
  55596. */
  55597. getAnimatables(): IAnimatable[];
  55598. /**
  55599. * Returns the texture used for reflections.
  55600. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55601. */
  55602. private _getReflectionTexture;
  55603. /**
  55604. * Returns an array of the actively used textures.
  55605. * @returns - Array of BaseTextures
  55606. */
  55607. getActiveTextures(): BaseTexture[];
  55608. /**
  55609. * Checks to see if a texture is used in the material.
  55610. * @param texture - Base texture to use.
  55611. * @returns - Boolean specifying if a texture is used in the material.
  55612. */
  55613. hasTexture(texture: BaseTexture): boolean;
  55614. /**
  55615. * Disposes the resources of the material.
  55616. * @param forceDisposeEffect - Forces the disposal of effects.
  55617. * @param forceDisposeTextures - Forces the disposal of all textures.
  55618. */
  55619. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55620. }
  55621. }
  55622. declare module BABYLON {
  55623. /**
  55624. * The Physically based material of BJS.
  55625. *
  55626. * This offers the main features of a standard PBR material.
  55627. * For more information, please refer to the documentation :
  55628. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55629. */
  55630. export class PBRMaterial extends PBRBaseMaterial {
  55631. /**
  55632. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55633. */
  55634. static readonly PBRMATERIAL_OPAQUE: number;
  55635. /**
  55636. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55637. */
  55638. static readonly PBRMATERIAL_ALPHATEST: number;
  55639. /**
  55640. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55641. */
  55642. static readonly PBRMATERIAL_ALPHABLEND: number;
  55643. /**
  55644. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55645. * They are also discarded below the alpha cutoff threshold to improve performances.
  55646. */
  55647. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55648. /**
  55649. * Defines the default value of how much AO map is occluding the analytical lights
  55650. * (point spot...).
  55651. */
  55652. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55653. /**
  55654. * Intensity of the direct lights e.g. the four lights available in your scene.
  55655. * This impacts both the direct diffuse and specular highlights.
  55656. */
  55657. directIntensity: number;
  55658. /**
  55659. * Intensity of the emissive part of the material.
  55660. * This helps controlling the emissive effect without modifying the emissive color.
  55661. */
  55662. emissiveIntensity: number;
  55663. /**
  55664. * Intensity of the environment e.g. how much the environment will light the object
  55665. * either through harmonics for rough material or through the refelction for shiny ones.
  55666. */
  55667. environmentIntensity: number;
  55668. /**
  55669. * This is a special control allowing the reduction of the specular highlights coming from the
  55670. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55671. */
  55672. specularIntensity: number;
  55673. /**
  55674. * Debug Control allowing disabling the bump map on this material.
  55675. */
  55676. disableBumpMap: boolean;
  55677. /**
  55678. * AKA Diffuse Texture in standard nomenclature.
  55679. */
  55680. albedoTexture: BaseTexture;
  55681. /**
  55682. * AKA Occlusion Texture in other nomenclature.
  55683. */
  55684. ambientTexture: BaseTexture;
  55685. /**
  55686. * AKA Occlusion Texture Intensity in other nomenclature.
  55687. */
  55688. ambientTextureStrength: number;
  55689. /**
  55690. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55691. * 1 means it completely occludes it
  55692. * 0 mean it has no impact
  55693. */
  55694. ambientTextureImpactOnAnalyticalLights: number;
  55695. /**
  55696. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55697. */
  55698. opacityTexture: BaseTexture;
  55699. /**
  55700. * Stores the reflection values in a texture.
  55701. */
  55702. reflectionTexture: Nullable<BaseTexture>;
  55703. /**
  55704. * Stores the emissive values in a texture.
  55705. */
  55706. emissiveTexture: BaseTexture;
  55707. /**
  55708. * AKA Specular texture in other nomenclature.
  55709. */
  55710. reflectivityTexture: BaseTexture;
  55711. /**
  55712. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55713. */
  55714. metallicTexture: BaseTexture;
  55715. /**
  55716. * Specifies the metallic scalar of the metallic/roughness workflow.
  55717. * Can also be used to scale the metalness values of the metallic texture.
  55718. */
  55719. metallic: Nullable<number>;
  55720. /**
  55721. * Specifies the roughness scalar of the metallic/roughness workflow.
  55722. * Can also be used to scale the roughness values of the metallic texture.
  55723. */
  55724. roughness: Nullable<number>;
  55725. /**
  55726. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55727. * By default the indexOfrefraction is used to compute F0;
  55728. *
  55729. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55730. *
  55731. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55732. * F90 = metallicReflectanceColor;
  55733. */
  55734. metallicF0Factor: number;
  55735. /**
  55736. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55737. * By default the F90 is always 1;
  55738. *
  55739. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55740. *
  55741. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55742. * F90 = metallicReflectanceColor;
  55743. */
  55744. metallicReflectanceColor: Color3;
  55745. /**
  55746. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55747. * This is multiply against the scalar values defined in the material.
  55748. */
  55749. metallicReflectanceTexture: Nullable<BaseTexture>;
  55750. /**
  55751. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55752. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55753. */
  55754. microSurfaceTexture: BaseTexture;
  55755. /**
  55756. * Stores surface normal data used to displace a mesh in a texture.
  55757. */
  55758. bumpTexture: BaseTexture;
  55759. /**
  55760. * Stores the pre-calculated light information of a mesh in a texture.
  55761. */
  55762. lightmapTexture: BaseTexture;
  55763. /**
  55764. * Stores the refracted light information in a texture.
  55765. */
  55766. get refractionTexture(): Nullable<BaseTexture>;
  55767. set refractionTexture(value: Nullable<BaseTexture>);
  55768. /**
  55769. * The color of a material in ambient lighting.
  55770. */
  55771. ambientColor: Color3;
  55772. /**
  55773. * AKA Diffuse Color in other nomenclature.
  55774. */
  55775. albedoColor: Color3;
  55776. /**
  55777. * AKA Specular Color in other nomenclature.
  55778. */
  55779. reflectivityColor: Color3;
  55780. /**
  55781. * The color reflected from the material.
  55782. */
  55783. reflectionColor: Color3;
  55784. /**
  55785. * The color emitted from the material.
  55786. */
  55787. emissiveColor: Color3;
  55788. /**
  55789. * AKA Glossiness in other nomenclature.
  55790. */
  55791. microSurface: number;
  55792. /**
  55793. * Index of refraction of the material base layer.
  55794. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55795. *
  55796. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55797. *
  55798. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55799. */
  55800. get indexOfRefraction(): number;
  55801. set indexOfRefraction(value: number);
  55802. /**
  55803. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55804. */
  55805. get invertRefractionY(): boolean;
  55806. set invertRefractionY(value: boolean);
  55807. /**
  55808. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55809. * Materials half opaque for instance using refraction could benefit from this control.
  55810. */
  55811. get linkRefractionWithTransparency(): boolean;
  55812. set linkRefractionWithTransparency(value: boolean);
  55813. /**
  55814. * If true, the light map contains occlusion information instead of lighting info.
  55815. */
  55816. useLightmapAsShadowmap: boolean;
  55817. /**
  55818. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55819. */
  55820. useAlphaFromAlbedoTexture: boolean;
  55821. /**
  55822. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55823. */
  55824. forceAlphaTest: boolean;
  55825. /**
  55826. * Defines the alpha limits in alpha test mode.
  55827. */
  55828. alphaCutOff: number;
  55829. /**
  55830. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55831. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55832. */
  55833. useSpecularOverAlpha: boolean;
  55834. /**
  55835. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55836. */
  55837. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55838. /**
  55839. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55840. */
  55841. useRoughnessFromMetallicTextureAlpha: boolean;
  55842. /**
  55843. * Specifies if the metallic texture contains the roughness information in its green channel.
  55844. */
  55845. useRoughnessFromMetallicTextureGreen: boolean;
  55846. /**
  55847. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55848. */
  55849. useMetallnessFromMetallicTextureBlue: boolean;
  55850. /**
  55851. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55852. */
  55853. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55854. /**
  55855. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55856. */
  55857. useAmbientInGrayScale: boolean;
  55858. /**
  55859. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55860. * The material will try to infer what glossiness each pixel should be.
  55861. */
  55862. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55863. /**
  55864. * BJS is using an harcoded light falloff based on a manually sets up range.
  55865. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55866. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55867. */
  55868. get usePhysicalLightFalloff(): boolean;
  55869. /**
  55870. * BJS is using an harcoded light falloff based on a manually sets up range.
  55871. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55872. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55873. */
  55874. set usePhysicalLightFalloff(value: boolean);
  55875. /**
  55876. * In order to support the falloff compatibility with gltf, a special mode has been added
  55877. * to reproduce the gltf light falloff.
  55878. */
  55879. get useGLTFLightFalloff(): boolean;
  55880. /**
  55881. * In order to support the falloff compatibility with gltf, a special mode has been added
  55882. * to reproduce the gltf light falloff.
  55883. */
  55884. set useGLTFLightFalloff(value: boolean);
  55885. /**
  55886. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55887. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55888. */
  55889. useRadianceOverAlpha: boolean;
  55890. /**
  55891. * Allows using an object space normal map (instead of tangent space).
  55892. */
  55893. useObjectSpaceNormalMap: boolean;
  55894. /**
  55895. * Allows using the bump map in parallax mode.
  55896. */
  55897. useParallax: boolean;
  55898. /**
  55899. * Allows using the bump map in parallax occlusion mode.
  55900. */
  55901. useParallaxOcclusion: boolean;
  55902. /**
  55903. * Controls the scale bias of the parallax mode.
  55904. */
  55905. parallaxScaleBias: number;
  55906. /**
  55907. * If sets to true, disables all the lights affecting the material.
  55908. */
  55909. disableLighting: boolean;
  55910. /**
  55911. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55912. */
  55913. forceIrradianceInFragment: boolean;
  55914. /**
  55915. * Number of Simultaneous lights allowed on the material.
  55916. */
  55917. maxSimultaneousLights: number;
  55918. /**
  55919. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55920. */
  55921. invertNormalMapX: boolean;
  55922. /**
  55923. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55924. */
  55925. invertNormalMapY: boolean;
  55926. /**
  55927. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55928. */
  55929. twoSidedLighting: boolean;
  55930. /**
  55931. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55932. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55933. */
  55934. useAlphaFresnel: boolean;
  55935. /**
  55936. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55937. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55938. */
  55939. useLinearAlphaFresnel: boolean;
  55940. /**
  55941. * Let user defines the brdf lookup texture used for IBL.
  55942. * A default 8bit version is embedded but you could point at :
  55943. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55944. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55945. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55946. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55947. */
  55948. environmentBRDFTexture: Nullable<BaseTexture>;
  55949. /**
  55950. * Force normal to face away from face.
  55951. */
  55952. forceNormalForward: boolean;
  55953. /**
  55954. * Enables specular anti aliasing in the PBR shader.
  55955. * It will both interacts on the Geometry for analytical and IBL lighting.
  55956. * It also prefilter the roughness map based on the bump values.
  55957. */
  55958. enableSpecularAntiAliasing: boolean;
  55959. /**
  55960. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55961. * makes the reflect vector face the model (under horizon).
  55962. */
  55963. useHorizonOcclusion: boolean;
  55964. /**
  55965. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55966. * too much the area relying on ambient texture to define their ambient occlusion.
  55967. */
  55968. useRadianceOcclusion: boolean;
  55969. /**
  55970. * If set to true, no lighting calculations will be applied.
  55971. */
  55972. unlit: boolean;
  55973. /**
  55974. * Gets the image processing configuration used either in this material.
  55975. */
  55976. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55977. /**
  55978. * Sets the Default image processing configuration used either in the this material.
  55979. *
  55980. * If sets to null, the scene one is in use.
  55981. */
  55982. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55983. /**
  55984. * Gets wether the color curves effect is enabled.
  55985. */
  55986. get cameraColorCurvesEnabled(): boolean;
  55987. /**
  55988. * Sets wether the color curves effect is enabled.
  55989. */
  55990. set cameraColorCurvesEnabled(value: boolean);
  55991. /**
  55992. * Gets wether the color grading effect is enabled.
  55993. */
  55994. get cameraColorGradingEnabled(): boolean;
  55995. /**
  55996. * Gets wether the color grading effect is enabled.
  55997. */
  55998. set cameraColorGradingEnabled(value: boolean);
  55999. /**
  56000. * Gets wether tonemapping is enabled or not.
  56001. */
  56002. get cameraToneMappingEnabled(): boolean;
  56003. /**
  56004. * Sets wether tonemapping is enabled or not
  56005. */
  56006. set cameraToneMappingEnabled(value: boolean);
  56007. /**
  56008. * The camera exposure used on this material.
  56009. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56010. * This corresponds to a photographic exposure.
  56011. */
  56012. get cameraExposure(): number;
  56013. /**
  56014. * The camera exposure used on this material.
  56015. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56016. * This corresponds to a photographic exposure.
  56017. */
  56018. set cameraExposure(value: number);
  56019. /**
  56020. * Gets The camera contrast used on this material.
  56021. */
  56022. get cameraContrast(): number;
  56023. /**
  56024. * Sets The camera contrast used on this material.
  56025. */
  56026. set cameraContrast(value: number);
  56027. /**
  56028. * Gets the Color Grading 2D Lookup Texture.
  56029. */
  56030. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56031. /**
  56032. * Sets the Color Grading 2D Lookup Texture.
  56033. */
  56034. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56035. /**
  56036. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56037. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56038. * 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;
  56039. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56040. */
  56041. get cameraColorCurves(): Nullable<ColorCurves>;
  56042. /**
  56043. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56044. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56045. * 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;
  56046. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56047. */
  56048. set cameraColorCurves(value: Nullable<ColorCurves>);
  56049. /**
  56050. * Instantiates a new PBRMaterial instance.
  56051. *
  56052. * @param name The material name
  56053. * @param scene The scene the material will be use in.
  56054. */
  56055. constructor(name: string, scene: Scene);
  56056. /**
  56057. * Returns the name of this material class.
  56058. */
  56059. getClassName(): string;
  56060. /**
  56061. * Makes a duplicate of the current material.
  56062. * @param name - name to use for the new material.
  56063. */
  56064. clone(name: string): PBRMaterial;
  56065. /**
  56066. * Serializes this PBR Material.
  56067. * @returns - An object with the serialized material.
  56068. */
  56069. serialize(): any;
  56070. /**
  56071. * Parses a PBR Material from a serialized object.
  56072. * @param source - Serialized object.
  56073. * @param scene - BJS scene instance.
  56074. * @param rootUrl - url for the scene object
  56075. * @returns - PBRMaterial
  56076. */
  56077. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56078. }
  56079. }
  56080. declare module BABYLON {
  56081. /**
  56082. * Direct draw surface info
  56083. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56084. */
  56085. export interface DDSInfo {
  56086. /**
  56087. * Width of the texture
  56088. */
  56089. width: number;
  56090. /**
  56091. * Width of the texture
  56092. */
  56093. height: number;
  56094. /**
  56095. * Number of Mipmaps for the texture
  56096. * @see https://en.wikipedia.org/wiki/Mipmap
  56097. */
  56098. mipmapCount: number;
  56099. /**
  56100. * If the textures format is a known fourCC format
  56101. * @see https://www.fourcc.org/
  56102. */
  56103. isFourCC: boolean;
  56104. /**
  56105. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56106. */
  56107. isRGB: boolean;
  56108. /**
  56109. * If the texture is a lumincance format
  56110. */
  56111. isLuminance: boolean;
  56112. /**
  56113. * If this is a cube texture
  56114. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56115. */
  56116. isCube: boolean;
  56117. /**
  56118. * If the texture is a compressed format eg. FOURCC_DXT1
  56119. */
  56120. isCompressed: boolean;
  56121. /**
  56122. * The dxgiFormat of the texture
  56123. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56124. */
  56125. dxgiFormat: number;
  56126. /**
  56127. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56128. */
  56129. textureType: number;
  56130. /**
  56131. * Sphericle polynomial created for the dds texture
  56132. */
  56133. sphericalPolynomial?: SphericalPolynomial;
  56134. }
  56135. /**
  56136. * Class used to provide DDS decompression tools
  56137. */
  56138. export class DDSTools {
  56139. /**
  56140. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56141. */
  56142. static StoreLODInAlphaChannel: boolean;
  56143. /**
  56144. * Gets DDS information from an array buffer
  56145. * @param data defines the array buffer view to read data from
  56146. * @returns the DDS information
  56147. */
  56148. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56149. private static _FloatView;
  56150. private static _Int32View;
  56151. private static _ToHalfFloat;
  56152. private static _FromHalfFloat;
  56153. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56154. private static _GetHalfFloatRGBAArrayBuffer;
  56155. private static _GetFloatRGBAArrayBuffer;
  56156. private static _GetFloatAsUIntRGBAArrayBuffer;
  56157. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56158. private static _GetRGBAArrayBuffer;
  56159. private static _ExtractLongWordOrder;
  56160. private static _GetRGBArrayBuffer;
  56161. private static _GetLuminanceArrayBuffer;
  56162. /**
  56163. * Uploads DDS Levels to a Babylon Texture
  56164. * @hidden
  56165. */
  56166. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56167. }
  56168. interface ThinEngine {
  56169. /**
  56170. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56171. * @param rootUrl defines the url where the file to load is located
  56172. * @param scene defines the current scene
  56173. * @param lodScale defines scale to apply to the mip map selection
  56174. * @param lodOffset defines offset to apply to the mip map selection
  56175. * @param onLoad defines an optional callback raised when the texture is loaded
  56176. * @param onError defines an optional callback raised if there is an issue to load the texture
  56177. * @param format defines the format of the data
  56178. * @param forcedExtension defines the extension to use to pick the right loader
  56179. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56180. * @returns the cube texture as an InternalTexture
  56181. */
  56182. 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;
  56183. }
  56184. }
  56185. declare module BABYLON {
  56186. /**
  56187. * Implementation of the DDS Texture Loader.
  56188. * @hidden
  56189. */
  56190. export class _DDSTextureLoader implements IInternalTextureLoader {
  56191. /**
  56192. * Defines wether the loader supports cascade loading the different faces.
  56193. */
  56194. readonly supportCascades: boolean;
  56195. /**
  56196. * This returns if the loader support the current file information.
  56197. * @param extension defines the file extension of the file being loaded
  56198. * @returns true if the loader can load the specified file
  56199. */
  56200. canLoad(extension: string): boolean;
  56201. /**
  56202. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56203. * @param data contains the texture data
  56204. * @param texture defines the BabylonJS internal texture
  56205. * @param createPolynomials will be true if polynomials have been requested
  56206. * @param onLoad defines the callback to trigger once the texture is ready
  56207. * @param onError defines the callback to trigger in case of error
  56208. */
  56209. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56210. /**
  56211. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56212. * @param data contains the texture data
  56213. * @param texture defines the BabylonJS internal texture
  56214. * @param callback defines the method to call once ready to upload
  56215. */
  56216. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56217. }
  56218. }
  56219. declare module BABYLON {
  56220. /**
  56221. * Implementation of the ENV Texture Loader.
  56222. * @hidden
  56223. */
  56224. export class _ENVTextureLoader implements IInternalTextureLoader {
  56225. /**
  56226. * Defines wether the loader supports cascade loading the different faces.
  56227. */
  56228. readonly supportCascades: boolean;
  56229. /**
  56230. * This returns if the loader support the current file information.
  56231. * @param extension defines the file extension of the file being loaded
  56232. * @returns true if the loader can load the specified file
  56233. */
  56234. canLoad(extension: string): boolean;
  56235. /**
  56236. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56237. * @param data contains the texture data
  56238. * @param texture defines the BabylonJS internal texture
  56239. * @param createPolynomials will be true if polynomials have been requested
  56240. * @param onLoad defines the callback to trigger once the texture is ready
  56241. * @param onError defines the callback to trigger in case of error
  56242. */
  56243. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56244. /**
  56245. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56246. * @param data contains the texture data
  56247. * @param texture defines the BabylonJS internal texture
  56248. * @param callback defines the method to call once ready to upload
  56249. */
  56250. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56251. }
  56252. }
  56253. declare module BABYLON {
  56254. /**
  56255. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56256. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56257. */
  56258. export class KhronosTextureContainer {
  56259. /** contents of the KTX container file */
  56260. data: ArrayBufferView;
  56261. private static HEADER_LEN;
  56262. private static COMPRESSED_2D;
  56263. private static COMPRESSED_3D;
  56264. private static TEX_2D;
  56265. private static TEX_3D;
  56266. /**
  56267. * Gets the openGL type
  56268. */
  56269. glType: number;
  56270. /**
  56271. * Gets the openGL type size
  56272. */
  56273. glTypeSize: number;
  56274. /**
  56275. * Gets the openGL format
  56276. */
  56277. glFormat: number;
  56278. /**
  56279. * Gets the openGL internal format
  56280. */
  56281. glInternalFormat: number;
  56282. /**
  56283. * Gets the base internal format
  56284. */
  56285. glBaseInternalFormat: number;
  56286. /**
  56287. * Gets image width in pixel
  56288. */
  56289. pixelWidth: number;
  56290. /**
  56291. * Gets image height in pixel
  56292. */
  56293. pixelHeight: number;
  56294. /**
  56295. * Gets image depth in pixels
  56296. */
  56297. pixelDepth: number;
  56298. /**
  56299. * Gets the number of array elements
  56300. */
  56301. numberOfArrayElements: number;
  56302. /**
  56303. * Gets the number of faces
  56304. */
  56305. numberOfFaces: number;
  56306. /**
  56307. * Gets the number of mipmap levels
  56308. */
  56309. numberOfMipmapLevels: number;
  56310. /**
  56311. * Gets the bytes of key value data
  56312. */
  56313. bytesOfKeyValueData: number;
  56314. /**
  56315. * Gets the load type
  56316. */
  56317. loadType: number;
  56318. /**
  56319. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56320. */
  56321. isInvalid: boolean;
  56322. /**
  56323. * Creates a new KhronosTextureContainer
  56324. * @param data contents of the KTX container file
  56325. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56326. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56327. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56328. */
  56329. constructor(
  56330. /** contents of the KTX container file */
  56331. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56332. /**
  56333. * Uploads KTX content to a Babylon Texture.
  56334. * It is assumed that the texture has already been created & is currently bound
  56335. * @hidden
  56336. */
  56337. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56338. private _upload2DCompressedLevels;
  56339. /**
  56340. * Checks if the given data starts with a KTX file identifier.
  56341. * @param data the data to check
  56342. * @returns true if the data is a KTX file or false otherwise
  56343. */
  56344. static IsValid(data: ArrayBufferView): boolean;
  56345. }
  56346. }
  56347. declare module BABYLON {
  56348. /**
  56349. * Class for loading KTX2 files
  56350. * !!! Experimental Extension Subject to Changes !!!
  56351. * @hidden
  56352. */
  56353. export class KhronosTextureContainer2 {
  56354. private static _ModulePromise;
  56355. private static _TranscodeFormat;
  56356. constructor(engine: ThinEngine);
  56357. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56358. private _determineTranscodeFormat;
  56359. /**
  56360. * Checks if the given data starts with a KTX2 file identifier.
  56361. * @param data the data to check
  56362. * @returns true if the data is a KTX2 file or false otherwise
  56363. */
  56364. static IsValid(data: ArrayBufferView): boolean;
  56365. }
  56366. }
  56367. declare module BABYLON {
  56368. /**
  56369. * Implementation of the KTX Texture Loader.
  56370. * @hidden
  56371. */
  56372. export class _KTXTextureLoader implements IInternalTextureLoader {
  56373. /**
  56374. * Defines wether the loader supports cascade loading the different faces.
  56375. */
  56376. readonly supportCascades: boolean;
  56377. /**
  56378. * This returns if the loader support the current file information.
  56379. * @param extension defines the file extension of the file being loaded
  56380. * @returns true if the loader can load the specified file
  56381. */
  56382. canLoad(extension: string): boolean;
  56383. /**
  56384. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56385. * @param data contains the texture data
  56386. * @param texture defines the BabylonJS internal texture
  56387. * @param createPolynomials will be true if polynomials have been requested
  56388. * @param onLoad defines the callback to trigger once the texture is ready
  56389. * @param onError defines the callback to trigger in case of error
  56390. */
  56391. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56392. /**
  56393. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56394. * @param data contains the texture data
  56395. * @param texture defines the BabylonJS internal texture
  56396. * @param callback defines the method to call once ready to upload
  56397. */
  56398. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56399. }
  56400. }
  56401. declare module BABYLON {
  56402. /** @hidden */
  56403. export var _forceSceneHelpersToBundle: boolean;
  56404. interface Scene {
  56405. /**
  56406. * Creates a default light for the scene.
  56407. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56408. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56409. */
  56410. createDefaultLight(replace?: boolean): void;
  56411. /**
  56412. * Creates a default camera for the scene.
  56413. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56414. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56415. * @param replace has default false, when true replaces the active camera in the scene
  56416. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56417. */
  56418. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56419. /**
  56420. * Creates a default camera and a default light.
  56421. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56422. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56423. * @param replace has the default false, when true replaces the active camera/light in the scene
  56424. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56425. */
  56426. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56427. /**
  56428. * Creates a new sky box
  56429. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56430. * @param environmentTexture defines the texture to use as environment texture
  56431. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56432. * @param scale defines the overall scale of the skybox
  56433. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56434. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56435. * @returns a new mesh holding the sky box
  56436. */
  56437. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56438. /**
  56439. * Creates a new environment
  56440. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56441. * @param options defines the options you can use to configure the environment
  56442. * @returns the new EnvironmentHelper
  56443. */
  56444. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56445. /**
  56446. * Creates a new VREXperienceHelper
  56447. * @see http://doc.babylonjs.com/how_to/webvr_helper
  56448. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56449. * @returns a new VREXperienceHelper
  56450. */
  56451. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56452. /**
  56453. * Creates a new WebXRDefaultExperience
  56454. * @see http://doc.babylonjs.com/how_to/webxr
  56455. * @param options experience options
  56456. * @returns a promise for a new WebXRDefaultExperience
  56457. */
  56458. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56459. }
  56460. }
  56461. declare module BABYLON {
  56462. /**
  56463. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56464. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56465. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56466. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56467. */
  56468. export class VideoDome extends TransformNode {
  56469. /**
  56470. * Define the video source as a Monoscopic panoramic 360 video.
  56471. */
  56472. static readonly MODE_MONOSCOPIC: number;
  56473. /**
  56474. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56475. */
  56476. static readonly MODE_TOPBOTTOM: number;
  56477. /**
  56478. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56479. */
  56480. static readonly MODE_SIDEBYSIDE: number;
  56481. private _halfDome;
  56482. private _useDirectMapping;
  56483. /**
  56484. * The video texture being displayed on the sphere
  56485. */
  56486. protected _videoTexture: VideoTexture;
  56487. /**
  56488. * Gets the video texture being displayed on the sphere
  56489. */
  56490. get videoTexture(): VideoTexture;
  56491. /**
  56492. * The skybox material
  56493. */
  56494. protected _material: BackgroundMaterial;
  56495. /**
  56496. * The surface used for the skybox
  56497. */
  56498. protected _mesh: Mesh;
  56499. /**
  56500. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56501. */
  56502. private _halfDomeMask;
  56503. /**
  56504. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56505. * Also see the options.resolution property.
  56506. */
  56507. get fovMultiplier(): number;
  56508. set fovMultiplier(value: number);
  56509. private _videoMode;
  56510. /**
  56511. * Gets or set the current video mode for the video. It can be:
  56512. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56513. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56514. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56515. */
  56516. get videoMode(): number;
  56517. set videoMode(value: number);
  56518. /**
  56519. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56520. *
  56521. */
  56522. get halfDome(): boolean;
  56523. /**
  56524. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56525. */
  56526. set halfDome(enabled: boolean);
  56527. /**
  56528. * Oberserver used in Stereoscopic VR Mode.
  56529. */
  56530. private _onBeforeCameraRenderObserver;
  56531. /**
  56532. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56533. * @param name Element's name, child elements will append suffixes for their own names.
  56534. * @param urlsOrVideo defines the url(s) or the video element to use
  56535. * @param options An object containing optional or exposed sub element properties
  56536. */
  56537. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56538. resolution?: number;
  56539. clickToPlay?: boolean;
  56540. autoPlay?: boolean;
  56541. loop?: boolean;
  56542. size?: number;
  56543. poster?: string;
  56544. faceForward?: boolean;
  56545. useDirectMapping?: boolean;
  56546. halfDomeMode?: boolean;
  56547. }, scene: Scene);
  56548. private _changeVideoMode;
  56549. /**
  56550. * Releases resources associated with this node.
  56551. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56552. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56553. */
  56554. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56555. }
  56556. }
  56557. declare module BABYLON {
  56558. /**
  56559. * This class can be used to get instrumentation data from a Babylon engine
  56560. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56561. */
  56562. export class EngineInstrumentation implements IDisposable {
  56563. /**
  56564. * Define the instrumented engine.
  56565. */
  56566. engine: Engine;
  56567. private _captureGPUFrameTime;
  56568. private _gpuFrameTimeToken;
  56569. private _gpuFrameTime;
  56570. private _captureShaderCompilationTime;
  56571. private _shaderCompilationTime;
  56572. private _onBeginFrameObserver;
  56573. private _onEndFrameObserver;
  56574. private _onBeforeShaderCompilationObserver;
  56575. private _onAfterShaderCompilationObserver;
  56576. /**
  56577. * Gets the perf counter used for GPU frame time
  56578. */
  56579. get gpuFrameTimeCounter(): PerfCounter;
  56580. /**
  56581. * Gets the GPU frame time capture status
  56582. */
  56583. get captureGPUFrameTime(): boolean;
  56584. /**
  56585. * Enable or disable the GPU frame time capture
  56586. */
  56587. set captureGPUFrameTime(value: boolean);
  56588. /**
  56589. * Gets the perf counter used for shader compilation time
  56590. */
  56591. get shaderCompilationTimeCounter(): PerfCounter;
  56592. /**
  56593. * Gets the shader compilation time capture status
  56594. */
  56595. get captureShaderCompilationTime(): boolean;
  56596. /**
  56597. * Enable or disable the shader compilation time capture
  56598. */
  56599. set captureShaderCompilationTime(value: boolean);
  56600. /**
  56601. * Instantiates a new engine instrumentation.
  56602. * This class can be used to get instrumentation data from a Babylon engine
  56603. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56604. * @param engine Defines the engine to instrument
  56605. */
  56606. constructor(
  56607. /**
  56608. * Define the instrumented engine.
  56609. */
  56610. engine: Engine);
  56611. /**
  56612. * Dispose and release associated resources.
  56613. */
  56614. dispose(): void;
  56615. }
  56616. }
  56617. declare module BABYLON {
  56618. /**
  56619. * This class can be used to get instrumentation data from a Babylon engine
  56620. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56621. */
  56622. export class SceneInstrumentation implements IDisposable {
  56623. /**
  56624. * Defines the scene to instrument
  56625. */
  56626. scene: Scene;
  56627. private _captureActiveMeshesEvaluationTime;
  56628. private _activeMeshesEvaluationTime;
  56629. private _captureRenderTargetsRenderTime;
  56630. private _renderTargetsRenderTime;
  56631. private _captureFrameTime;
  56632. private _frameTime;
  56633. private _captureRenderTime;
  56634. private _renderTime;
  56635. private _captureInterFrameTime;
  56636. private _interFrameTime;
  56637. private _captureParticlesRenderTime;
  56638. private _particlesRenderTime;
  56639. private _captureSpritesRenderTime;
  56640. private _spritesRenderTime;
  56641. private _capturePhysicsTime;
  56642. private _physicsTime;
  56643. private _captureAnimationsTime;
  56644. private _animationsTime;
  56645. private _captureCameraRenderTime;
  56646. private _cameraRenderTime;
  56647. private _onBeforeActiveMeshesEvaluationObserver;
  56648. private _onAfterActiveMeshesEvaluationObserver;
  56649. private _onBeforeRenderTargetsRenderObserver;
  56650. private _onAfterRenderTargetsRenderObserver;
  56651. private _onAfterRenderObserver;
  56652. private _onBeforeDrawPhaseObserver;
  56653. private _onAfterDrawPhaseObserver;
  56654. private _onBeforeAnimationsObserver;
  56655. private _onBeforeParticlesRenderingObserver;
  56656. private _onAfterParticlesRenderingObserver;
  56657. private _onBeforeSpritesRenderingObserver;
  56658. private _onAfterSpritesRenderingObserver;
  56659. private _onBeforePhysicsObserver;
  56660. private _onAfterPhysicsObserver;
  56661. private _onAfterAnimationsObserver;
  56662. private _onBeforeCameraRenderObserver;
  56663. private _onAfterCameraRenderObserver;
  56664. /**
  56665. * Gets the perf counter used for active meshes evaluation time
  56666. */
  56667. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56668. /**
  56669. * Gets the active meshes evaluation time capture status
  56670. */
  56671. get captureActiveMeshesEvaluationTime(): boolean;
  56672. /**
  56673. * Enable or disable the active meshes evaluation time capture
  56674. */
  56675. set captureActiveMeshesEvaluationTime(value: boolean);
  56676. /**
  56677. * Gets the perf counter used for render targets render time
  56678. */
  56679. get renderTargetsRenderTimeCounter(): PerfCounter;
  56680. /**
  56681. * Gets the render targets render time capture status
  56682. */
  56683. get captureRenderTargetsRenderTime(): boolean;
  56684. /**
  56685. * Enable or disable the render targets render time capture
  56686. */
  56687. set captureRenderTargetsRenderTime(value: boolean);
  56688. /**
  56689. * Gets the perf counter used for particles render time
  56690. */
  56691. get particlesRenderTimeCounter(): PerfCounter;
  56692. /**
  56693. * Gets the particles render time capture status
  56694. */
  56695. get captureParticlesRenderTime(): boolean;
  56696. /**
  56697. * Enable or disable the particles render time capture
  56698. */
  56699. set captureParticlesRenderTime(value: boolean);
  56700. /**
  56701. * Gets the perf counter used for sprites render time
  56702. */
  56703. get spritesRenderTimeCounter(): PerfCounter;
  56704. /**
  56705. * Gets the sprites render time capture status
  56706. */
  56707. get captureSpritesRenderTime(): boolean;
  56708. /**
  56709. * Enable or disable the sprites render time capture
  56710. */
  56711. set captureSpritesRenderTime(value: boolean);
  56712. /**
  56713. * Gets the perf counter used for physics time
  56714. */
  56715. get physicsTimeCounter(): PerfCounter;
  56716. /**
  56717. * Gets the physics time capture status
  56718. */
  56719. get capturePhysicsTime(): boolean;
  56720. /**
  56721. * Enable or disable the physics time capture
  56722. */
  56723. set capturePhysicsTime(value: boolean);
  56724. /**
  56725. * Gets the perf counter used for animations time
  56726. */
  56727. get animationsTimeCounter(): PerfCounter;
  56728. /**
  56729. * Gets the animations time capture status
  56730. */
  56731. get captureAnimationsTime(): boolean;
  56732. /**
  56733. * Enable or disable the animations time capture
  56734. */
  56735. set captureAnimationsTime(value: boolean);
  56736. /**
  56737. * Gets the perf counter used for frame time capture
  56738. */
  56739. get frameTimeCounter(): PerfCounter;
  56740. /**
  56741. * Gets the frame time capture status
  56742. */
  56743. get captureFrameTime(): boolean;
  56744. /**
  56745. * Enable or disable the frame time capture
  56746. */
  56747. set captureFrameTime(value: boolean);
  56748. /**
  56749. * Gets the perf counter used for inter-frames time capture
  56750. */
  56751. get interFrameTimeCounter(): PerfCounter;
  56752. /**
  56753. * Gets the inter-frames time capture status
  56754. */
  56755. get captureInterFrameTime(): boolean;
  56756. /**
  56757. * Enable or disable the inter-frames time capture
  56758. */
  56759. set captureInterFrameTime(value: boolean);
  56760. /**
  56761. * Gets the perf counter used for render time capture
  56762. */
  56763. get renderTimeCounter(): PerfCounter;
  56764. /**
  56765. * Gets the render time capture status
  56766. */
  56767. get captureRenderTime(): boolean;
  56768. /**
  56769. * Enable or disable the render time capture
  56770. */
  56771. set captureRenderTime(value: boolean);
  56772. /**
  56773. * Gets the perf counter used for camera render time capture
  56774. */
  56775. get cameraRenderTimeCounter(): PerfCounter;
  56776. /**
  56777. * Gets the camera render time capture status
  56778. */
  56779. get captureCameraRenderTime(): boolean;
  56780. /**
  56781. * Enable or disable the camera render time capture
  56782. */
  56783. set captureCameraRenderTime(value: boolean);
  56784. /**
  56785. * Gets the perf counter used for draw calls
  56786. */
  56787. get drawCallsCounter(): PerfCounter;
  56788. /**
  56789. * Instantiates a new scene instrumentation.
  56790. * This class can be used to get instrumentation data from a Babylon engine
  56791. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56792. * @param scene Defines the scene to instrument
  56793. */
  56794. constructor(
  56795. /**
  56796. * Defines the scene to instrument
  56797. */
  56798. scene: Scene);
  56799. /**
  56800. * Dispose and release associated resources.
  56801. */
  56802. dispose(): void;
  56803. }
  56804. }
  56805. declare module BABYLON {
  56806. /** @hidden */
  56807. export var glowMapGenerationPixelShader: {
  56808. name: string;
  56809. shader: string;
  56810. };
  56811. }
  56812. declare module BABYLON {
  56813. /** @hidden */
  56814. export var glowMapGenerationVertexShader: {
  56815. name: string;
  56816. shader: string;
  56817. };
  56818. }
  56819. declare module BABYLON {
  56820. /**
  56821. * Effect layer options. This helps customizing the behaviour
  56822. * of the effect layer.
  56823. */
  56824. export interface IEffectLayerOptions {
  56825. /**
  56826. * Multiplication factor apply to the canvas size to compute the render target size
  56827. * used to generated the objects (the smaller the faster).
  56828. */
  56829. mainTextureRatio: number;
  56830. /**
  56831. * Enforces a fixed size texture to ensure effect stability across devices.
  56832. */
  56833. mainTextureFixedSize?: number;
  56834. /**
  56835. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56836. */
  56837. alphaBlendingMode: number;
  56838. /**
  56839. * The camera attached to the layer.
  56840. */
  56841. camera: Nullable<Camera>;
  56842. /**
  56843. * The rendering group to draw the layer in.
  56844. */
  56845. renderingGroupId: number;
  56846. }
  56847. /**
  56848. * The effect layer Helps adding post process effect blended with the main pass.
  56849. *
  56850. * This can be for instance use to generate glow or higlight effects on the scene.
  56851. *
  56852. * The effect layer class can not be used directly and is intented to inherited from to be
  56853. * customized per effects.
  56854. */
  56855. export abstract class EffectLayer {
  56856. private _vertexBuffers;
  56857. private _indexBuffer;
  56858. private _cachedDefines;
  56859. private _effectLayerMapGenerationEffect;
  56860. private _effectLayerOptions;
  56861. private _mergeEffect;
  56862. protected _scene: Scene;
  56863. protected _engine: Engine;
  56864. protected _maxSize: number;
  56865. protected _mainTextureDesiredSize: ISize;
  56866. protected _mainTexture: RenderTargetTexture;
  56867. protected _shouldRender: boolean;
  56868. protected _postProcesses: PostProcess[];
  56869. protected _textures: BaseTexture[];
  56870. protected _emissiveTextureAndColor: {
  56871. texture: Nullable<BaseTexture>;
  56872. color: Color4;
  56873. };
  56874. /**
  56875. * The name of the layer
  56876. */
  56877. name: string;
  56878. /**
  56879. * The clear color of the texture used to generate the glow map.
  56880. */
  56881. neutralColor: Color4;
  56882. /**
  56883. * Specifies whether the highlight layer is enabled or not.
  56884. */
  56885. isEnabled: boolean;
  56886. /**
  56887. * Gets the camera attached to the layer.
  56888. */
  56889. get camera(): Nullable<Camera>;
  56890. /**
  56891. * Gets the rendering group id the layer should render in.
  56892. */
  56893. get renderingGroupId(): number;
  56894. set renderingGroupId(renderingGroupId: number);
  56895. /**
  56896. * An event triggered when the effect layer has been disposed.
  56897. */
  56898. onDisposeObservable: Observable<EffectLayer>;
  56899. /**
  56900. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56901. */
  56902. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56903. /**
  56904. * An event triggered when the generated texture is being merged in the scene.
  56905. */
  56906. onBeforeComposeObservable: Observable<EffectLayer>;
  56907. /**
  56908. * An event triggered when the mesh is rendered into the effect render target.
  56909. */
  56910. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56911. /**
  56912. * An event triggered after the mesh has been rendered into the effect render target.
  56913. */
  56914. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56915. /**
  56916. * An event triggered when the generated texture has been merged in the scene.
  56917. */
  56918. onAfterComposeObservable: Observable<EffectLayer>;
  56919. /**
  56920. * An event triggered when the efffect layer changes its size.
  56921. */
  56922. onSizeChangedObservable: Observable<EffectLayer>;
  56923. /** @hidden */
  56924. static _SceneComponentInitialization: (scene: Scene) => void;
  56925. /**
  56926. * Instantiates a new effect Layer and references it in the scene.
  56927. * @param name The name of the layer
  56928. * @param scene The scene to use the layer in
  56929. */
  56930. constructor(
  56931. /** The Friendly of the effect in the scene */
  56932. name: string, scene: Scene);
  56933. /**
  56934. * Get the effect name of the layer.
  56935. * @return The effect name
  56936. */
  56937. abstract getEffectName(): string;
  56938. /**
  56939. * Checks for the readiness of the element composing the layer.
  56940. * @param subMesh the mesh to check for
  56941. * @param useInstances specify whether or not to use instances to render the mesh
  56942. * @return true if ready otherwise, false
  56943. */
  56944. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56945. /**
  56946. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56947. * @returns true if the effect requires stencil during the main canvas render pass.
  56948. */
  56949. abstract needStencil(): boolean;
  56950. /**
  56951. * Create the merge effect. This is the shader use to blit the information back
  56952. * to the main canvas at the end of the scene rendering.
  56953. * @returns The effect containing the shader used to merge the effect on the main canvas
  56954. */
  56955. protected abstract _createMergeEffect(): Effect;
  56956. /**
  56957. * Creates the render target textures and post processes used in the effect layer.
  56958. */
  56959. protected abstract _createTextureAndPostProcesses(): void;
  56960. /**
  56961. * Implementation specific of rendering the generating effect on the main canvas.
  56962. * @param effect The effect used to render through
  56963. */
  56964. protected abstract _internalRender(effect: Effect): void;
  56965. /**
  56966. * Sets the required values for both the emissive texture and and the main color.
  56967. */
  56968. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56969. /**
  56970. * Free any resources and references associated to a mesh.
  56971. * Internal use
  56972. * @param mesh The mesh to free.
  56973. */
  56974. abstract _disposeMesh(mesh: Mesh): void;
  56975. /**
  56976. * Serializes this layer (Glow or Highlight for example)
  56977. * @returns a serialized layer object
  56978. */
  56979. abstract serialize?(): any;
  56980. /**
  56981. * Initializes the effect layer with the required options.
  56982. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56983. */
  56984. protected _init(options: Partial<IEffectLayerOptions>): void;
  56985. /**
  56986. * Generates the index buffer of the full screen quad blending to the main canvas.
  56987. */
  56988. private _generateIndexBuffer;
  56989. /**
  56990. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  56991. */
  56992. private _generateVertexBuffer;
  56993. /**
  56994. * Sets the main texture desired size which is the closest power of two
  56995. * of the engine canvas size.
  56996. */
  56997. private _setMainTextureSize;
  56998. /**
  56999. * Creates the main texture for the effect layer.
  57000. */
  57001. protected _createMainTexture(): void;
  57002. /**
  57003. * Adds specific effects defines.
  57004. * @param defines The defines to add specifics to.
  57005. */
  57006. protected _addCustomEffectDefines(defines: string[]): void;
  57007. /**
  57008. * Checks for the readiness of the element composing the layer.
  57009. * @param subMesh the mesh to check for
  57010. * @param useInstances specify whether or not to use instances to render the mesh
  57011. * @param emissiveTexture the associated emissive texture used to generate the glow
  57012. * @return true if ready otherwise, false
  57013. */
  57014. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57015. /**
  57016. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57017. */
  57018. render(): void;
  57019. /**
  57020. * Determine if a given mesh will be used in the current effect.
  57021. * @param mesh mesh to test
  57022. * @returns true if the mesh will be used
  57023. */
  57024. hasMesh(mesh: AbstractMesh): boolean;
  57025. /**
  57026. * Returns true if the layer contains information to display, otherwise false.
  57027. * @returns true if the glow layer should be rendered
  57028. */
  57029. shouldRender(): boolean;
  57030. /**
  57031. * Returns true if the mesh should render, otherwise false.
  57032. * @param mesh The mesh to render
  57033. * @returns true if it should render otherwise false
  57034. */
  57035. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57036. /**
  57037. * Returns true if the mesh can be rendered, otherwise false.
  57038. * @param mesh The mesh to render
  57039. * @param material The material used on the mesh
  57040. * @returns true if it can be rendered otherwise false
  57041. */
  57042. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57043. /**
  57044. * Returns true if the mesh should render, otherwise false.
  57045. * @param mesh The mesh to render
  57046. * @returns true if it should render otherwise false
  57047. */
  57048. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57049. /**
  57050. * Renders the submesh passed in parameter to the generation map.
  57051. */
  57052. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57053. /**
  57054. * Defines whether the current material of the mesh should be use to render the effect.
  57055. * @param mesh defines the current mesh to render
  57056. */
  57057. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57058. /**
  57059. * Rebuild the required buffers.
  57060. * @hidden Internal use only.
  57061. */
  57062. _rebuild(): void;
  57063. /**
  57064. * Dispose only the render target textures and post process.
  57065. */
  57066. private _disposeTextureAndPostProcesses;
  57067. /**
  57068. * Dispose the highlight layer and free resources.
  57069. */
  57070. dispose(): void;
  57071. /**
  57072. * Gets the class name of the effect layer
  57073. * @returns the string with the class name of the effect layer
  57074. */
  57075. getClassName(): string;
  57076. /**
  57077. * Creates an effect layer from parsed effect layer data
  57078. * @param parsedEffectLayer defines effect layer data
  57079. * @param scene defines the current scene
  57080. * @param rootUrl defines the root URL containing the effect layer information
  57081. * @returns a parsed effect Layer
  57082. */
  57083. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57084. }
  57085. }
  57086. declare module BABYLON {
  57087. interface AbstractScene {
  57088. /**
  57089. * The list of effect layers (highlights/glow) added to the scene
  57090. * @see http://doc.babylonjs.com/how_to/highlight_layer
  57091. * @see http://doc.babylonjs.com/how_to/glow_layer
  57092. */
  57093. effectLayers: Array<EffectLayer>;
  57094. /**
  57095. * Removes the given effect layer from this scene.
  57096. * @param toRemove defines the effect layer to remove
  57097. * @returns the index of the removed effect layer
  57098. */
  57099. removeEffectLayer(toRemove: EffectLayer): number;
  57100. /**
  57101. * Adds the given effect layer to this scene
  57102. * @param newEffectLayer defines the effect layer to add
  57103. */
  57104. addEffectLayer(newEffectLayer: EffectLayer): void;
  57105. }
  57106. /**
  57107. * Defines the layer scene component responsible to manage any effect layers
  57108. * in a given scene.
  57109. */
  57110. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57111. /**
  57112. * The component name helpfull to identify the component in the list of scene components.
  57113. */
  57114. readonly name: string;
  57115. /**
  57116. * The scene the component belongs to.
  57117. */
  57118. scene: Scene;
  57119. private _engine;
  57120. private _renderEffects;
  57121. private _needStencil;
  57122. private _previousStencilState;
  57123. /**
  57124. * Creates a new instance of the component for the given scene
  57125. * @param scene Defines the scene to register the component in
  57126. */
  57127. constructor(scene: Scene);
  57128. /**
  57129. * Registers the component in a given scene
  57130. */
  57131. register(): void;
  57132. /**
  57133. * Rebuilds the elements related to this component in case of
  57134. * context lost for instance.
  57135. */
  57136. rebuild(): void;
  57137. /**
  57138. * Serializes the component data to the specified json object
  57139. * @param serializationObject The object to serialize to
  57140. */
  57141. serialize(serializationObject: any): void;
  57142. /**
  57143. * Adds all the elements from the container to the scene
  57144. * @param container the container holding the elements
  57145. */
  57146. addFromContainer(container: AbstractScene): void;
  57147. /**
  57148. * Removes all the elements in the container from the scene
  57149. * @param container contains the elements to remove
  57150. * @param dispose if the removed element should be disposed (default: false)
  57151. */
  57152. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57153. /**
  57154. * Disposes the component and the associated ressources.
  57155. */
  57156. dispose(): void;
  57157. private _isReadyForMesh;
  57158. private _renderMainTexture;
  57159. private _setStencil;
  57160. private _setStencilBack;
  57161. private _draw;
  57162. private _drawCamera;
  57163. private _drawRenderingGroup;
  57164. }
  57165. }
  57166. declare module BABYLON {
  57167. /** @hidden */
  57168. export var glowMapMergePixelShader: {
  57169. name: string;
  57170. shader: string;
  57171. };
  57172. }
  57173. declare module BABYLON {
  57174. /** @hidden */
  57175. export var glowMapMergeVertexShader: {
  57176. name: string;
  57177. shader: string;
  57178. };
  57179. }
  57180. declare module BABYLON {
  57181. interface AbstractScene {
  57182. /**
  57183. * Return a the first highlight layer of the scene with a given name.
  57184. * @param name The name of the highlight layer to look for.
  57185. * @return The highlight layer if found otherwise null.
  57186. */
  57187. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57188. }
  57189. /**
  57190. * Glow layer options. This helps customizing the behaviour
  57191. * of the glow layer.
  57192. */
  57193. export interface IGlowLayerOptions {
  57194. /**
  57195. * Multiplication factor apply to the canvas size to compute the render target size
  57196. * used to generated the glowing objects (the smaller the faster).
  57197. */
  57198. mainTextureRatio: number;
  57199. /**
  57200. * Enforces a fixed size texture to ensure resize independant blur.
  57201. */
  57202. mainTextureFixedSize?: number;
  57203. /**
  57204. * How big is the kernel of the blur texture.
  57205. */
  57206. blurKernelSize: number;
  57207. /**
  57208. * The camera attached to the layer.
  57209. */
  57210. camera: Nullable<Camera>;
  57211. /**
  57212. * Enable MSAA by chosing the number of samples.
  57213. */
  57214. mainTextureSamples?: number;
  57215. /**
  57216. * The rendering group to draw the layer in.
  57217. */
  57218. renderingGroupId: number;
  57219. }
  57220. /**
  57221. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57222. *
  57223. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57224. *
  57225. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57226. */
  57227. export class GlowLayer extends EffectLayer {
  57228. /**
  57229. * Effect Name of the layer.
  57230. */
  57231. static readonly EffectName: string;
  57232. /**
  57233. * The default blur kernel size used for the glow.
  57234. */
  57235. static DefaultBlurKernelSize: number;
  57236. /**
  57237. * The default texture size ratio used for the glow.
  57238. */
  57239. static DefaultTextureRatio: number;
  57240. /**
  57241. * Sets the kernel size of the blur.
  57242. */
  57243. set blurKernelSize(value: number);
  57244. /**
  57245. * Gets the kernel size of the blur.
  57246. */
  57247. get blurKernelSize(): number;
  57248. /**
  57249. * Sets the glow intensity.
  57250. */
  57251. set intensity(value: number);
  57252. /**
  57253. * Gets the glow intensity.
  57254. */
  57255. get intensity(): number;
  57256. private _options;
  57257. private _intensity;
  57258. private _horizontalBlurPostprocess1;
  57259. private _verticalBlurPostprocess1;
  57260. private _horizontalBlurPostprocess2;
  57261. private _verticalBlurPostprocess2;
  57262. private _blurTexture1;
  57263. private _blurTexture2;
  57264. private _postProcesses1;
  57265. private _postProcesses2;
  57266. private _includedOnlyMeshes;
  57267. private _excludedMeshes;
  57268. private _meshesUsingTheirOwnMaterials;
  57269. /**
  57270. * Callback used to let the user override the color selection on a per mesh basis
  57271. */
  57272. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57273. /**
  57274. * Callback used to let the user override the texture selection on a per mesh basis
  57275. */
  57276. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57277. /**
  57278. * Instantiates a new glow Layer and references it to the scene.
  57279. * @param name The name of the layer
  57280. * @param scene The scene to use the layer in
  57281. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57282. */
  57283. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57284. /**
  57285. * Get the effect name of the layer.
  57286. * @return The effect name
  57287. */
  57288. getEffectName(): string;
  57289. /**
  57290. * Create the merge effect. This is the shader use to blit the information back
  57291. * to the main canvas at the end of the scene rendering.
  57292. */
  57293. protected _createMergeEffect(): Effect;
  57294. /**
  57295. * Creates the render target textures and post processes used in the glow layer.
  57296. */
  57297. protected _createTextureAndPostProcesses(): void;
  57298. /**
  57299. * Checks for the readiness of the element composing the layer.
  57300. * @param subMesh the mesh to check for
  57301. * @param useInstances specify wether or not to use instances to render the mesh
  57302. * @param emissiveTexture the associated emissive texture used to generate the glow
  57303. * @return true if ready otherwise, false
  57304. */
  57305. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57306. /**
  57307. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57308. */
  57309. needStencil(): boolean;
  57310. /**
  57311. * Returns true if the mesh can be rendered, otherwise false.
  57312. * @param mesh The mesh to render
  57313. * @param material The material used on the mesh
  57314. * @returns true if it can be rendered otherwise false
  57315. */
  57316. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57317. /**
  57318. * Implementation specific of rendering the generating effect on the main canvas.
  57319. * @param effect The effect used to render through
  57320. */
  57321. protected _internalRender(effect: Effect): void;
  57322. /**
  57323. * Sets the required values for both the emissive texture and and the main color.
  57324. */
  57325. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57326. /**
  57327. * Returns true if the mesh should render, otherwise false.
  57328. * @param mesh The mesh to render
  57329. * @returns true if it should render otherwise false
  57330. */
  57331. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57332. /**
  57333. * Adds specific effects defines.
  57334. * @param defines The defines to add specifics to.
  57335. */
  57336. protected _addCustomEffectDefines(defines: string[]): void;
  57337. /**
  57338. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57339. * @param mesh The mesh to exclude from the glow layer
  57340. */
  57341. addExcludedMesh(mesh: Mesh): void;
  57342. /**
  57343. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57344. * @param mesh The mesh to remove
  57345. */
  57346. removeExcludedMesh(mesh: Mesh): void;
  57347. /**
  57348. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57349. * @param mesh The mesh to include in the glow layer
  57350. */
  57351. addIncludedOnlyMesh(mesh: Mesh): void;
  57352. /**
  57353. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57354. * @param mesh The mesh to remove
  57355. */
  57356. removeIncludedOnlyMesh(mesh: Mesh): void;
  57357. /**
  57358. * Determine if a given mesh will be used in the glow layer
  57359. * @param mesh The mesh to test
  57360. * @returns true if the mesh will be highlighted by the current glow layer
  57361. */
  57362. hasMesh(mesh: AbstractMesh): boolean;
  57363. /**
  57364. * Defines whether the current material of the mesh should be use to render the effect.
  57365. * @param mesh defines the current mesh to render
  57366. */
  57367. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57368. /**
  57369. * Add a mesh to be rendered through its own material and not with emissive only.
  57370. * @param mesh The mesh for which we need to use its material
  57371. */
  57372. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57373. /**
  57374. * Remove a mesh from being rendered through its own material and not with emissive only.
  57375. * @param mesh The mesh for which we need to not use its material
  57376. */
  57377. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57378. /**
  57379. * Free any resources and references associated to a mesh.
  57380. * Internal use
  57381. * @param mesh The mesh to free.
  57382. * @hidden
  57383. */
  57384. _disposeMesh(mesh: Mesh): void;
  57385. /**
  57386. * Gets the class name of the effect layer
  57387. * @returns the string with the class name of the effect layer
  57388. */
  57389. getClassName(): string;
  57390. /**
  57391. * Serializes this glow layer
  57392. * @returns a serialized glow layer object
  57393. */
  57394. serialize(): any;
  57395. /**
  57396. * Creates a Glow Layer from parsed glow layer data
  57397. * @param parsedGlowLayer defines glow layer data
  57398. * @param scene defines the current scene
  57399. * @param rootUrl defines the root URL containing the glow layer information
  57400. * @returns a parsed Glow Layer
  57401. */
  57402. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57403. }
  57404. }
  57405. declare module BABYLON {
  57406. /** @hidden */
  57407. export var glowBlurPostProcessPixelShader: {
  57408. name: string;
  57409. shader: string;
  57410. };
  57411. }
  57412. declare module BABYLON {
  57413. interface AbstractScene {
  57414. /**
  57415. * Return a the first highlight layer of the scene with a given name.
  57416. * @param name The name of the highlight layer to look for.
  57417. * @return The highlight layer if found otherwise null.
  57418. */
  57419. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57420. }
  57421. /**
  57422. * Highlight layer options. This helps customizing the behaviour
  57423. * of the highlight layer.
  57424. */
  57425. export interface IHighlightLayerOptions {
  57426. /**
  57427. * Multiplication factor apply to the canvas size to compute the render target size
  57428. * used to generated the glowing objects (the smaller the faster).
  57429. */
  57430. mainTextureRatio: number;
  57431. /**
  57432. * Enforces a fixed size texture to ensure resize independant blur.
  57433. */
  57434. mainTextureFixedSize?: number;
  57435. /**
  57436. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57437. * of the picture to blur (the smaller the faster).
  57438. */
  57439. blurTextureSizeRatio: number;
  57440. /**
  57441. * How big in texel of the blur texture is the vertical blur.
  57442. */
  57443. blurVerticalSize: number;
  57444. /**
  57445. * How big in texel of the blur texture is the horizontal blur.
  57446. */
  57447. blurHorizontalSize: number;
  57448. /**
  57449. * Alpha blending mode used to apply the blur. Default is combine.
  57450. */
  57451. alphaBlendingMode: number;
  57452. /**
  57453. * The camera attached to the layer.
  57454. */
  57455. camera: Nullable<Camera>;
  57456. /**
  57457. * Should we display highlight as a solid stroke?
  57458. */
  57459. isStroke?: boolean;
  57460. /**
  57461. * The rendering group to draw the layer in.
  57462. */
  57463. renderingGroupId: number;
  57464. }
  57465. /**
  57466. * The highlight layer Helps adding a glow effect around a mesh.
  57467. *
  57468. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57469. * glowy meshes to your scene.
  57470. *
  57471. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57472. */
  57473. export class HighlightLayer extends EffectLayer {
  57474. name: string;
  57475. /**
  57476. * Effect Name of the highlight layer.
  57477. */
  57478. static readonly EffectName: string;
  57479. /**
  57480. * The neutral color used during the preparation of the glow effect.
  57481. * This is black by default as the blend operation is a blend operation.
  57482. */
  57483. static NeutralColor: Color4;
  57484. /**
  57485. * Stencil value used for glowing meshes.
  57486. */
  57487. static GlowingMeshStencilReference: number;
  57488. /**
  57489. * Stencil value used for the other meshes in the scene.
  57490. */
  57491. static NormalMeshStencilReference: number;
  57492. /**
  57493. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57494. */
  57495. innerGlow: boolean;
  57496. /**
  57497. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57498. */
  57499. outerGlow: boolean;
  57500. /**
  57501. * Specifies the horizontal size of the blur.
  57502. */
  57503. set blurHorizontalSize(value: number);
  57504. /**
  57505. * Specifies the vertical size of the blur.
  57506. */
  57507. set blurVerticalSize(value: number);
  57508. /**
  57509. * Gets the horizontal size of the blur.
  57510. */
  57511. get blurHorizontalSize(): number;
  57512. /**
  57513. * Gets the vertical size of the blur.
  57514. */
  57515. get blurVerticalSize(): number;
  57516. /**
  57517. * An event triggered when the highlight layer is being blurred.
  57518. */
  57519. onBeforeBlurObservable: Observable<HighlightLayer>;
  57520. /**
  57521. * An event triggered when the highlight layer has been blurred.
  57522. */
  57523. onAfterBlurObservable: Observable<HighlightLayer>;
  57524. private _instanceGlowingMeshStencilReference;
  57525. private _options;
  57526. private _downSamplePostprocess;
  57527. private _horizontalBlurPostprocess;
  57528. private _verticalBlurPostprocess;
  57529. private _blurTexture;
  57530. private _meshes;
  57531. private _excludedMeshes;
  57532. /**
  57533. * Instantiates a new highlight Layer and references it to the scene..
  57534. * @param name The name of the layer
  57535. * @param scene The scene to use the layer in
  57536. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57537. */
  57538. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57539. /**
  57540. * Get the effect name of the layer.
  57541. * @return The effect name
  57542. */
  57543. getEffectName(): string;
  57544. /**
  57545. * Create the merge effect. This is the shader use to blit the information back
  57546. * to the main canvas at the end of the scene rendering.
  57547. */
  57548. protected _createMergeEffect(): Effect;
  57549. /**
  57550. * Creates the render target textures and post processes used in the highlight layer.
  57551. */
  57552. protected _createTextureAndPostProcesses(): void;
  57553. /**
  57554. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57555. */
  57556. needStencil(): boolean;
  57557. /**
  57558. * Checks for the readiness of the element composing the layer.
  57559. * @param subMesh the mesh to check for
  57560. * @param useInstances specify wether or not to use instances to render the mesh
  57561. * @param emissiveTexture the associated emissive texture used to generate the glow
  57562. * @return true if ready otherwise, false
  57563. */
  57564. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57565. /**
  57566. * Implementation specific of rendering the generating effect on the main canvas.
  57567. * @param effect The effect used to render through
  57568. */
  57569. protected _internalRender(effect: Effect): void;
  57570. /**
  57571. * Returns true if the layer contains information to display, otherwise false.
  57572. */
  57573. shouldRender(): boolean;
  57574. /**
  57575. * Returns true if the mesh should render, otherwise false.
  57576. * @param mesh The mesh to render
  57577. * @returns true if it should render otherwise false
  57578. */
  57579. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57580. /**
  57581. * Adds specific effects defines.
  57582. * @param defines The defines to add specifics to.
  57583. */
  57584. protected _addCustomEffectDefines(defines: string[]): void;
  57585. /**
  57586. * Sets the required values for both the emissive texture and and the main color.
  57587. */
  57588. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57589. /**
  57590. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57591. * @param mesh The mesh to exclude from the highlight layer
  57592. */
  57593. addExcludedMesh(mesh: Mesh): void;
  57594. /**
  57595. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57596. * @param mesh The mesh to highlight
  57597. */
  57598. removeExcludedMesh(mesh: Mesh): void;
  57599. /**
  57600. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57601. * @param mesh mesh to test
  57602. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57603. */
  57604. hasMesh(mesh: AbstractMesh): boolean;
  57605. /**
  57606. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57607. * @param mesh The mesh to highlight
  57608. * @param color The color of the highlight
  57609. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57610. */
  57611. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57612. /**
  57613. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57614. * @param mesh The mesh to highlight
  57615. */
  57616. removeMesh(mesh: Mesh): void;
  57617. /**
  57618. * Remove all the meshes currently referenced in the highlight layer
  57619. */
  57620. removeAllMeshes(): void;
  57621. /**
  57622. * Force the stencil to the normal expected value for none glowing parts
  57623. */
  57624. private _defaultStencilReference;
  57625. /**
  57626. * Free any resources and references associated to a mesh.
  57627. * Internal use
  57628. * @param mesh The mesh to free.
  57629. * @hidden
  57630. */
  57631. _disposeMesh(mesh: Mesh): void;
  57632. /**
  57633. * Dispose the highlight layer and free resources.
  57634. */
  57635. dispose(): void;
  57636. /**
  57637. * Gets the class name of the effect layer
  57638. * @returns the string with the class name of the effect layer
  57639. */
  57640. getClassName(): string;
  57641. /**
  57642. * Serializes this Highlight layer
  57643. * @returns a serialized Highlight layer object
  57644. */
  57645. serialize(): any;
  57646. /**
  57647. * Creates a Highlight layer from parsed Highlight layer data
  57648. * @param parsedHightlightLayer defines the Highlight layer data
  57649. * @param scene defines the current scene
  57650. * @param rootUrl defines the root URL containing the Highlight layer information
  57651. * @returns a parsed Highlight layer
  57652. */
  57653. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57654. }
  57655. }
  57656. declare module BABYLON {
  57657. interface AbstractScene {
  57658. /**
  57659. * The list of layers (background and foreground) of the scene
  57660. */
  57661. layers: Array<Layer>;
  57662. }
  57663. /**
  57664. * Defines the layer scene component responsible to manage any layers
  57665. * in a given scene.
  57666. */
  57667. export class LayerSceneComponent implements ISceneComponent {
  57668. /**
  57669. * The component name helpfull to identify the component in the list of scene components.
  57670. */
  57671. readonly name: string;
  57672. /**
  57673. * The scene the component belongs to.
  57674. */
  57675. scene: Scene;
  57676. private _engine;
  57677. /**
  57678. * Creates a new instance of the component for the given scene
  57679. * @param scene Defines the scene to register the component in
  57680. */
  57681. constructor(scene: Scene);
  57682. /**
  57683. * Registers the component in a given scene
  57684. */
  57685. register(): void;
  57686. /**
  57687. * Rebuilds the elements related to this component in case of
  57688. * context lost for instance.
  57689. */
  57690. rebuild(): void;
  57691. /**
  57692. * Disposes the component and the associated ressources.
  57693. */
  57694. dispose(): void;
  57695. private _draw;
  57696. private _drawCameraPredicate;
  57697. private _drawCameraBackground;
  57698. private _drawCameraForeground;
  57699. private _drawRenderTargetPredicate;
  57700. private _drawRenderTargetBackground;
  57701. private _drawRenderTargetForeground;
  57702. /**
  57703. * Adds all the elements from the container to the scene
  57704. * @param container the container holding the elements
  57705. */
  57706. addFromContainer(container: AbstractScene): void;
  57707. /**
  57708. * Removes all the elements in the container from the scene
  57709. * @param container contains the elements to remove
  57710. * @param dispose if the removed element should be disposed (default: false)
  57711. */
  57712. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57713. }
  57714. }
  57715. declare module BABYLON {
  57716. /** @hidden */
  57717. export var layerPixelShader: {
  57718. name: string;
  57719. shader: string;
  57720. };
  57721. }
  57722. declare module BABYLON {
  57723. /** @hidden */
  57724. export var layerVertexShader: {
  57725. name: string;
  57726. shader: string;
  57727. };
  57728. }
  57729. declare module BABYLON {
  57730. /**
  57731. * This represents a full screen 2d layer.
  57732. * This can be useful to display a picture in the background of your scene for instance.
  57733. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57734. */
  57735. export class Layer {
  57736. /**
  57737. * Define the name of the layer.
  57738. */
  57739. name: string;
  57740. /**
  57741. * Define the texture the layer should display.
  57742. */
  57743. texture: Nullable<Texture>;
  57744. /**
  57745. * Is the layer in background or foreground.
  57746. */
  57747. isBackground: boolean;
  57748. /**
  57749. * Define the color of the layer (instead of texture).
  57750. */
  57751. color: Color4;
  57752. /**
  57753. * Define the scale of the layer in order to zoom in out of the texture.
  57754. */
  57755. scale: Vector2;
  57756. /**
  57757. * Define an offset for the layer in order to shift the texture.
  57758. */
  57759. offset: Vector2;
  57760. /**
  57761. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57762. */
  57763. alphaBlendingMode: number;
  57764. /**
  57765. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57766. * Alpha test will not mix with the background color in case of transparency.
  57767. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57768. */
  57769. alphaTest: boolean;
  57770. /**
  57771. * Define a mask to restrict the layer to only some of the scene cameras.
  57772. */
  57773. layerMask: number;
  57774. /**
  57775. * Define the list of render target the layer is visible into.
  57776. */
  57777. renderTargetTextures: RenderTargetTexture[];
  57778. /**
  57779. * Define if the layer is only used in renderTarget or if it also
  57780. * renders in the main frame buffer of the canvas.
  57781. */
  57782. renderOnlyInRenderTargetTextures: boolean;
  57783. private _scene;
  57784. private _vertexBuffers;
  57785. private _indexBuffer;
  57786. private _effect;
  57787. private _previousDefines;
  57788. /**
  57789. * An event triggered when the layer is disposed.
  57790. */
  57791. onDisposeObservable: Observable<Layer>;
  57792. private _onDisposeObserver;
  57793. /**
  57794. * Back compatibility with callback before the onDisposeObservable existed.
  57795. * The set callback will be triggered when the layer has been disposed.
  57796. */
  57797. set onDispose(callback: () => void);
  57798. /**
  57799. * An event triggered before rendering the scene
  57800. */
  57801. onBeforeRenderObservable: Observable<Layer>;
  57802. private _onBeforeRenderObserver;
  57803. /**
  57804. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57805. * The set callback will be triggered just before rendering the layer.
  57806. */
  57807. set onBeforeRender(callback: () => void);
  57808. /**
  57809. * An event triggered after rendering the scene
  57810. */
  57811. onAfterRenderObservable: Observable<Layer>;
  57812. private _onAfterRenderObserver;
  57813. /**
  57814. * Back compatibility with callback before the onAfterRenderObservable existed.
  57815. * The set callback will be triggered just after rendering the layer.
  57816. */
  57817. set onAfterRender(callback: () => void);
  57818. /**
  57819. * Instantiates a new layer.
  57820. * This represents a full screen 2d layer.
  57821. * This can be useful to display a picture in the background of your scene for instance.
  57822. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57823. * @param name Define the name of the layer in the scene
  57824. * @param imgUrl Define the url of the texture to display in the layer
  57825. * @param scene Define the scene the layer belongs to
  57826. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57827. * @param color Defines a color for the layer
  57828. */
  57829. constructor(
  57830. /**
  57831. * Define the name of the layer.
  57832. */
  57833. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57834. private _createIndexBuffer;
  57835. /** @hidden */
  57836. _rebuild(): void;
  57837. /**
  57838. * Renders the layer in the scene.
  57839. */
  57840. render(): void;
  57841. /**
  57842. * Disposes and releases the associated ressources.
  57843. */
  57844. dispose(): void;
  57845. }
  57846. }
  57847. declare module BABYLON {
  57848. /** @hidden */
  57849. export var lensFlarePixelShader: {
  57850. name: string;
  57851. shader: string;
  57852. };
  57853. }
  57854. declare module BABYLON {
  57855. /** @hidden */
  57856. export var lensFlareVertexShader: {
  57857. name: string;
  57858. shader: string;
  57859. };
  57860. }
  57861. declare module BABYLON {
  57862. /**
  57863. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57864. * It is usually composed of several `lensFlare`.
  57865. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57866. */
  57867. export class LensFlareSystem {
  57868. /**
  57869. * Define the name of the lens flare system
  57870. */
  57871. name: string;
  57872. /**
  57873. * List of lens flares used in this system.
  57874. */
  57875. lensFlares: LensFlare[];
  57876. /**
  57877. * Define a limit from the border the lens flare can be visible.
  57878. */
  57879. borderLimit: number;
  57880. /**
  57881. * Define a viewport border we do not want to see the lens flare in.
  57882. */
  57883. viewportBorder: number;
  57884. /**
  57885. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57886. */
  57887. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57888. /**
  57889. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57890. */
  57891. layerMask: number;
  57892. /**
  57893. * Define the id of the lens flare system in the scene.
  57894. * (equal to name by default)
  57895. */
  57896. id: string;
  57897. private _scene;
  57898. private _emitter;
  57899. private _vertexBuffers;
  57900. private _indexBuffer;
  57901. private _effect;
  57902. private _positionX;
  57903. private _positionY;
  57904. private _isEnabled;
  57905. /** @hidden */
  57906. static _SceneComponentInitialization: (scene: Scene) => void;
  57907. /**
  57908. * Instantiates a lens flare system.
  57909. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57910. * It is usually composed of several `lensFlare`.
  57911. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57912. * @param name Define the name of the lens flare system in the scene
  57913. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57914. * @param scene Define the scene the lens flare system belongs to
  57915. */
  57916. constructor(
  57917. /**
  57918. * Define the name of the lens flare system
  57919. */
  57920. name: string, emitter: any, scene: Scene);
  57921. /**
  57922. * Define if the lens flare system is enabled.
  57923. */
  57924. get isEnabled(): boolean;
  57925. set isEnabled(value: boolean);
  57926. /**
  57927. * Get the scene the effects belongs to.
  57928. * @returns the scene holding the lens flare system
  57929. */
  57930. getScene(): Scene;
  57931. /**
  57932. * Get the emitter of the lens flare system.
  57933. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57934. * @returns the emitter of the lens flare system
  57935. */
  57936. getEmitter(): any;
  57937. /**
  57938. * Set the emitter of the lens flare system.
  57939. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57940. * @param newEmitter Define the new emitter of the system
  57941. */
  57942. setEmitter(newEmitter: any): void;
  57943. /**
  57944. * Get the lens flare system emitter position.
  57945. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57946. * @returns the position
  57947. */
  57948. getEmitterPosition(): Vector3;
  57949. /**
  57950. * @hidden
  57951. */
  57952. computeEffectivePosition(globalViewport: Viewport): boolean;
  57953. /** @hidden */
  57954. _isVisible(): boolean;
  57955. /**
  57956. * @hidden
  57957. */
  57958. render(): boolean;
  57959. /**
  57960. * Dispose and release the lens flare with its associated resources.
  57961. */
  57962. dispose(): void;
  57963. /**
  57964. * Parse a lens flare system from a JSON repressentation
  57965. * @param parsedLensFlareSystem Define the JSON to parse
  57966. * @param scene Define the scene the parsed system should be instantiated in
  57967. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57968. * @returns the parsed system
  57969. */
  57970. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57971. /**
  57972. * Serialize the current Lens Flare System into a JSON representation.
  57973. * @returns the serialized JSON
  57974. */
  57975. serialize(): any;
  57976. }
  57977. }
  57978. declare module BABYLON {
  57979. /**
  57980. * This represents one of the lens effect in a `lensFlareSystem`.
  57981. * It controls one of the indiviual texture used in the effect.
  57982. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57983. */
  57984. export class LensFlare {
  57985. /**
  57986. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57987. */
  57988. size: number;
  57989. /**
  57990. * 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.
  57991. */
  57992. position: number;
  57993. /**
  57994. * Define the lens color.
  57995. */
  57996. color: Color3;
  57997. /**
  57998. * Define the lens texture.
  57999. */
  58000. texture: Nullable<Texture>;
  58001. /**
  58002. * Define the alpha mode to render this particular lens.
  58003. */
  58004. alphaMode: number;
  58005. private _system;
  58006. /**
  58007. * Creates a new Lens Flare.
  58008. * This represents one of the lens effect in a `lensFlareSystem`.
  58009. * It controls one of the indiviual texture used in the effect.
  58010. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58011. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58012. * @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.
  58013. * @param color Define the lens color
  58014. * @param imgUrl Define the lens texture url
  58015. * @param system Define the `lensFlareSystem` this flare is part of
  58016. * @returns The newly created Lens Flare
  58017. */
  58018. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58019. /**
  58020. * Instantiates a new Lens Flare.
  58021. * This represents one of the lens effect in a `lensFlareSystem`.
  58022. * It controls one of the indiviual texture used in the effect.
  58023. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58024. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58025. * @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.
  58026. * @param color Define the lens color
  58027. * @param imgUrl Define the lens texture url
  58028. * @param system Define the `lensFlareSystem` this flare is part of
  58029. */
  58030. constructor(
  58031. /**
  58032. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58033. */
  58034. size: number,
  58035. /**
  58036. * 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.
  58037. */
  58038. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58039. /**
  58040. * Dispose and release the lens flare with its associated resources.
  58041. */
  58042. dispose(): void;
  58043. }
  58044. }
  58045. declare module BABYLON {
  58046. interface AbstractScene {
  58047. /**
  58048. * The list of lens flare system added to the scene
  58049. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58050. */
  58051. lensFlareSystems: Array<LensFlareSystem>;
  58052. /**
  58053. * Removes the given lens flare system from this scene.
  58054. * @param toRemove The lens flare system to remove
  58055. * @returns The index of the removed lens flare system
  58056. */
  58057. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58058. /**
  58059. * Adds the given lens flare system to this scene
  58060. * @param newLensFlareSystem The lens flare system to add
  58061. */
  58062. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58063. /**
  58064. * Gets a lens flare system using its name
  58065. * @param name defines the name to look for
  58066. * @returns the lens flare system or null if not found
  58067. */
  58068. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58069. /**
  58070. * Gets a lens flare system using its id
  58071. * @param id defines the id to look for
  58072. * @returns the lens flare system or null if not found
  58073. */
  58074. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58075. }
  58076. /**
  58077. * Defines the lens flare scene component responsible to manage any lens flares
  58078. * in a given scene.
  58079. */
  58080. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58081. /**
  58082. * The component name helpfull to identify the component in the list of scene components.
  58083. */
  58084. readonly name: string;
  58085. /**
  58086. * The scene the component belongs to.
  58087. */
  58088. scene: Scene;
  58089. /**
  58090. * Creates a new instance of the component for the given scene
  58091. * @param scene Defines the scene to register the component in
  58092. */
  58093. constructor(scene: Scene);
  58094. /**
  58095. * Registers the component in a given scene
  58096. */
  58097. register(): void;
  58098. /**
  58099. * Rebuilds the elements related to this component in case of
  58100. * context lost for instance.
  58101. */
  58102. rebuild(): void;
  58103. /**
  58104. * Adds all the elements from the container to the scene
  58105. * @param container the container holding the elements
  58106. */
  58107. addFromContainer(container: AbstractScene): void;
  58108. /**
  58109. * Removes all the elements in the container from the scene
  58110. * @param container contains the elements to remove
  58111. * @param dispose if the removed element should be disposed (default: false)
  58112. */
  58113. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58114. /**
  58115. * Serializes the component data to the specified json object
  58116. * @param serializationObject The object to serialize to
  58117. */
  58118. serialize(serializationObject: any): void;
  58119. /**
  58120. * Disposes the component and the associated ressources.
  58121. */
  58122. dispose(): void;
  58123. private _draw;
  58124. }
  58125. }
  58126. declare module BABYLON {
  58127. /** @hidden */
  58128. export var depthPixelShader: {
  58129. name: string;
  58130. shader: string;
  58131. };
  58132. }
  58133. declare module BABYLON {
  58134. /** @hidden */
  58135. export var depthVertexShader: {
  58136. name: string;
  58137. shader: string;
  58138. };
  58139. }
  58140. declare module BABYLON {
  58141. /**
  58142. * This represents a depth renderer in Babylon.
  58143. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58144. */
  58145. export class DepthRenderer {
  58146. private _scene;
  58147. private _depthMap;
  58148. private _effect;
  58149. private readonly _storeNonLinearDepth;
  58150. private readonly _clearColor;
  58151. /** Get if the depth renderer is using packed depth or not */
  58152. readonly isPacked: boolean;
  58153. private _cachedDefines;
  58154. private _camera;
  58155. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58156. enabled: boolean;
  58157. /**
  58158. * Specifiess that the depth renderer will only be used within
  58159. * the camera it is created for.
  58160. * This can help forcing its rendering during the camera processing.
  58161. */
  58162. useOnlyInActiveCamera: boolean;
  58163. /** @hidden */
  58164. static _SceneComponentInitialization: (scene: Scene) => void;
  58165. /**
  58166. * Instantiates a depth renderer
  58167. * @param scene The scene the renderer belongs to
  58168. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58169. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58170. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58171. */
  58172. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58173. /**
  58174. * Creates the depth rendering effect and checks if the effect is ready.
  58175. * @param subMesh The submesh to be used to render the depth map of
  58176. * @param useInstances If multiple world instances should be used
  58177. * @returns if the depth renderer is ready to render the depth map
  58178. */
  58179. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58180. /**
  58181. * Gets the texture which the depth map will be written to.
  58182. * @returns The depth map texture
  58183. */
  58184. getDepthMap(): RenderTargetTexture;
  58185. /**
  58186. * Disposes of the depth renderer.
  58187. */
  58188. dispose(): void;
  58189. }
  58190. }
  58191. declare module BABYLON {
  58192. /** @hidden */
  58193. export var minmaxReduxPixelShader: {
  58194. name: string;
  58195. shader: string;
  58196. };
  58197. }
  58198. declare module BABYLON {
  58199. /**
  58200. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58201. * and maximum values from all values of the texture.
  58202. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58203. * The source values are read from the red channel of the texture.
  58204. */
  58205. export class MinMaxReducer {
  58206. /**
  58207. * Observable triggered when the computation has been performed
  58208. */
  58209. onAfterReductionPerformed: Observable<{
  58210. min: number;
  58211. max: number;
  58212. }>;
  58213. protected _camera: Camera;
  58214. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58215. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58216. protected _postProcessManager: PostProcessManager;
  58217. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58218. protected _forceFullscreenViewport: boolean;
  58219. /**
  58220. * Creates a min/max reducer
  58221. * @param camera The camera to use for the post processes
  58222. */
  58223. constructor(camera: Camera);
  58224. /**
  58225. * Gets the texture used to read the values from.
  58226. */
  58227. get sourceTexture(): Nullable<RenderTargetTexture>;
  58228. /**
  58229. * Sets the source texture to read the values from.
  58230. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58231. * because in such textures '1' value must not be taken into account to compute the maximum
  58232. * as this value is used to clear the texture.
  58233. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58234. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58235. * @param depthRedux Indicates if the texture is a depth texture or not
  58236. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58237. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58238. */
  58239. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58240. /**
  58241. * Defines the refresh rate of the computation.
  58242. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58243. */
  58244. get refreshRate(): number;
  58245. set refreshRate(value: number);
  58246. protected _activated: boolean;
  58247. /**
  58248. * Gets the activation status of the reducer
  58249. */
  58250. get activated(): boolean;
  58251. /**
  58252. * Activates the reduction computation.
  58253. * When activated, the observers registered in onAfterReductionPerformed are
  58254. * called after the compuation is performed
  58255. */
  58256. activate(): void;
  58257. /**
  58258. * Deactivates the reduction computation.
  58259. */
  58260. deactivate(): void;
  58261. /**
  58262. * Disposes the min/max reducer
  58263. * @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.
  58264. */
  58265. dispose(disposeAll?: boolean): void;
  58266. }
  58267. }
  58268. declare module BABYLON {
  58269. /**
  58270. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58271. */
  58272. export class DepthReducer extends MinMaxReducer {
  58273. private _depthRenderer;
  58274. private _depthRendererId;
  58275. /**
  58276. * Gets the depth renderer used for the computation.
  58277. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58278. */
  58279. get depthRenderer(): Nullable<DepthRenderer>;
  58280. /**
  58281. * Creates a depth reducer
  58282. * @param camera The camera used to render the depth texture
  58283. */
  58284. constructor(camera: Camera);
  58285. /**
  58286. * Sets the depth renderer to use to generate the depth map
  58287. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58288. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58289. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58290. */
  58291. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58292. /** @hidden */
  58293. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58294. /**
  58295. * Activates the reduction computation.
  58296. * When activated, the observers registered in onAfterReductionPerformed are
  58297. * called after the compuation is performed
  58298. */
  58299. activate(): void;
  58300. /**
  58301. * Deactivates the reduction computation.
  58302. */
  58303. deactivate(): void;
  58304. /**
  58305. * Disposes the depth reducer
  58306. * @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.
  58307. */
  58308. dispose(disposeAll?: boolean): void;
  58309. }
  58310. }
  58311. declare module BABYLON {
  58312. /**
  58313. * A CSM implementation allowing casting shadows on large scenes.
  58314. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58315. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58316. */
  58317. export class CascadedShadowGenerator extends ShadowGenerator {
  58318. private static readonly frustumCornersNDCSpace;
  58319. /**
  58320. * Name of the CSM class
  58321. */
  58322. static CLASSNAME: string;
  58323. /**
  58324. * Defines the default number of cascades used by the CSM.
  58325. */
  58326. static readonly DEFAULT_CASCADES_COUNT: number;
  58327. /**
  58328. * Defines the minimum number of cascades used by the CSM.
  58329. */
  58330. static readonly MIN_CASCADES_COUNT: number;
  58331. /**
  58332. * Defines the maximum number of cascades used by the CSM.
  58333. */
  58334. static readonly MAX_CASCADES_COUNT: number;
  58335. protected _validateFilter(filter: number): number;
  58336. /**
  58337. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58338. */
  58339. penumbraDarkness: number;
  58340. private _numCascades;
  58341. /**
  58342. * Gets or set the number of cascades used by the CSM.
  58343. */
  58344. get numCascades(): number;
  58345. set numCascades(value: number);
  58346. /**
  58347. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58348. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58349. */
  58350. stabilizeCascades: boolean;
  58351. private _freezeShadowCastersBoundingInfo;
  58352. private _freezeShadowCastersBoundingInfoObservable;
  58353. /**
  58354. * Enables or disables the shadow casters bounding info computation.
  58355. * If your shadow casters don't move, you can disable this feature.
  58356. * If it is enabled, the bounding box computation is done every frame.
  58357. */
  58358. get freezeShadowCastersBoundingInfo(): boolean;
  58359. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58360. private _scbiMin;
  58361. private _scbiMax;
  58362. protected _computeShadowCastersBoundingInfo(): void;
  58363. protected _shadowCastersBoundingInfo: BoundingInfo;
  58364. /**
  58365. * Gets or sets the shadow casters bounding info.
  58366. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58367. * so that the system won't overwrite the bounds you provide
  58368. */
  58369. get shadowCastersBoundingInfo(): BoundingInfo;
  58370. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58371. protected _breaksAreDirty: boolean;
  58372. protected _minDistance: number;
  58373. protected _maxDistance: number;
  58374. /**
  58375. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58376. *
  58377. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58378. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58379. * @param min minimal distance for the breaks (default to 0.)
  58380. * @param max maximal distance for the breaks (default to 1.)
  58381. */
  58382. setMinMaxDistance(min: number, max: number): void;
  58383. /** Gets the minimal distance used in the cascade break computation */
  58384. get minDistance(): number;
  58385. /** Gets the maximal distance used in the cascade break computation */
  58386. get maxDistance(): number;
  58387. /**
  58388. * Gets the class name of that object
  58389. * @returns "CascadedShadowGenerator"
  58390. */
  58391. getClassName(): string;
  58392. private _cascadeMinExtents;
  58393. private _cascadeMaxExtents;
  58394. /**
  58395. * Gets a cascade minimum extents
  58396. * @param cascadeIndex index of the cascade
  58397. * @returns the minimum cascade extents
  58398. */
  58399. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58400. /**
  58401. * Gets a cascade maximum extents
  58402. * @param cascadeIndex index of the cascade
  58403. * @returns the maximum cascade extents
  58404. */
  58405. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58406. private _cascades;
  58407. private _currentLayer;
  58408. private _viewSpaceFrustumsZ;
  58409. private _viewMatrices;
  58410. private _projectionMatrices;
  58411. private _transformMatrices;
  58412. private _transformMatricesAsArray;
  58413. private _frustumLengths;
  58414. private _lightSizeUVCorrection;
  58415. private _depthCorrection;
  58416. private _frustumCornersWorldSpace;
  58417. private _frustumCenter;
  58418. private _shadowCameraPos;
  58419. private _shadowMaxZ;
  58420. /**
  58421. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58422. * It defaults to camera.maxZ
  58423. */
  58424. get shadowMaxZ(): number;
  58425. /**
  58426. * Sets the shadow max z distance.
  58427. */
  58428. set shadowMaxZ(value: number);
  58429. protected _debug: boolean;
  58430. /**
  58431. * Gets or sets the debug flag.
  58432. * When enabled, the cascades are materialized by different colors on the screen.
  58433. */
  58434. get debug(): boolean;
  58435. set debug(dbg: boolean);
  58436. private _depthClamp;
  58437. /**
  58438. * Gets or sets the depth clamping value.
  58439. *
  58440. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58441. * to account for the shadow casters far away.
  58442. *
  58443. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58444. */
  58445. get depthClamp(): boolean;
  58446. set depthClamp(value: boolean);
  58447. private _cascadeBlendPercentage;
  58448. /**
  58449. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58450. * It defaults to 0.1 (10% blending).
  58451. */
  58452. get cascadeBlendPercentage(): number;
  58453. set cascadeBlendPercentage(value: number);
  58454. private _lambda;
  58455. /**
  58456. * Gets or set the lambda parameter.
  58457. * This parameter is used to split the camera frustum and create the cascades.
  58458. * 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.
  58459. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58460. */
  58461. get lambda(): number;
  58462. set lambda(value: number);
  58463. /**
  58464. * Gets the view matrix corresponding to a given cascade
  58465. * @param cascadeNum cascade to retrieve the view matrix from
  58466. * @returns the cascade view matrix
  58467. */
  58468. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58469. /**
  58470. * Gets the projection matrix corresponding to a given cascade
  58471. * @param cascadeNum cascade to retrieve the projection matrix from
  58472. * @returns the cascade projection matrix
  58473. */
  58474. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58475. /**
  58476. * Gets the transformation matrix corresponding to a given cascade
  58477. * @param cascadeNum cascade to retrieve the transformation matrix from
  58478. * @returns the cascade transformation matrix
  58479. */
  58480. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58481. private _depthRenderer;
  58482. /**
  58483. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58484. *
  58485. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58486. *
  58487. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58488. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58489. * @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
  58490. */
  58491. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58492. private _depthReducer;
  58493. private _autoCalcDepthBounds;
  58494. /**
  58495. * Gets or sets the autoCalcDepthBounds property.
  58496. *
  58497. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58498. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58499. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58500. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58501. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58502. */
  58503. get autoCalcDepthBounds(): boolean;
  58504. set autoCalcDepthBounds(value: boolean);
  58505. /**
  58506. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58507. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58508. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58509. * for setting the refresh rate on the renderer yourself!
  58510. */
  58511. get autoCalcDepthBoundsRefreshRate(): number;
  58512. set autoCalcDepthBoundsRefreshRate(value: number);
  58513. /**
  58514. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58515. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58516. * you change the camera near/far planes!
  58517. */
  58518. splitFrustum(): void;
  58519. private _splitFrustum;
  58520. private _computeMatrices;
  58521. private _computeFrustumInWorldSpace;
  58522. private _computeCascadeFrustum;
  58523. /**
  58524. * Support test.
  58525. */
  58526. static get IsSupported(): boolean;
  58527. /** @hidden */
  58528. static _SceneComponentInitialization: (scene: Scene) => void;
  58529. /**
  58530. * Creates a Cascaded Shadow Generator object.
  58531. * A ShadowGenerator is the required tool to use the shadows.
  58532. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58533. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58534. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58535. * @param light The directional light object generating the shadows.
  58536. * @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.
  58537. */
  58538. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58539. protected _initializeGenerator(): void;
  58540. protected _createTargetRenderTexture(): void;
  58541. protected _initializeShadowMap(): void;
  58542. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58543. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58544. /**
  58545. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58546. * @param defines Defines of the material we want to update
  58547. * @param lightIndex Index of the light in the enabled light list of the material
  58548. */
  58549. prepareDefines(defines: any, lightIndex: number): void;
  58550. /**
  58551. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58552. * defined in the generator but impacting the effect).
  58553. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58554. * @param effect The effect we are binfing the information for
  58555. */
  58556. bindShadowLight(lightIndex: string, effect: Effect): void;
  58557. /**
  58558. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58559. * (eq to view projection * shadow projection matrices)
  58560. * @returns The transform matrix used to create the shadow map
  58561. */
  58562. getTransformMatrix(): Matrix;
  58563. /**
  58564. * Disposes the ShadowGenerator.
  58565. * Returns nothing.
  58566. */
  58567. dispose(): void;
  58568. /**
  58569. * Serializes the shadow generator setup to a json object.
  58570. * @returns The serialized JSON object
  58571. */
  58572. serialize(): any;
  58573. /**
  58574. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58575. * @param parsedShadowGenerator The JSON object to parse
  58576. * @param scene The scene to create the shadow map for
  58577. * @returns The parsed shadow generator
  58578. */
  58579. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58580. }
  58581. }
  58582. declare module BABYLON {
  58583. /**
  58584. * Defines the shadow generator component responsible to manage any shadow generators
  58585. * in a given scene.
  58586. */
  58587. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58588. /**
  58589. * The component name helpfull to identify the component in the list of scene components.
  58590. */
  58591. readonly name: string;
  58592. /**
  58593. * The scene the component belongs to.
  58594. */
  58595. scene: Scene;
  58596. /**
  58597. * Creates a new instance of the component for the given scene
  58598. * @param scene Defines the scene to register the component in
  58599. */
  58600. constructor(scene: Scene);
  58601. /**
  58602. * Registers the component in a given scene
  58603. */
  58604. register(): void;
  58605. /**
  58606. * Rebuilds the elements related to this component in case of
  58607. * context lost for instance.
  58608. */
  58609. rebuild(): void;
  58610. /**
  58611. * Serializes the component data to the specified json object
  58612. * @param serializationObject The object to serialize to
  58613. */
  58614. serialize(serializationObject: any): void;
  58615. /**
  58616. * Adds all the elements from the container to the scene
  58617. * @param container the container holding the elements
  58618. */
  58619. addFromContainer(container: AbstractScene): void;
  58620. /**
  58621. * Removes all the elements in the container from the scene
  58622. * @param container contains the elements to remove
  58623. * @param dispose if the removed element should be disposed (default: false)
  58624. */
  58625. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58626. /**
  58627. * Rebuilds the elements related to this component in case of
  58628. * context lost for instance.
  58629. */
  58630. dispose(): void;
  58631. private _gatherRenderTargets;
  58632. }
  58633. }
  58634. declare module BABYLON {
  58635. /**
  58636. * A point light is a light defined by an unique point in world space.
  58637. * The light is emitted in every direction from this point.
  58638. * A good example of a point light is a standard light bulb.
  58639. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58640. */
  58641. export class PointLight extends ShadowLight {
  58642. private _shadowAngle;
  58643. /**
  58644. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58645. * This specifies what angle the shadow will use to be created.
  58646. *
  58647. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58648. */
  58649. get shadowAngle(): number;
  58650. /**
  58651. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58652. * This specifies what angle the shadow will use to be created.
  58653. *
  58654. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58655. */
  58656. set shadowAngle(value: number);
  58657. /**
  58658. * Gets the direction if it has been set.
  58659. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58660. */
  58661. get direction(): Vector3;
  58662. /**
  58663. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58664. */
  58665. set direction(value: Vector3);
  58666. /**
  58667. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58668. * A PointLight emits the light in every direction.
  58669. * It can cast shadows.
  58670. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58671. * ```javascript
  58672. * var pointLight = new PointLight("pl", camera.position, scene);
  58673. * ```
  58674. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58675. * @param name The light friendly name
  58676. * @param position The position of the point light in the scene
  58677. * @param scene The scene the lights belongs to
  58678. */
  58679. constructor(name: string, position: Vector3, scene: Scene);
  58680. /**
  58681. * Returns the string "PointLight"
  58682. * @returns the class name
  58683. */
  58684. getClassName(): string;
  58685. /**
  58686. * Returns the integer 0.
  58687. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58688. */
  58689. getTypeID(): number;
  58690. /**
  58691. * Specifies wether or not the shadowmap should be a cube texture.
  58692. * @returns true if the shadowmap needs to be a cube texture.
  58693. */
  58694. needCube(): boolean;
  58695. /**
  58696. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58697. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58698. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58699. */
  58700. getShadowDirection(faceIndex?: number): Vector3;
  58701. /**
  58702. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58703. * - fov = PI / 2
  58704. * - aspect ratio : 1.0
  58705. * - z-near and far equal to the active camera minZ and maxZ.
  58706. * Returns the PointLight.
  58707. */
  58708. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58709. protected _buildUniformLayout(): void;
  58710. /**
  58711. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58712. * @param effect The effect to update
  58713. * @param lightIndex The index of the light in the effect to update
  58714. * @returns The point light
  58715. */
  58716. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58717. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58718. /**
  58719. * Prepares the list of defines specific to the light type.
  58720. * @param defines the list of defines
  58721. * @param lightIndex defines the index of the light for the effect
  58722. */
  58723. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58724. }
  58725. }
  58726. declare module BABYLON {
  58727. /**
  58728. * Header information of HDR texture files.
  58729. */
  58730. export interface HDRInfo {
  58731. /**
  58732. * The height of the texture in pixels.
  58733. */
  58734. height: number;
  58735. /**
  58736. * The width of the texture in pixels.
  58737. */
  58738. width: number;
  58739. /**
  58740. * The index of the beginning of the data in the binary file.
  58741. */
  58742. dataPosition: number;
  58743. }
  58744. /**
  58745. * This groups tools to convert HDR texture to native colors array.
  58746. */
  58747. export class HDRTools {
  58748. private static Ldexp;
  58749. private static Rgbe2float;
  58750. private static readStringLine;
  58751. /**
  58752. * Reads header information from an RGBE texture stored in a native array.
  58753. * More information on this format are available here:
  58754. * https://en.wikipedia.org/wiki/RGBE_image_format
  58755. *
  58756. * @param uint8array The binary file stored in native array.
  58757. * @return The header information.
  58758. */
  58759. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58760. /**
  58761. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58762. * This RGBE texture needs to store the information as a panorama.
  58763. *
  58764. * More information on this format are available here:
  58765. * https://en.wikipedia.org/wiki/RGBE_image_format
  58766. *
  58767. * @param buffer The binary file stored in an array buffer.
  58768. * @param size The expected size of the extracted cubemap.
  58769. * @return The Cube Map information.
  58770. */
  58771. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58772. /**
  58773. * Returns the pixels data extracted from an RGBE texture.
  58774. * This pixels will be stored left to right up to down in the R G B order in one array.
  58775. *
  58776. * More information on this format are available here:
  58777. * https://en.wikipedia.org/wiki/RGBE_image_format
  58778. *
  58779. * @param uint8array The binary file stored in an array buffer.
  58780. * @param hdrInfo The header information of the file.
  58781. * @return The pixels data in RGB right to left up to down order.
  58782. */
  58783. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58784. private static RGBE_ReadPixels_RLE;
  58785. }
  58786. }
  58787. declare module BABYLON {
  58788. /**
  58789. * Effect Render Options
  58790. */
  58791. export interface IEffectRendererOptions {
  58792. /**
  58793. * Defines the vertices positions.
  58794. */
  58795. positions?: number[];
  58796. /**
  58797. * Defines the indices.
  58798. */
  58799. indices?: number[];
  58800. }
  58801. /**
  58802. * Helper class to render one or more effects.
  58803. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58804. */
  58805. export class EffectRenderer {
  58806. private engine;
  58807. private static _DefaultOptions;
  58808. private _vertexBuffers;
  58809. private _indexBuffer;
  58810. private _fullscreenViewport;
  58811. /**
  58812. * Creates an effect renderer
  58813. * @param engine the engine to use for rendering
  58814. * @param options defines the options of the effect renderer
  58815. */
  58816. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58817. /**
  58818. * Sets the current viewport in normalized coordinates 0-1
  58819. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58820. */
  58821. setViewport(viewport?: Viewport): void;
  58822. /**
  58823. * Binds the embedded attributes buffer to the effect.
  58824. * @param effect Defines the effect to bind the attributes for
  58825. */
  58826. bindBuffers(effect: Effect): void;
  58827. /**
  58828. * Sets the current effect wrapper to use during draw.
  58829. * The effect needs to be ready before calling this api.
  58830. * This also sets the default full screen position attribute.
  58831. * @param effectWrapper Defines the effect to draw with
  58832. */
  58833. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58834. /**
  58835. * Restores engine states
  58836. */
  58837. restoreStates(): void;
  58838. /**
  58839. * Draws a full screen quad.
  58840. */
  58841. draw(): void;
  58842. private isRenderTargetTexture;
  58843. /**
  58844. * renders one or more effects to a specified texture
  58845. * @param effectWrapper the effect to renderer
  58846. * @param outputTexture texture to draw to, if null it will render to the screen.
  58847. */
  58848. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58849. /**
  58850. * Disposes of the effect renderer
  58851. */
  58852. dispose(): void;
  58853. }
  58854. /**
  58855. * Options to create an EffectWrapper
  58856. */
  58857. interface EffectWrapperCreationOptions {
  58858. /**
  58859. * Engine to use to create the effect
  58860. */
  58861. engine: ThinEngine;
  58862. /**
  58863. * Fragment shader for the effect
  58864. */
  58865. fragmentShader: string;
  58866. /**
  58867. * Use the shader store instead of direct source code
  58868. */
  58869. useShaderStore?: boolean;
  58870. /**
  58871. * Vertex shader for the effect
  58872. */
  58873. vertexShader?: string;
  58874. /**
  58875. * Attributes to use in the shader
  58876. */
  58877. attributeNames?: Array<string>;
  58878. /**
  58879. * Uniforms to use in the shader
  58880. */
  58881. uniformNames?: Array<string>;
  58882. /**
  58883. * Texture sampler names to use in the shader
  58884. */
  58885. samplerNames?: Array<string>;
  58886. /**
  58887. * Defines to use in the shader
  58888. */
  58889. defines?: Array<string>;
  58890. /**
  58891. * Callback when effect is compiled
  58892. */
  58893. onCompiled?: Nullable<(effect: Effect) => void>;
  58894. /**
  58895. * The friendly name of the effect displayed in Spector.
  58896. */
  58897. name?: string;
  58898. }
  58899. /**
  58900. * Wraps an effect to be used for rendering
  58901. */
  58902. export class EffectWrapper {
  58903. /**
  58904. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58905. */
  58906. onApplyObservable: Observable<{}>;
  58907. /**
  58908. * The underlying effect
  58909. */
  58910. effect: Effect;
  58911. /**
  58912. * Creates an effect to be renderer
  58913. * @param creationOptions options to create the effect
  58914. */
  58915. constructor(creationOptions: EffectWrapperCreationOptions);
  58916. /**
  58917. * Disposes of the effect wrapper
  58918. */
  58919. dispose(): void;
  58920. }
  58921. }
  58922. declare module BABYLON {
  58923. /** @hidden */
  58924. export var hdrFilteringVertexShader: {
  58925. name: string;
  58926. shader: string;
  58927. };
  58928. }
  58929. declare module BABYLON {
  58930. /** @hidden */
  58931. export var hdrFilteringPixelShader: {
  58932. name: string;
  58933. shader: string;
  58934. };
  58935. }
  58936. declare module BABYLON {
  58937. /**
  58938. * Options for texture filtering
  58939. */
  58940. interface IHDRFilteringOptions {
  58941. /**
  58942. * Scales pixel intensity for the input HDR map.
  58943. */
  58944. hdrScale?: number;
  58945. /**
  58946. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58947. */
  58948. quality?: number;
  58949. }
  58950. /**
  58951. * Filters HDR maps to get correct renderings of PBR reflections
  58952. */
  58953. export class HDRFiltering {
  58954. private _engine;
  58955. private _effectRenderer;
  58956. private _effectWrapper;
  58957. private _lodGenerationOffset;
  58958. private _lodGenerationScale;
  58959. /**
  58960. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58961. * you care about baking speed.
  58962. */
  58963. quality: number;
  58964. /**
  58965. * Scales pixel intensity for the input HDR map.
  58966. */
  58967. hdrScale: number;
  58968. /**
  58969. * Instantiates HDR filter for reflection maps
  58970. *
  58971. * @param engine Thin engine
  58972. * @param options Options
  58973. */
  58974. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58975. private _createRenderTarget;
  58976. private _prefilterInternal;
  58977. private _createEffect;
  58978. /**
  58979. * Get a value indicating if the filter is ready to be used
  58980. * @param texture Texture to filter
  58981. * @returns true if the filter is ready
  58982. */
  58983. isReady(texture: BaseTexture): boolean;
  58984. /**
  58985. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58986. * Prefiltering will be invoked at the end of next rendering pass.
  58987. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58988. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58989. * @param texture Texture to filter
  58990. * @param onFinished Callback when filtering is done
  58991. * @return Promise called when prefiltering is done
  58992. */
  58993. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  58994. }
  58995. }
  58996. declare module BABYLON {
  58997. /**
  58998. * This represents a texture coming from an HDR input.
  58999. *
  59000. * The only supported format is currently panorama picture stored in RGBE format.
  59001. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59002. */
  59003. export class HDRCubeTexture extends BaseTexture {
  59004. private static _facesMapping;
  59005. private _generateHarmonics;
  59006. private _noMipmap;
  59007. private _prefilterOnLoad;
  59008. private _textureMatrix;
  59009. private _size;
  59010. private _onLoad;
  59011. private _onError;
  59012. /**
  59013. * The texture URL.
  59014. */
  59015. url: string;
  59016. /**
  59017. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59018. */
  59019. coordinatesMode: number;
  59020. protected _isBlocking: boolean;
  59021. /**
  59022. * Sets wether or not the texture is blocking during loading.
  59023. */
  59024. set isBlocking(value: boolean);
  59025. /**
  59026. * Gets wether or not the texture is blocking during loading.
  59027. */
  59028. get isBlocking(): boolean;
  59029. protected _rotationY: number;
  59030. /**
  59031. * Sets texture matrix rotation angle around Y axis in radians.
  59032. */
  59033. set rotationY(value: number);
  59034. /**
  59035. * Gets texture matrix rotation angle around Y axis radians.
  59036. */
  59037. get rotationY(): number;
  59038. /**
  59039. * Gets or sets the center of the bounding box associated with the cube texture
  59040. * It must define where the camera used to render the texture was set
  59041. */
  59042. boundingBoxPosition: Vector3;
  59043. private _boundingBoxSize;
  59044. /**
  59045. * Gets or sets the size of the bounding box associated with the cube texture
  59046. * When defined, the cubemap will switch to local mode
  59047. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59048. * @example https://www.babylonjs-playground.com/#RNASML
  59049. */
  59050. set boundingBoxSize(value: Vector3);
  59051. get boundingBoxSize(): Vector3;
  59052. /**
  59053. * Instantiates an HDRTexture from the following parameters.
  59054. *
  59055. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59056. * @param sceneOrEngine The scene or engine the texture will be used in
  59057. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59058. * @param noMipmap Forces to not generate the mipmap if true
  59059. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59060. * @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)
  59061. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59062. */
  59063. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, prefilterOnLoad?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59064. /**
  59065. * Get the current class name of the texture useful for serialization or dynamic coding.
  59066. * @returns "HDRCubeTexture"
  59067. */
  59068. getClassName(): string;
  59069. /**
  59070. * Occurs when the file is raw .hdr file.
  59071. */
  59072. private loadTexture;
  59073. clone(): HDRCubeTexture;
  59074. delayLoad(): void;
  59075. /**
  59076. * Get the texture reflection matrix used to rotate/transform the reflection.
  59077. * @returns the reflection matrix
  59078. */
  59079. getReflectionTextureMatrix(): Matrix;
  59080. /**
  59081. * Set the texture reflection matrix used to rotate/transform the reflection.
  59082. * @param value Define the reflection matrix to set
  59083. */
  59084. setReflectionTextureMatrix(value: Matrix): void;
  59085. /**
  59086. * Parses a JSON representation of an HDR Texture in order to create the texture
  59087. * @param parsedTexture Define the JSON representation
  59088. * @param scene Define the scene the texture should be created in
  59089. * @param rootUrl Define the root url in case we need to load relative dependencies
  59090. * @returns the newly created texture after parsing
  59091. */
  59092. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59093. serialize(): any;
  59094. }
  59095. }
  59096. declare module BABYLON {
  59097. /**
  59098. * Class used to control physics engine
  59099. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59100. */
  59101. export class PhysicsEngine implements IPhysicsEngine {
  59102. private _physicsPlugin;
  59103. /**
  59104. * Global value used to control the smallest number supported by the simulation
  59105. */
  59106. static Epsilon: number;
  59107. private _impostors;
  59108. private _joints;
  59109. private _subTimeStep;
  59110. /**
  59111. * Gets the gravity vector used by the simulation
  59112. */
  59113. gravity: Vector3;
  59114. /**
  59115. * Factory used to create the default physics plugin.
  59116. * @returns The default physics plugin
  59117. */
  59118. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59119. /**
  59120. * Creates a new Physics Engine
  59121. * @param gravity defines the gravity vector used by the simulation
  59122. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59123. */
  59124. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59125. /**
  59126. * Sets the gravity vector used by the simulation
  59127. * @param gravity defines the gravity vector to use
  59128. */
  59129. setGravity(gravity: Vector3): void;
  59130. /**
  59131. * Set the time step of the physics engine.
  59132. * Default is 1/60.
  59133. * To slow it down, enter 1/600 for example.
  59134. * To speed it up, 1/30
  59135. * @param newTimeStep defines the new timestep to apply to this world.
  59136. */
  59137. setTimeStep(newTimeStep?: number): void;
  59138. /**
  59139. * Get the time step of the physics engine.
  59140. * @returns the current time step
  59141. */
  59142. getTimeStep(): number;
  59143. /**
  59144. * Set the sub time step of the physics engine.
  59145. * Default is 0 meaning there is no sub steps
  59146. * To increase physics resolution precision, set a small value (like 1 ms)
  59147. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59148. */
  59149. setSubTimeStep(subTimeStep?: number): void;
  59150. /**
  59151. * Get the sub time step of the physics engine.
  59152. * @returns the current sub time step
  59153. */
  59154. getSubTimeStep(): number;
  59155. /**
  59156. * Release all resources
  59157. */
  59158. dispose(): void;
  59159. /**
  59160. * Gets the name of the current physics plugin
  59161. * @returns the name of the plugin
  59162. */
  59163. getPhysicsPluginName(): string;
  59164. /**
  59165. * Adding a new impostor for the impostor tracking.
  59166. * This will be done by the impostor itself.
  59167. * @param impostor the impostor to add
  59168. */
  59169. addImpostor(impostor: PhysicsImpostor): void;
  59170. /**
  59171. * Remove an impostor from the engine.
  59172. * This impostor and its mesh will not longer be updated by the physics engine.
  59173. * @param impostor the impostor to remove
  59174. */
  59175. removeImpostor(impostor: PhysicsImpostor): void;
  59176. /**
  59177. * Add a joint to the physics engine
  59178. * @param mainImpostor defines the main impostor to which the joint is added.
  59179. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59180. * @param joint defines the joint that will connect both impostors.
  59181. */
  59182. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59183. /**
  59184. * Removes a joint from the simulation
  59185. * @param mainImpostor defines the impostor used with the joint
  59186. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59187. * @param joint defines the joint to remove
  59188. */
  59189. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59190. /**
  59191. * Called by the scene. No need to call it.
  59192. * @param delta defines the timespam between frames
  59193. */
  59194. _step(delta: number): void;
  59195. /**
  59196. * Gets the current plugin used to run the simulation
  59197. * @returns current plugin
  59198. */
  59199. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59200. /**
  59201. * Gets the list of physic impostors
  59202. * @returns an array of PhysicsImpostor
  59203. */
  59204. getImpostors(): Array<PhysicsImpostor>;
  59205. /**
  59206. * Gets the impostor for a physics enabled object
  59207. * @param object defines the object impersonated by the impostor
  59208. * @returns the PhysicsImpostor or null if not found
  59209. */
  59210. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59211. /**
  59212. * Gets the impostor for a physics body object
  59213. * @param body defines physics body used by the impostor
  59214. * @returns the PhysicsImpostor or null if not found
  59215. */
  59216. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59217. /**
  59218. * Does a raycast in the physics world
  59219. * @param from when should the ray start?
  59220. * @param to when should the ray end?
  59221. * @returns PhysicsRaycastResult
  59222. */
  59223. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59224. }
  59225. }
  59226. declare module BABYLON {
  59227. /** @hidden */
  59228. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59229. private _useDeltaForWorldStep;
  59230. world: any;
  59231. name: string;
  59232. private _physicsMaterials;
  59233. private _fixedTimeStep;
  59234. private _cannonRaycastResult;
  59235. private _raycastResult;
  59236. private _physicsBodysToRemoveAfterStep;
  59237. private _firstFrame;
  59238. BJSCANNON: any;
  59239. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59240. setGravity(gravity: Vector3): void;
  59241. setTimeStep(timeStep: number): void;
  59242. getTimeStep(): number;
  59243. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59244. private _removeMarkedPhysicsBodiesFromWorld;
  59245. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59246. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59247. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59248. private _processChildMeshes;
  59249. removePhysicsBody(impostor: PhysicsImpostor): void;
  59250. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59251. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59252. private _addMaterial;
  59253. private _checkWithEpsilon;
  59254. private _createShape;
  59255. private _createHeightmap;
  59256. private _minus90X;
  59257. private _plus90X;
  59258. private _tmpPosition;
  59259. private _tmpDeltaPosition;
  59260. private _tmpUnityRotation;
  59261. private _updatePhysicsBodyTransformation;
  59262. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59263. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59264. isSupported(): boolean;
  59265. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59266. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59267. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59268. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59269. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59270. getBodyMass(impostor: PhysicsImpostor): number;
  59271. getBodyFriction(impostor: PhysicsImpostor): number;
  59272. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59273. getBodyRestitution(impostor: PhysicsImpostor): number;
  59274. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59275. sleepBody(impostor: PhysicsImpostor): void;
  59276. wakeUpBody(impostor: PhysicsImpostor): void;
  59277. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59278. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59279. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59280. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59281. getRadius(impostor: PhysicsImpostor): number;
  59282. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59283. dispose(): void;
  59284. private _extendNamespace;
  59285. /**
  59286. * Does a raycast in the physics world
  59287. * @param from when should the ray start?
  59288. * @param to when should the ray end?
  59289. * @returns PhysicsRaycastResult
  59290. */
  59291. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59292. }
  59293. }
  59294. declare module BABYLON {
  59295. /** @hidden */
  59296. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59297. private _useDeltaForWorldStep;
  59298. world: any;
  59299. name: string;
  59300. BJSOIMO: any;
  59301. private _raycastResult;
  59302. private _fixedTimeStep;
  59303. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59304. setGravity(gravity: Vector3): void;
  59305. setTimeStep(timeStep: number): void;
  59306. getTimeStep(): number;
  59307. private _tmpImpostorsArray;
  59308. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59309. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59310. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59311. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59312. private _tmpPositionVector;
  59313. removePhysicsBody(impostor: PhysicsImpostor): void;
  59314. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59315. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59316. isSupported(): boolean;
  59317. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59318. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59319. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59320. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59321. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59322. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59323. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59324. getBodyMass(impostor: PhysicsImpostor): number;
  59325. getBodyFriction(impostor: PhysicsImpostor): number;
  59326. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59327. getBodyRestitution(impostor: PhysicsImpostor): number;
  59328. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59329. sleepBody(impostor: PhysicsImpostor): void;
  59330. wakeUpBody(impostor: PhysicsImpostor): void;
  59331. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59332. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59333. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59334. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59335. getRadius(impostor: PhysicsImpostor): number;
  59336. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59337. dispose(): void;
  59338. /**
  59339. * Does a raycast in the physics world
  59340. * @param from when should the ray start?
  59341. * @param to when should the ray end?
  59342. * @returns PhysicsRaycastResult
  59343. */
  59344. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59345. }
  59346. }
  59347. declare module BABYLON {
  59348. /**
  59349. * Class containing static functions to help procedurally build meshes
  59350. */
  59351. export class RibbonBuilder {
  59352. /**
  59353. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59354. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59355. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59356. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59357. * * 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
  59358. * * 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
  59359. * * 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
  59360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59361. * * 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
  59362. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59363. * * 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
  59364. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59365. * * 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
  59366. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59368. * @param name defines the name of the mesh
  59369. * @param options defines the options used to create the mesh
  59370. * @param scene defines the hosting scene
  59371. * @returns the ribbon mesh
  59372. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59373. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59374. */
  59375. static CreateRibbon(name: string, options: {
  59376. pathArray: Vector3[][];
  59377. closeArray?: boolean;
  59378. closePath?: boolean;
  59379. offset?: number;
  59380. updatable?: boolean;
  59381. sideOrientation?: number;
  59382. frontUVs?: Vector4;
  59383. backUVs?: Vector4;
  59384. instance?: Mesh;
  59385. invertUV?: boolean;
  59386. uvs?: Vector2[];
  59387. colors?: Color4[];
  59388. }, scene?: Nullable<Scene>): Mesh;
  59389. }
  59390. }
  59391. declare module BABYLON {
  59392. /**
  59393. * Class containing static functions to help procedurally build meshes
  59394. */
  59395. export class ShapeBuilder {
  59396. /**
  59397. * 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.
  59398. * * 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.
  59399. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59400. * * 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.
  59401. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59402. * * 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
  59403. * * 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
  59404. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59406. * * 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
  59407. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59409. * @param name defines the name of the mesh
  59410. * @param options defines the options used to create the mesh
  59411. * @param scene defines the hosting scene
  59412. * @returns the extruded shape mesh
  59413. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59414. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59415. */
  59416. static ExtrudeShape(name: string, options: {
  59417. shape: Vector3[];
  59418. path: Vector3[];
  59419. scale?: number;
  59420. rotation?: number;
  59421. cap?: number;
  59422. updatable?: boolean;
  59423. sideOrientation?: number;
  59424. frontUVs?: Vector4;
  59425. backUVs?: Vector4;
  59426. instance?: Mesh;
  59427. invertUV?: boolean;
  59428. }, scene?: Nullable<Scene>): Mesh;
  59429. /**
  59430. * Creates an custom extruded shape mesh.
  59431. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59432. * * 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.
  59433. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59434. * * 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
  59435. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59436. * * 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
  59437. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59438. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59439. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59440. * * 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
  59441. * * 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
  59442. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59444. * * 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
  59445. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59447. * @param name defines the name of the mesh
  59448. * @param options defines the options used to create the mesh
  59449. * @param scene defines the hosting scene
  59450. * @returns the custom extruded shape mesh
  59451. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59452. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59454. */
  59455. static ExtrudeShapeCustom(name: string, options: {
  59456. shape: Vector3[];
  59457. path: Vector3[];
  59458. scaleFunction?: any;
  59459. rotationFunction?: any;
  59460. ribbonCloseArray?: boolean;
  59461. ribbonClosePath?: boolean;
  59462. cap?: number;
  59463. updatable?: boolean;
  59464. sideOrientation?: number;
  59465. frontUVs?: Vector4;
  59466. backUVs?: Vector4;
  59467. instance?: Mesh;
  59468. invertUV?: boolean;
  59469. }, scene?: Nullable<Scene>): Mesh;
  59470. private static _ExtrudeShapeGeneric;
  59471. }
  59472. }
  59473. declare module BABYLON {
  59474. /**
  59475. * AmmoJS Physics plugin
  59476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59477. * @see https://github.com/kripken/ammo.js/
  59478. */
  59479. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59480. private _useDeltaForWorldStep;
  59481. /**
  59482. * Reference to the Ammo library
  59483. */
  59484. bjsAMMO: any;
  59485. /**
  59486. * Created ammoJS world which physics bodies are added to
  59487. */
  59488. world: any;
  59489. /**
  59490. * Name of the plugin
  59491. */
  59492. name: string;
  59493. private _timeStep;
  59494. private _fixedTimeStep;
  59495. private _maxSteps;
  59496. private _tmpQuaternion;
  59497. private _tmpAmmoTransform;
  59498. private _tmpAmmoQuaternion;
  59499. private _tmpAmmoConcreteContactResultCallback;
  59500. private _collisionConfiguration;
  59501. private _dispatcher;
  59502. private _overlappingPairCache;
  59503. private _solver;
  59504. private _softBodySolver;
  59505. private _tmpAmmoVectorA;
  59506. private _tmpAmmoVectorB;
  59507. private _tmpAmmoVectorC;
  59508. private _tmpAmmoVectorD;
  59509. private _tmpContactCallbackResult;
  59510. private _tmpAmmoVectorRCA;
  59511. private _tmpAmmoVectorRCB;
  59512. private _raycastResult;
  59513. private static readonly DISABLE_COLLISION_FLAG;
  59514. private static readonly KINEMATIC_FLAG;
  59515. private static readonly DISABLE_DEACTIVATION_FLAG;
  59516. /**
  59517. * Initializes the ammoJS plugin
  59518. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59519. * @param ammoInjection can be used to inject your own ammo reference
  59520. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59521. */
  59522. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59523. /**
  59524. * Sets the gravity of the physics world (m/(s^2))
  59525. * @param gravity Gravity to set
  59526. */
  59527. setGravity(gravity: Vector3): void;
  59528. /**
  59529. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59530. * @param timeStep timestep to use in seconds
  59531. */
  59532. setTimeStep(timeStep: number): void;
  59533. /**
  59534. * 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)
  59535. * @param fixedTimeStep fixedTimeStep to use in seconds
  59536. */
  59537. setFixedTimeStep(fixedTimeStep: number): void;
  59538. /**
  59539. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59540. * @param maxSteps the maximum number of steps by the physics engine per frame
  59541. */
  59542. setMaxSteps(maxSteps: number): void;
  59543. /**
  59544. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59545. * @returns the current timestep in seconds
  59546. */
  59547. getTimeStep(): number;
  59548. /**
  59549. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59550. */
  59551. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59552. private _isImpostorInContact;
  59553. private _isImpostorPairInContact;
  59554. private _stepSimulation;
  59555. /**
  59556. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59557. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59558. * After the step the babylon meshes are set to the position of the physics imposters
  59559. * @param delta amount of time to step forward
  59560. * @param impostors array of imposters to update before/after the step
  59561. */
  59562. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59563. /**
  59564. * Update babylon mesh to match physics world object
  59565. * @param impostor imposter to match
  59566. */
  59567. private _afterSoftStep;
  59568. /**
  59569. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59570. * @param impostor imposter to match
  59571. */
  59572. private _ropeStep;
  59573. /**
  59574. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59575. * @param impostor imposter to match
  59576. */
  59577. private _softbodyOrClothStep;
  59578. private _tmpMatrix;
  59579. /**
  59580. * Applies an impulse on the imposter
  59581. * @param impostor imposter to apply impulse to
  59582. * @param force amount of force to be applied to the imposter
  59583. * @param contactPoint the location to apply the impulse on the imposter
  59584. */
  59585. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59586. /**
  59587. * Applies a force on the imposter
  59588. * @param impostor imposter to apply force
  59589. * @param force amount of force to be applied to the imposter
  59590. * @param contactPoint the location to apply the force on the imposter
  59591. */
  59592. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59593. /**
  59594. * Creates a physics body using the plugin
  59595. * @param impostor the imposter to create the physics body on
  59596. */
  59597. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59598. /**
  59599. * Removes the physics body from the imposter and disposes of the body's memory
  59600. * @param impostor imposter to remove the physics body from
  59601. */
  59602. removePhysicsBody(impostor: PhysicsImpostor): void;
  59603. /**
  59604. * Generates a joint
  59605. * @param impostorJoint the imposter joint to create the joint with
  59606. */
  59607. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59608. /**
  59609. * Removes a joint
  59610. * @param impostorJoint the imposter joint to remove the joint from
  59611. */
  59612. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59613. private _addMeshVerts;
  59614. /**
  59615. * Initialise the soft body vertices to match its object's (mesh) vertices
  59616. * Softbody vertices (nodes) are in world space and to match this
  59617. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59618. * @param impostor to create the softbody for
  59619. */
  59620. private _softVertexData;
  59621. /**
  59622. * Create an impostor's soft body
  59623. * @param impostor to create the softbody for
  59624. */
  59625. private _createSoftbody;
  59626. /**
  59627. * Create cloth for an impostor
  59628. * @param impostor to create the softbody for
  59629. */
  59630. private _createCloth;
  59631. /**
  59632. * Create rope for an impostor
  59633. * @param impostor to create the softbody for
  59634. */
  59635. private _createRope;
  59636. /**
  59637. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59638. * @param impostor to create the custom physics shape for
  59639. */
  59640. private _createCustom;
  59641. private _addHullVerts;
  59642. private _createShape;
  59643. /**
  59644. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59645. * @param impostor imposter containing the physics body and babylon object
  59646. */
  59647. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59648. /**
  59649. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59650. * @param impostor imposter containing the physics body and babylon object
  59651. * @param newPosition new position
  59652. * @param newRotation new rotation
  59653. */
  59654. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59655. /**
  59656. * If this plugin is supported
  59657. * @returns true if its supported
  59658. */
  59659. isSupported(): boolean;
  59660. /**
  59661. * Sets the linear velocity of the physics body
  59662. * @param impostor imposter to set the velocity on
  59663. * @param velocity velocity to set
  59664. */
  59665. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59666. /**
  59667. * Sets the angular velocity of the physics body
  59668. * @param impostor imposter to set the velocity on
  59669. * @param velocity velocity to set
  59670. */
  59671. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59672. /**
  59673. * gets the linear velocity
  59674. * @param impostor imposter to get linear velocity from
  59675. * @returns linear velocity
  59676. */
  59677. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59678. /**
  59679. * gets the angular velocity
  59680. * @param impostor imposter to get angular velocity from
  59681. * @returns angular velocity
  59682. */
  59683. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59684. /**
  59685. * Sets the mass of physics body
  59686. * @param impostor imposter to set the mass on
  59687. * @param mass mass to set
  59688. */
  59689. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59690. /**
  59691. * Gets the mass of the physics body
  59692. * @param impostor imposter to get the mass from
  59693. * @returns mass
  59694. */
  59695. getBodyMass(impostor: PhysicsImpostor): number;
  59696. /**
  59697. * Gets friction of the impostor
  59698. * @param impostor impostor to get friction from
  59699. * @returns friction value
  59700. */
  59701. getBodyFriction(impostor: PhysicsImpostor): number;
  59702. /**
  59703. * Sets friction of the impostor
  59704. * @param impostor impostor to set friction on
  59705. * @param friction friction value
  59706. */
  59707. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59708. /**
  59709. * Gets restitution of the impostor
  59710. * @param impostor impostor to get restitution from
  59711. * @returns restitution value
  59712. */
  59713. getBodyRestitution(impostor: PhysicsImpostor): number;
  59714. /**
  59715. * Sets resitution of the impostor
  59716. * @param impostor impostor to set resitution on
  59717. * @param restitution resitution value
  59718. */
  59719. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59720. /**
  59721. * Gets pressure inside the impostor
  59722. * @param impostor impostor to get pressure from
  59723. * @returns pressure value
  59724. */
  59725. getBodyPressure(impostor: PhysicsImpostor): number;
  59726. /**
  59727. * Sets pressure inside a soft body impostor
  59728. * Cloth and rope must remain 0 pressure
  59729. * @param impostor impostor to set pressure on
  59730. * @param pressure pressure value
  59731. */
  59732. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59733. /**
  59734. * Gets stiffness of the impostor
  59735. * @param impostor impostor to get stiffness from
  59736. * @returns pressure value
  59737. */
  59738. getBodyStiffness(impostor: PhysicsImpostor): number;
  59739. /**
  59740. * Sets stiffness of the impostor
  59741. * @param impostor impostor to set stiffness on
  59742. * @param stiffness stiffness value from 0 to 1
  59743. */
  59744. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59745. /**
  59746. * Gets velocityIterations of the impostor
  59747. * @param impostor impostor to get velocity iterations from
  59748. * @returns velocityIterations value
  59749. */
  59750. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59751. /**
  59752. * Sets velocityIterations of the impostor
  59753. * @param impostor impostor to set velocity iterations on
  59754. * @param velocityIterations velocityIterations value
  59755. */
  59756. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59757. /**
  59758. * Gets positionIterations of the impostor
  59759. * @param impostor impostor to get position iterations from
  59760. * @returns positionIterations value
  59761. */
  59762. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59763. /**
  59764. * Sets positionIterations of the impostor
  59765. * @param impostor impostor to set position on
  59766. * @param positionIterations positionIterations value
  59767. */
  59768. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59769. /**
  59770. * Append an anchor to a cloth object
  59771. * @param impostor is the cloth impostor to add anchor to
  59772. * @param otherImpostor is the rigid impostor to anchor to
  59773. * @param width ratio across width from 0 to 1
  59774. * @param height ratio up height from 0 to 1
  59775. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59776. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59777. */
  59778. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59779. /**
  59780. * Append an hook to a rope object
  59781. * @param impostor is the rope impostor to add hook to
  59782. * @param otherImpostor is the rigid impostor to hook to
  59783. * @param length ratio along the rope from 0 to 1
  59784. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59785. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59786. */
  59787. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59788. /**
  59789. * Sleeps the physics body and stops it from being active
  59790. * @param impostor impostor to sleep
  59791. */
  59792. sleepBody(impostor: PhysicsImpostor): void;
  59793. /**
  59794. * Activates the physics body
  59795. * @param impostor impostor to activate
  59796. */
  59797. wakeUpBody(impostor: PhysicsImpostor): void;
  59798. /**
  59799. * Updates the distance parameters of the joint
  59800. * @param joint joint to update
  59801. * @param maxDistance maximum distance of the joint
  59802. * @param minDistance minimum distance of the joint
  59803. */
  59804. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59805. /**
  59806. * Sets a motor on the joint
  59807. * @param joint joint to set motor on
  59808. * @param speed speed of the motor
  59809. * @param maxForce maximum force of the motor
  59810. * @param motorIndex index of the motor
  59811. */
  59812. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59813. /**
  59814. * Sets the motors limit
  59815. * @param joint joint to set limit on
  59816. * @param upperLimit upper limit
  59817. * @param lowerLimit lower limit
  59818. */
  59819. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59820. /**
  59821. * Syncs the position and rotation of a mesh with the impostor
  59822. * @param mesh mesh to sync
  59823. * @param impostor impostor to update the mesh with
  59824. */
  59825. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59826. /**
  59827. * Gets the radius of the impostor
  59828. * @param impostor impostor to get radius from
  59829. * @returns the radius
  59830. */
  59831. getRadius(impostor: PhysicsImpostor): number;
  59832. /**
  59833. * Gets the box size of the impostor
  59834. * @param impostor impostor to get box size from
  59835. * @param result the resulting box size
  59836. */
  59837. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59838. /**
  59839. * Disposes of the impostor
  59840. */
  59841. dispose(): void;
  59842. /**
  59843. * Does a raycast in the physics world
  59844. * @param from when should the ray start?
  59845. * @param to when should the ray end?
  59846. * @returns PhysicsRaycastResult
  59847. */
  59848. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59849. }
  59850. }
  59851. declare module BABYLON {
  59852. interface AbstractScene {
  59853. /**
  59854. * The list of reflection probes added to the scene
  59855. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59856. */
  59857. reflectionProbes: Array<ReflectionProbe>;
  59858. /**
  59859. * Removes the given reflection probe from this scene.
  59860. * @param toRemove The reflection probe to remove
  59861. * @returns The index of the removed reflection probe
  59862. */
  59863. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59864. /**
  59865. * Adds the given reflection probe to this scene.
  59866. * @param newReflectionProbe The reflection probe to add
  59867. */
  59868. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59869. }
  59870. /**
  59871. * Class used to generate realtime reflection / refraction cube textures
  59872. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59873. */
  59874. export class ReflectionProbe {
  59875. /** defines the name of the probe */
  59876. name: string;
  59877. private _scene;
  59878. private _renderTargetTexture;
  59879. private _projectionMatrix;
  59880. private _viewMatrix;
  59881. private _target;
  59882. private _add;
  59883. private _attachedMesh;
  59884. private _invertYAxis;
  59885. /** Gets or sets probe position (center of the cube map) */
  59886. position: Vector3;
  59887. /**
  59888. * Creates a new reflection probe
  59889. * @param name defines the name of the probe
  59890. * @param size defines the texture resolution (for each face)
  59891. * @param scene defines the hosting scene
  59892. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59893. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59894. */
  59895. constructor(
  59896. /** defines the name of the probe */
  59897. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59898. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59899. get samples(): number;
  59900. set samples(value: number);
  59901. /** Gets or sets the refresh rate to use (on every frame by default) */
  59902. get refreshRate(): number;
  59903. set refreshRate(value: number);
  59904. /**
  59905. * Gets the hosting scene
  59906. * @returns a Scene
  59907. */
  59908. getScene(): Scene;
  59909. /** Gets the internal CubeTexture used to render to */
  59910. get cubeTexture(): RenderTargetTexture;
  59911. /** Gets the list of meshes to render */
  59912. get renderList(): Nullable<AbstractMesh[]>;
  59913. /**
  59914. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59915. * @param mesh defines the mesh to attach to
  59916. */
  59917. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59918. /**
  59919. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59920. * @param renderingGroupId The rendering group id corresponding to its index
  59921. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59922. */
  59923. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59924. /**
  59925. * Clean all associated resources
  59926. */
  59927. dispose(): void;
  59928. /**
  59929. * Converts the reflection probe information to a readable string for debug purpose.
  59930. * @param fullDetails Supports for multiple levels of logging within scene loading
  59931. * @returns the human readable reflection probe info
  59932. */
  59933. toString(fullDetails?: boolean): string;
  59934. /**
  59935. * Get the class name of the relfection probe.
  59936. * @returns "ReflectionProbe"
  59937. */
  59938. getClassName(): string;
  59939. /**
  59940. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59941. * @returns The JSON representation of the texture
  59942. */
  59943. serialize(): any;
  59944. /**
  59945. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59946. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59947. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59948. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59949. * @returns The parsed reflection probe if successful
  59950. */
  59951. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59952. }
  59953. }
  59954. declare module BABYLON {
  59955. /** @hidden */
  59956. export var _BabylonLoaderRegistered: boolean;
  59957. /**
  59958. * Helps setting up some configuration for the babylon file loader.
  59959. */
  59960. export class BabylonFileLoaderConfiguration {
  59961. /**
  59962. * The loader does not allow injecting custom physix engine into the plugins.
  59963. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59964. * So you could set this variable to your engine import to make it work.
  59965. */
  59966. static LoaderInjectedPhysicsEngine: any;
  59967. }
  59968. }
  59969. declare module BABYLON {
  59970. /**
  59971. * The Physically based simple base material of BJS.
  59972. *
  59973. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59974. * It is used as the base class for both the specGloss and metalRough conventions.
  59975. */
  59976. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59977. /**
  59978. * Number of Simultaneous lights allowed on the material.
  59979. */
  59980. maxSimultaneousLights: number;
  59981. /**
  59982. * If sets to true, disables all the lights affecting the material.
  59983. */
  59984. disableLighting: boolean;
  59985. /**
  59986. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59987. */
  59988. environmentTexture: BaseTexture;
  59989. /**
  59990. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  59991. */
  59992. invertNormalMapX: boolean;
  59993. /**
  59994. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  59995. */
  59996. invertNormalMapY: boolean;
  59997. /**
  59998. * Normal map used in the model.
  59999. */
  60000. normalTexture: BaseTexture;
  60001. /**
  60002. * Emissivie color used to self-illuminate the model.
  60003. */
  60004. emissiveColor: Color3;
  60005. /**
  60006. * Emissivie texture used to self-illuminate the model.
  60007. */
  60008. emissiveTexture: BaseTexture;
  60009. /**
  60010. * Occlusion Channel Strenght.
  60011. */
  60012. occlusionStrength: number;
  60013. /**
  60014. * Occlusion Texture of the material (adding extra occlusion effects).
  60015. */
  60016. occlusionTexture: BaseTexture;
  60017. /**
  60018. * Defines the alpha limits in alpha test mode.
  60019. */
  60020. alphaCutOff: number;
  60021. /**
  60022. * Gets the current double sided mode.
  60023. */
  60024. get doubleSided(): boolean;
  60025. /**
  60026. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60027. */
  60028. set doubleSided(value: boolean);
  60029. /**
  60030. * Stores the pre-calculated light information of a mesh in a texture.
  60031. */
  60032. lightmapTexture: BaseTexture;
  60033. /**
  60034. * If true, the light map contains occlusion information instead of lighting info.
  60035. */
  60036. useLightmapAsShadowmap: boolean;
  60037. /**
  60038. * Instantiates a new PBRMaterial instance.
  60039. *
  60040. * @param name The material name
  60041. * @param scene The scene the material will be use in.
  60042. */
  60043. constructor(name: string, scene: Scene);
  60044. getClassName(): string;
  60045. }
  60046. }
  60047. declare module BABYLON {
  60048. /**
  60049. * The PBR material of BJS following the metal roughness convention.
  60050. *
  60051. * This fits to the PBR convention in the GLTF definition:
  60052. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60053. */
  60054. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60055. /**
  60056. * The base color has two different interpretations depending on the value of metalness.
  60057. * When the material is a metal, the base color is the specific measured reflectance value
  60058. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60059. * of the material.
  60060. */
  60061. baseColor: Color3;
  60062. /**
  60063. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60064. * well as opacity information in the alpha channel.
  60065. */
  60066. baseTexture: BaseTexture;
  60067. /**
  60068. * Specifies the metallic scalar value of the material.
  60069. * Can also be used to scale the metalness values of the metallic texture.
  60070. */
  60071. metallic: number;
  60072. /**
  60073. * Specifies the roughness scalar value of the material.
  60074. * Can also be used to scale the roughness values of the metallic texture.
  60075. */
  60076. roughness: number;
  60077. /**
  60078. * Texture containing both the metallic value in the B channel and the
  60079. * roughness value in the G channel to keep better precision.
  60080. */
  60081. metallicRoughnessTexture: BaseTexture;
  60082. /**
  60083. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60084. *
  60085. * @param name The material name
  60086. * @param scene The scene the material will be use in.
  60087. */
  60088. constructor(name: string, scene: Scene);
  60089. /**
  60090. * Return the currrent class name of the material.
  60091. */
  60092. getClassName(): string;
  60093. /**
  60094. * Makes a duplicate of the current material.
  60095. * @param name - name to use for the new material.
  60096. */
  60097. clone(name: string): PBRMetallicRoughnessMaterial;
  60098. /**
  60099. * Serialize the material to a parsable JSON object.
  60100. */
  60101. serialize(): any;
  60102. /**
  60103. * Parses a JSON object correponding to the serialize function.
  60104. */
  60105. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60106. }
  60107. }
  60108. declare module BABYLON {
  60109. /**
  60110. * The PBR material of BJS following the specular glossiness convention.
  60111. *
  60112. * This fits to the PBR convention in the GLTF definition:
  60113. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60114. */
  60115. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60116. /**
  60117. * Specifies the diffuse color of the material.
  60118. */
  60119. diffuseColor: Color3;
  60120. /**
  60121. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60122. * channel.
  60123. */
  60124. diffuseTexture: BaseTexture;
  60125. /**
  60126. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60127. */
  60128. specularColor: Color3;
  60129. /**
  60130. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60131. */
  60132. glossiness: number;
  60133. /**
  60134. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60135. */
  60136. specularGlossinessTexture: BaseTexture;
  60137. /**
  60138. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60139. *
  60140. * @param name The material name
  60141. * @param scene The scene the material will be use in.
  60142. */
  60143. constructor(name: string, scene: Scene);
  60144. /**
  60145. * Return the currrent class name of the material.
  60146. */
  60147. getClassName(): string;
  60148. /**
  60149. * Makes a duplicate of the current material.
  60150. * @param name - name to use for the new material.
  60151. */
  60152. clone(name: string): PBRSpecularGlossinessMaterial;
  60153. /**
  60154. * Serialize the material to a parsable JSON object.
  60155. */
  60156. serialize(): any;
  60157. /**
  60158. * Parses a JSON object correponding to the serialize function.
  60159. */
  60160. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60161. }
  60162. }
  60163. declare module BABYLON {
  60164. /**
  60165. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60166. * It can help converting any input color in a desired output one. This can then be used to create effects
  60167. * from sepia, black and white to sixties or futuristic rendering...
  60168. *
  60169. * The only supported format is currently 3dl.
  60170. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60171. */
  60172. export class ColorGradingTexture extends BaseTexture {
  60173. /**
  60174. * The texture URL.
  60175. */
  60176. url: string;
  60177. /**
  60178. * Empty line regex stored for GC.
  60179. */
  60180. private static _noneEmptyLineRegex;
  60181. private _textureMatrix;
  60182. private _onLoad;
  60183. /**
  60184. * Instantiates a ColorGradingTexture from the following parameters.
  60185. *
  60186. * @param url The location of the color gradind data (currently only supporting 3dl)
  60187. * @param sceneOrEngine The scene or engine the texture will be used in
  60188. * @param onLoad defines a callback triggered when the texture has been loaded
  60189. */
  60190. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60191. /**
  60192. * Fires the onload event from the constructor if requested.
  60193. */
  60194. private _triggerOnLoad;
  60195. /**
  60196. * Returns the texture matrix used in most of the material.
  60197. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60198. */
  60199. getTextureMatrix(): Matrix;
  60200. /**
  60201. * Occurs when the file being loaded is a .3dl LUT file.
  60202. */
  60203. private load3dlTexture;
  60204. /**
  60205. * Starts the loading process of the texture.
  60206. */
  60207. private loadTexture;
  60208. /**
  60209. * Clones the color gradind texture.
  60210. */
  60211. clone(): ColorGradingTexture;
  60212. /**
  60213. * Called during delayed load for textures.
  60214. */
  60215. delayLoad(): void;
  60216. /**
  60217. * Parses a color grading texture serialized by Babylon.
  60218. * @param parsedTexture The texture information being parsedTexture
  60219. * @param scene The scene to load the texture in
  60220. * @param rootUrl The root url of the data assets to load
  60221. * @return A color gradind texture
  60222. */
  60223. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60224. /**
  60225. * Serializes the LUT texture to json format.
  60226. */
  60227. serialize(): any;
  60228. }
  60229. }
  60230. declare module BABYLON {
  60231. /**
  60232. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60233. */
  60234. export class EquiRectangularCubeTexture extends BaseTexture {
  60235. /** The six faces of the cube. */
  60236. private static _FacesMapping;
  60237. private _noMipmap;
  60238. private _onLoad;
  60239. private _onError;
  60240. /** The size of the cubemap. */
  60241. private _size;
  60242. /** The buffer of the image. */
  60243. private _buffer;
  60244. /** The width of the input image. */
  60245. private _width;
  60246. /** The height of the input image. */
  60247. private _height;
  60248. /** The URL to the image. */
  60249. url: string;
  60250. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60251. coordinatesMode: number;
  60252. /**
  60253. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60254. * @param url The location of the image
  60255. * @param scene The scene the texture will be used in
  60256. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60257. * @param noMipmap Forces to not generate the mipmap if true
  60258. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60259. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60260. * @param onLoad — defines a callback called when texture is loaded
  60261. * @param onError — defines a callback called if there is an error
  60262. */
  60263. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60264. /**
  60265. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60266. */
  60267. private loadImage;
  60268. /**
  60269. * Convert the image buffer into a cubemap and create a CubeTexture.
  60270. */
  60271. private loadTexture;
  60272. /**
  60273. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60274. * @param buffer The ArrayBuffer that should be converted.
  60275. * @returns The buffer as Float32Array.
  60276. */
  60277. private getFloat32ArrayFromArrayBuffer;
  60278. /**
  60279. * Get the current class name of the texture useful for serialization or dynamic coding.
  60280. * @returns "EquiRectangularCubeTexture"
  60281. */
  60282. getClassName(): string;
  60283. /**
  60284. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60285. * @returns A clone of the current EquiRectangularCubeTexture.
  60286. */
  60287. clone(): EquiRectangularCubeTexture;
  60288. }
  60289. }
  60290. declare module BABYLON {
  60291. /**
  60292. * Defines the options related to the creation of an HtmlElementTexture
  60293. */
  60294. export interface IHtmlElementTextureOptions {
  60295. /**
  60296. * Defines wether mip maps should be created or not.
  60297. */
  60298. generateMipMaps?: boolean;
  60299. /**
  60300. * Defines the sampling mode of the texture.
  60301. */
  60302. samplingMode?: number;
  60303. /**
  60304. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60305. */
  60306. engine: Nullable<ThinEngine>;
  60307. /**
  60308. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60309. */
  60310. scene: Nullable<Scene>;
  60311. }
  60312. /**
  60313. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60314. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60315. * is automatically managed.
  60316. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60317. * in your application.
  60318. *
  60319. * As the update is not automatic, you need to call them manually.
  60320. */
  60321. export class HtmlElementTexture extends BaseTexture {
  60322. /**
  60323. * The texture URL.
  60324. */
  60325. element: HTMLVideoElement | HTMLCanvasElement;
  60326. private static readonly DefaultOptions;
  60327. private _textureMatrix;
  60328. private _isVideo;
  60329. private _generateMipMaps;
  60330. private _samplingMode;
  60331. /**
  60332. * Instantiates a HtmlElementTexture from the following parameters.
  60333. *
  60334. * @param name Defines the name of the texture
  60335. * @param element Defines the video or canvas the texture is filled with
  60336. * @param options Defines the other none mandatory texture creation options
  60337. */
  60338. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60339. private _createInternalTexture;
  60340. /**
  60341. * Returns the texture matrix used in most of the material.
  60342. */
  60343. getTextureMatrix(): Matrix;
  60344. /**
  60345. * Updates the content of the texture.
  60346. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60347. */
  60348. update(invertY?: Nullable<boolean>): void;
  60349. }
  60350. }
  60351. declare module BABYLON {
  60352. /**
  60353. * Based on jsTGALoader - Javascript loader for TGA file
  60354. * By Vincent Thibault
  60355. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60356. */
  60357. export class TGATools {
  60358. private static _TYPE_INDEXED;
  60359. private static _TYPE_RGB;
  60360. private static _TYPE_GREY;
  60361. private static _TYPE_RLE_INDEXED;
  60362. private static _TYPE_RLE_RGB;
  60363. private static _TYPE_RLE_GREY;
  60364. private static _ORIGIN_MASK;
  60365. private static _ORIGIN_SHIFT;
  60366. private static _ORIGIN_BL;
  60367. private static _ORIGIN_BR;
  60368. private static _ORIGIN_UL;
  60369. private static _ORIGIN_UR;
  60370. /**
  60371. * Gets the header of a TGA file
  60372. * @param data defines the TGA data
  60373. * @returns the header
  60374. */
  60375. static GetTGAHeader(data: Uint8Array): any;
  60376. /**
  60377. * Uploads TGA content to a Babylon Texture
  60378. * @hidden
  60379. */
  60380. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60381. /** @hidden */
  60382. 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;
  60383. /** @hidden */
  60384. 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;
  60385. /** @hidden */
  60386. 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;
  60387. /** @hidden */
  60388. 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;
  60389. /** @hidden */
  60390. 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;
  60391. /** @hidden */
  60392. 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;
  60393. }
  60394. }
  60395. declare module BABYLON {
  60396. /**
  60397. * Implementation of the TGA Texture Loader.
  60398. * @hidden
  60399. */
  60400. export class _TGATextureLoader implements IInternalTextureLoader {
  60401. /**
  60402. * Defines wether the loader supports cascade loading the different faces.
  60403. */
  60404. readonly supportCascades: boolean;
  60405. /**
  60406. * This returns if the loader support the current file information.
  60407. * @param extension defines the file extension of the file being loaded
  60408. * @returns true if the loader can load the specified file
  60409. */
  60410. canLoad(extension: string): boolean;
  60411. /**
  60412. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60413. * @param data contains the texture data
  60414. * @param texture defines the BabylonJS internal texture
  60415. * @param createPolynomials will be true if polynomials have been requested
  60416. * @param onLoad defines the callback to trigger once the texture is ready
  60417. * @param onError defines the callback to trigger in case of error
  60418. */
  60419. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60420. /**
  60421. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60422. * @param data contains the texture data
  60423. * @param texture defines the BabylonJS internal texture
  60424. * @param callback defines the method to call once ready to upload
  60425. */
  60426. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60427. }
  60428. }
  60429. declare module BABYLON {
  60430. /**
  60431. * Info about the .basis files
  60432. */
  60433. class BasisFileInfo {
  60434. /**
  60435. * If the file has alpha
  60436. */
  60437. hasAlpha: boolean;
  60438. /**
  60439. * Info about each image of the basis file
  60440. */
  60441. images: Array<{
  60442. levels: Array<{
  60443. width: number;
  60444. height: number;
  60445. transcodedPixels: ArrayBufferView;
  60446. }>;
  60447. }>;
  60448. }
  60449. /**
  60450. * Result of transcoding a basis file
  60451. */
  60452. class TranscodeResult {
  60453. /**
  60454. * Info about the .basis file
  60455. */
  60456. fileInfo: BasisFileInfo;
  60457. /**
  60458. * Format to use when loading the file
  60459. */
  60460. format: number;
  60461. }
  60462. /**
  60463. * Configuration options for the Basis transcoder
  60464. */
  60465. export class BasisTranscodeConfiguration {
  60466. /**
  60467. * Supported compression formats used to determine the supported output format of the transcoder
  60468. */
  60469. supportedCompressionFormats?: {
  60470. /**
  60471. * etc1 compression format
  60472. */
  60473. etc1?: boolean;
  60474. /**
  60475. * s3tc compression format
  60476. */
  60477. s3tc?: boolean;
  60478. /**
  60479. * pvrtc compression format
  60480. */
  60481. pvrtc?: boolean;
  60482. /**
  60483. * etc2 compression format
  60484. */
  60485. etc2?: boolean;
  60486. };
  60487. /**
  60488. * If mipmap levels should be loaded for transcoded images (Default: true)
  60489. */
  60490. loadMipmapLevels?: boolean;
  60491. /**
  60492. * Index of a single image to load (Default: all images)
  60493. */
  60494. loadSingleImage?: number;
  60495. }
  60496. /**
  60497. * Used to load .Basis files
  60498. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60499. */
  60500. export class BasisTools {
  60501. private static _IgnoreSupportedFormats;
  60502. /**
  60503. * URL to use when loading the basis transcoder
  60504. */
  60505. static JSModuleURL: string;
  60506. /**
  60507. * URL to use when loading the wasm module for the transcoder
  60508. */
  60509. static WasmModuleURL: string;
  60510. /**
  60511. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60512. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60513. * @returns internal format corresponding to the Basis format
  60514. */
  60515. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60516. private static _WorkerPromise;
  60517. private static _Worker;
  60518. private static _actionId;
  60519. private static _CreateWorkerAsync;
  60520. /**
  60521. * Transcodes a loaded image file to compressed pixel data
  60522. * @param data image data to transcode
  60523. * @param config configuration options for the transcoding
  60524. * @returns a promise resulting in the transcoded image
  60525. */
  60526. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60527. /**
  60528. * Loads a texture from the transcode result
  60529. * @param texture texture load to
  60530. * @param transcodeResult the result of transcoding the basis file to load from
  60531. */
  60532. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60533. }
  60534. }
  60535. declare module BABYLON {
  60536. /**
  60537. * Loader for .basis file format
  60538. */
  60539. export class _BasisTextureLoader implements IInternalTextureLoader {
  60540. /**
  60541. * Defines whether the loader supports cascade loading the different faces.
  60542. */
  60543. readonly supportCascades: boolean;
  60544. /**
  60545. * This returns if the loader support the current file information.
  60546. * @param extension defines the file extension of the file being loaded
  60547. * @returns true if the loader can load the specified file
  60548. */
  60549. canLoad(extension: string): boolean;
  60550. /**
  60551. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60552. * @param data contains the texture data
  60553. * @param texture defines the BabylonJS internal texture
  60554. * @param createPolynomials will be true if polynomials have been requested
  60555. * @param onLoad defines the callback to trigger once the texture is ready
  60556. * @param onError defines the callback to trigger in case of error
  60557. */
  60558. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60559. /**
  60560. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60561. * @param data contains the texture data
  60562. * @param texture defines the BabylonJS internal texture
  60563. * @param callback defines the method to call once ready to upload
  60564. */
  60565. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60566. }
  60567. }
  60568. declare module BABYLON {
  60569. /**
  60570. * Defines the basic options interface of a TexturePacker Frame
  60571. */
  60572. export interface ITexturePackerFrame {
  60573. /**
  60574. * The frame ID
  60575. */
  60576. id: number;
  60577. /**
  60578. * The frames Scale
  60579. */
  60580. scale: Vector2;
  60581. /**
  60582. * The Frames offset
  60583. */
  60584. offset: Vector2;
  60585. }
  60586. /**
  60587. * This is a support class for frame Data on texture packer sets.
  60588. */
  60589. export class TexturePackerFrame implements ITexturePackerFrame {
  60590. /**
  60591. * The frame ID
  60592. */
  60593. id: number;
  60594. /**
  60595. * The frames Scale
  60596. */
  60597. scale: Vector2;
  60598. /**
  60599. * The Frames offset
  60600. */
  60601. offset: Vector2;
  60602. /**
  60603. * Initializes a texture package frame.
  60604. * @param id The numerical frame identifier
  60605. * @param scale Scalar Vector2 for UV frame
  60606. * @param offset Vector2 for the frame position in UV units.
  60607. * @returns TexturePackerFrame
  60608. */
  60609. constructor(id: number, scale: Vector2, offset: Vector2);
  60610. }
  60611. }
  60612. declare module BABYLON {
  60613. /**
  60614. * Defines the basic options interface of a TexturePacker
  60615. */
  60616. export interface ITexturePackerOptions {
  60617. /**
  60618. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60619. */
  60620. map?: string[];
  60621. /**
  60622. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60623. */
  60624. uvsIn?: string;
  60625. /**
  60626. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60627. */
  60628. uvsOut?: string;
  60629. /**
  60630. * number representing the layout style. Defaults to LAYOUT_STRIP
  60631. */
  60632. layout?: number;
  60633. /**
  60634. * number of columns if using custom column count layout(2). This defaults to 4.
  60635. */
  60636. colnum?: number;
  60637. /**
  60638. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60639. */
  60640. updateInputMeshes?: boolean;
  60641. /**
  60642. * boolean flag to dispose all the source textures. Defaults to true.
  60643. */
  60644. disposeSources?: boolean;
  60645. /**
  60646. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60647. */
  60648. fillBlanks?: boolean;
  60649. /**
  60650. * string value representing the context fill style color. Defaults to 'black'.
  60651. */
  60652. customFillColor?: string;
  60653. /**
  60654. * Width and Height Value of each Frame in the TexturePacker Sets
  60655. */
  60656. frameSize?: number;
  60657. /**
  60658. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60659. */
  60660. paddingRatio?: number;
  60661. /**
  60662. * Number that declares the fill method for the padding gutter.
  60663. */
  60664. paddingMode?: number;
  60665. /**
  60666. * If in SUBUV_COLOR padding mode what color to use.
  60667. */
  60668. paddingColor?: Color3 | Color4;
  60669. }
  60670. /**
  60671. * Defines the basic interface of a TexturePacker JSON File
  60672. */
  60673. export interface ITexturePackerJSON {
  60674. /**
  60675. * The frame ID
  60676. */
  60677. name: string;
  60678. /**
  60679. * The base64 channel data
  60680. */
  60681. sets: any;
  60682. /**
  60683. * The options of the Packer
  60684. */
  60685. options: ITexturePackerOptions;
  60686. /**
  60687. * The frame data of the Packer
  60688. */
  60689. frames: Array<number>;
  60690. }
  60691. /**
  60692. * This is a support class that generates a series of packed texture sets.
  60693. * @see https://doc.babylonjs.com/babylon101/materials
  60694. */
  60695. export class TexturePacker {
  60696. /** Packer Layout Constant 0 */
  60697. static readonly LAYOUT_STRIP: number;
  60698. /** Packer Layout Constant 1 */
  60699. static readonly LAYOUT_POWER2: number;
  60700. /** Packer Layout Constant 2 */
  60701. static readonly LAYOUT_COLNUM: number;
  60702. /** Packer Layout Constant 0 */
  60703. static readonly SUBUV_WRAP: number;
  60704. /** Packer Layout Constant 1 */
  60705. static readonly SUBUV_EXTEND: number;
  60706. /** Packer Layout Constant 2 */
  60707. static readonly SUBUV_COLOR: number;
  60708. /** The Name of the Texture Package */
  60709. name: string;
  60710. /** The scene scope of the TexturePacker */
  60711. scene: Scene;
  60712. /** The Meshes to target */
  60713. meshes: AbstractMesh[];
  60714. /** Arguments passed with the Constructor */
  60715. options: ITexturePackerOptions;
  60716. /** The promise that is started upon initialization */
  60717. promise: Nullable<Promise<TexturePacker | string>>;
  60718. /** The Container object for the channel sets that are generated */
  60719. sets: object;
  60720. /** The Container array for the frames that are generated */
  60721. frames: TexturePackerFrame[];
  60722. /** The expected number of textures the system is parsing. */
  60723. private _expecting;
  60724. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60725. private _paddingValue;
  60726. /**
  60727. * Initializes a texture package series from an array of meshes or a single mesh.
  60728. * @param name The name of the package
  60729. * @param meshes The target meshes to compose the package from
  60730. * @param options The arguments that texture packer should follow while building.
  60731. * @param scene The scene which the textures are scoped to.
  60732. * @returns TexturePacker
  60733. */
  60734. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60735. /**
  60736. * Starts the package process
  60737. * @param resolve The promises resolution function
  60738. * @returns TexturePacker
  60739. */
  60740. private _createFrames;
  60741. /**
  60742. * Calculates the Size of the Channel Sets
  60743. * @returns Vector2
  60744. */
  60745. private _calculateSize;
  60746. /**
  60747. * Calculates the UV data for the frames.
  60748. * @param baseSize the base frameSize
  60749. * @param padding the base frame padding
  60750. * @param dtSize size of the Dynamic Texture for that channel
  60751. * @param dtUnits is 1/dtSize
  60752. * @param update flag to update the input meshes
  60753. */
  60754. private _calculateMeshUVFrames;
  60755. /**
  60756. * Calculates the frames Offset.
  60757. * @param index of the frame
  60758. * @returns Vector2
  60759. */
  60760. private _getFrameOffset;
  60761. /**
  60762. * Updates a Mesh to the frame data
  60763. * @param mesh that is the target
  60764. * @param frameID or the frame index
  60765. */
  60766. private _updateMeshUV;
  60767. /**
  60768. * Updates a Meshes materials to use the texture packer channels
  60769. * @param m is the mesh to target
  60770. * @param force all channels on the packer to be set.
  60771. */
  60772. private _updateTextureReferences;
  60773. /**
  60774. * Public method to set a Mesh to a frame
  60775. * @param m that is the target
  60776. * @param frameID or the frame index
  60777. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60778. */
  60779. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60780. /**
  60781. * Starts the async promise to compile the texture packer.
  60782. * @returns Promise<void>
  60783. */
  60784. processAsync(): Promise<void>;
  60785. /**
  60786. * Disposes all textures associated with this packer
  60787. */
  60788. dispose(): void;
  60789. /**
  60790. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60791. * @param imageType is the image type to use.
  60792. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60793. */
  60794. download(imageType?: string, quality?: number): void;
  60795. /**
  60796. * Public method to load a texturePacker JSON file.
  60797. * @param data of the JSON file in string format.
  60798. */
  60799. updateFromJSON(data: string): void;
  60800. }
  60801. }
  60802. declare module BABYLON {
  60803. /**
  60804. * 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.
  60805. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60806. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60807. */
  60808. export class CustomProceduralTexture extends ProceduralTexture {
  60809. private _animate;
  60810. private _time;
  60811. private _config;
  60812. private _texturePath;
  60813. /**
  60814. * Instantiates a new Custom Procedural Texture.
  60815. * 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.
  60816. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60817. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60818. * @param name Define the name of the texture
  60819. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60820. * @param size Define the size of the texture to create
  60821. * @param scene Define the scene the texture belongs to
  60822. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60823. * @param generateMipMaps Define if the texture should creates mip maps or not
  60824. */
  60825. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60826. private _loadJson;
  60827. /**
  60828. * Is the texture ready to be used ? (rendered at least once)
  60829. * @returns true if ready, otherwise, false.
  60830. */
  60831. isReady(): boolean;
  60832. /**
  60833. * Render the texture to its associated render target.
  60834. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60835. */
  60836. render(useCameraPostProcess?: boolean): void;
  60837. /**
  60838. * Update the list of dependant textures samplers in the shader.
  60839. */
  60840. updateTextures(): void;
  60841. /**
  60842. * Update the uniform values of the procedural texture in the shader.
  60843. */
  60844. updateShaderUniforms(): void;
  60845. /**
  60846. * Define if the texture animates or not.
  60847. */
  60848. get animate(): boolean;
  60849. set animate(value: boolean);
  60850. }
  60851. }
  60852. declare module BABYLON {
  60853. /** @hidden */
  60854. export var noisePixelShader: {
  60855. name: string;
  60856. shader: string;
  60857. };
  60858. }
  60859. declare module BABYLON {
  60860. /**
  60861. * Class used to generate noise procedural textures
  60862. */
  60863. export class NoiseProceduralTexture extends ProceduralTexture {
  60864. private _time;
  60865. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60866. brightness: number;
  60867. /** Defines the number of octaves to process */
  60868. octaves: number;
  60869. /** Defines the level of persistence (0.8 by default) */
  60870. persistence: number;
  60871. /** Gets or sets animation speed factor (default is 1) */
  60872. animationSpeedFactor: number;
  60873. /**
  60874. * Creates a new NoiseProceduralTexture
  60875. * @param name defines the name fo the texture
  60876. * @param size defines the size of the texture (default is 256)
  60877. * @param scene defines the hosting scene
  60878. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60879. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60880. */
  60881. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60882. private _updateShaderUniforms;
  60883. protected _getDefines(): string;
  60884. /** Generate the current state of the procedural texture */
  60885. render(useCameraPostProcess?: boolean): void;
  60886. /**
  60887. * Serializes this noise procedural texture
  60888. * @returns a serialized noise procedural texture object
  60889. */
  60890. serialize(): any;
  60891. /**
  60892. * Clone the texture.
  60893. * @returns the cloned texture
  60894. */
  60895. clone(): NoiseProceduralTexture;
  60896. /**
  60897. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60898. * @param parsedTexture defines parsed texture data
  60899. * @param scene defines the current scene
  60900. * @param rootUrl defines the root URL containing noise procedural texture information
  60901. * @returns a parsed NoiseProceduralTexture
  60902. */
  60903. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60904. }
  60905. }
  60906. declare module BABYLON {
  60907. /**
  60908. * Raw cube texture where the raw buffers are passed in
  60909. */
  60910. export class RawCubeTexture extends CubeTexture {
  60911. /**
  60912. * Creates a cube texture where the raw buffers are passed in.
  60913. * @param scene defines the scene the texture is attached to
  60914. * @param data defines the array of data to use to create each face
  60915. * @param size defines the size of the textures
  60916. * @param format defines the format of the data
  60917. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60918. * @param generateMipMaps defines if the engine should generate the mip levels
  60919. * @param invertY defines if data must be stored with Y axis inverted
  60920. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60921. * @param compression defines the compression used (null by default)
  60922. */
  60923. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60924. /**
  60925. * Updates the raw cube texture.
  60926. * @param data defines the data to store
  60927. * @param format defines the data format
  60928. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60929. * @param invertY defines if data must be stored with Y axis inverted
  60930. * @param compression defines the compression used (null by default)
  60931. * @param level defines which level of the texture to update
  60932. */
  60933. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60934. /**
  60935. * Updates a raw cube texture with RGBD encoded data.
  60936. * @param data defines the array of data [mipmap][face] to use to create each face
  60937. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60938. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60939. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60940. * @returns a promsie that resolves when the operation is complete
  60941. */
  60942. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60943. /**
  60944. * Clones the raw cube texture.
  60945. * @return a new cube texture
  60946. */
  60947. clone(): CubeTexture;
  60948. /** @hidden */
  60949. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60950. }
  60951. }
  60952. declare module BABYLON {
  60953. /**
  60954. * Class used to store 2D array textures containing user data
  60955. */
  60956. export class RawTexture2DArray extends Texture {
  60957. /** Gets or sets the texture format to use */
  60958. format: number;
  60959. /**
  60960. * Create a new RawTexture2DArray
  60961. * @param data defines the data of the texture
  60962. * @param width defines the width of the texture
  60963. * @param height defines the height of the texture
  60964. * @param depth defines the number of layers of the texture
  60965. * @param format defines the texture format to use
  60966. * @param scene defines the hosting scene
  60967. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60968. * @param invertY defines if texture must be stored with Y axis inverted
  60969. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60970. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60971. */
  60972. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60973. /** Gets or sets the texture format to use */
  60974. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60975. /**
  60976. * Update the texture with new data
  60977. * @param data defines the data to store in the texture
  60978. */
  60979. update(data: ArrayBufferView): void;
  60980. }
  60981. }
  60982. declare module BABYLON {
  60983. /**
  60984. * Class used to store 3D textures containing user data
  60985. */
  60986. export class RawTexture3D extends Texture {
  60987. /** Gets or sets the texture format to use */
  60988. format: number;
  60989. /**
  60990. * Create a new RawTexture3D
  60991. * @param data defines the data of the texture
  60992. * @param width defines the width of the texture
  60993. * @param height defines the height of the texture
  60994. * @param depth defines the depth of the texture
  60995. * @param format defines the texture format to use
  60996. * @param scene defines the hosting scene
  60997. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60998. * @param invertY defines if texture must be stored with Y axis inverted
  60999. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61000. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61001. */
  61002. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61003. /** Gets or sets the texture format to use */
  61004. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61005. /**
  61006. * Update the texture with new data
  61007. * @param data defines the data to store in the texture
  61008. */
  61009. update(data: ArrayBufferView): void;
  61010. }
  61011. }
  61012. declare module BABYLON {
  61013. /**
  61014. * Creates a refraction texture used by refraction channel of the standard material.
  61015. * It is like a mirror but to see through a material.
  61016. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61017. */
  61018. export class RefractionTexture extends RenderTargetTexture {
  61019. /**
  61020. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61021. * 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.
  61022. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61023. */
  61024. refractionPlane: Plane;
  61025. /**
  61026. * Define how deep under the surface we should see.
  61027. */
  61028. depth: number;
  61029. /**
  61030. * Creates a refraction texture used by refraction channel of the standard material.
  61031. * It is like a mirror but to see through a material.
  61032. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61033. * @param name Define the texture name
  61034. * @param size Define the size of the underlying texture
  61035. * @param scene Define the scene the refraction belongs to
  61036. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61037. */
  61038. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61039. /**
  61040. * Clone the refraction texture.
  61041. * @returns the cloned texture
  61042. */
  61043. clone(): RefractionTexture;
  61044. /**
  61045. * Serialize the texture to a JSON representation you could use in Parse later on
  61046. * @returns the serialized JSON representation
  61047. */
  61048. serialize(): any;
  61049. }
  61050. }
  61051. declare module BABYLON {
  61052. /**
  61053. * Block used to add support for vertex skinning (bones)
  61054. */
  61055. export class BonesBlock extends NodeMaterialBlock {
  61056. /**
  61057. * Creates a new BonesBlock
  61058. * @param name defines the block name
  61059. */
  61060. constructor(name: string);
  61061. /**
  61062. * Initialize the block and prepare the context for build
  61063. * @param state defines the state that will be used for the build
  61064. */
  61065. initialize(state: NodeMaterialBuildState): void;
  61066. /**
  61067. * Gets the current class name
  61068. * @returns the class name
  61069. */
  61070. getClassName(): string;
  61071. /**
  61072. * Gets the matrix indices input component
  61073. */
  61074. get matricesIndices(): NodeMaterialConnectionPoint;
  61075. /**
  61076. * Gets the matrix weights input component
  61077. */
  61078. get matricesWeights(): NodeMaterialConnectionPoint;
  61079. /**
  61080. * Gets the extra matrix indices input component
  61081. */
  61082. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61083. /**
  61084. * Gets the extra matrix weights input component
  61085. */
  61086. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61087. /**
  61088. * Gets the world input component
  61089. */
  61090. get world(): NodeMaterialConnectionPoint;
  61091. /**
  61092. * Gets the output component
  61093. */
  61094. get output(): NodeMaterialConnectionPoint;
  61095. autoConfigure(material: NodeMaterial): void;
  61096. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61097. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61098. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61099. protected _buildBlock(state: NodeMaterialBuildState): this;
  61100. }
  61101. }
  61102. declare module BABYLON {
  61103. /**
  61104. * Block used to add support for instances
  61105. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61106. */
  61107. export class InstancesBlock extends NodeMaterialBlock {
  61108. /**
  61109. * Creates a new InstancesBlock
  61110. * @param name defines the block name
  61111. */
  61112. constructor(name: string);
  61113. /**
  61114. * Gets the current class name
  61115. * @returns the class name
  61116. */
  61117. getClassName(): string;
  61118. /**
  61119. * Gets the first world row input component
  61120. */
  61121. get world0(): NodeMaterialConnectionPoint;
  61122. /**
  61123. * Gets the second world row input component
  61124. */
  61125. get world1(): NodeMaterialConnectionPoint;
  61126. /**
  61127. * Gets the third world row input component
  61128. */
  61129. get world2(): NodeMaterialConnectionPoint;
  61130. /**
  61131. * Gets the forth world row input component
  61132. */
  61133. get world3(): NodeMaterialConnectionPoint;
  61134. /**
  61135. * Gets the world input component
  61136. */
  61137. get world(): NodeMaterialConnectionPoint;
  61138. /**
  61139. * Gets the output component
  61140. */
  61141. get output(): NodeMaterialConnectionPoint;
  61142. /**
  61143. * Gets the isntanceID component
  61144. */
  61145. get instanceID(): NodeMaterialConnectionPoint;
  61146. autoConfigure(material: NodeMaterial): void;
  61147. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61148. protected _buildBlock(state: NodeMaterialBuildState): this;
  61149. }
  61150. }
  61151. declare module BABYLON {
  61152. /**
  61153. * Block used to add morph targets support to vertex shader
  61154. */
  61155. export class MorphTargetsBlock extends NodeMaterialBlock {
  61156. private _repeatableContentAnchor;
  61157. /**
  61158. * Create a new MorphTargetsBlock
  61159. * @param name defines the block name
  61160. */
  61161. constructor(name: string);
  61162. /**
  61163. * Gets the current class name
  61164. * @returns the class name
  61165. */
  61166. getClassName(): string;
  61167. /**
  61168. * Gets the position input component
  61169. */
  61170. get position(): NodeMaterialConnectionPoint;
  61171. /**
  61172. * Gets the normal input component
  61173. */
  61174. get normal(): NodeMaterialConnectionPoint;
  61175. /**
  61176. * Gets the tangent input component
  61177. */
  61178. get tangent(): NodeMaterialConnectionPoint;
  61179. /**
  61180. * Gets the tangent input component
  61181. */
  61182. get uv(): NodeMaterialConnectionPoint;
  61183. /**
  61184. * Gets the position output component
  61185. */
  61186. get positionOutput(): NodeMaterialConnectionPoint;
  61187. /**
  61188. * Gets the normal output component
  61189. */
  61190. get normalOutput(): NodeMaterialConnectionPoint;
  61191. /**
  61192. * Gets the tangent output component
  61193. */
  61194. get tangentOutput(): NodeMaterialConnectionPoint;
  61195. /**
  61196. * Gets the tangent output component
  61197. */
  61198. get uvOutput(): NodeMaterialConnectionPoint;
  61199. initialize(state: NodeMaterialBuildState): void;
  61200. autoConfigure(material: NodeMaterial): void;
  61201. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61202. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61203. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61204. protected _buildBlock(state: NodeMaterialBuildState): this;
  61205. }
  61206. }
  61207. declare module BABYLON {
  61208. /**
  61209. * Block used to get data information from a light
  61210. */
  61211. export class LightInformationBlock extends NodeMaterialBlock {
  61212. private _lightDataUniformName;
  61213. private _lightColorUniformName;
  61214. private _lightTypeDefineName;
  61215. /**
  61216. * Gets or sets the light associated with this block
  61217. */
  61218. light: Nullable<Light>;
  61219. /**
  61220. * Creates a new LightInformationBlock
  61221. * @param name defines the block name
  61222. */
  61223. constructor(name: string);
  61224. /**
  61225. * Gets the current class name
  61226. * @returns the class name
  61227. */
  61228. getClassName(): string;
  61229. /**
  61230. * Gets the world position input component
  61231. */
  61232. get worldPosition(): NodeMaterialConnectionPoint;
  61233. /**
  61234. * Gets the direction output component
  61235. */
  61236. get direction(): NodeMaterialConnectionPoint;
  61237. /**
  61238. * Gets the direction output component
  61239. */
  61240. get color(): NodeMaterialConnectionPoint;
  61241. /**
  61242. * Gets the direction output component
  61243. */
  61244. get intensity(): NodeMaterialConnectionPoint;
  61245. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61246. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61247. protected _buildBlock(state: NodeMaterialBuildState): this;
  61248. serialize(): any;
  61249. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61250. }
  61251. }
  61252. declare module BABYLON {
  61253. /**
  61254. * Block used to add image processing support to fragment shader
  61255. */
  61256. export class ImageProcessingBlock extends NodeMaterialBlock {
  61257. /**
  61258. * Create a new ImageProcessingBlock
  61259. * @param name defines the block name
  61260. */
  61261. constructor(name: string);
  61262. /**
  61263. * Gets the current class name
  61264. * @returns the class name
  61265. */
  61266. getClassName(): string;
  61267. /**
  61268. * Gets the color input component
  61269. */
  61270. get color(): NodeMaterialConnectionPoint;
  61271. /**
  61272. * Gets the output component
  61273. */
  61274. get output(): NodeMaterialConnectionPoint;
  61275. /**
  61276. * Initialize the block and prepare the context for build
  61277. * @param state defines the state that will be used for the build
  61278. */
  61279. initialize(state: NodeMaterialBuildState): void;
  61280. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61281. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61282. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61283. protected _buildBlock(state: NodeMaterialBuildState): this;
  61284. }
  61285. }
  61286. declare module BABYLON {
  61287. /**
  61288. * Block used to pertub normals based on a normal map
  61289. */
  61290. export class PerturbNormalBlock extends NodeMaterialBlock {
  61291. private _tangentSpaceParameterName;
  61292. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61293. invertX: boolean;
  61294. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61295. invertY: boolean;
  61296. /**
  61297. * Create a new PerturbNormalBlock
  61298. * @param name defines the block name
  61299. */
  61300. constructor(name: string);
  61301. /**
  61302. * Gets the current class name
  61303. * @returns the class name
  61304. */
  61305. getClassName(): string;
  61306. /**
  61307. * Gets the world position input component
  61308. */
  61309. get worldPosition(): NodeMaterialConnectionPoint;
  61310. /**
  61311. * Gets the world normal input component
  61312. */
  61313. get worldNormal(): NodeMaterialConnectionPoint;
  61314. /**
  61315. * Gets the world tangent input component
  61316. */
  61317. get worldTangent(): NodeMaterialConnectionPoint;
  61318. /**
  61319. * Gets the uv input component
  61320. */
  61321. get uv(): NodeMaterialConnectionPoint;
  61322. /**
  61323. * Gets the normal map color input component
  61324. */
  61325. get normalMapColor(): NodeMaterialConnectionPoint;
  61326. /**
  61327. * Gets the strength input component
  61328. */
  61329. get strength(): NodeMaterialConnectionPoint;
  61330. /**
  61331. * Gets the output component
  61332. */
  61333. get output(): NodeMaterialConnectionPoint;
  61334. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61335. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61336. autoConfigure(material: NodeMaterial): void;
  61337. protected _buildBlock(state: NodeMaterialBuildState): this;
  61338. protected _dumpPropertiesCode(): string;
  61339. serialize(): any;
  61340. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61341. }
  61342. }
  61343. declare module BABYLON {
  61344. /**
  61345. * Block used to discard a pixel if a value is smaller than a cutoff
  61346. */
  61347. export class DiscardBlock extends NodeMaterialBlock {
  61348. /**
  61349. * Create a new DiscardBlock
  61350. * @param name defines the block name
  61351. */
  61352. constructor(name: string);
  61353. /**
  61354. * Gets the current class name
  61355. * @returns the class name
  61356. */
  61357. getClassName(): string;
  61358. /**
  61359. * Gets the color input component
  61360. */
  61361. get value(): NodeMaterialConnectionPoint;
  61362. /**
  61363. * Gets the cutoff input component
  61364. */
  61365. get cutoff(): NodeMaterialConnectionPoint;
  61366. protected _buildBlock(state: NodeMaterialBuildState): this;
  61367. }
  61368. }
  61369. declare module BABYLON {
  61370. /**
  61371. * Block used to test if the fragment shader is front facing
  61372. */
  61373. export class FrontFacingBlock extends NodeMaterialBlock {
  61374. /**
  61375. * Creates a new FrontFacingBlock
  61376. * @param name defines the block name
  61377. */
  61378. constructor(name: string);
  61379. /**
  61380. * Gets the current class name
  61381. * @returns the class name
  61382. */
  61383. getClassName(): string;
  61384. /**
  61385. * Gets the output component
  61386. */
  61387. get output(): NodeMaterialConnectionPoint;
  61388. protected _buildBlock(state: NodeMaterialBuildState): this;
  61389. }
  61390. }
  61391. declare module BABYLON {
  61392. /**
  61393. * Block used to get the derivative value on x and y of a given input
  61394. */
  61395. export class DerivativeBlock extends NodeMaterialBlock {
  61396. /**
  61397. * Create a new DerivativeBlock
  61398. * @param name defines the block name
  61399. */
  61400. constructor(name: string);
  61401. /**
  61402. * Gets the current class name
  61403. * @returns the class name
  61404. */
  61405. getClassName(): string;
  61406. /**
  61407. * Gets the input component
  61408. */
  61409. get input(): NodeMaterialConnectionPoint;
  61410. /**
  61411. * Gets the derivative output on x
  61412. */
  61413. get dx(): NodeMaterialConnectionPoint;
  61414. /**
  61415. * Gets the derivative output on y
  61416. */
  61417. get dy(): NodeMaterialConnectionPoint;
  61418. protected _buildBlock(state: NodeMaterialBuildState): this;
  61419. }
  61420. }
  61421. declare module BABYLON {
  61422. /**
  61423. * Block used to make gl_FragCoord available
  61424. */
  61425. export class FragCoordBlock extends NodeMaterialBlock {
  61426. /**
  61427. * Creates a new FragCoordBlock
  61428. * @param name defines the block name
  61429. */
  61430. constructor(name: string);
  61431. /**
  61432. * Gets the current class name
  61433. * @returns the class name
  61434. */
  61435. getClassName(): string;
  61436. /**
  61437. * Gets the xy component
  61438. */
  61439. get xy(): NodeMaterialConnectionPoint;
  61440. /**
  61441. * Gets the xyz component
  61442. */
  61443. get xyz(): NodeMaterialConnectionPoint;
  61444. /**
  61445. * Gets the xyzw component
  61446. */
  61447. get xyzw(): NodeMaterialConnectionPoint;
  61448. /**
  61449. * Gets the x component
  61450. */
  61451. get x(): NodeMaterialConnectionPoint;
  61452. /**
  61453. * Gets the y component
  61454. */
  61455. get y(): NodeMaterialConnectionPoint;
  61456. /**
  61457. * Gets the z component
  61458. */
  61459. get z(): NodeMaterialConnectionPoint;
  61460. /**
  61461. * Gets the w component
  61462. */
  61463. get output(): NodeMaterialConnectionPoint;
  61464. protected writeOutputs(state: NodeMaterialBuildState): string;
  61465. protected _buildBlock(state: NodeMaterialBuildState): this;
  61466. }
  61467. }
  61468. declare module BABYLON {
  61469. /**
  61470. * Block used to get the screen sizes
  61471. */
  61472. export class ScreenSizeBlock extends NodeMaterialBlock {
  61473. private _varName;
  61474. private _scene;
  61475. /**
  61476. * Creates a new ScreenSizeBlock
  61477. * @param name defines the block name
  61478. */
  61479. constructor(name: string);
  61480. /**
  61481. * Gets the current class name
  61482. * @returns the class name
  61483. */
  61484. getClassName(): string;
  61485. /**
  61486. * Gets the xy component
  61487. */
  61488. get xy(): NodeMaterialConnectionPoint;
  61489. /**
  61490. * Gets the x component
  61491. */
  61492. get x(): NodeMaterialConnectionPoint;
  61493. /**
  61494. * Gets the y component
  61495. */
  61496. get y(): NodeMaterialConnectionPoint;
  61497. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61498. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61499. protected _buildBlock(state: NodeMaterialBuildState): this;
  61500. }
  61501. }
  61502. declare module BABYLON {
  61503. /**
  61504. * Block used to add support for scene fog
  61505. */
  61506. export class FogBlock extends NodeMaterialBlock {
  61507. private _fogDistanceName;
  61508. private _fogParameters;
  61509. /**
  61510. * Create a new FogBlock
  61511. * @param name defines the block name
  61512. */
  61513. constructor(name: string);
  61514. /**
  61515. * Gets the current class name
  61516. * @returns the class name
  61517. */
  61518. getClassName(): string;
  61519. /**
  61520. * Gets the world position input component
  61521. */
  61522. get worldPosition(): NodeMaterialConnectionPoint;
  61523. /**
  61524. * Gets the view input component
  61525. */
  61526. get view(): NodeMaterialConnectionPoint;
  61527. /**
  61528. * Gets the color input component
  61529. */
  61530. get input(): NodeMaterialConnectionPoint;
  61531. /**
  61532. * Gets the fog color input component
  61533. */
  61534. get fogColor(): NodeMaterialConnectionPoint;
  61535. /**
  61536. * Gets the output component
  61537. */
  61538. get output(): NodeMaterialConnectionPoint;
  61539. autoConfigure(material: NodeMaterial): void;
  61540. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61541. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61542. protected _buildBlock(state: NodeMaterialBuildState): this;
  61543. }
  61544. }
  61545. declare module BABYLON {
  61546. /**
  61547. * Block used to add light in the fragment shader
  61548. */
  61549. export class LightBlock extends NodeMaterialBlock {
  61550. private _lightId;
  61551. /**
  61552. * Gets or sets the light associated with this block
  61553. */
  61554. light: Nullable<Light>;
  61555. /**
  61556. * Create a new LightBlock
  61557. * @param name defines the block name
  61558. */
  61559. constructor(name: string);
  61560. /**
  61561. * Gets the current class name
  61562. * @returns the class name
  61563. */
  61564. getClassName(): string;
  61565. /**
  61566. * Gets the world position input component
  61567. */
  61568. get worldPosition(): NodeMaterialConnectionPoint;
  61569. /**
  61570. * Gets the world normal input component
  61571. */
  61572. get worldNormal(): NodeMaterialConnectionPoint;
  61573. /**
  61574. * Gets the camera (or eye) position component
  61575. */
  61576. get cameraPosition(): NodeMaterialConnectionPoint;
  61577. /**
  61578. * Gets the glossiness component
  61579. */
  61580. get glossiness(): NodeMaterialConnectionPoint;
  61581. /**
  61582. * Gets the glossinness power component
  61583. */
  61584. get glossPower(): NodeMaterialConnectionPoint;
  61585. /**
  61586. * Gets the diffuse color component
  61587. */
  61588. get diffuseColor(): NodeMaterialConnectionPoint;
  61589. /**
  61590. * Gets the specular color component
  61591. */
  61592. get specularColor(): NodeMaterialConnectionPoint;
  61593. /**
  61594. * Gets the diffuse output component
  61595. */
  61596. get diffuseOutput(): NodeMaterialConnectionPoint;
  61597. /**
  61598. * Gets the specular output component
  61599. */
  61600. get specularOutput(): NodeMaterialConnectionPoint;
  61601. /**
  61602. * Gets the shadow output component
  61603. */
  61604. get shadow(): NodeMaterialConnectionPoint;
  61605. autoConfigure(material: NodeMaterial): void;
  61606. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61607. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61608. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61609. private _injectVertexCode;
  61610. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61611. serialize(): any;
  61612. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61613. }
  61614. }
  61615. declare module BABYLON {
  61616. /**
  61617. * Block used to read a reflection texture from a sampler
  61618. */
  61619. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61620. /**
  61621. * Create a new ReflectionTextureBlock
  61622. * @param name defines the block name
  61623. */
  61624. constructor(name: string);
  61625. /**
  61626. * Gets the current class name
  61627. * @returns the class name
  61628. */
  61629. getClassName(): string;
  61630. /**
  61631. * Gets the world position input component
  61632. */
  61633. get position(): NodeMaterialConnectionPoint;
  61634. /**
  61635. * Gets the world position input component
  61636. */
  61637. get worldPosition(): NodeMaterialConnectionPoint;
  61638. /**
  61639. * Gets the world normal input component
  61640. */
  61641. get worldNormal(): NodeMaterialConnectionPoint;
  61642. /**
  61643. * Gets the world input component
  61644. */
  61645. get world(): NodeMaterialConnectionPoint;
  61646. /**
  61647. * Gets the camera (or eye) position component
  61648. */
  61649. get cameraPosition(): NodeMaterialConnectionPoint;
  61650. /**
  61651. * Gets the view input component
  61652. */
  61653. get view(): NodeMaterialConnectionPoint;
  61654. /**
  61655. * Gets the rgb output component
  61656. */
  61657. get rgb(): NodeMaterialConnectionPoint;
  61658. /**
  61659. * Gets the r output component
  61660. */
  61661. get r(): NodeMaterialConnectionPoint;
  61662. /**
  61663. * Gets the g output component
  61664. */
  61665. get g(): NodeMaterialConnectionPoint;
  61666. /**
  61667. * Gets the b output component
  61668. */
  61669. get b(): NodeMaterialConnectionPoint;
  61670. autoConfigure(material: NodeMaterial): void;
  61671. protected _buildBlock(state: NodeMaterialBuildState): this;
  61672. }
  61673. }
  61674. declare module BABYLON {
  61675. /**
  61676. * Block used to add 2 vectors
  61677. */
  61678. export class AddBlock extends NodeMaterialBlock {
  61679. /**
  61680. * Creates a new AddBlock
  61681. * @param name defines the block name
  61682. */
  61683. constructor(name: string);
  61684. /**
  61685. * Gets the current class name
  61686. * @returns the class name
  61687. */
  61688. getClassName(): string;
  61689. /**
  61690. * Gets the left operand input component
  61691. */
  61692. get left(): NodeMaterialConnectionPoint;
  61693. /**
  61694. * Gets the right operand input component
  61695. */
  61696. get right(): NodeMaterialConnectionPoint;
  61697. /**
  61698. * Gets the output component
  61699. */
  61700. get output(): NodeMaterialConnectionPoint;
  61701. protected _buildBlock(state: NodeMaterialBuildState): this;
  61702. }
  61703. }
  61704. declare module BABYLON {
  61705. /**
  61706. * Block used to scale a vector by a float
  61707. */
  61708. export class ScaleBlock extends NodeMaterialBlock {
  61709. /**
  61710. * Creates a new ScaleBlock
  61711. * @param name defines the block name
  61712. */
  61713. constructor(name: string);
  61714. /**
  61715. * Gets the current class name
  61716. * @returns the class name
  61717. */
  61718. getClassName(): string;
  61719. /**
  61720. * Gets the input component
  61721. */
  61722. get input(): NodeMaterialConnectionPoint;
  61723. /**
  61724. * Gets the factor input component
  61725. */
  61726. get factor(): NodeMaterialConnectionPoint;
  61727. /**
  61728. * Gets the output component
  61729. */
  61730. get output(): NodeMaterialConnectionPoint;
  61731. protected _buildBlock(state: NodeMaterialBuildState): this;
  61732. }
  61733. }
  61734. declare module BABYLON {
  61735. /**
  61736. * Block used to clamp a float
  61737. */
  61738. export class ClampBlock extends NodeMaterialBlock {
  61739. /** Gets or sets the minimum range */
  61740. minimum: number;
  61741. /** Gets or sets the maximum range */
  61742. maximum: number;
  61743. /**
  61744. * Creates a new ClampBlock
  61745. * @param name defines the block name
  61746. */
  61747. constructor(name: string);
  61748. /**
  61749. * Gets the current class name
  61750. * @returns the class name
  61751. */
  61752. getClassName(): string;
  61753. /**
  61754. * Gets the value input component
  61755. */
  61756. get value(): NodeMaterialConnectionPoint;
  61757. /**
  61758. * Gets the output component
  61759. */
  61760. get output(): NodeMaterialConnectionPoint;
  61761. protected _buildBlock(state: NodeMaterialBuildState): this;
  61762. protected _dumpPropertiesCode(): string;
  61763. serialize(): any;
  61764. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61765. }
  61766. }
  61767. declare module BABYLON {
  61768. /**
  61769. * Block used to apply a cross product between 2 vectors
  61770. */
  61771. export class CrossBlock extends NodeMaterialBlock {
  61772. /**
  61773. * Creates a new CrossBlock
  61774. * @param name defines the block name
  61775. */
  61776. constructor(name: string);
  61777. /**
  61778. * Gets the current class name
  61779. * @returns the class name
  61780. */
  61781. getClassName(): string;
  61782. /**
  61783. * Gets the left operand input component
  61784. */
  61785. get left(): NodeMaterialConnectionPoint;
  61786. /**
  61787. * Gets the right operand input component
  61788. */
  61789. get right(): NodeMaterialConnectionPoint;
  61790. /**
  61791. * Gets the output component
  61792. */
  61793. get output(): NodeMaterialConnectionPoint;
  61794. protected _buildBlock(state: NodeMaterialBuildState): this;
  61795. }
  61796. }
  61797. declare module BABYLON {
  61798. /**
  61799. * Block used to apply a dot product between 2 vectors
  61800. */
  61801. export class DotBlock extends NodeMaterialBlock {
  61802. /**
  61803. * Creates a new DotBlock
  61804. * @param name defines the block name
  61805. */
  61806. constructor(name: string);
  61807. /**
  61808. * Gets the current class name
  61809. * @returns the class name
  61810. */
  61811. getClassName(): string;
  61812. /**
  61813. * Gets the left operand input component
  61814. */
  61815. get left(): NodeMaterialConnectionPoint;
  61816. /**
  61817. * Gets the right operand input component
  61818. */
  61819. get right(): NodeMaterialConnectionPoint;
  61820. /**
  61821. * Gets the output component
  61822. */
  61823. get output(): NodeMaterialConnectionPoint;
  61824. protected _buildBlock(state: NodeMaterialBuildState): this;
  61825. }
  61826. }
  61827. declare module BABYLON {
  61828. /**
  61829. * Block used to normalize a vector
  61830. */
  61831. export class NormalizeBlock extends NodeMaterialBlock {
  61832. /**
  61833. * Creates a new NormalizeBlock
  61834. * @param name defines the block name
  61835. */
  61836. constructor(name: string);
  61837. /**
  61838. * Gets the current class name
  61839. * @returns the class name
  61840. */
  61841. getClassName(): string;
  61842. /**
  61843. * Gets the input component
  61844. */
  61845. get input(): NodeMaterialConnectionPoint;
  61846. /**
  61847. * Gets the output component
  61848. */
  61849. get output(): NodeMaterialConnectionPoint;
  61850. protected _buildBlock(state: NodeMaterialBuildState): this;
  61851. }
  61852. }
  61853. declare module BABYLON {
  61854. /**
  61855. * Operations supported by the Trigonometry block
  61856. */
  61857. export enum TrigonometryBlockOperations {
  61858. /** Cos */
  61859. Cos = 0,
  61860. /** Sin */
  61861. Sin = 1,
  61862. /** Abs */
  61863. Abs = 2,
  61864. /** Exp */
  61865. Exp = 3,
  61866. /** Exp2 */
  61867. Exp2 = 4,
  61868. /** Round */
  61869. Round = 5,
  61870. /** Floor */
  61871. Floor = 6,
  61872. /** Ceiling */
  61873. Ceiling = 7,
  61874. /** Square root */
  61875. Sqrt = 8,
  61876. /** Log */
  61877. Log = 9,
  61878. /** Tangent */
  61879. Tan = 10,
  61880. /** Arc tangent */
  61881. ArcTan = 11,
  61882. /** Arc cosinus */
  61883. ArcCos = 12,
  61884. /** Arc sinus */
  61885. ArcSin = 13,
  61886. /** Fraction */
  61887. Fract = 14,
  61888. /** Sign */
  61889. Sign = 15,
  61890. /** To radians (from degrees) */
  61891. Radians = 16,
  61892. /** To degrees (from radians) */
  61893. Degrees = 17
  61894. }
  61895. /**
  61896. * Block used to apply trigonometry operation to floats
  61897. */
  61898. export class TrigonometryBlock extends NodeMaterialBlock {
  61899. /**
  61900. * Gets or sets the operation applied by the block
  61901. */
  61902. operation: TrigonometryBlockOperations;
  61903. /**
  61904. * Creates a new TrigonometryBlock
  61905. * @param name defines the block name
  61906. */
  61907. constructor(name: string);
  61908. /**
  61909. * Gets the current class name
  61910. * @returns the class name
  61911. */
  61912. getClassName(): string;
  61913. /**
  61914. * Gets the input component
  61915. */
  61916. get input(): NodeMaterialConnectionPoint;
  61917. /**
  61918. * Gets the output component
  61919. */
  61920. get output(): NodeMaterialConnectionPoint;
  61921. protected _buildBlock(state: NodeMaterialBuildState): this;
  61922. serialize(): any;
  61923. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61924. protected _dumpPropertiesCode(): string;
  61925. }
  61926. }
  61927. declare module BABYLON {
  61928. /**
  61929. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61930. */
  61931. export class ColorMergerBlock extends NodeMaterialBlock {
  61932. /**
  61933. * Create a new ColorMergerBlock
  61934. * @param name defines the block name
  61935. */
  61936. constructor(name: string);
  61937. /**
  61938. * Gets the current class name
  61939. * @returns the class name
  61940. */
  61941. getClassName(): string;
  61942. /**
  61943. * Gets the rgb component (input)
  61944. */
  61945. get rgbIn(): NodeMaterialConnectionPoint;
  61946. /**
  61947. * Gets the r component (input)
  61948. */
  61949. get r(): NodeMaterialConnectionPoint;
  61950. /**
  61951. * Gets the g component (input)
  61952. */
  61953. get g(): NodeMaterialConnectionPoint;
  61954. /**
  61955. * Gets the b component (input)
  61956. */
  61957. get b(): NodeMaterialConnectionPoint;
  61958. /**
  61959. * Gets the a component (input)
  61960. */
  61961. get a(): NodeMaterialConnectionPoint;
  61962. /**
  61963. * Gets the rgba component (output)
  61964. */
  61965. get rgba(): NodeMaterialConnectionPoint;
  61966. /**
  61967. * Gets the rgb component (output)
  61968. */
  61969. get rgbOut(): NodeMaterialConnectionPoint;
  61970. /**
  61971. * Gets the rgb component (output)
  61972. * @deprecated Please use rgbOut instead.
  61973. */
  61974. get rgb(): NodeMaterialConnectionPoint;
  61975. protected _buildBlock(state: NodeMaterialBuildState): this;
  61976. }
  61977. }
  61978. declare module BABYLON {
  61979. /**
  61980. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61981. */
  61982. export class VectorSplitterBlock extends NodeMaterialBlock {
  61983. /**
  61984. * Create a new VectorSplitterBlock
  61985. * @param name defines the block name
  61986. */
  61987. constructor(name: string);
  61988. /**
  61989. * Gets the current class name
  61990. * @returns the class name
  61991. */
  61992. getClassName(): string;
  61993. /**
  61994. * Gets the xyzw component (input)
  61995. */
  61996. get xyzw(): NodeMaterialConnectionPoint;
  61997. /**
  61998. * Gets the xyz component (input)
  61999. */
  62000. get xyzIn(): NodeMaterialConnectionPoint;
  62001. /**
  62002. * Gets the xy component (input)
  62003. */
  62004. get xyIn(): NodeMaterialConnectionPoint;
  62005. /**
  62006. * Gets the xyz component (output)
  62007. */
  62008. get xyzOut(): NodeMaterialConnectionPoint;
  62009. /**
  62010. * Gets the xy component (output)
  62011. */
  62012. get xyOut(): NodeMaterialConnectionPoint;
  62013. /**
  62014. * Gets the x component (output)
  62015. */
  62016. get x(): NodeMaterialConnectionPoint;
  62017. /**
  62018. * Gets the y component (output)
  62019. */
  62020. get y(): NodeMaterialConnectionPoint;
  62021. /**
  62022. * Gets the z component (output)
  62023. */
  62024. get z(): NodeMaterialConnectionPoint;
  62025. /**
  62026. * Gets the w component (output)
  62027. */
  62028. get w(): NodeMaterialConnectionPoint;
  62029. protected _inputRename(name: string): string;
  62030. protected _outputRename(name: string): string;
  62031. protected _buildBlock(state: NodeMaterialBuildState): this;
  62032. }
  62033. }
  62034. declare module BABYLON {
  62035. /**
  62036. * Block used to lerp between 2 values
  62037. */
  62038. export class LerpBlock extends NodeMaterialBlock {
  62039. /**
  62040. * Creates a new LerpBlock
  62041. * @param name defines the block name
  62042. */
  62043. constructor(name: string);
  62044. /**
  62045. * Gets the current class name
  62046. * @returns the class name
  62047. */
  62048. getClassName(): string;
  62049. /**
  62050. * Gets the left operand input component
  62051. */
  62052. get left(): NodeMaterialConnectionPoint;
  62053. /**
  62054. * Gets the right operand input component
  62055. */
  62056. get right(): NodeMaterialConnectionPoint;
  62057. /**
  62058. * Gets the gradient operand input component
  62059. */
  62060. get gradient(): NodeMaterialConnectionPoint;
  62061. /**
  62062. * Gets the output component
  62063. */
  62064. get output(): NodeMaterialConnectionPoint;
  62065. protected _buildBlock(state: NodeMaterialBuildState): this;
  62066. }
  62067. }
  62068. declare module BABYLON {
  62069. /**
  62070. * Block used to divide 2 vectors
  62071. */
  62072. export class DivideBlock extends NodeMaterialBlock {
  62073. /**
  62074. * Creates a new DivideBlock
  62075. * @param name defines the block name
  62076. */
  62077. constructor(name: string);
  62078. /**
  62079. * Gets the current class name
  62080. * @returns the class name
  62081. */
  62082. getClassName(): string;
  62083. /**
  62084. * Gets the left operand input component
  62085. */
  62086. get left(): NodeMaterialConnectionPoint;
  62087. /**
  62088. * Gets the right operand input component
  62089. */
  62090. get right(): NodeMaterialConnectionPoint;
  62091. /**
  62092. * Gets the output component
  62093. */
  62094. get output(): NodeMaterialConnectionPoint;
  62095. protected _buildBlock(state: NodeMaterialBuildState): this;
  62096. }
  62097. }
  62098. declare module BABYLON {
  62099. /**
  62100. * Block used to subtract 2 vectors
  62101. */
  62102. export class SubtractBlock extends NodeMaterialBlock {
  62103. /**
  62104. * Creates a new SubtractBlock
  62105. * @param name defines the block name
  62106. */
  62107. constructor(name: string);
  62108. /**
  62109. * Gets the current class name
  62110. * @returns the class name
  62111. */
  62112. getClassName(): string;
  62113. /**
  62114. * Gets the left operand input component
  62115. */
  62116. get left(): NodeMaterialConnectionPoint;
  62117. /**
  62118. * Gets the right operand input component
  62119. */
  62120. get right(): NodeMaterialConnectionPoint;
  62121. /**
  62122. * Gets the output component
  62123. */
  62124. get output(): NodeMaterialConnectionPoint;
  62125. protected _buildBlock(state: NodeMaterialBuildState): this;
  62126. }
  62127. }
  62128. declare module BABYLON {
  62129. /**
  62130. * Block used to step a value
  62131. */
  62132. export class StepBlock extends NodeMaterialBlock {
  62133. /**
  62134. * Creates a new StepBlock
  62135. * @param name defines the block name
  62136. */
  62137. constructor(name: string);
  62138. /**
  62139. * Gets the current class name
  62140. * @returns the class name
  62141. */
  62142. getClassName(): string;
  62143. /**
  62144. * Gets the value operand input component
  62145. */
  62146. get value(): NodeMaterialConnectionPoint;
  62147. /**
  62148. * Gets the edge operand input component
  62149. */
  62150. get edge(): NodeMaterialConnectionPoint;
  62151. /**
  62152. * Gets the output component
  62153. */
  62154. get output(): NodeMaterialConnectionPoint;
  62155. protected _buildBlock(state: NodeMaterialBuildState): this;
  62156. }
  62157. }
  62158. declare module BABYLON {
  62159. /**
  62160. * Block used to get the opposite (1 - x) of a value
  62161. */
  62162. export class OneMinusBlock extends NodeMaterialBlock {
  62163. /**
  62164. * Creates a new OneMinusBlock
  62165. * @param name defines the block name
  62166. */
  62167. constructor(name: string);
  62168. /**
  62169. * Gets the current class name
  62170. * @returns the class name
  62171. */
  62172. getClassName(): string;
  62173. /**
  62174. * Gets the input component
  62175. */
  62176. get input(): NodeMaterialConnectionPoint;
  62177. /**
  62178. * Gets the output component
  62179. */
  62180. get output(): NodeMaterialConnectionPoint;
  62181. protected _buildBlock(state: NodeMaterialBuildState): this;
  62182. }
  62183. }
  62184. declare module BABYLON {
  62185. /**
  62186. * Block used to get the view direction
  62187. */
  62188. export class ViewDirectionBlock extends NodeMaterialBlock {
  62189. /**
  62190. * Creates a new ViewDirectionBlock
  62191. * @param name defines the block name
  62192. */
  62193. constructor(name: string);
  62194. /**
  62195. * Gets the current class name
  62196. * @returns the class name
  62197. */
  62198. getClassName(): string;
  62199. /**
  62200. * Gets the world position component
  62201. */
  62202. get worldPosition(): NodeMaterialConnectionPoint;
  62203. /**
  62204. * Gets the camera position component
  62205. */
  62206. get cameraPosition(): NodeMaterialConnectionPoint;
  62207. /**
  62208. * Gets the output component
  62209. */
  62210. get output(): NodeMaterialConnectionPoint;
  62211. autoConfigure(material: NodeMaterial): void;
  62212. protected _buildBlock(state: NodeMaterialBuildState): this;
  62213. }
  62214. }
  62215. declare module BABYLON {
  62216. /**
  62217. * Block used to compute fresnel value
  62218. */
  62219. export class FresnelBlock extends NodeMaterialBlock {
  62220. /**
  62221. * Create a new FresnelBlock
  62222. * @param name defines the block name
  62223. */
  62224. constructor(name: string);
  62225. /**
  62226. * Gets the current class name
  62227. * @returns the class name
  62228. */
  62229. getClassName(): string;
  62230. /**
  62231. * Gets the world normal input component
  62232. */
  62233. get worldNormal(): NodeMaterialConnectionPoint;
  62234. /**
  62235. * Gets the view direction input component
  62236. */
  62237. get viewDirection(): NodeMaterialConnectionPoint;
  62238. /**
  62239. * Gets the bias input component
  62240. */
  62241. get bias(): NodeMaterialConnectionPoint;
  62242. /**
  62243. * Gets the camera (or eye) position component
  62244. */
  62245. get power(): NodeMaterialConnectionPoint;
  62246. /**
  62247. * Gets the fresnel output component
  62248. */
  62249. get fresnel(): NodeMaterialConnectionPoint;
  62250. autoConfigure(material: NodeMaterial): void;
  62251. protected _buildBlock(state: NodeMaterialBuildState): this;
  62252. }
  62253. }
  62254. declare module BABYLON {
  62255. /**
  62256. * Block used to get the max of 2 values
  62257. */
  62258. export class MaxBlock extends NodeMaterialBlock {
  62259. /**
  62260. * Creates a new MaxBlock
  62261. * @param name defines the block name
  62262. */
  62263. constructor(name: string);
  62264. /**
  62265. * Gets the current class name
  62266. * @returns the class name
  62267. */
  62268. getClassName(): string;
  62269. /**
  62270. * Gets the left operand input component
  62271. */
  62272. get left(): NodeMaterialConnectionPoint;
  62273. /**
  62274. * Gets the right operand input component
  62275. */
  62276. get right(): NodeMaterialConnectionPoint;
  62277. /**
  62278. * Gets the output component
  62279. */
  62280. get output(): NodeMaterialConnectionPoint;
  62281. protected _buildBlock(state: NodeMaterialBuildState): this;
  62282. }
  62283. }
  62284. declare module BABYLON {
  62285. /**
  62286. * Block used to get the min of 2 values
  62287. */
  62288. export class MinBlock extends NodeMaterialBlock {
  62289. /**
  62290. * Creates a new MinBlock
  62291. * @param name defines the block name
  62292. */
  62293. constructor(name: string);
  62294. /**
  62295. * Gets the current class name
  62296. * @returns the class name
  62297. */
  62298. getClassName(): string;
  62299. /**
  62300. * Gets the left operand input component
  62301. */
  62302. get left(): NodeMaterialConnectionPoint;
  62303. /**
  62304. * Gets the right operand input component
  62305. */
  62306. get right(): NodeMaterialConnectionPoint;
  62307. /**
  62308. * Gets the output component
  62309. */
  62310. get output(): NodeMaterialConnectionPoint;
  62311. protected _buildBlock(state: NodeMaterialBuildState): this;
  62312. }
  62313. }
  62314. declare module BABYLON {
  62315. /**
  62316. * Block used to get the distance between 2 values
  62317. */
  62318. export class DistanceBlock extends NodeMaterialBlock {
  62319. /**
  62320. * Creates a new DistanceBlock
  62321. * @param name defines the block name
  62322. */
  62323. constructor(name: string);
  62324. /**
  62325. * Gets the current class name
  62326. * @returns the class name
  62327. */
  62328. getClassName(): string;
  62329. /**
  62330. * Gets the left operand input component
  62331. */
  62332. get left(): NodeMaterialConnectionPoint;
  62333. /**
  62334. * Gets the right operand input component
  62335. */
  62336. get right(): NodeMaterialConnectionPoint;
  62337. /**
  62338. * Gets the output component
  62339. */
  62340. get output(): NodeMaterialConnectionPoint;
  62341. protected _buildBlock(state: NodeMaterialBuildState): this;
  62342. }
  62343. }
  62344. declare module BABYLON {
  62345. /**
  62346. * Block used to get the length of a vector
  62347. */
  62348. export class LengthBlock extends NodeMaterialBlock {
  62349. /**
  62350. * Creates a new LengthBlock
  62351. * @param name defines the block name
  62352. */
  62353. constructor(name: string);
  62354. /**
  62355. * Gets the current class name
  62356. * @returns the class name
  62357. */
  62358. getClassName(): string;
  62359. /**
  62360. * Gets the value input component
  62361. */
  62362. get value(): NodeMaterialConnectionPoint;
  62363. /**
  62364. * Gets the output component
  62365. */
  62366. get output(): NodeMaterialConnectionPoint;
  62367. protected _buildBlock(state: NodeMaterialBuildState): this;
  62368. }
  62369. }
  62370. declare module BABYLON {
  62371. /**
  62372. * Block used to get negative version of a value (i.e. x * -1)
  62373. */
  62374. export class NegateBlock extends NodeMaterialBlock {
  62375. /**
  62376. * Creates a new NegateBlock
  62377. * @param name defines the block name
  62378. */
  62379. constructor(name: string);
  62380. /**
  62381. * Gets the current class name
  62382. * @returns the class name
  62383. */
  62384. getClassName(): string;
  62385. /**
  62386. * Gets the value input component
  62387. */
  62388. get value(): NodeMaterialConnectionPoint;
  62389. /**
  62390. * Gets the output component
  62391. */
  62392. get output(): NodeMaterialConnectionPoint;
  62393. protected _buildBlock(state: NodeMaterialBuildState): this;
  62394. }
  62395. }
  62396. declare module BABYLON {
  62397. /**
  62398. * Block used to get the value of the first parameter raised to the power of the second
  62399. */
  62400. export class PowBlock extends NodeMaterialBlock {
  62401. /**
  62402. * Creates a new PowBlock
  62403. * @param name defines the block name
  62404. */
  62405. constructor(name: string);
  62406. /**
  62407. * Gets the current class name
  62408. * @returns the class name
  62409. */
  62410. getClassName(): string;
  62411. /**
  62412. * Gets the value operand input component
  62413. */
  62414. get value(): NodeMaterialConnectionPoint;
  62415. /**
  62416. * Gets the power operand input component
  62417. */
  62418. get power(): NodeMaterialConnectionPoint;
  62419. /**
  62420. * Gets the output component
  62421. */
  62422. get output(): NodeMaterialConnectionPoint;
  62423. protected _buildBlock(state: NodeMaterialBuildState): this;
  62424. }
  62425. }
  62426. declare module BABYLON {
  62427. /**
  62428. * Block used to get a random number
  62429. */
  62430. export class RandomNumberBlock extends NodeMaterialBlock {
  62431. /**
  62432. * Creates a new RandomNumberBlock
  62433. * @param name defines the block name
  62434. */
  62435. constructor(name: string);
  62436. /**
  62437. * Gets the current class name
  62438. * @returns the class name
  62439. */
  62440. getClassName(): string;
  62441. /**
  62442. * Gets the seed input component
  62443. */
  62444. get seed(): NodeMaterialConnectionPoint;
  62445. /**
  62446. * Gets the output component
  62447. */
  62448. get output(): NodeMaterialConnectionPoint;
  62449. protected _buildBlock(state: NodeMaterialBuildState): this;
  62450. }
  62451. }
  62452. declare module BABYLON {
  62453. /**
  62454. * Block used to compute arc tangent of 2 values
  62455. */
  62456. export class ArcTan2Block extends NodeMaterialBlock {
  62457. /**
  62458. * Creates a new ArcTan2Block
  62459. * @param name defines the block name
  62460. */
  62461. constructor(name: string);
  62462. /**
  62463. * Gets the current class name
  62464. * @returns the class name
  62465. */
  62466. getClassName(): string;
  62467. /**
  62468. * Gets the x operand input component
  62469. */
  62470. get x(): NodeMaterialConnectionPoint;
  62471. /**
  62472. * Gets the y operand input component
  62473. */
  62474. get y(): NodeMaterialConnectionPoint;
  62475. /**
  62476. * Gets the output component
  62477. */
  62478. get output(): NodeMaterialConnectionPoint;
  62479. protected _buildBlock(state: NodeMaterialBuildState): this;
  62480. }
  62481. }
  62482. declare module BABYLON {
  62483. /**
  62484. * Block used to smooth step a value
  62485. */
  62486. export class SmoothStepBlock extends NodeMaterialBlock {
  62487. /**
  62488. * Creates a new SmoothStepBlock
  62489. * @param name defines the block name
  62490. */
  62491. constructor(name: string);
  62492. /**
  62493. * Gets the current class name
  62494. * @returns the class name
  62495. */
  62496. getClassName(): string;
  62497. /**
  62498. * Gets the value operand input component
  62499. */
  62500. get value(): NodeMaterialConnectionPoint;
  62501. /**
  62502. * Gets the first edge operand input component
  62503. */
  62504. get edge0(): NodeMaterialConnectionPoint;
  62505. /**
  62506. * Gets the second edge operand input component
  62507. */
  62508. get edge1(): NodeMaterialConnectionPoint;
  62509. /**
  62510. * Gets the output component
  62511. */
  62512. get output(): NodeMaterialConnectionPoint;
  62513. protected _buildBlock(state: NodeMaterialBuildState): this;
  62514. }
  62515. }
  62516. declare module BABYLON {
  62517. /**
  62518. * Block used to get the reciprocal (1 / x) of a value
  62519. */
  62520. export class ReciprocalBlock extends NodeMaterialBlock {
  62521. /**
  62522. * Creates a new ReciprocalBlock
  62523. * @param name defines the block name
  62524. */
  62525. constructor(name: string);
  62526. /**
  62527. * Gets the current class name
  62528. * @returns the class name
  62529. */
  62530. getClassName(): string;
  62531. /**
  62532. * Gets the input component
  62533. */
  62534. get input(): NodeMaterialConnectionPoint;
  62535. /**
  62536. * Gets the output component
  62537. */
  62538. get output(): NodeMaterialConnectionPoint;
  62539. protected _buildBlock(state: NodeMaterialBuildState): this;
  62540. }
  62541. }
  62542. declare module BABYLON {
  62543. /**
  62544. * Block used to replace a color by another one
  62545. */
  62546. export class ReplaceColorBlock extends NodeMaterialBlock {
  62547. /**
  62548. * Creates a new ReplaceColorBlock
  62549. * @param name defines the block name
  62550. */
  62551. constructor(name: string);
  62552. /**
  62553. * Gets the current class name
  62554. * @returns the class name
  62555. */
  62556. getClassName(): string;
  62557. /**
  62558. * Gets the value input component
  62559. */
  62560. get value(): NodeMaterialConnectionPoint;
  62561. /**
  62562. * Gets the reference input component
  62563. */
  62564. get reference(): NodeMaterialConnectionPoint;
  62565. /**
  62566. * Gets the distance input component
  62567. */
  62568. get distance(): NodeMaterialConnectionPoint;
  62569. /**
  62570. * Gets the replacement input component
  62571. */
  62572. get replacement(): NodeMaterialConnectionPoint;
  62573. /**
  62574. * Gets the output component
  62575. */
  62576. get output(): NodeMaterialConnectionPoint;
  62577. protected _buildBlock(state: NodeMaterialBuildState): this;
  62578. }
  62579. }
  62580. declare module BABYLON {
  62581. /**
  62582. * Block used to posterize a value
  62583. * @see https://en.wikipedia.org/wiki/Posterization
  62584. */
  62585. export class PosterizeBlock extends NodeMaterialBlock {
  62586. /**
  62587. * Creates a new PosterizeBlock
  62588. * @param name defines the block name
  62589. */
  62590. constructor(name: string);
  62591. /**
  62592. * Gets the current class name
  62593. * @returns the class name
  62594. */
  62595. getClassName(): string;
  62596. /**
  62597. * Gets the value input component
  62598. */
  62599. get value(): NodeMaterialConnectionPoint;
  62600. /**
  62601. * Gets the steps input component
  62602. */
  62603. get steps(): NodeMaterialConnectionPoint;
  62604. /**
  62605. * Gets the output component
  62606. */
  62607. get output(): NodeMaterialConnectionPoint;
  62608. protected _buildBlock(state: NodeMaterialBuildState): this;
  62609. }
  62610. }
  62611. declare module BABYLON {
  62612. /**
  62613. * Operations supported by the Wave block
  62614. */
  62615. export enum WaveBlockKind {
  62616. /** SawTooth */
  62617. SawTooth = 0,
  62618. /** Square */
  62619. Square = 1,
  62620. /** Triangle */
  62621. Triangle = 2
  62622. }
  62623. /**
  62624. * Block used to apply wave operation to floats
  62625. */
  62626. export class WaveBlock extends NodeMaterialBlock {
  62627. /**
  62628. * Gets or sets the kibnd of wave to be applied by the block
  62629. */
  62630. kind: WaveBlockKind;
  62631. /**
  62632. * Creates a new WaveBlock
  62633. * @param name defines the block name
  62634. */
  62635. constructor(name: string);
  62636. /**
  62637. * Gets the current class name
  62638. * @returns the class name
  62639. */
  62640. getClassName(): string;
  62641. /**
  62642. * Gets the input component
  62643. */
  62644. get input(): NodeMaterialConnectionPoint;
  62645. /**
  62646. * Gets the output component
  62647. */
  62648. get output(): NodeMaterialConnectionPoint;
  62649. protected _buildBlock(state: NodeMaterialBuildState): this;
  62650. serialize(): any;
  62651. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62652. }
  62653. }
  62654. declare module BABYLON {
  62655. /**
  62656. * Class used to store a color step for the GradientBlock
  62657. */
  62658. export class GradientBlockColorStep {
  62659. /**
  62660. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62661. */
  62662. step: number;
  62663. /**
  62664. * Gets or sets the color associated with this step
  62665. */
  62666. color: Color3;
  62667. /**
  62668. * Creates a new GradientBlockColorStep
  62669. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62670. * @param color defines the color associated with this step
  62671. */
  62672. constructor(
  62673. /**
  62674. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62675. */
  62676. step: number,
  62677. /**
  62678. * Gets or sets the color associated with this step
  62679. */
  62680. color: Color3);
  62681. }
  62682. /**
  62683. * Block used to return a color from a gradient based on an input value between 0 and 1
  62684. */
  62685. export class GradientBlock extends NodeMaterialBlock {
  62686. /**
  62687. * Gets or sets the list of color steps
  62688. */
  62689. colorSteps: GradientBlockColorStep[];
  62690. /**
  62691. * Creates a new GradientBlock
  62692. * @param name defines the block name
  62693. */
  62694. constructor(name: string);
  62695. /**
  62696. * Gets the current class name
  62697. * @returns the class name
  62698. */
  62699. getClassName(): string;
  62700. /**
  62701. * Gets the gradient input component
  62702. */
  62703. get gradient(): NodeMaterialConnectionPoint;
  62704. /**
  62705. * Gets the output component
  62706. */
  62707. get output(): NodeMaterialConnectionPoint;
  62708. private _writeColorConstant;
  62709. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62710. serialize(): any;
  62711. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62712. protected _dumpPropertiesCode(): string;
  62713. }
  62714. }
  62715. declare module BABYLON {
  62716. /**
  62717. * Block used to normalize lerp between 2 values
  62718. */
  62719. export class NLerpBlock extends NodeMaterialBlock {
  62720. /**
  62721. * Creates a new NLerpBlock
  62722. * @param name defines the block name
  62723. */
  62724. constructor(name: string);
  62725. /**
  62726. * Gets the current class name
  62727. * @returns the class name
  62728. */
  62729. getClassName(): string;
  62730. /**
  62731. * Gets the left operand input component
  62732. */
  62733. get left(): NodeMaterialConnectionPoint;
  62734. /**
  62735. * Gets the right operand input component
  62736. */
  62737. get right(): NodeMaterialConnectionPoint;
  62738. /**
  62739. * Gets the gradient operand input component
  62740. */
  62741. get gradient(): NodeMaterialConnectionPoint;
  62742. /**
  62743. * Gets the output component
  62744. */
  62745. get output(): NodeMaterialConnectionPoint;
  62746. protected _buildBlock(state: NodeMaterialBuildState): this;
  62747. }
  62748. }
  62749. declare module BABYLON {
  62750. /**
  62751. * block used to Generate a Worley Noise 3D Noise Pattern
  62752. */
  62753. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62754. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62755. manhattanDistance: boolean;
  62756. /**
  62757. * Creates a new WorleyNoise3DBlock
  62758. * @param name defines the block name
  62759. */
  62760. constructor(name: string);
  62761. /**
  62762. * Gets the current class name
  62763. * @returns the class name
  62764. */
  62765. getClassName(): string;
  62766. /**
  62767. * Gets the seed input component
  62768. */
  62769. get seed(): NodeMaterialConnectionPoint;
  62770. /**
  62771. * Gets the jitter input component
  62772. */
  62773. get jitter(): NodeMaterialConnectionPoint;
  62774. /**
  62775. * Gets the output component
  62776. */
  62777. get output(): NodeMaterialConnectionPoint;
  62778. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62779. /**
  62780. * Exposes the properties to the UI?
  62781. */
  62782. protected _dumpPropertiesCode(): string;
  62783. /**
  62784. * Exposes the properties to the Seralize?
  62785. */
  62786. serialize(): any;
  62787. /**
  62788. * Exposes the properties to the deseralize?
  62789. */
  62790. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62791. }
  62792. }
  62793. declare module BABYLON {
  62794. /**
  62795. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62796. */
  62797. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62798. /**
  62799. * Creates a new SimplexPerlin3DBlock
  62800. * @param name defines the block name
  62801. */
  62802. constructor(name: string);
  62803. /**
  62804. * Gets the current class name
  62805. * @returns the class name
  62806. */
  62807. getClassName(): string;
  62808. /**
  62809. * Gets the seed operand input component
  62810. */
  62811. get seed(): NodeMaterialConnectionPoint;
  62812. /**
  62813. * Gets the output component
  62814. */
  62815. get output(): NodeMaterialConnectionPoint;
  62816. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62817. }
  62818. }
  62819. declare module BABYLON {
  62820. /**
  62821. * Block used to blend normals
  62822. */
  62823. export class NormalBlendBlock extends NodeMaterialBlock {
  62824. /**
  62825. * Creates a new NormalBlendBlock
  62826. * @param name defines the block name
  62827. */
  62828. constructor(name: string);
  62829. /**
  62830. * Gets the current class name
  62831. * @returns the class name
  62832. */
  62833. getClassName(): string;
  62834. /**
  62835. * Gets the first input component
  62836. */
  62837. get normalMap0(): NodeMaterialConnectionPoint;
  62838. /**
  62839. * Gets the second input component
  62840. */
  62841. get normalMap1(): NodeMaterialConnectionPoint;
  62842. /**
  62843. * Gets the output component
  62844. */
  62845. get output(): NodeMaterialConnectionPoint;
  62846. protected _buildBlock(state: NodeMaterialBuildState): this;
  62847. }
  62848. }
  62849. declare module BABYLON {
  62850. /**
  62851. * Block used to rotate a 2d vector by a given angle
  62852. */
  62853. export class Rotate2dBlock extends NodeMaterialBlock {
  62854. /**
  62855. * Creates a new Rotate2dBlock
  62856. * @param name defines the block name
  62857. */
  62858. constructor(name: string);
  62859. /**
  62860. * Gets the current class name
  62861. * @returns the class name
  62862. */
  62863. getClassName(): string;
  62864. /**
  62865. * Gets the input vector
  62866. */
  62867. get input(): NodeMaterialConnectionPoint;
  62868. /**
  62869. * Gets the input angle
  62870. */
  62871. get angle(): NodeMaterialConnectionPoint;
  62872. /**
  62873. * Gets the output component
  62874. */
  62875. get output(): NodeMaterialConnectionPoint;
  62876. autoConfigure(material: NodeMaterial): void;
  62877. protected _buildBlock(state: NodeMaterialBuildState): this;
  62878. }
  62879. }
  62880. declare module BABYLON {
  62881. /**
  62882. * Block used to get the reflected vector from a direction and a normal
  62883. */
  62884. export class ReflectBlock extends NodeMaterialBlock {
  62885. /**
  62886. * Creates a new ReflectBlock
  62887. * @param name defines the block name
  62888. */
  62889. constructor(name: string);
  62890. /**
  62891. * Gets the current class name
  62892. * @returns the class name
  62893. */
  62894. getClassName(): string;
  62895. /**
  62896. * Gets the incident component
  62897. */
  62898. get incident(): NodeMaterialConnectionPoint;
  62899. /**
  62900. * Gets the normal component
  62901. */
  62902. get normal(): NodeMaterialConnectionPoint;
  62903. /**
  62904. * Gets the output component
  62905. */
  62906. get output(): NodeMaterialConnectionPoint;
  62907. protected _buildBlock(state: NodeMaterialBuildState): this;
  62908. }
  62909. }
  62910. declare module BABYLON {
  62911. /**
  62912. * Block used to get the refracted vector from a direction and a normal
  62913. */
  62914. export class RefractBlock extends NodeMaterialBlock {
  62915. /**
  62916. * Creates a new RefractBlock
  62917. * @param name defines the block name
  62918. */
  62919. constructor(name: string);
  62920. /**
  62921. * Gets the current class name
  62922. * @returns the class name
  62923. */
  62924. getClassName(): string;
  62925. /**
  62926. * Gets the incident component
  62927. */
  62928. get incident(): NodeMaterialConnectionPoint;
  62929. /**
  62930. * Gets the normal component
  62931. */
  62932. get normal(): NodeMaterialConnectionPoint;
  62933. /**
  62934. * Gets the index of refraction component
  62935. */
  62936. get ior(): NodeMaterialConnectionPoint;
  62937. /**
  62938. * Gets the output component
  62939. */
  62940. get output(): NodeMaterialConnectionPoint;
  62941. protected _buildBlock(state: NodeMaterialBuildState): this;
  62942. }
  62943. }
  62944. declare module BABYLON {
  62945. /**
  62946. * Block used to desaturate a color
  62947. */
  62948. export class DesaturateBlock extends NodeMaterialBlock {
  62949. /**
  62950. * Creates a new DesaturateBlock
  62951. * @param name defines the block name
  62952. */
  62953. constructor(name: string);
  62954. /**
  62955. * Gets the current class name
  62956. * @returns the class name
  62957. */
  62958. getClassName(): string;
  62959. /**
  62960. * Gets the color operand input component
  62961. */
  62962. get color(): NodeMaterialConnectionPoint;
  62963. /**
  62964. * Gets the level operand input component
  62965. */
  62966. get level(): NodeMaterialConnectionPoint;
  62967. /**
  62968. * Gets the output component
  62969. */
  62970. get output(): NodeMaterialConnectionPoint;
  62971. protected _buildBlock(state: NodeMaterialBuildState): this;
  62972. }
  62973. }
  62974. declare module BABYLON {
  62975. /**
  62976. * Block used to implement the ambient occlusion module of the PBR material
  62977. */
  62978. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62979. /**
  62980. * Create a new AmbientOcclusionBlock
  62981. * @param name defines the block name
  62982. */
  62983. constructor(name: string);
  62984. /**
  62985. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62986. */
  62987. useAmbientInGrayScale: boolean;
  62988. /**
  62989. * Initialize the block and prepare the context for build
  62990. * @param state defines the state that will be used for the build
  62991. */
  62992. initialize(state: NodeMaterialBuildState): void;
  62993. /**
  62994. * Gets the current class name
  62995. * @returns the class name
  62996. */
  62997. getClassName(): string;
  62998. /**
  62999. * Gets the texture input component
  63000. */
  63001. get texture(): NodeMaterialConnectionPoint;
  63002. /**
  63003. * Gets the texture intensity component
  63004. */
  63005. get intensity(): NodeMaterialConnectionPoint;
  63006. /**
  63007. * Gets the direct light intensity input component
  63008. */
  63009. get directLightIntensity(): NodeMaterialConnectionPoint;
  63010. /**
  63011. * Gets the ambient occlusion object output component
  63012. */
  63013. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63014. /**
  63015. * Gets the main code of the block (fragment side)
  63016. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63017. * @returns the shader code
  63018. */
  63019. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63020. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63021. protected _buildBlock(state: NodeMaterialBuildState): this;
  63022. protected _dumpPropertiesCode(): string;
  63023. serialize(): any;
  63024. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63025. }
  63026. }
  63027. declare module BABYLON {
  63028. /**
  63029. * Block used to implement the reflection module of the PBR material
  63030. */
  63031. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63032. /** @hidden */
  63033. _defineLODReflectionAlpha: string;
  63034. /** @hidden */
  63035. _defineLinearSpecularReflection: string;
  63036. private _vEnvironmentIrradianceName;
  63037. /** @hidden */
  63038. _vReflectionMicrosurfaceInfosName: string;
  63039. /** @hidden */
  63040. _vReflectionInfosName: string;
  63041. /** @hidden */
  63042. _vReflectionFilteringInfoName: string;
  63043. private _scene;
  63044. /**
  63045. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63046. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63047. * It's less burden on the user side in the editor part.
  63048. */
  63049. /** @hidden */
  63050. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63051. /** @hidden */
  63052. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63053. /** @hidden */
  63054. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63055. /**
  63056. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63057. * diffuse part of the IBL.
  63058. */
  63059. useSphericalHarmonics: boolean;
  63060. /**
  63061. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63062. */
  63063. forceIrradianceInFragment: boolean;
  63064. /**
  63065. * Create a new ReflectionBlock
  63066. * @param name defines the block name
  63067. */
  63068. constructor(name: string);
  63069. /**
  63070. * Gets the current class name
  63071. * @returns the class name
  63072. */
  63073. getClassName(): string;
  63074. /**
  63075. * Gets the position input component
  63076. */
  63077. get position(): NodeMaterialConnectionPoint;
  63078. /**
  63079. * Gets the world position input component
  63080. */
  63081. get worldPosition(): NodeMaterialConnectionPoint;
  63082. /**
  63083. * Gets the world normal input component
  63084. */
  63085. get worldNormal(): NodeMaterialConnectionPoint;
  63086. /**
  63087. * Gets the world input component
  63088. */
  63089. get world(): NodeMaterialConnectionPoint;
  63090. /**
  63091. * Gets the camera (or eye) position component
  63092. */
  63093. get cameraPosition(): NodeMaterialConnectionPoint;
  63094. /**
  63095. * Gets the view input component
  63096. */
  63097. get view(): NodeMaterialConnectionPoint;
  63098. /**
  63099. * Gets the color input component
  63100. */
  63101. get color(): NodeMaterialConnectionPoint;
  63102. /**
  63103. * Gets the reflection object output component
  63104. */
  63105. get reflection(): NodeMaterialConnectionPoint;
  63106. /**
  63107. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63108. */
  63109. get hasTexture(): boolean;
  63110. /**
  63111. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63112. */
  63113. get reflectionColor(): string;
  63114. protected _getTexture(): Nullable<BaseTexture>;
  63115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63116. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63117. /**
  63118. * Gets the code to inject in the vertex shader
  63119. * @param state current state of the node material building
  63120. * @returns the shader code
  63121. */
  63122. handleVertexSide(state: NodeMaterialBuildState): string;
  63123. /**
  63124. * Gets the main code of the block (fragment side)
  63125. * @param state current state of the node material building
  63126. * @param normalVarName name of the existing variable corresponding to the normal
  63127. * @returns the shader code
  63128. */
  63129. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63130. protected _buildBlock(state: NodeMaterialBuildState): this;
  63131. protected _dumpPropertiesCode(): string;
  63132. serialize(): any;
  63133. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63134. }
  63135. }
  63136. declare module BABYLON {
  63137. /**
  63138. * Block used to implement the sheen module of the PBR material
  63139. */
  63140. export class SheenBlock extends NodeMaterialBlock {
  63141. /**
  63142. * Create a new SheenBlock
  63143. * @param name defines the block name
  63144. */
  63145. constructor(name: string);
  63146. /**
  63147. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63148. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63149. * making it easier to setup and tweak the effect
  63150. */
  63151. albedoScaling: boolean;
  63152. /**
  63153. * Defines if the sheen is linked to the sheen color.
  63154. */
  63155. linkSheenWithAlbedo: boolean;
  63156. /**
  63157. * Initialize the block and prepare the context for build
  63158. * @param state defines the state that will be used for the build
  63159. */
  63160. initialize(state: NodeMaterialBuildState): void;
  63161. /**
  63162. * Gets the current class name
  63163. * @returns the class name
  63164. */
  63165. getClassName(): string;
  63166. /**
  63167. * Gets the intensity input component
  63168. */
  63169. get intensity(): NodeMaterialConnectionPoint;
  63170. /**
  63171. * Gets the color input component
  63172. */
  63173. get color(): NodeMaterialConnectionPoint;
  63174. /**
  63175. * Gets the roughness input component
  63176. */
  63177. get roughness(): NodeMaterialConnectionPoint;
  63178. /**
  63179. * Gets the sheen object output component
  63180. */
  63181. get sheen(): NodeMaterialConnectionPoint;
  63182. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63183. /**
  63184. * Gets the main code of the block (fragment side)
  63185. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63186. * @returns the shader code
  63187. */
  63188. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63189. protected _buildBlock(state: NodeMaterialBuildState): this;
  63190. protected _dumpPropertiesCode(): string;
  63191. serialize(): any;
  63192. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63193. }
  63194. }
  63195. declare module BABYLON {
  63196. /**
  63197. * Block used to implement the reflectivity module of the PBR material
  63198. */
  63199. export class ReflectivityBlock extends NodeMaterialBlock {
  63200. private _metallicReflectanceColor;
  63201. private _metallicF0Factor;
  63202. /** @hidden */
  63203. _vMetallicReflectanceFactorsName: string;
  63204. /**
  63205. * The property below is set by the main PBR block prior to calling methods of this class.
  63206. */
  63207. /** @hidden */
  63208. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63209. /**
  63210. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63211. */
  63212. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63213. /**
  63214. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63215. */
  63216. useMetallnessFromMetallicTextureBlue: boolean;
  63217. /**
  63218. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63219. */
  63220. useRoughnessFromMetallicTextureAlpha: boolean;
  63221. /**
  63222. * Specifies if the metallic texture contains the roughness information in its green channel.
  63223. */
  63224. useRoughnessFromMetallicTextureGreen: boolean;
  63225. /**
  63226. * Create a new ReflectivityBlock
  63227. * @param name defines the block name
  63228. */
  63229. constructor(name: string);
  63230. /**
  63231. * Initialize the block and prepare the context for build
  63232. * @param state defines the state that will be used for the build
  63233. */
  63234. initialize(state: NodeMaterialBuildState): void;
  63235. /**
  63236. * Gets the current class name
  63237. * @returns the class name
  63238. */
  63239. getClassName(): string;
  63240. /**
  63241. * Gets the metallic input component
  63242. */
  63243. get metallic(): NodeMaterialConnectionPoint;
  63244. /**
  63245. * Gets the roughness input component
  63246. */
  63247. get roughness(): NodeMaterialConnectionPoint;
  63248. /**
  63249. * Gets the texture input component
  63250. */
  63251. get texture(): NodeMaterialConnectionPoint;
  63252. /**
  63253. * Gets the reflectivity object output component
  63254. */
  63255. get reflectivity(): NodeMaterialConnectionPoint;
  63256. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63257. /**
  63258. * Gets the main code of the block (fragment side)
  63259. * @param state current state of the node material building
  63260. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63261. * @returns the shader code
  63262. */
  63263. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63264. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63265. protected _buildBlock(state: NodeMaterialBuildState): this;
  63266. protected _dumpPropertiesCode(): string;
  63267. serialize(): any;
  63268. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63269. }
  63270. }
  63271. declare module BABYLON {
  63272. /**
  63273. * Block used to implement the anisotropy module of the PBR material
  63274. */
  63275. export class AnisotropyBlock extends NodeMaterialBlock {
  63276. /**
  63277. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63278. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63279. * It's less burden on the user side in the editor part.
  63280. */
  63281. /** @hidden */
  63282. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63283. /** @hidden */
  63284. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63285. /**
  63286. * Create a new AnisotropyBlock
  63287. * @param name defines the block name
  63288. */
  63289. constructor(name: string);
  63290. /**
  63291. * Initialize the block and prepare the context for build
  63292. * @param state defines the state that will be used for the build
  63293. */
  63294. initialize(state: NodeMaterialBuildState): void;
  63295. /**
  63296. * Gets the current class name
  63297. * @returns the class name
  63298. */
  63299. getClassName(): string;
  63300. /**
  63301. * Gets the intensity input component
  63302. */
  63303. get intensity(): NodeMaterialConnectionPoint;
  63304. /**
  63305. * Gets the direction input component
  63306. */
  63307. get direction(): NodeMaterialConnectionPoint;
  63308. /**
  63309. * Gets the texture input component
  63310. */
  63311. get texture(): NodeMaterialConnectionPoint;
  63312. /**
  63313. * Gets the uv input component
  63314. */
  63315. get uv(): NodeMaterialConnectionPoint;
  63316. /**
  63317. * Gets the worldTangent input component
  63318. */
  63319. get worldTangent(): NodeMaterialConnectionPoint;
  63320. /**
  63321. * Gets the anisotropy object output component
  63322. */
  63323. get anisotropy(): NodeMaterialConnectionPoint;
  63324. private _generateTBNSpace;
  63325. /**
  63326. * Gets the main code of the block (fragment side)
  63327. * @param state current state of the node material building
  63328. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63329. * @returns the shader code
  63330. */
  63331. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63332. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63333. protected _buildBlock(state: NodeMaterialBuildState): this;
  63334. }
  63335. }
  63336. declare module BABYLON {
  63337. /**
  63338. * Block used to implement the clear coat module of the PBR material
  63339. */
  63340. export class ClearCoatBlock extends NodeMaterialBlock {
  63341. private _scene;
  63342. /**
  63343. * Create a new ClearCoatBlock
  63344. * @param name defines the block name
  63345. */
  63346. constructor(name: string);
  63347. /**
  63348. * Initialize the block and prepare the context for build
  63349. * @param state defines the state that will be used for the build
  63350. */
  63351. initialize(state: NodeMaterialBuildState): void;
  63352. /**
  63353. * Gets the current class name
  63354. * @returns the class name
  63355. */
  63356. getClassName(): string;
  63357. /**
  63358. * Gets the intensity input component
  63359. */
  63360. get intensity(): NodeMaterialConnectionPoint;
  63361. /**
  63362. * Gets the roughness input component
  63363. */
  63364. get roughness(): NodeMaterialConnectionPoint;
  63365. /**
  63366. * Gets the ior input component
  63367. */
  63368. get ior(): NodeMaterialConnectionPoint;
  63369. /**
  63370. * Gets the texture input component
  63371. */
  63372. get texture(): NodeMaterialConnectionPoint;
  63373. /**
  63374. * Gets the bump texture input component
  63375. */
  63376. get bumpTexture(): NodeMaterialConnectionPoint;
  63377. /**
  63378. * Gets the uv input component
  63379. */
  63380. get uv(): NodeMaterialConnectionPoint;
  63381. /**
  63382. * Gets the tint color input component
  63383. */
  63384. get tintColor(): NodeMaterialConnectionPoint;
  63385. /**
  63386. * Gets the tint "at distance" input component
  63387. */
  63388. get tintAtDistance(): NodeMaterialConnectionPoint;
  63389. /**
  63390. * Gets the tint thickness input component
  63391. */
  63392. get tintThickness(): NodeMaterialConnectionPoint;
  63393. /**
  63394. * Gets the world tangent input component
  63395. */
  63396. get worldTangent(): NodeMaterialConnectionPoint;
  63397. /**
  63398. * Gets the clear coat object output component
  63399. */
  63400. get clearcoat(): NodeMaterialConnectionPoint;
  63401. autoConfigure(material: NodeMaterial): void;
  63402. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63403. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63404. private _generateTBNSpace;
  63405. /**
  63406. * Gets the main code of the block (fragment side)
  63407. * @param state current state of the node material building
  63408. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63409. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63410. * @param worldPosVarName name of the variable holding the world position
  63411. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63412. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63413. * @param worldNormalVarName name of the variable holding the world normal
  63414. * @returns the shader code
  63415. */
  63416. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63417. protected _buildBlock(state: NodeMaterialBuildState): this;
  63418. }
  63419. }
  63420. declare module BABYLON {
  63421. /**
  63422. * Block used to implement the sub surface module of the PBR material
  63423. */
  63424. export class SubSurfaceBlock extends NodeMaterialBlock {
  63425. /**
  63426. * Create a new SubSurfaceBlock
  63427. * @param name defines the block name
  63428. */
  63429. constructor(name: string);
  63430. /**
  63431. * Stores the intensity of the different subsurface effects in the thickness texture.
  63432. * * the green channel is the translucency intensity.
  63433. * * the blue channel is the scattering intensity.
  63434. * * the alpha channel is the refraction intensity.
  63435. */
  63436. useMaskFromThicknessTexture: boolean;
  63437. /**
  63438. * Initialize the block and prepare the context for build
  63439. * @param state defines the state that will be used for the build
  63440. */
  63441. initialize(state: NodeMaterialBuildState): void;
  63442. /**
  63443. * Gets the current class name
  63444. * @returns the class name
  63445. */
  63446. getClassName(): string;
  63447. /**
  63448. * Gets the min thickness input component
  63449. */
  63450. get minThickness(): NodeMaterialConnectionPoint;
  63451. /**
  63452. * Gets the max thickness input component
  63453. */
  63454. get maxThickness(): NodeMaterialConnectionPoint;
  63455. /**
  63456. * Gets the thickness texture component
  63457. */
  63458. get thicknessTexture(): NodeMaterialConnectionPoint;
  63459. /**
  63460. * Gets the tint color input component
  63461. */
  63462. get tintColor(): NodeMaterialConnectionPoint;
  63463. /**
  63464. * Gets the translucency intensity input component
  63465. */
  63466. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63467. /**
  63468. * Gets the translucency diffusion distance input component
  63469. */
  63470. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63471. /**
  63472. * Gets the refraction object parameters
  63473. */
  63474. get refraction(): NodeMaterialConnectionPoint;
  63475. /**
  63476. * Gets the sub surface object output component
  63477. */
  63478. get subsurface(): NodeMaterialConnectionPoint;
  63479. autoConfigure(material: NodeMaterial): void;
  63480. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63481. /**
  63482. * Gets the main code of the block (fragment side)
  63483. * @param state current state of the node material building
  63484. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63485. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63486. * @param worldPosVarName name of the variable holding the world position
  63487. * @returns the shader code
  63488. */
  63489. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63490. protected _buildBlock(state: NodeMaterialBuildState): this;
  63491. }
  63492. }
  63493. declare module BABYLON {
  63494. /**
  63495. * Block used to implement the PBR metallic/roughness model
  63496. */
  63497. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63498. /**
  63499. * Gets or sets the light associated with this block
  63500. */
  63501. light: Nullable<Light>;
  63502. private _lightId;
  63503. private _scene;
  63504. private _environmentBRDFTexture;
  63505. private _environmentBrdfSamplerName;
  63506. private _vNormalWName;
  63507. private _invertNormalName;
  63508. /**
  63509. * Create a new ReflectionBlock
  63510. * @param name defines the block name
  63511. */
  63512. constructor(name: string);
  63513. /**
  63514. * Intensity of the direct lights e.g. the four lights available in your scene.
  63515. * This impacts both the direct diffuse and specular highlights.
  63516. */
  63517. directIntensity: number;
  63518. /**
  63519. * Intensity of the environment e.g. how much the environment will light the object
  63520. * either through harmonics for rough material or through the refelction for shiny ones.
  63521. */
  63522. environmentIntensity: number;
  63523. /**
  63524. * This is a special control allowing the reduction of the specular highlights coming from the
  63525. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63526. */
  63527. specularIntensity: number;
  63528. /**
  63529. * Defines the falloff type used in this material.
  63530. * It by default is Physical.
  63531. */
  63532. lightFalloff: number;
  63533. /**
  63534. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63535. */
  63536. useAlphaFromAlbedoTexture: boolean;
  63537. /**
  63538. * Specifies that alpha test should be used
  63539. */
  63540. useAlphaTest: boolean;
  63541. /**
  63542. * Defines the alpha limits in alpha test mode.
  63543. */
  63544. alphaTestCutoff: number;
  63545. /**
  63546. * Specifies that alpha blending should be used
  63547. */
  63548. useAlphaBlending: boolean;
  63549. /**
  63550. * Defines if the alpha value should be determined via the rgb values.
  63551. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63552. */
  63553. opacityRGB: boolean;
  63554. /**
  63555. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63556. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63557. */
  63558. useRadianceOverAlpha: boolean;
  63559. /**
  63560. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63561. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63562. */
  63563. useSpecularOverAlpha: boolean;
  63564. /**
  63565. * Enables specular anti aliasing in the PBR shader.
  63566. * It will both interacts on the Geometry for analytical and IBL lighting.
  63567. * It also prefilter the roughness map based on the bump values.
  63568. */
  63569. enableSpecularAntiAliasing: boolean;
  63570. /**
  63571. * Enables realtime filtering on the texture.
  63572. */
  63573. realTimeFiltering: boolean;
  63574. /**
  63575. * Quality switch for realtime filtering
  63576. */
  63577. realTimeFilteringQuality: number;
  63578. /**
  63579. * Defines if the material uses energy conservation.
  63580. */
  63581. useEnergyConservation: boolean;
  63582. /**
  63583. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63584. * too much the area relying on ambient texture to define their ambient occlusion.
  63585. */
  63586. useRadianceOcclusion: boolean;
  63587. /**
  63588. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63589. * makes the reflect vector face the model (under horizon).
  63590. */
  63591. useHorizonOcclusion: boolean;
  63592. /**
  63593. * If set to true, no lighting calculations will be applied.
  63594. */
  63595. unlit: boolean;
  63596. /**
  63597. * Force normal to face away from face.
  63598. */
  63599. forceNormalForward: boolean;
  63600. /**
  63601. * Defines the material debug mode.
  63602. * It helps seeing only some components of the material while troubleshooting.
  63603. */
  63604. debugMode: number;
  63605. /**
  63606. * Specify from where on screen the debug mode should start.
  63607. * The value goes from -1 (full screen) to 1 (not visible)
  63608. * It helps with side by side comparison against the final render
  63609. * This defaults to 0
  63610. */
  63611. debugLimit: number;
  63612. /**
  63613. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63614. * You can use the factor to better multiply the final value.
  63615. */
  63616. debugFactor: number;
  63617. /**
  63618. * Initialize the block and prepare the context for build
  63619. * @param state defines the state that will be used for the build
  63620. */
  63621. initialize(state: NodeMaterialBuildState): void;
  63622. /**
  63623. * Gets the current class name
  63624. * @returns the class name
  63625. */
  63626. getClassName(): string;
  63627. /**
  63628. * Gets the world position input component
  63629. */
  63630. get worldPosition(): NodeMaterialConnectionPoint;
  63631. /**
  63632. * Gets the world normal input component
  63633. */
  63634. get worldNormal(): NodeMaterialConnectionPoint;
  63635. /**
  63636. * Gets the perturbed normal input component
  63637. */
  63638. get perturbedNormal(): NodeMaterialConnectionPoint;
  63639. /**
  63640. * Gets the camera position input component
  63641. */
  63642. get cameraPosition(): NodeMaterialConnectionPoint;
  63643. /**
  63644. * Gets the base color input component
  63645. */
  63646. get baseColor(): NodeMaterialConnectionPoint;
  63647. /**
  63648. * Gets the opacity texture input component
  63649. */
  63650. get opacityTexture(): NodeMaterialConnectionPoint;
  63651. /**
  63652. * Gets the ambient color input component
  63653. */
  63654. get ambientColor(): NodeMaterialConnectionPoint;
  63655. /**
  63656. * Gets the reflectivity object parameters
  63657. */
  63658. get reflectivity(): NodeMaterialConnectionPoint;
  63659. /**
  63660. * Gets the ambient occlusion object parameters
  63661. */
  63662. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63663. /**
  63664. * Gets the reflection object parameters
  63665. */
  63666. get reflection(): NodeMaterialConnectionPoint;
  63667. /**
  63668. * Gets the sheen object parameters
  63669. */
  63670. get sheen(): NodeMaterialConnectionPoint;
  63671. /**
  63672. * Gets the clear coat object parameters
  63673. */
  63674. get clearcoat(): NodeMaterialConnectionPoint;
  63675. /**
  63676. * Gets the sub surface object parameters
  63677. */
  63678. get subsurface(): NodeMaterialConnectionPoint;
  63679. /**
  63680. * Gets the anisotropy object parameters
  63681. */
  63682. get anisotropy(): NodeMaterialConnectionPoint;
  63683. /**
  63684. * Gets the ambient output component
  63685. */
  63686. get ambient(): NodeMaterialConnectionPoint;
  63687. /**
  63688. * Gets the diffuse output component
  63689. */
  63690. get diffuse(): NodeMaterialConnectionPoint;
  63691. /**
  63692. * Gets the specular output component
  63693. */
  63694. get specular(): NodeMaterialConnectionPoint;
  63695. /**
  63696. * Gets the sheen output component
  63697. */
  63698. get sheenDir(): NodeMaterialConnectionPoint;
  63699. /**
  63700. * Gets the clear coat output component
  63701. */
  63702. get clearcoatDir(): NodeMaterialConnectionPoint;
  63703. /**
  63704. * Gets the indirect diffuse output component
  63705. */
  63706. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63707. /**
  63708. * Gets the indirect specular output component
  63709. */
  63710. get specularIndirect(): NodeMaterialConnectionPoint;
  63711. /**
  63712. * Gets the indirect sheen output component
  63713. */
  63714. get sheenIndirect(): NodeMaterialConnectionPoint;
  63715. /**
  63716. * Gets the indirect clear coat output component
  63717. */
  63718. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63719. /**
  63720. * Gets the refraction output component
  63721. */
  63722. get refraction(): NodeMaterialConnectionPoint;
  63723. /**
  63724. * Gets the global lighting output component
  63725. */
  63726. get lighting(): NodeMaterialConnectionPoint;
  63727. /**
  63728. * Gets the shadow output component
  63729. */
  63730. get shadow(): NodeMaterialConnectionPoint;
  63731. /**
  63732. * Gets the alpha output component
  63733. */
  63734. get alpha(): NodeMaterialConnectionPoint;
  63735. autoConfigure(material: NodeMaterial): void;
  63736. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63737. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63738. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63739. private _injectVertexCode;
  63740. /**
  63741. * Gets the code corresponding to the albedo/opacity module
  63742. * @returns the shader code
  63743. */
  63744. getAlbedoOpacityCode(): string;
  63745. protected _buildBlock(state: NodeMaterialBuildState): this;
  63746. protected _dumpPropertiesCode(): string;
  63747. serialize(): any;
  63748. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63749. }
  63750. }
  63751. declare module BABYLON {
  63752. /**
  63753. * Block used to compute value of one parameter modulo another
  63754. */
  63755. export class ModBlock extends NodeMaterialBlock {
  63756. /**
  63757. * Creates a new ModBlock
  63758. * @param name defines the block name
  63759. */
  63760. constructor(name: string);
  63761. /**
  63762. * Gets the current class name
  63763. * @returns the class name
  63764. */
  63765. getClassName(): string;
  63766. /**
  63767. * Gets the left operand input component
  63768. */
  63769. get left(): NodeMaterialConnectionPoint;
  63770. /**
  63771. * Gets the right operand input component
  63772. */
  63773. get right(): NodeMaterialConnectionPoint;
  63774. /**
  63775. * Gets the output component
  63776. */
  63777. get output(): NodeMaterialConnectionPoint;
  63778. protected _buildBlock(state: NodeMaterialBuildState): this;
  63779. }
  63780. }
  63781. declare module BABYLON {
  63782. /**
  63783. * Helper class to push actions to a pool of workers.
  63784. */
  63785. export class WorkerPool implements IDisposable {
  63786. private _workerInfos;
  63787. private _pendingActions;
  63788. /**
  63789. * Constructor
  63790. * @param workers Array of workers to use for actions
  63791. */
  63792. constructor(workers: Array<Worker>);
  63793. /**
  63794. * Terminates all workers and clears any pending actions.
  63795. */
  63796. dispose(): void;
  63797. /**
  63798. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63799. * pended until a worker has completed its action.
  63800. * @param action The action to perform. Call onComplete when the action is complete.
  63801. */
  63802. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63803. private _execute;
  63804. }
  63805. }
  63806. declare module BABYLON {
  63807. /**
  63808. * Configuration for Draco compression
  63809. */
  63810. export interface IDracoCompressionConfiguration {
  63811. /**
  63812. * Configuration for the decoder.
  63813. */
  63814. decoder: {
  63815. /**
  63816. * The url to the WebAssembly module.
  63817. */
  63818. wasmUrl?: string;
  63819. /**
  63820. * The url to the WebAssembly binary.
  63821. */
  63822. wasmBinaryUrl?: string;
  63823. /**
  63824. * The url to the fallback JavaScript module.
  63825. */
  63826. fallbackUrl?: string;
  63827. };
  63828. }
  63829. /**
  63830. * Draco compression (https://google.github.io/draco/)
  63831. *
  63832. * This class wraps the Draco module.
  63833. *
  63834. * **Encoder**
  63835. *
  63836. * The encoder is not currently implemented.
  63837. *
  63838. * **Decoder**
  63839. *
  63840. * 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.
  63841. *
  63842. * To update the configuration, use the following code:
  63843. * ```javascript
  63844. * DracoCompression.Configuration = {
  63845. * decoder: {
  63846. * wasmUrl: "<url to the WebAssembly library>",
  63847. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63848. * fallbackUrl: "<url to the fallback JavaScript library>",
  63849. * }
  63850. * };
  63851. * ```
  63852. *
  63853. * 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.
  63854. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63855. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63856. *
  63857. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63858. * ```javascript
  63859. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63860. * ```
  63861. *
  63862. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63863. */
  63864. export class DracoCompression implements IDisposable {
  63865. private _workerPoolPromise?;
  63866. private _decoderModulePromise?;
  63867. /**
  63868. * The configuration. Defaults to the following urls:
  63869. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63870. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63871. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63872. */
  63873. static Configuration: IDracoCompressionConfiguration;
  63874. /**
  63875. * Returns true if the decoder configuration is available.
  63876. */
  63877. static get DecoderAvailable(): boolean;
  63878. /**
  63879. * Default number of workers to create when creating the draco compression object.
  63880. */
  63881. static DefaultNumWorkers: number;
  63882. private static GetDefaultNumWorkers;
  63883. private static _Default;
  63884. /**
  63885. * Default instance for the draco compression object.
  63886. */
  63887. static get Default(): DracoCompression;
  63888. /**
  63889. * Constructor
  63890. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63891. */
  63892. constructor(numWorkers?: number);
  63893. /**
  63894. * Stop all async operations and release resources.
  63895. */
  63896. dispose(): void;
  63897. /**
  63898. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63899. * @returns a promise that resolves when ready
  63900. */
  63901. whenReadyAsync(): Promise<void>;
  63902. /**
  63903. * Decode Draco compressed mesh data to vertex data.
  63904. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63905. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63906. * @returns A promise that resolves with the decoded vertex data
  63907. */
  63908. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63909. [kind: string]: number;
  63910. }): Promise<VertexData>;
  63911. }
  63912. }
  63913. declare module BABYLON {
  63914. /**
  63915. * Class for building Constructive Solid Geometry
  63916. */
  63917. export class CSG {
  63918. private polygons;
  63919. /**
  63920. * The world matrix
  63921. */
  63922. matrix: Matrix;
  63923. /**
  63924. * Stores the position
  63925. */
  63926. position: Vector3;
  63927. /**
  63928. * Stores the rotation
  63929. */
  63930. rotation: Vector3;
  63931. /**
  63932. * Stores the rotation quaternion
  63933. */
  63934. rotationQuaternion: Nullable<Quaternion>;
  63935. /**
  63936. * Stores the scaling vector
  63937. */
  63938. scaling: Vector3;
  63939. /**
  63940. * Convert the Mesh to CSG
  63941. * @param mesh The Mesh to convert to CSG
  63942. * @returns A new CSG from the Mesh
  63943. */
  63944. static FromMesh(mesh: Mesh): CSG;
  63945. /**
  63946. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63947. * @param polygons Polygons used to construct a CSG solid
  63948. */
  63949. private static FromPolygons;
  63950. /**
  63951. * Clones, or makes a deep copy, of the CSG
  63952. * @returns A new CSG
  63953. */
  63954. clone(): CSG;
  63955. /**
  63956. * Unions this CSG with another CSG
  63957. * @param csg The CSG to union against this CSG
  63958. * @returns The unioned CSG
  63959. */
  63960. union(csg: CSG): CSG;
  63961. /**
  63962. * Unions this CSG with another CSG in place
  63963. * @param csg The CSG to union against this CSG
  63964. */
  63965. unionInPlace(csg: CSG): void;
  63966. /**
  63967. * Subtracts this CSG with another CSG
  63968. * @param csg The CSG to subtract against this CSG
  63969. * @returns A new CSG
  63970. */
  63971. subtract(csg: CSG): CSG;
  63972. /**
  63973. * Subtracts this CSG with another CSG in place
  63974. * @param csg The CSG to subtact against this CSG
  63975. */
  63976. subtractInPlace(csg: CSG): void;
  63977. /**
  63978. * Intersect this CSG with another CSG
  63979. * @param csg The CSG to intersect against this CSG
  63980. * @returns A new CSG
  63981. */
  63982. intersect(csg: CSG): CSG;
  63983. /**
  63984. * Intersects this CSG with another CSG in place
  63985. * @param csg The CSG to intersect against this CSG
  63986. */
  63987. intersectInPlace(csg: CSG): void;
  63988. /**
  63989. * Return a new CSG solid with solid and empty space switched. This solid is
  63990. * not modified.
  63991. * @returns A new CSG solid with solid and empty space switched
  63992. */
  63993. inverse(): CSG;
  63994. /**
  63995. * Inverses the CSG in place
  63996. */
  63997. inverseInPlace(): void;
  63998. /**
  63999. * This is used to keep meshes transformations so they can be restored
  64000. * when we build back a Babylon Mesh
  64001. * NB : All CSG operations are performed in world coordinates
  64002. * @param csg The CSG to copy the transform attributes from
  64003. * @returns This CSG
  64004. */
  64005. copyTransformAttributes(csg: CSG): CSG;
  64006. /**
  64007. * Build Raw mesh from CSG
  64008. * Coordinates here are in world space
  64009. * @param name The name of the mesh geometry
  64010. * @param scene The Scene
  64011. * @param keepSubMeshes Specifies if the submeshes should be kept
  64012. * @returns A new Mesh
  64013. */
  64014. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64015. /**
  64016. * Build Mesh from CSG taking material and transforms into account
  64017. * @param name The name of the Mesh
  64018. * @param material The material of the Mesh
  64019. * @param scene The Scene
  64020. * @param keepSubMeshes Specifies if submeshes should be kept
  64021. * @returns The new Mesh
  64022. */
  64023. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64024. }
  64025. }
  64026. declare module BABYLON {
  64027. /**
  64028. * Class used to create a trail following a mesh
  64029. */
  64030. export class TrailMesh extends Mesh {
  64031. private _generator;
  64032. private _autoStart;
  64033. private _running;
  64034. private _diameter;
  64035. private _length;
  64036. private _sectionPolygonPointsCount;
  64037. private _sectionVectors;
  64038. private _sectionNormalVectors;
  64039. private _beforeRenderObserver;
  64040. /**
  64041. * @constructor
  64042. * @param name The value used by scene.getMeshByName() to do a lookup.
  64043. * @param generator The mesh or transform node to generate a trail.
  64044. * @param scene The scene to add this mesh to.
  64045. * @param diameter Diameter of trailing mesh. Default is 1.
  64046. * @param length Length of trailing mesh. Default is 60.
  64047. * @param autoStart Automatically start trailing mesh. Default true.
  64048. */
  64049. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64050. /**
  64051. * "TrailMesh"
  64052. * @returns "TrailMesh"
  64053. */
  64054. getClassName(): string;
  64055. private _createMesh;
  64056. /**
  64057. * Start trailing mesh.
  64058. */
  64059. start(): void;
  64060. /**
  64061. * Stop trailing mesh.
  64062. */
  64063. stop(): void;
  64064. /**
  64065. * Update trailing mesh geometry.
  64066. */
  64067. update(): void;
  64068. /**
  64069. * Returns a new TrailMesh object.
  64070. * @param name is a string, the name given to the new mesh
  64071. * @param newGenerator use new generator object for cloned trail mesh
  64072. * @returns a new mesh
  64073. */
  64074. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64075. /**
  64076. * Serializes this trail mesh
  64077. * @param serializationObject object to write serialization to
  64078. */
  64079. serialize(serializationObject: any): void;
  64080. /**
  64081. * Parses a serialized trail mesh
  64082. * @param parsedMesh the serialized mesh
  64083. * @param scene the scene to create the trail mesh in
  64084. * @returns the created trail mesh
  64085. */
  64086. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64087. }
  64088. }
  64089. declare module BABYLON {
  64090. /**
  64091. * Class containing static functions to help procedurally build meshes
  64092. */
  64093. export class TiledBoxBuilder {
  64094. /**
  64095. * Creates a box mesh
  64096. * 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)
  64097. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64099. * * 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
  64100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64101. * @param name defines the name of the mesh
  64102. * @param options defines the options used to create the mesh
  64103. * @param scene defines the hosting scene
  64104. * @returns the box mesh
  64105. */
  64106. static CreateTiledBox(name: string, options: {
  64107. pattern?: number;
  64108. width?: number;
  64109. height?: number;
  64110. depth?: number;
  64111. tileSize?: number;
  64112. tileWidth?: number;
  64113. tileHeight?: number;
  64114. alignHorizontal?: number;
  64115. alignVertical?: number;
  64116. faceUV?: Vector4[];
  64117. faceColors?: Color4[];
  64118. sideOrientation?: number;
  64119. updatable?: boolean;
  64120. }, scene?: Nullable<Scene>): Mesh;
  64121. }
  64122. }
  64123. declare module BABYLON {
  64124. /**
  64125. * Class containing static functions to help procedurally build meshes
  64126. */
  64127. export class TorusKnotBuilder {
  64128. /**
  64129. * Creates a torus knot mesh
  64130. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64131. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64132. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64133. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64135. * * 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
  64136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64137. * @param name defines the name of the mesh
  64138. * @param options defines the options used to create the mesh
  64139. * @param scene defines the hosting scene
  64140. * @returns the torus knot mesh
  64141. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64142. */
  64143. static CreateTorusKnot(name: string, options: {
  64144. radius?: number;
  64145. tube?: number;
  64146. radialSegments?: number;
  64147. tubularSegments?: number;
  64148. p?: number;
  64149. q?: number;
  64150. updatable?: boolean;
  64151. sideOrientation?: number;
  64152. frontUVs?: Vector4;
  64153. backUVs?: Vector4;
  64154. }, scene: any): Mesh;
  64155. }
  64156. }
  64157. declare module BABYLON {
  64158. /**
  64159. * Polygon
  64160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64161. */
  64162. export class Polygon {
  64163. /**
  64164. * Creates a rectangle
  64165. * @param xmin bottom X coord
  64166. * @param ymin bottom Y coord
  64167. * @param xmax top X coord
  64168. * @param ymax top Y coord
  64169. * @returns points that make the resulting rectation
  64170. */
  64171. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64172. /**
  64173. * Creates a circle
  64174. * @param radius radius of circle
  64175. * @param cx scale in x
  64176. * @param cy scale in y
  64177. * @param numberOfSides number of sides that make up the circle
  64178. * @returns points that make the resulting circle
  64179. */
  64180. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64181. /**
  64182. * Creates a polygon from input string
  64183. * @param input Input polygon data
  64184. * @returns the parsed points
  64185. */
  64186. static Parse(input: string): Vector2[];
  64187. /**
  64188. * Starts building a polygon from x and y coordinates
  64189. * @param x x coordinate
  64190. * @param y y coordinate
  64191. * @returns the started path2
  64192. */
  64193. static StartingAt(x: number, y: number): Path2;
  64194. }
  64195. /**
  64196. * Builds a polygon
  64197. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64198. */
  64199. export class PolygonMeshBuilder {
  64200. private _points;
  64201. private _outlinepoints;
  64202. private _holes;
  64203. private _name;
  64204. private _scene;
  64205. private _epoints;
  64206. private _eholes;
  64207. private _addToepoint;
  64208. /**
  64209. * Babylon reference to the earcut plugin.
  64210. */
  64211. bjsEarcut: any;
  64212. /**
  64213. * Creates a PolygonMeshBuilder
  64214. * @param name name of the builder
  64215. * @param contours Path of the polygon
  64216. * @param scene scene to add to when creating the mesh
  64217. * @param earcutInjection can be used to inject your own earcut reference
  64218. */
  64219. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64220. /**
  64221. * Adds a whole within the polygon
  64222. * @param hole Array of points defining the hole
  64223. * @returns this
  64224. */
  64225. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64226. /**
  64227. * Creates the polygon
  64228. * @param updatable If the mesh should be updatable
  64229. * @param depth The depth of the mesh created
  64230. * @returns the created mesh
  64231. */
  64232. build(updatable?: boolean, depth?: number): Mesh;
  64233. /**
  64234. * Creates the polygon
  64235. * @param depth The depth of the mesh created
  64236. * @returns the created VertexData
  64237. */
  64238. buildVertexData(depth?: number): VertexData;
  64239. /**
  64240. * Adds a side to the polygon
  64241. * @param positions points that make the polygon
  64242. * @param normals normals of the polygon
  64243. * @param uvs uvs of the polygon
  64244. * @param indices indices of the polygon
  64245. * @param bounds bounds of the polygon
  64246. * @param points points of the polygon
  64247. * @param depth depth of the polygon
  64248. * @param flip flip of the polygon
  64249. */
  64250. private addSide;
  64251. }
  64252. }
  64253. declare module BABYLON {
  64254. /**
  64255. * Class containing static functions to help procedurally build meshes
  64256. */
  64257. export class PolygonBuilder {
  64258. /**
  64259. * Creates a polygon mesh
  64260. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64261. * * 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
  64262. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64264. * * 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)
  64265. * * Remember you can only change the shape positions, not their number when updating a polygon
  64266. * @param name defines the name of the mesh
  64267. * @param options defines the options used to create the mesh
  64268. * @param scene defines the hosting scene
  64269. * @param earcutInjection can be used to inject your own earcut reference
  64270. * @returns the polygon mesh
  64271. */
  64272. static CreatePolygon(name: string, options: {
  64273. shape: Vector3[];
  64274. holes?: Vector3[][];
  64275. depth?: number;
  64276. faceUV?: Vector4[];
  64277. faceColors?: Color4[];
  64278. updatable?: boolean;
  64279. sideOrientation?: number;
  64280. frontUVs?: Vector4;
  64281. backUVs?: Vector4;
  64282. wrap?: boolean;
  64283. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64284. /**
  64285. * Creates an extruded polygon mesh, with depth in the Y direction.
  64286. * * 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)
  64287. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64288. * @param name defines the name of the mesh
  64289. * @param options defines the options used to create the mesh
  64290. * @param scene defines the hosting scene
  64291. * @param earcutInjection can be used to inject your own earcut reference
  64292. * @returns the polygon mesh
  64293. */
  64294. static ExtrudePolygon(name: string, options: {
  64295. shape: Vector3[];
  64296. holes?: Vector3[][];
  64297. depth?: number;
  64298. faceUV?: Vector4[];
  64299. faceColors?: Color4[];
  64300. updatable?: boolean;
  64301. sideOrientation?: number;
  64302. frontUVs?: Vector4;
  64303. backUVs?: Vector4;
  64304. wrap?: boolean;
  64305. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64306. }
  64307. }
  64308. declare module BABYLON {
  64309. /**
  64310. * Class containing static functions to help procedurally build meshes
  64311. */
  64312. export class LatheBuilder {
  64313. /**
  64314. * Creates lathe mesh.
  64315. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64316. * * 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
  64317. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64318. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64319. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64320. * * 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
  64321. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64322. * * 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
  64323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64324. * * 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
  64325. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64327. * @param name defines the name of the mesh
  64328. * @param options defines the options used to create the mesh
  64329. * @param scene defines the hosting scene
  64330. * @returns the lathe mesh
  64331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64332. */
  64333. static CreateLathe(name: string, options: {
  64334. shape: Vector3[];
  64335. radius?: number;
  64336. tessellation?: number;
  64337. clip?: number;
  64338. arc?: number;
  64339. closed?: boolean;
  64340. updatable?: boolean;
  64341. sideOrientation?: number;
  64342. frontUVs?: Vector4;
  64343. backUVs?: Vector4;
  64344. cap?: number;
  64345. invertUV?: boolean;
  64346. }, scene?: Nullable<Scene>): Mesh;
  64347. }
  64348. }
  64349. declare module BABYLON {
  64350. /**
  64351. * Class containing static functions to help procedurally build meshes
  64352. */
  64353. export class TiledPlaneBuilder {
  64354. /**
  64355. * Creates a tiled plane mesh
  64356. * * The parameter `pattern` will, depending on value, do nothing or
  64357. * * * flip (reflect about central vertical) alternate tiles across and up
  64358. * * * flip every tile on alternate rows
  64359. * * * rotate (180 degs) alternate tiles across and up
  64360. * * * rotate every tile on alternate rows
  64361. * * * flip and rotate alternate tiles across and up
  64362. * * * flip and rotate every tile on alternate rows
  64363. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64364. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64365. * * 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
  64366. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64367. * * 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)
  64368. * * 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)
  64369. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64370. * @param name defines the name of the mesh
  64371. * @param options defines the options used to create the mesh
  64372. * @param scene defines the hosting scene
  64373. * @returns the box mesh
  64374. */
  64375. static CreateTiledPlane(name: string, options: {
  64376. pattern?: number;
  64377. tileSize?: number;
  64378. tileWidth?: number;
  64379. tileHeight?: number;
  64380. size?: number;
  64381. width?: number;
  64382. height?: number;
  64383. alignHorizontal?: number;
  64384. alignVertical?: number;
  64385. sideOrientation?: number;
  64386. frontUVs?: Vector4;
  64387. backUVs?: Vector4;
  64388. updatable?: boolean;
  64389. }, scene?: Nullable<Scene>): Mesh;
  64390. }
  64391. }
  64392. declare module BABYLON {
  64393. /**
  64394. * Class containing static functions to help procedurally build meshes
  64395. */
  64396. export class TubeBuilder {
  64397. /**
  64398. * Creates a tube mesh.
  64399. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64400. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64401. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64402. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64403. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64404. * * 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)
  64405. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64406. * * 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
  64407. * * 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
  64408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64409. * * 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
  64410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64412. * @param name defines the name of the mesh
  64413. * @param options defines the options used to create the mesh
  64414. * @param scene defines the hosting scene
  64415. * @returns the tube mesh
  64416. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64417. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64418. */
  64419. static CreateTube(name: string, options: {
  64420. path: Vector3[];
  64421. radius?: number;
  64422. tessellation?: number;
  64423. radiusFunction?: {
  64424. (i: number, distance: number): number;
  64425. };
  64426. cap?: number;
  64427. arc?: number;
  64428. updatable?: boolean;
  64429. sideOrientation?: number;
  64430. frontUVs?: Vector4;
  64431. backUVs?: Vector4;
  64432. instance?: Mesh;
  64433. invertUV?: boolean;
  64434. }, scene?: Nullable<Scene>): Mesh;
  64435. }
  64436. }
  64437. declare module BABYLON {
  64438. /**
  64439. * Class containing static functions to help procedurally build meshes
  64440. */
  64441. export class IcoSphereBuilder {
  64442. /**
  64443. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64444. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64445. * * 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`)
  64446. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64447. * * 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
  64448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64449. * * 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
  64450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64451. * @param name defines the name of the mesh
  64452. * @param options defines the options used to create the mesh
  64453. * @param scene defines the hosting scene
  64454. * @returns the icosahedron mesh
  64455. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64456. */
  64457. static CreateIcoSphere(name: string, options: {
  64458. radius?: number;
  64459. radiusX?: number;
  64460. radiusY?: number;
  64461. radiusZ?: number;
  64462. flat?: boolean;
  64463. subdivisions?: number;
  64464. sideOrientation?: number;
  64465. frontUVs?: Vector4;
  64466. backUVs?: Vector4;
  64467. updatable?: boolean;
  64468. }, scene?: Nullable<Scene>): Mesh;
  64469. }
  64470. }
  64471. declare module BABYLON {
  64472. /**
  64473. * Class containing static functions to help procedurally build meshes
  64474. */
  64475. export class DecalBuilder {
  64476. /**
  64477. * Creates a decal mesh.
  64478. * 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
  64479. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64480. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64481. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64482. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64483. * @param name defines the name of the mesh
  64484. * @param sourceMesh defines the mesh where the decal must be applied
  64485. * @param options defines the options used to create the mesh
  64486. * @param scene defines the hosting scene
  64487. * @returns the decal mesh
  64488. * @see https://doc.babylonjs.com/how_to/decals
  64489. */
  64490. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64491. position?: Vector3;
  64492. normal?: Vector3;
  64493. size?: Vector3;
  64494. angle?: number;
  64495. }): Mesh;
  64496. }
  64497. }
  64498. declare module BABYLON {
  64499. /**
  64500. * Class containing static functions to help procedurally build meshes
  64501. */
  64502. export class MeshBuilder {
  64503. /**
  64504. * Creates a box mesh
  64505. * * The parameter `size` sets the size (float) of each box side (default 1)
  64506. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64507. * * 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)
  64508. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64510. * * 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
  64511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64512. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64513. * @param name defines the name of the mesh
  64514. * @param options defines the options used to create the mesh
  64515. * @param scene defines the hosting scene
  64516. * @returns the box mesh
  64517. */
  64518. static CreateBox(name: string, options: {
  64519. size?: number;
  64520. width?: number;
  64521. height?: number;
  64522. depth?: number;
  64523. faceUV?: Vector4[];
  64524. faceColors?: Color4[];
  64525. sideOrientation?: number;
  64526. frontUVs?: Vector4;
  64527. backUVs?: Vector4;
  64528. wrap?: boolean;
  64529. topBaseAt?: number;
  64530. bottomBaseAt?: number;
  64531. updatable?: boolean;
  64532. }, scene?: Nullable<Scene>): Mesh;
  64533. /**
  64534. * Creates a tiled box mesh
  64535. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64537. * @param name defines the name of the mesh
  64538. * @param options defines the options used to create the mesh
  64539. * @param scene defines the hosting scene
  64540. * @returns the tiled box mesh
  64541. */
  64542. static CreateTiledBox(name: string, options: {
  64543. pattern?: number;
  64544. size?: number;
  64545. width?: number;
  64546. height?: number;
  64547. depth: number;
  64548. tileSize?: number;
  64549. tileWidth?: number;
  64550. tileHeight?: number;
  64551. faceUV?: Vector4[];
  64552. faceColors?: Color4[];
  64553. alignHorizontal?: number;
  64554. alignVertical?: number;
  64555. sideOrientation?: number;
  64556. updatable?: boolean;
  64557. }, scene?: Nullable<Scene>): Mesh;
  64558. /**
  64559. * Creates a sphere mesh
  64560. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64561. * * 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`)
  64562. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64563. * * 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
  64564. * * 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)
  64565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64566. * * 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
  64567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64568. * @param name defines the name of the mesh
  64569. * @param options defines the options used to create the mesh
  64570. * @param scene defines the hosting scene
  64571. * @returns the sphere mesh
  64572. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64573. */
  64574. static CreateSphere(name: string, options: {
  64575. segments?: number;
  64576. diameter?: number;
  64577. diameterX?: number;
  64578. diameterY?: number;
  64579. diameterZ?: number;
  64580. arc?: number;
  64581. slice?: number;
  64582. sideOrientation?: number;
  64583. frontUVs?: Vector4;
  64584. backUVs?: Vector4;
  64585. updatable?: boolean;
  64586. }, scene?: Nullable<Scene>): Mesh;
  64587. /**
  64588. * Creates a plane polygonal mesh. By default, this is a disc
  64589. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64590. * * 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
  64591. * * 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
  64592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64593. * * 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
  64594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64595. * @param name defines the name of the mesh
  64596. * @param options defines the options used to create the mesh
  64597. * @param scene defines the hosting scene
  64598. * @returns the plane polygonal mesh
  64599. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64600. */
  64601. static CreateDisc(name: string, options: {
  64602. radius?: number;
  64603. tessellation?: number;
  64604. arc?: number;
  64605. updatable?: boolean;
  64606. sideOrientation?: number;
  64607. frontUVs?: Vector4;
  64608. backUVs?: Vector4;
  64609. }, scene?: Nullable<Scene>): Mesh;
  64610. /**
  64611. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64612. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64613. * * 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`)
  64614. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64615. * * 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
  64616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64617. * * 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
  64618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64619. * @param name defines the name of the mesh
  64620. * @param options defines the options used to create the mesh
  64621. * @param scene defines the hosting scene
  64622. * @returns the icosahedron mesh
  64623. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64624. */
  64625. static CreateIcoSphere(name: string, options: {
  64626. radius?: number;
  64627. radiusX?: number;
  64628. radiusY?: number;
  64629. radiusZ?: number;
  64630. flat?: boolean;
  64631. subdivisions?: number;
  64632. sideOrientation?: number;
  64633. frontUVs?: Vector4;
  64634. backUVs?: Vector4;
  64635. updatable?: boolean;
  64636. }, scene?: Nullable<Scene>): Mesh;
  64637. /**
  64638. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64639. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64640. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64641. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64642. * * 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
  64643. * * 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
  64644. * * 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
  64645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64646. * * 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
  64647. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64648. * * 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
  64649. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64650. * * 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
  64651. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64653. * @param name defines the name of the mesh
  64654. * @param options defines the options used to create the mesh
  64655. * @param scene defines the hosting scene
  64656. * @returns the ribbon mesh
  64657. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64658. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64659. */
  64660. static CreateRibbon(name: string, options: {
  64661. pathArray: Vector3[][];
  64662. closeArray?: boolean;
  64663. closePath?: boolean;
  64664. offset?: number;
  64665. updatable?: boolean;
  64666. sideOrientation?: number;
  64667. frontUVs?: Vector4;
  64668. backUVs?: Vector4;
  64669. instance?: Mesh;
  64670. invertUV?: boolean;
  64671. uvs?: Vector2[];
  64672. colors?: Color4[];
  64673. }, scene?: Nullable<Scene>): Mesh;
  64674. /**
  64675. * Creates a cylinder or a cone mesh
  64676. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64677. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64678. * * 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.
  64679. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64680. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64681. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64682. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64683. * * 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).
  64684. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64685. * * 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).
  64686. * * 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
  64687. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64688. * * 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
  64689. * * 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.
  64690. * * If `enclose` is false, a ring surface is one element.
  64691. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64692. * * 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
  64693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64694. * * 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
  64695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64696. * @param name defines the name of the mesh
  64697. * @param options defines the options used to create the mesh
  64698. * @param scene defines the hosting scene
  64699. * @returns the cylinder mesh
  64700. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64701. */
  64702. static CreateCylinder(name: string, options: {
  64703. height?: number;
  64704. diameterTop?: number;
  64705. diameterBottom?: number;
  64706. diameter?: number;
  64707. tessellation?: number;
  64708. subdivisions?: number;
  64709. arc?: number;
  64710. faceColors?: Color4[];
  64711. faceUV?: Vector4[];
  64712. updatable?: boolean;
  64713. hasRings?: boolean;
  64714. enclose?: boolean;
  64715. cap?: number;
  64716. sideOrientation?: number;
  64717. frontUVs?: Vector4;
  64718. backUVs?: Vector4;
  64719. }, scene?: Nullable<Scene>): Mesh;
  64720. /**
  64721. * Creates a torus mesh
  64722. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64723. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64724. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64726. * * 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
  64727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64728. * @param name defines the name of the mesh
  64729. * @param options defines the options used to create the mesh
  64730. * @param scene defines the hosting scene
  64731. * @returns the torus mesh
  64732. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64733. */
  64734. static CreateTorus(name: string, options: {
  64735. diameter?: number;
  64736. thickness?: number;
  64737. tessellation?: number;
  64738. updatable?: boolean;
  64739. sideOrientation?: number;
  64740. frontUVs?: Vector4;
  64741. backUVs?: Vector4;
  64742. }, scene?: Nullable<Scene>): Mesh;
  64743. /**
  64744. * Creates a torus knot mesh
  64745. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64746. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64747. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64748. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64750. * * 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
  64751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64752. * @param name defines the name of the mesh
  64753. * @param options defines the options used to create the mesh
  64754. * @param scene defines the hosting scene
  64755. * @returns the torus knot mesh
  64756. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64757. */
  64758. static CreateTorusKnot(name: string, options: {
  64759. radius?: number;
  64760. tube?: number;
  64761. radialSegments?: number;
  64762. tubularSegments?: number;
  64763. p?: number;
  64764. q?: number;
  64765. updatable?: boolean;
  64766. sideOrientation?: number;
  64767. frontUVs?: Vector4;
  64768. backUVs?: Vector4;
  64769. }, scene?: Nullable<Scene>): Mesh;
  64770. /**
  64771. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64772. * * 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
  64773. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64774. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64775. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64776. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64777. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64778. * * 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
  64779. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64781. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64782. * @param name defines the name of the new line system
  64783. * @param options defines the options used to create the line system
  64784. * @param scene defines the hosting scene
  64785. * @returns a new line system mesh
  64786. */
  64787. static CreateLineSystem(name: string, options: {
  64788. lines: Vector3[][];
  64789. updatable?: boolean;
  64790. instance?: Nullable<LinesMesh>;
  64791. colors?: Nullable<Color4[][]>;
  64792. useVertexAlpha?: boolean;
  64793. }, scene: Nullable<Scene>): LinesMesh;
  64794. /**
  64795. * Creates a line mesh
  64796. * 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
  64797. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64798. * * The parameter `points` is an array successive Vector3
  64799. * * 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
  64800. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64801. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64802. * * When updating an instance, remember that only point positions can change, not the number of points
  64803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64804. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64805. * @param name defines the name of the new line system
  64806. * @param options defines the options used to create the line system
  64807. * @param scene defines the hosting scene
  64808. * @returns a new line mesh
  64809. */
  64810. static CreateLines(name: string, options: {
  64811. points: Vector3[];
  64812. updatable?: boolean;
  64813. instance?: Nullable<LinesMesh>;
  64814. colors?: Color4[];
  64815. useVertexAlpha?: boolean;
  64816. }, scene?: Nullable<Scene>): LinesMesh;
  64817. /**
  64818. * Creates a dashed line mesh
  64819. * * 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
  64820. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64821. * * The parameter `points` is an array successive Vector3
  64822. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64823. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64824. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64825. * * 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
  64826. * * When updating an instance, remember that only point positions can change, not the number of points
  64827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64828. * @param name defines the name of the mesh
  64829. * @param options defines the options used to create the mesh
  64830. * @param scene defines the hosting scene
  64831. * @returns the dashed line mesh
  64832. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64833. */
  64834. static CreateDashedLines(name: string, options: {
  64835. points: Vector3[];
  64836. dashSize?: number;
  64837. gapSize?: number;
  64838. dashNb?: number;
  64839. updatable?: boolean;
  64840. instance?: LinesMesh;
  64841. }, scene?: Nullable<Scene>): LinesMesh;
  64842. /**
  64843. * 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.
  64844. * * 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.
  64845. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64846. * * 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.
  64847. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64848. * * 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
  64849. * * 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
  64850. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64852. * * 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
  64853. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64855. * @param name defines the name of the mesh
  64856. * @param options defines the options used to create the mesh
  64857. * @param scene defines the hosting scene
  64858. * @returns the extruded shape mesh
  64859. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64860. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64861. */
  64862. static ExtrudeShape(name: string, options: {
  64863. shape: Vector3[];
  64864. path: Vector3[];
  64865. scale?: number;
  64866. rotation?: number;
  64867. cap?: number;
  64868. updatable?: boolean;
  64869. sideOrientation?: number;
  64870. frontUVs?: Vector4;
  64871. backUVs?: Vector4;
  64872. instance?: Mesh;
  64873. invertUV?: boolean;
  64874. }, scene?: Nullable<Scene>): Mesh;
  64875. /**
  64876. * Creates an custom extruded shape mesh.
  64877. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64878. * * 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.
  64879. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64880. * * 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
  64881. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64882. * * 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
  64883. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64884. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64885. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64886. * * 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
  64887. * * 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
  64888. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64890. * * 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
  64891. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64893. * @param name defines the name of the mesh
  64894. * @param options defines the options used to create the mesh
  64895. * @param scene defines the hosting scene
  64896. * @returns the custom extruded shape mesh
  64897. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64898. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64899. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64900. */
  64901. static ExtrudeShapeCustom(name: string, options: {
  64902. shape: Vector3[];
  64903. path: Vector3[];
  64904. scaleFunction?: any;
  64905. rotationFunction?: any;
  64906. ribbonCloseArray?: boolean;
  64907. ribbonClosePath?: boolean;
  64908. cap?: number;
  64909. updatable?: boolean;
  64910. sideOrientation?: number;
  64911. frontUVs?: Vector4;
  64912. backUVs?: Vector4;
  64913. instance?: Mesh;
  64914. invertUV?: boolean;
  64915. }, scene?: Nullable<Scene>): Mesh;
  64916. /**
  64917. * Creates lathe mesh.
  64918. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64919. * * 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
  64920. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64921. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64922. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64923. * * 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
  64924. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64925. * * 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
  64926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64927. * * 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
  64928. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64930. * @param name defines the name of the mesh
  64931. * @param options defines the options used to create the mesh
  64932. * @param scene defines the hosting scene
  64933. * @returns the lathe mesh
  64934. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64935. */
  64936. static CreateLathe(name: string, options: {
  64937. shape: Vector3[];
  64938. radius?: number;
  64939. tessellation?: number;
  64940. clip?: number;
  64941. arc?: number;
  64942. closed?: boolean;
  64943. updatable?: boolean;
  64944. sideOrientation?: number;
  64945. frontUVs?: Vector4;
  64946. backUVs?: Vector4;
  64947. cap?: number;
  64948. invertUV?: boolean;
  64949. }, scene?: Nullable<Scene>): Mesh;
  64950. /**
  64951. * Creates a tiled plane mesh
  64952. * * You can set a limited pattern arrangement with the tiles
  64953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64954. * * 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
  64955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64956. * @param name defines the name of the mesh
  64957. * @param options defines the options used to create the mesh
  64958. * @param scene defines the hosting scene
  64959. * @returns the plane mesh
  64960. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64961. */
  64962. static CreateTiledPlane(name: string, options: {
  64963. pattern?: number;
  64964. tileSize?: number;
  64965. tileWidth?: number;
  64966. tileHeight?: number;
  64967. size?: number;
  64968. width?: number;
  64969. height?: number;
  64970. alignHorizontal?: number;
  64971. alignVertical?: number;
  64972. sideOrientation?: number;
  64973. frontUVs?: Vector4;
  64974. backUVs?: Vector4;
  64975. updatable?: boolean;
  64976. }, scene?: Nullable<Scene>): Mesh;
  64977. /**
  64978. * Creates a plane mesh
  64979. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64980. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64981. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64983. * * 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
  64984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64985. * @param name defines the name of the mesh
  64986. * @param options defines the options used to create the mesh
  64987. * @param scene defines the hosting scene
  64988. * @returns the plane mesh
  64989. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64990. */
  64991. static CreatePlane(name: string, options: {
  64992. size?: number;
  64993. width?: number;
  64994. height?: number;
  64995. sideOrientation?: number;
  64996. frontUVs?: Vector4;
  64997. backUVs?: Vector4;
  64998. updatable?: boolean;
  64999. sourcePlane?: Plane;
  65000. }, scene?: Nullable<Scene>): Mesh;
  65001. /**
  65002. * Creates a ground mesh
  65003. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65004. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65006. * @param name defines the name of the mesh
  65007. * @param options defines the options used to create the mesh
  65008. * @param scene defines the hosting scene
  65009. * @returns the ground mesh
  65010. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65011. */
  65012. static CreateGround(name: string, options: {
  65013. width?: number;
  65014. height?: number;
  65015. subdivisions?: number;
  65016. subdivisionsX?: number;
  65017. subdivisionsY?: number;
  65018. updatable?: boolean;
  65019. }, scene?: Nullable<Scene>): Mesh;
  65020. /**
  65021. * Creates a tiled ground mesh
  65022. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65023. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65024. * * 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
  65025. * * 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
  65026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65027. * @param name defines the name of the mesh
  65028. * @param options defines the options used to create the mesh
  65029. * @param scene defines the hosting scene
  65030. * @returns the tiled ground mesh
  65031. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65032. */
  65033. static CreateTiledGround(name: string, options: {
  65034. xmin: number;
  65035. zmin: number;
  65036. xmax: number;
  65037. zmax: number;
  65038. subdivisions?: {
  65039. w: number;
  65040. h: number;
  65041. };
  65042. precision?: {
  65043. w: number;
  65044. h: number;
  65045. };
  65046. updatable?: boolean;
  65047. }, scene?: Nullable<Scene>): Mesh;
  65048. /**
  65049. * Creates a ground mesh from a height map
  65050. * * The parameter `url` sets the URL of the height map image resource.
  65051. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65052. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65053. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65054. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65055. * * 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.
  65056. * * 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).
  65057. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65059. * @param name defines the name of the mesh
  65060. * @param url defines the url to the height map
  65061. * @param options defines the options used to create the mesh
  65062. * @param scene defines the hosting scene
  65063. * @returns the ground mesh
  65064. * @see https://doc.babylonjs.com/babylon101/height_map
  65065. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65066. */
  65067. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65068. width?: number;
  65069. height?: number;
  65070. subdivisions?: number;
  65071. minHeight?: number;
  65072. maxHeight?: number;
  65073. colorFilter?: Color3;
  65074. alphaFilter?: number;
  65075. updatable?: boolean;
  65076. onReady?: (mesh: GroundMesh) => void;
  65077. }, scene?: Nullable<Scene>): GroundMesh;
  65078. /**
  65079. * Creates a polygon mesh
  65080. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65081. * * 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
  65082. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65084. * * 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)
  65085. * * Remember you can only change the shape positions, not their number when updating a polygon
  65086. * @param name defines the name of the mesh
  65087. * @param options defines the options used to create the mesh
  65088. * @param scene defines the hosting scene
  65089. * @param earcutInjection can be used to inject your own earcut reference
  65090. * @returns the polygon mesh
  65091. */
  65092. static CreatePolygon(name: string, options: {
  65093. shape: Vector3[];
  65094. holes?: Vector3[][];
  65095. depth?: number;
  65096. faceUV?: Vector4[];
  65097. faceColors?: Color4[];
  65098. updatable?: boolean;
  65099. sideOrientation?: number;
  65100. frontUVs?: Vector4;
  65101. backUVs?: Vector4;
  65102. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65103. /**
  65104. * Creates an extruded polygon mesh, with depth in the Y direction.
  65105. * * 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)
  65106. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65107. * @param name defines the name of the mesh
  65108. * @param options defines the options used to create the mesh
  65109. * @param scene defines the hosting scene
  65110. * @param earcutInjection can be used to inject your own earcut reference
  65111. * @returns the polygon mesh
  65112. */
  65113. static ExtrudePolygon(name: string, options: {
  65114. shape: Vector3[];
  65115. holes?: Vector3[][];
  65116. depth?: number;
  65117. faceUV?: Vector4[];
  65118. faceColors?: Color4[];
  65119. updatable?: boolean;
  65120. sideOrientation?: number;
  65121. frontUVs?: Vector4;
  65122. backUVs?: Vector4;
  65123. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65124. /**
  65125. * Creates a tube mesh.
  65126. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65127. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65128. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65129. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65130. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65131. * * 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)
  65132. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65133. * * 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
  65134. * * 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
  65135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65136. * * 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
  65137. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65139. * @param name defines the name of the mesh
  65140. * @param options defines the options used to create the mesh
  65141. * @param scene defines the hosting scene
  65142. * @returns the tube mesh
  65143. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65144. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65145. */
  65146. static CreateTube(name: string, options: {
  65147. path: Vector3[];
  65148. radius?: number;
  65149. tessellation?: number;
  65150. radiusFunction?: {
  65151. (i: number, distance: number): number;
  65152. };
  65153. cap?: number;
  65154. arc?: number;
  65155. updatable?: boolean;
  65156. sideOrientation?: number;
  65157. frontUVs?: Vector4;
  65158. backUVs?: Vector4;
  65159. instance?: Mesh;
  65160. invertUV?: boolean;
  65161. }, scene?: Nullable<Scene>): Mesh;
  65162. /**
  65163. * Creates a polyhedron mesh
  65164. * * 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
  65165. * * The parameter `size` (positive float, default 1) sets the polygon size
  65166. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65167. * * 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`
  65168. * * 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
  65169. * * 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)`)
  65170. * * 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
  65171. * * 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
  65172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65173. * * 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
  65174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65175. * @param name defines the name of the mesh
  65176. * @param options defines the options used to create the mesh
  65177. * @param scene defines the hosting scene
  65178. * @returns the polyhedron mesh
  65179. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65180. */
  65181. static CreatePolyhedron(name: string, options: {
  65182. type?: number;
  65183. size?: number;
  65184. sizeX?: number;
  65185. sizeY?: number;
  65186. sizeZ?: number;
  65187. custom?: any;
  65188. faceUV?: Vector4[];
  65189. faceColors?: Color4[];
  65190. flat?: boolean;
  65191. updatable?: boolean;
  65192. sideOrientation?: number;
  65193. frontUVs?: Vector4;
  65194. backUVs?: Vector4;
  65195. }, scene?: Nullable<Scene>): Mesh;
  65196. /**
  65197. * Creates a decal mesh.
  65198. * 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
  65199. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65200. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65201. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65202. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65203. * @param name defines the name of the mesh
  65204. * @param sourceMesh defines the mesh where the decal must be applied
  65205. * @param options defines the options used to create the mesh
  65206. * @param scene defines the hosting scene
  65207. * @returns the decal mesh
  65208. * @see https://doc.babylonjs.com/how_to/decals
  65209. */
  65210. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65211. position?: Vector3;
  65212. normal?: Vector3;
  65213. size?: Vector3;
  65214. angle?: number;
  65215. }): Mesh;
  65216. }
  65217. }
  65218. declare module BABYLON {
  65219. /**
  65220. * A simplifier interface for future simplification implementations
  65221. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65222. */
  65223. export interface ISimplifier {
  65224. /**
  65225. * Simplification of a given mesh according to the given settings.
  65226. * Since this requires computation, it is assumed that the function runs async.
  65227. * @param settings The settings of the simplification, including quality and distance
  65228. * @param successCallback A callback that will be called after the mesh was simplified.
  65229. * @param errorCallback in case of an error, this callback will be called. optional.
  65230. */
  65231. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65232. }
  65233. /**
  65234. * Expected simplification settings.
  65235. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65236. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65237. */
  65238. export interface ISimplificationSettings {
  65239. /**
  65240. * Gets or sets the expected quality
  65241. */
  65242. quality: number;
  65243. /**
  65244. * Gets or sets the distance when this optimized version should be used
  65245. */
  65246. distance: number;
  65247. /**
  65248. * Gets an already optimized mesh
  65249. */
  65250. optimizeMesh?: boolean;
  65251. }
  65252. /**
  65253. * Class used to specify simplification options
  65254. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65255. */
  65256. export class SimplificationSettings implements ISimplificationSettings {
  65257. /** expected quality */
  65258. quality: number;
  65259. /** distance when this optimized version should be used */
  65260. distance: number;
  65261. /** already optimized mesh */
  65262. optimizeMesh?: boolean | undefined;
  65263. /**
  65264. * Creates a SimplificationSettings
  65265. * @param quality expected quality
  65266. * @param distance distance when this optimized version should be used
  65267. * @param optimizeMesh already optimized mesh
  65268. */
  65269. constructor(
  65270. /** expected quality */
  65271. quality: number,
  65272. /** distance when this optimized version should be used */
  65273. distance: number,
  65274. /** already optimized mesh */
  65275. optimizeMesh?: boolean | undefined);
  65276. }
  65277. /**
  65278. * Interface used to define a simplification task
  65279. */
  65280. export interface ISimplificationTask {
  65281. /**
  65282. * Array of settings
  65283. */
  65284. settings: Array<ISimplificationSettings>;
  65285. /**
  65286. * Simplification type
  65287. */
  65288. simplificationType: SimplificationType;
  65289. /**
  65290. * Mesh to simplify
  65291. */
  65292. mesh: Mesh;
  65293. /**
  65294. * Callback called on success
  65295. */
  65296. successCallback?: () => void;
  65297. /**
  65298. * Defines if parallel processing can be used
  65299. */
  65300. parallelProcessing: boolean;
  65301. }
  65302. /**
  65303. * Queue used to order the simplification tasks
  65304. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65305. */
  65306. export class SimplificationQueue {
  65307. private _simplificationArray;
  65308. /**
  65309. * Gets a boolean indicating that the process is still running
  65310. */
  65311. running: boolean;
  65312. /**
  65313. * Creates a new queue
  65314. */
  65315. constructor();
  65316. /**
  65317. * Adds a new simplification task
  65318. * @param task defines a task to add
  65319. */
  65320. addTask(task: ISimplificationTask): void;
  65321. /**
  65322. * Execute next task
  65323. */
  65324. executeNext(): void;
  65325. /**
  65326. * Execute a simplification task
  65327. * @param task defines the task to run
  65328. */
  65329. runSimplification(task: ISimplificationTask): void;
  65330. private getSimplifier;
  65331. }
  65332. /**
  65333. * The implemented types of simplification
  65334. * At the moment only Quadratic Error Decimation is implemented
  65335. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65336. */
  65337. export enum SimplificationType {
  65338. /** Quadratic error decimation */
  65339. QUADRATIC = 0
  65340. }
  65341. /**
  65342. * An implementation of the Quadratic Error simplification algorithm.
  65343. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65344. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65345. * @author RaananW
  65346. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65347. */
  65348. export class QuadraticErrorSimplification implements ISimplifier {
  65349. private _mesh;
  65350. private triangles;
  65351. private vertices;
  65352. private references;
  65353. private _reconstructedMesh;
  65354. /** Gets or sets the number pf sync interations */
  65355. syncIterations: number;
  65356. /** Gets or sets the aggressiveness of the simplifier */
  65357. aggressiveness: number;
  65358. /** Gets or sets the number of allowed iterations for decimation */
  65359. decimationIterations: number;
  65360. /** Gets or sets the espilon to use for bounding box computation */
  65361. boundingBoxEpsilon: number;
  65362. /**
  65363. * Creates a new QuadraticErrorSimplification
  65364. * @param _mesh defines the target mesh
  65365. */
  65366. constructor(_mesh: Mesh);
  65367. /**
  65368. * Simplification of a given mesh according to the given settings.
  65369. * Since this requires computation, it is assumed that the function runs async.
  65370. * @param settings The settings of the simplification, including quality and distance
  65371. * @param successCallback A callback that will be called after the mesh was simplified.
  65372. */
  65373. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65374. private runDecimation;
  65375. private initWithMesh;
  65376. private init;
  65377. private reconstructMesh;
  65378. private initDecimatedMesh;
  65379. private isFlipped;
  65380. private updateTriangles;
  65381. private identifyBorder;
  65382. private updateMesh;
  65383. private vertexError;
  65384. private calculateError;
  65385. }
  65386. }
  65387. declare module BABYLON {
  65388. interface Scene {
  65389. /** @hidden (Backing field) */
  65390. _simplificationQueue: SimplificationQueue;
  65391. /**
  65392. * Gets or sets the simplification queue attached to the scene
  65393. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65394. */
  65395. simplificationQueue: SimplificationQueue;
  65396. }
  65397. interface Mesh {
  65398. /**
  65399. * Simplify the mesh according to the given array of settings.
  65400. * Function will return immediately and will simplify async
  65401. * @param settings a collection of simplification settings
  65402. * @param parallelProcessing should all levels calculate parallel or one after the other
  65403. * @param simplificationType the type of simplification to run
  65404. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65405. * @returns the current mesh
  65406. */
  65407. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65408. }
  65409. /**
  65410. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65411. * created in a scene
  65412. */
  65413. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65414. /**
  65415. * The component name helpfull to identify the component in the list of scene components.
  65416. */
  65417. readonly name: string;
  65418. /**
  65419. * The scene the component belongs to.
  65420. */
  65421. scene: Scene;
  65422. /**
  65423. * Creates a new instance of the component for the given scene
  65424. * @param scene Defines the scene to register the component in
  65425. */
  65426. constructor(scene: Scene);
  65427. /**
  65428. * Registers the component in a given scene
  65429. */
  65430. register(): void;
  65431. /**
  65432. * Rebuilds the elements related to this component in case of
  65433. * context lost for instance.
  65434. */
  65435. rebuild(): void;
  65436. /**
  65437. * Disposes the component and the associated ressources
  65438. */
  65439. dispose(): void;
  65440. private _beforeCameraUpdate;
  65441. }
  65442. }
  65443. declare module BABYLON {
  65444. interface Mesh {
  65445. /**
  65446. * Creates a new thin instance
  65447. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65448. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  65449. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65450. */
  65451. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65452. /**
  65453. * Adds the transformation (matrix) of the current mesh as a thin instance
  65454. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  65455. * @returns the thin instance index number
  65456. */
  65457. thinInstanceAddSelf(refresh: boolean): number;
  65458. /**
  65459. * Registers a custom attribute to be used with thin instances
  65460. * @param kind name of the attribute
  65461. * @param stride size in floats of the attribute
  65462. */
  65463. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65464. /**
  65465. * Sets the matrix of a thin instance
  65466. * @param index index of the thin instance
  65467. * @param matrix matrix to set
  65468. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  65469. */
  65470. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65471. /**
  65472. * Sets the value of a custom attribute for a thin instance
  65473. * @param kind name of the attribute
  65474. * @param index index of the thin instance
  65475. * @param value value to set
  65476. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  65477. */
  65478. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65479. /**
  65480. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  65481. */
  65482. thinInstanceCount: number;
  65483. /**
  65484. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65485. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65486. * @param buffer buffer to set
  65487. * @param stride size in floats of each value of the buffer
  65488. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65489. */
  65490. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65491. /**
  65492. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65493. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65494. */
  65495. thinInstanceBufferUpdated(kind: string): void;
  65496. /**
  65497. * Refreshes the bounding info, taking into account all the thin instances defined
  65498. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65499. */
  65500. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65501. /** @hidden */
  65502. _thinInstanceInitializeUserStorage(): void;
  65503. /** @hidden */
  65504. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65505. /** @hidden */
  65506. _userThinInstanceBuffersStorage: {
  65507. data: {
  65508. [key: string]: Float32Array;
  65509. };
  65510. sizes: {
  65511. [key: string]: number;
  65512. };
  65513. vertexBuffers: {
  65514. [key: string]: Nullable<VertexBuffer>;
  65515. };
  65516. strides: {
  65517. [key: string]: number;
  65518. };
  65519. };
  65520. }
  65521. }
  65522. declare module BABYLON {
  65523. /**
  65524. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65525. */
  65526. export interface INavigationEnginePlugin {
  65527. /**
  65528. * plugin name
  65529. */
  65530. name: string;
  65531. /**
  65532. * Creates a navigation mesh
  65533. * @param meshes array of all the geometry used to compute the navigatio mesh
  65534. * @param parameters bunch of parameters used to filter geometry
  65535. */
  65536. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65537. /**
  65538. * Create a navigation mesh debug mesh
  65539. * @param scene is where the mesh will be added
  65540. * @returns debug display mesh
  65541. */
  65542. createDebugNavMesh(scene: Scene): Mesh;
  65543. /**
  65544. * Get a navigation mesh constrained position, closest to the parameter position
  65545. * @param position world position
  65546. * @returns the closest point to position constrained by the navigation mesh
  65547. */
  65548. getClosestPoint(position: Vector3): Vector3;
  65549. /**
  65550. * Get a navigation mesh constrained position, closest to the parameter position
  65551. * @param position world position
  65552. * @param result output the closest point to position constrained by the navigation mesh
  65553. */
  65554. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65555. /**
  65556. * Get a navigation mesh constrained position, within a particular radius
  65557. * @param position world position
  65558. * @param maxRadius the maximum distance to the constrained world position
  65559. * @returns the closest point to position constrained by the navigation mesh
  65560. */
  65561. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65562. /**
  65563. * Get a navigation mesh constrained position, within a particular radius
  65564. * @param position world position
  65565. * @param maxRadius the maximum distance to the constrained world position
  65566. * @param result output the closest point to position constrained by the navigation mesh
  65567. */
  65568. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65569. /**
  65570. * Compute the final position from a segment made of destination-position
  65571. * @param position world position
  65572. * @param destination world position
  65573. * @returns the resulting point along the navmesh
  65574. */
  65575. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65576. /**
  65577. * Compute the final position from a segment made of destination-position
  65578. * @param position world position
  65579. * @param destination world position
  65580. * @param result output the resulting point along the navmesh
  65581. */
  65582. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65583. /**
  65584. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65585. * @param start world position
  65586. * @param end world position
  65587. * @returns array containing world position composing the path
  65588. */
  65589. computePath(start: Vector3, end: Vector3): Vector3[];
  65590. /**
  65591. * If this plugin is supported
  65592. * @returns true if plugin is supported
  65593. */
  65594. isSupported(): boolean;
  65595. /**
  65596. * Create a new Crowd so you can add agents
  65597. * @param maxAgents the maximum agent count in the crowd
  65598. * @param maxAgentRadius the maximum radius an agent can have
  65599. * @param scene to attach the crowd to
  65600. * @returns the crowd you can add agents to
  65601. */
  65602. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65603. /**
  65604. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65605. * The queries will try to find a solution within those bounds
  65606. * default is (1,1,1)
  65607. * @param extent x,y,z value that define the extent around the queries point of reference
  65608. */
  65609. setDefaultQueryExtent(extent: Vector3): void;
  65610. /**
  65611. * Get the Bounding box extent specified by setDefaultQueryExtent
  65612. * @returns the box extent values
  65613. */
  65614. getDefaultQueryExtent(): Vector3;
  65615. /**
  65616. * build the navmesh from a previously saved state using getNavmeshData
  65617. * @param data the Uint8Array returned by getNavmeshData
  65618. */
  65619. buildFromNavmeshData(data: Uint8Array): void;
  65620. /**
  65621. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65622. * @returns data the Uint8Array that can be saved and reused
  65623. */
  65624. getNavmeshData(): Uint8Array;
  65625. /**
  65626. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65627. * @param result output the box extent values
  65628. */
  65629. getDefaultQueryExtentToRef(result: Vector3): void;
  65630. /**
  65631. * Release all resources
  65632. */
  65633. dispose(): void;
  65634. }
  65635. /**
  65636. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65637. */
  65638. export interface ICrowd {
  65639. /**
  65640. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65641. * You can attach anything to that node. The node position is updated in the scene update tick.
  65642. * @param pos world position that will be constrained by the navigation mesh
  65643. * @param parameters agent parameters
  65644. * @param transform hooked to the agent that will be update by the scene
  65645. * @returns agent index
  65646. */
  65647. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65648. /**
  65649. * Returns the agent position in world space
  65650. * @param index agent index returned by addAgent
  65651. * @returns world space position
  65652. */
  65653. getAgentPosition(index: number): Vector3;
  65654. /**
  65655. * Gets the agent position result in world space
  65656. * @param index agent index returned by addAgent
  65657. * @param result output world space position
  65658. */
  65659. getAgentPositionToRef(index: number, result: Vector3): void;
  65660. /**
  65661. * Gets the agent velocity in world space
  65662. * @param index agent index returned by addAgent
  65663. * @returns world space velocity
  65664. */
  65665. getAgentVelocity(index: number): Vector3;
  65666. /**
  65667. * Gets the agent velocity result in world space
  65668. * @param index agent index returned by addAgent
  65669. * @param result output world space velocity
  65670. */
  65671. getAgentVelocityToRef(index: number, result: Vector3): void;
  65672. /**
  65673. * remove a particular agent previously created
  65674. * @param index agent index returned by addAgent
  65675. */
  65676. removeAgent(index: number): void;
  65677. /**
  65678. * get the list of all agents attached to this crowd
  65679. * @returns list of agent indices
  65680. */
  65681. getAgents(): number[];
  65682. /**
  65683. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65684. * @param deltaTime in seconds
  65685. */
  65686. update(deltaTime: number): void;
  65687. /**
  65688. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65689. * @param index agent index returned by addAgent
  65690. * @param destination targeted world position
  65691. */
  65692. agentGoto(index: number, destination: Vector3): void;
  65693. /**
  65694. * Teleport the agent to a new position
  65695. * @param index agent index returned by addAgent
  65696. * @param destination targeted world position
  65697. */
  65698. agentTeleport(index: number, destination: Vector3): void;
  65699. /**
  65700. * Update agent parameters
  65701. * @param index agent index returned by addAgent
  65702. * @param parameters agent parameters
  65703. */
  65704. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65705. /**
  65706. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65707. * The queries will try to find a solution within those bounds
  65708. * default is (1,1,1)
  65709. * @param extent x,y,z value that define the extent around the queries point of reference
  65710. */
  65711. setDefaultQueryExtent(extent: Vector3): void;
  65712. /**
  65713. * Get the Bounding box extent specified by setDefaultQueryExtent
  65714. * @returns the box extent values
  65715. */
  65716. getDefaultQueryExtent(): Vector3;
  65717. /**
  65718. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65719. * @param result output the box extent values
  65720. */
  65721. getDefaultQueryExtentToRef(result: Vector3): void;
  65722. /**
  65723. * Release all resources
  65724. */
  65725. dispose(): void;
  65726. }
  65727. /**
  65728. * Configures an agent
  65729. */
  65730. export interface IAgentParameters {
  65731. /**
  65732. * Agent radius. [Limit: >= 0]
  65733. */
  65734. radius: number;
  65735. /**
  65736. * Agent height. [Limit: > 0]
  65737. */
  65738. height: number;
  65739. /**
  65740. * Maximum allowed acceleration. [Limit: >= 0]
  65741. */
  65742. maxAcceleration: number;
  65743. /**
  65744. * Maximum allowed speed. [Limit: >= 0]
  65745. */
  65746. maxSpeed: number;
  65747. /**
  65748. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65749. */
  65750. collisionQueryRange: number;
  65751. /**
  65752. * The path visibility optimization range. [Limit: > 0]
  65753. */
  65754. pathOptimizationRange: number;
  65755. /**
  65756. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65757. */
  65758. separationWeight: number;
  65759. }
  65760. /**
  65761. * Configures the navigation mesh creation
  65762. */
  65763. export interface INavMeshParameters {
  65764. /**
  65765. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65766. */
  65767. cs: number;
  65768. /**
  65769. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65770. */
  65771. ch: number;
  65772. /**
  65773. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65774. */
  65775. walkableSlopeAngle: number;
  65776. /**
  65777. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65778. * be considered walkable. [Limit: >= 3] [Units: vx]
  65779. */
  65780. walkableHeight: number;
  65781. /**
  65782. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65783. */
  65784. walkableClimb: number;
  65785. /**
  65786. * The distance to erode/shrink the walkable area of the heightfield away from
  65787. * obstructions. [Limit: >=0] [Units: vx]
  65788. */
  65789. walkableRadius: number;
  65790. /**
  65791. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65792. */
  65793. maxEdgeLen: number;
  65794. /**
  65795. * The maximum distance a simplfied contour's border edges should deviate
  65796. * the original raw contour. [Limit: >=0] [Units: vx]
  65797. */
  65798. maxSimplificationError: number;
  65799. /**
  65800. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65801. */
  65802. minRegionArea: number;
  65803. /**
  65804. * Any regions with a span count smaller than this value will, if possible,
  65805. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65806. */
  65807. mergeRegionArea: number;
  65808. /**
  65809. * The maximum number of vertices allowed for polygons generated during the
  65810. * contour to polygon conversion process. [Limit: >= 3]
  65811. */
  65812. maxVertsPerPoly: number;
  65813. /**
  65814. * Sets the sampling distance to use when generating the detail mesh.
  65815. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65816. */
  65817. detailSampleDist: number;
  65818. /**
  65819. * The maximum distance the detail mesh surface should deviate from heightfield
  65820. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65821. */
  65822. detailSampleMaxError: number;
  65823. }
  65824. }
  65825. declare module BABYLON {
  65826. /**
  65827. * RecastJS navigation plugin
  65828. */
  65829. export class RecastJSPlugin implements INavigationEnginePlugin {
  65830. /**
  65831. * Reference to the Recast library
  65832. */
  65833. bjsRECAST: any;
  65834. /**
  65835. * plugin name
  65836. */
  65837. name: string;
  65838. /**
  65839. * the first navmesh created. We might extend this to support multiple navmeshes
  65840. */
  65841. navMesh: any;
  65842. /**
  65843. * Initializes the recastJS plugin
  65844. * @param recastInjection can be used to inject your own recast reference
  65845. */
  65846. constructor(recastInjection?: any);
  65847. /**
  65848. * Creates a navigation mesh
  65849. * @param meshes array of all the geometry used to compute the navigatio mesh
  65850. * @param parameters bunch of parameters used to filter geometry
  65851. */
  65852. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65853. /**
  65854. * Create a navigation mesh debug mesh
  65855. * @param scene is where the mesh will be added
  65856. * @returns debug display mesh
  65857. */
  65858. createDebugNavMesh(scene: Scene): Mesh;
  65859. /**
  65860. * Get a navigation mesh constrained position, closest to the parameter position
  65861. * @param position world position
  65862. * @returns the closest point to position constrained by the navigation mesh
  65863. */
  65864. getClosestPoint(position: Vector3): Vector3;
  65865. /**
  65866. * Get a navigation mesh constrained position, closest to the parameter position
  65867. * @param position world position
  65868. * @param result output the closest point to position constrained by the navigation mesh
  65869. */
  65870. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65871. /**
  65872. * Get a navigation mesh constrained position, within a particular radius
  65873. * @param position world position
  65874. * @param maxRadius the maximum distance to the constrained world position
  65875. * @returns the closest point to position constrained by the navigation mesh
  65876. */
  65877. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65878. /**
  65879. * Get a navigation mesh constrained position, within a particular radius
  65880. * @param position world position
  65881. * @param maxRadius the maximum distance to the constrained world position
  65882. * @param result output the closest point to position constrained by the navigation mesh
  65883. */
  65884. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65885. /**
  65886. * Compute the final position from a segment made of destination-position
  65887. * @param position world position
  65888. * @param destination world position
  65889. * @returns the resulting point along the navmesh
  65890. */
  65891. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65892. /**
  65893. * Compute the final position from a segment made of destination-position
  65894. * @param position world position
  65895. * @param destination world position
  65896. * @param result output the resulting point along the navmesh
  65897. */
  65898. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65899. /**
  65900. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65901. * @param start world position
  65902. * @param end world position
  65903. * @returns array containing world position composing the path
  65904. */
  65905. computePath(start: Vector3, end: Vector3): Vector3[];
  65906. /**
  65907. * Create a new Crowd so you can add agents
  65908. * @param maxAgents the maximum agent count in the crowd
  65909. * @param maxAgentRadius the maximum radius an agent can have
  65910. * @param scene to attach the crowd to
  65911. * @returns the crowd you can add agents to
  65912. */
  65913. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65914. /**
  65915. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65916. * The queries will try to find a solution within those bounds
  65917. * default is (1,1,1)
  65918. * @param extent x,y,z value that define the extent around the queries point of reference
  65919. */
  65920. setDefaultQueryExtent(extent: Vector3): void;
  65921. /**
  65922. * Get the Bounding box extent specified by setDefaultQueryExtent
  65923. * @returns the box extent values
  65924. */
  65925. getDefaultQueryExtent(): Vector3;
  65926. /**
  65927. * build the navmesh from a previously saved state using getNavmeshData
  65928. * @param data the Uint8Array returned by getNavmeshData
  65929. */
  65930. buildFromNavmeshData(data: Uint8Array): void;
  65931. /**
  65932. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65933. * @returns data the Uint8Array that can be saved and reused
  65934. */
  65935. getNavmeshData(): Uint8Array;
  65936. /**
  65937. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65938. * @param result output the box extent values
  65939. */
  65940. getDefaultQueryExtentToRef(result: Vector3): void;
  65941. /**
  65942. * Disposes
  65943. */
  65944. dispose(): void;
  65945. /**
  65946. * If this plugin is supported
  65947. * @returns true if plugin is supported
  65948. */
  65949. isSupported(): boolean;
  65950. }
  65951. /**
  65952. * Recast detour crowd implementation
  65953. */
  65954. export class RecastJSCrowd implements ICrowd {
  65955. /**
  65956. * Recast/detour plugin
  65957. */
  65958. bjsRECASTPlugin: RecastJSPlugin;
  65959. /**
  65960. * Link to the detour crowd
  65961. */
  65962. recastCrowd: any;
  65963. /**
  65964. * One transform per agent
  65965. */
  65966. transforms: TransformNode[];
  65967. /**
  65968. * All agents created
  65969. */
  65970. agents: number[];
  65971. /**
  65972. * Link to the scene is kept to unregister the crowd from the scene
  65973. */
  65974. private _scene;
  65975. /**
  65976. * Observer for crowd updates
  65977. */
  65978. private _onBeforeAnimationsObserver;
  65979. /**
  65980. * Constructor
  65981. * @param plugin recastJS plugin
  65982. * @param maxAgents the maximum agent count in the crowd
  65983. * @param maxAgentRadius the maximum radius an agent can have
  65984. * @param scene to attach the crowd to
  65985. * @returns the crowd you can add agents to
  65986. */
  65987. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65988. /**
  65989. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65990. * You can attach anything to that node. The node position is updated in the scene update tick.
  65991. * @param pos world position that will be constrained by the navigation mesh
  65992. * @param parameters agent parameters
  65993. * @param transform hooked to the agent that will be update by the scene
  65994. * @returns agent index
  65995. */
  65996. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65997. /**
  65998. * Returns the agent position in world space
  65999. * @param index agent index returned by addAgent
  66000. * @returns world space position
  66001. */
  66002. getAgentPosition(index: number): Vector3;
  66003. /**
  66004. * Returns the agent position result in world space
  66005. * @param index agent index returned by addAgent
  66006. * @param result output world space position
  66007. */
  66008. getAgentPositionToRef(index: number, result: Vector3): void;
  66009. /**
  66010. * Returns the agent velocity in world space
  66011. * @param index agent index returned by addAgent
  66012. * @returns world space velocity
  66013. */
  66014. getAgentVelocity(index: number): Vector3;
  66015. /**
  66016. * Returns the agent velocity result in world space
  66017. * @param index agent index returned by addAgent
  66018. * @param result output world space velocity
  66019. */
  66020. getAgentVelocityToRef(index: number, result: Vector3): void;
  66021. /**
  66022. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66023. * @param index agent index returned by addAgent
  66024. * @param destination targeted world position
  66025. */
  66026. agentGoto(index: number, destination: Vector3): void;
  66027. /**
  66028. * Teleport the agent to a new position
  66029. * @param index agent index returned by addAgent
  66030. * @param destination targeted world position
  66031. */
  66032. agentTeleport(index: number, destination: Vector3): void;
  66033. /**
  66034. * Update agent parameters
  66035. * @param index agent index returned by addAgent
  66036. * @param parameters agent parameters
  66037. */
  66038. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66039. /**
  66040. * remove a particular agent previously created
  66041. * @param index agent index returned by addAgent
  66042. */
  66043. removeAgent(index: number): void;
  66044. /**
  66045. * get the list of all agents attached to this crowd
  66046. * @returns list of agent indices
  66047. */
  66048. getAgents(): number[];
  66049. /**
  66050. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66051. * @param deltaTime in seconds
  66052. */
  66053. update(deltaTime: number): void;
  66054. /**
  66055. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66056. * The queries will try to find a solution within those bounds
  66057. * default is (1,1,1)
  66058. * @param extent x,y,z value that define the extent around the queries point of reference
  66059. */
  66060. setDefaultQueryExtent(extent: Vector3): void;
  66061. /**
  66062. * Get the Bounding box extent specified by setDefaultQueryExtent
  66063. * @returns the box extent values
  66064. */
  66065. getDefaultQueryExtent(): Vector3;
  66066. /**
  66067. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66068. * @param result output the box extent values
  66069. */
  66070. getDefaultQueryExtentToRef(result: Vector3): void;
  66071. /**
  66072. * Release all resources
  66073. */
  66074. dispose(): void;
  66075. }
  66076. }
  66077. declare module BABYLON {
  66078. /**
  66079. * Class used to enable access to IndexedDB
  66080. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66081. */
  66082. export class Database implements IOfflineProvider {
  66083. private _callbackManifestChecked;
  66084. private _currentSceneUrl;
  66085. private _db;
  66086. private _enableSceneOffline;
  66087. private _enableTexturesOffline;
  66088. private _manifestVersionFound;
  66089. private _mustUpdateRessources;
  66090. private _hasReachedQuota;
  66091. private _isSupported;
  66092. private _idbFactory;
  66093. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66094. private static IsUASupportingBlobStorage;
  66095. /**
  66096. * Gets a boolean indicating if Database storate is enabled (off by default)
  66097. */
  66098. static IDBStorageEnabled: boolean;
  66099. /**
  66100. * Gets a boolean indicating if scene must be saved in the database
  66101. */
  66102. get enableSceneOffline(): boolean;
  66103. /**
  66104. * Gets a boolean indicating if textures must be saved in the database
  66105. */
  66106. get enableTexturesOffline(): boolean;
  66107. /**
  66108. * Creates a new Database
  66109. * @param urlToScene defines the url to load the scene
  66110. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66111. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66112. */
  66113. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66114. private static _ParseURL;
  66115. private static _ReturnFullUrlLocation;
  66116. private _checkManifestFile;
  66117. /**
  66118. * Open the database and make it available
  66119. * @param successCallback defines the callback to call on success
  66120. * @param errorCallback defines the callback to call on error
  66121. */
  66122. open(successCallback: () => void, errorCallback: () => void): void;
  66123. /**
  66124. * Loads an image from the database
  66125. * @param url defines the url to load from
  66126. * @param image defines the target DOM image
  66127. */
  66128. loadImage(url: string, image: HTMLImageElement): void;
  66129. private _loadImageFromDBAsync;
  66130. private _saveImageIntoDBAsync;
  66131. private _checkVersionFromDB;
  66132. private _loadVersionFromDBAsync;
  66133. private _saveVersionIntoDBAsync;
  66134. /**
  66135. * Loads a file from database
  66136. * @param url defines the URL to load from
  66137. * @param sceneLoaded defines a callback to call on success
  66138. * @param progressCallBack defines a callback to call when progress changed
  66139. * @param errorCallback defines a callback to call on error
  66140. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66141. */
  66142. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66143. private _loadFileAsync;
  66144. private _saveFileAsync;
  66145. /**
  66146. * Validates if xhr data is correct
  66147. * @param xhr defines the request to validate
  66148. * @param dataType defines the expected data type
  66149. * @returns true if data is correct
  66150. */
  66151. private static _ValidateXHRData;
  66152. }
  66153. }
  66154. declare module BABYLON {
  66155. /** @hidden */
  66156. export var gpuUpdateParticlesPixelShader: {
  66157. name: string;
  66158. shader: string;
  66159. };
  66160. }
  66161. declare module BABYLON {
  66162. /** @hidden */
  66163. export var gpuUpdateParticlesVertexShader: {
  66164. name: string;
  66165. shader: string;
  66166. };
  66167. }
  66168. declare module BABYLON {
  66169. /** @hidden */
  66170. export var clipPlaneFragmentDeclaration2: {
  66171. name: string;
  66172. shader: string;
  66173. };
  66174. }
  66175. declare module BABYLON {
  66176. /** @hidden */
  66177. export var gpuRenderParticlesPixelShader: {
  66178. name: string;
  66179. shader: string;
  66180. };
  66181. }
  66182. declare module BABYLON {
  66183. /** @hidden */
  66184. export var clipPlaneVertexDeclaration2: {
  66185. name: string;
  66186. shader: string;
  66187. };
  66188. }
  66189. declare module BABYLON {
  66190. /** @hidden */
  66191. export var gpuRenderParticlesVertexShader: {
  66192. name: string;
  66193. shader: string;
  66194. };
  66195. }
  66196. declare module BABYLON {
  66197. /**
  66198. * This represents a GPU particle system in Babylon
  66199. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66200. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66201. */
  66202. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66203. /**
  66204. * The layer mask we are rendering the particles through.
  66205. */
  66206. layerMask: number;
  66207. private _capacity;
  66208. private _activeCount;
  66209. private _currentActiveCount;
  66210. private _accumulatedCount;
  66211. private _renderEffect;
  66212. private _updateEffect;
  66213. private _buffer0;
  66214. private _buffer1;
  66215. private _spriteBuffer;
  66216. private _updateVAO;
  66217. private _renderVAO;
  66218. private _targetIndex;
  66219. private _sourceBuffer;
  66220. private _targetBuffer;
  66221. private _engine;
  66222. private _currentRenderId;
  66223. private _started;
  66224. private _stopped;
  66225. private _timeDelta;
  66226. private _randomTexture;
  66227. private _randomTexture2;
  66228. private _attributesStrideSize;
  66229. private _updateEffectOptions;
  66230. private _randomTextureSize;
  66231. private _actualFrame;
  66232. private _customEffect;
  66233. private readonly _rawTextureWidth;
  66234. /**
  66235. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66236. */
  66237. static get IsSupported(): boolean;
  66238. /**
  66239. * An event triggered when the system is disposed.
  66240. */
  66241. onDisposeObservable: Observable<IParticleSystem>;
  66242. /**
  66243. * Gets the maximum number of particles active at the same time.
  66244. * @returns The max number of active particles.
  66245. */
  66246. getCapacity(): number;
  66247. /**
  66248. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66249. * to override the particles.
  66250. */
  66251. forceDepthWrite: boolean;
  66252. /**
  66253. * Gets or set the number of active particles
  66254. */
  66255. get activeParticleCount(): number;
  66256. set activeParticleCount(value: number);
  66257. private _preWarmDone;
  66258. /**
  66259. * Specifies if the particles are updated in emitter local space or world space.
  66260. */
  66261. isLocal: boolean;
  66262. /**
  66263. * Is this system ready to be used/rendered
  66264. * @return true if the system is ready
  66265. */
  66266. isReady(): boolean;
  66267. /**
  66268. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66269. * @returns True if it has been started, otherwise false.
  66270. */
  66271. isStarted(): boolean;
  66272. /**
  66273. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66274. * @returns True if it has been stopped, otherwise false.
  66275. */
  66276. isStopped(): boolean;
  66277. /**
  66278. * Gets a boolean indicating that the system is stopping
  66279. * @returns true if the system is currently stopping
  66280. */
  66281. isStopping(): boolean;
  66282. /**
  66283. * Gets the number of particles active at the same time.
  66284. * @returns The number of active particles.
  66285. */
  66286. getActiveCount(): number;
  66287. /**
  66288. * Starts the particle system and begins to emit
  66289. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66290. */
  66291. start(delay?: number): void;
  66292. /**
  66293. * Stops the particle system.
  66294. */
  66295. stop(): void;
  66296. /**
  66297. * Remove all active particles
  66298. */
  66299. reset(): void;
  66300. /**
  66301. * Returns the string "GPUParticleSystem"
  66302. * @returns a string containing the class name
  66303. */
  66304. getClassName(): string;
  66305. /**
  66306. * Gets the custom effect used to render the particles
  66307. * @param blendMode Blend mode for which the effect should be retrieved
  66308. * @returns The effect
  66309. */
  66310. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66311. /**
  66312. * Sets the custom effect used to render the particles
  66313. * @param effect The effect to set
  66314. * @param blendMode Blend mode for which the effect should be set
  66315. */
  66316. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66317. /** @hidden */
  66318. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66319. /**
  66320. * Observable that will be called just before the particles are drawn
  66321. */
  66322. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66323. /**
  66324. * Gets the name of the particle vertex shader
  66325. */
  66326. get vertexShaderName(): string;
  66327. private _colorGradientsTexture;
  66328. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66329. /**
  66330. * Adds a new color gradient
  66331. * @param gradient defines the gradient to use (between 0 and 1)
  66332. * @param color1 defines the color to affect to the specified gradient
  66333. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66334. * @returns the current particle system
  66335. */
  66336. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66337. private _refreshColorGradient;
  66338. /** Force the system to rebuild all gradients that need to be resync */
  66339. forceRefreshGradients(): void;
  66340. /**
  66341. * Remove a specific color gradient
  66342. * @param gradient defines the gradient to remove
  66343. * @returns the current particle system
  66344. */
  66345. removeColorGradient(gradient: number): GPUParticleSystem;
  66346. private _angularSpeedGradientsTexture;
  66347. private _sizeGradientsTexture;
  66348. private _velocityGradientsTexture;
  66349. private _limitVelocityGradientsTexture;
  66350. private _dragGradientsTexture;
  66351. private _addFactorGradient;
  66352. /**
  66353. * Adds a new size gradient
  66354. * @param gradient defines the gradient to use (between 0 and 1)
  66355. * @param factor defines the size factor to affect to the specified gradient
  66356. * @returns the current particle system
  66357. */
  66358. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66359. /**
  66360. * Remove a specific size gradient
  66361. * @param gradient defines the gradient to remove
  66362. * @returns the current particle system
  66363. */
  66364. removeSizeGradient(gradient: number): GPUParticleSystem;
  66365. private _refreshFactorGradient;
  66366. /**
  66367. * Adds a new angular speed gradient
  66368. * @param gradient defines the gradient to use (between 0 and 1)
  66369. * @param factor defines the angular speed to affect to the specified gradient
  66370. * @returns the current particle system
  66371. */
  66372. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66373. /**
  66374. * Remove a specific angular speed gradient
  66375. * @param gradient defines the gradient to remove
  66376. * @returns the current particle system
  66377. */
  66378. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66379. /**
  66380. * Adds a new velocity gradient
  66381. * @param gradient defines the gradient to use (between 0 and 1)
  66382. * @param factor defines the velocity to affect to the specified gradient
  66383. * @returns the current particle system
  66384. */
  66385. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66386. /**
  66387. * Remove a specific velocity gradient
  66388. * @param gradient defines the gradient to remove
  66389. * @returns the current particle system
  66390. */
  66391. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66392. /**
  66393. * Adds a new limit velocity gradient
  66394. * @param gradient defines the gradient to use (between 0 and 1)
  66395. * @param factor defines the limit velocity value to affect to the specified gradient
  66396. * @returns the current particle system
  66397. */
  66398. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66399. /**
  66400. * Remove a specific limit velocity gradient
  66401. * @param gradient defines the gradient to remove
  66402. * @returns the current particle system
  66403. */
  66404. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66405. /**
  66406. * Adds a new drag gradient
  66407. * @param gradient defines the gradient to use (between 0 and 1)
  66408. * @param factor defines the drag value to affect to the specified gradient
  66409. * @returns the current particle system
  66410. */
  66411. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66412. /**
  66413. * Remove a specific drag gradient
  66414. * @param gradient defines the gradient to remove
  66415. * @returns the current particle system
  66416. */
  66417. removeDragGradient(gradient: number): GPUParticleSystem;
  66418. /**
  66419. * Not supported by GPUParticleSystem
  66420. * @param gradient defines the gradient to use (between 0 and 1)
  66421. * @param factor defines the emit rate value to affect to the specified gradient
  66422. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66423. * @returns the current particle system
  66424. */
  66425. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66426. /**
  66427. * Not supported by GPUParticleSystem
  66428. * @param gradient defines the gradient to remove
  66429. * @returns the current particle system
  66430. */
  66431. removeEmitRateGradient(gradient: number): IParticleSystem;
  66432. /**
  66433. * Not supported by GPUParticleSystem
  66434. * @param gradient defines the gradient to use (between 0 and 1)
  66435. * @param factor defines the start size value to affect to the specified gradient
  66436. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66437. * @returns the current particle system
  66438. */
  66439. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66440. /**
  66441. * Not supported by GPUParticleSystem
  66442. * @param gradient defines the gradient to remove
  66443. * @returns the current particle system
  66444. */
  66445. removeStartSizeGradient(gradient: number): IParticleSystem;
  66446. /**
  66447. * Not supported by GPUParticleSystem
  66448. * @param gradient defines the gradient to use (between 0 and 1)
  66449. * @param min defines the color remap minimal range
  66450. * @param max defines the color remap maximal range
  66451. * @returns the current particle system
  66452. */
  66453. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66454. /**
  66455. * Not supported by GPUParticleSystem
  66456. * @param gradient defines the gradient to remove
  66457. * @returns the current particle system
  66458. */
  66459. removeColorRemapGradient(): IParticleSystem;
  66460. /**
  66461. * Not supported by GPUParticleSystem
  66462. * @param gradient defines the gradient to use (between 0 and 1)
  66463. * @param min defines the alpha remap minimal range
  66464. * @param max defines the alpha remap maximal range
  66465. * @returns the current particle system
  66466. */
  66467. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66468. /**
  66469. * Not supported by GPUParticleSystem
  66470. * @param gradient defines the gradient to remove
  66471. * @returns the current particle system
  66472. */
  66473. removeAlphaRemapGradient(): IParticleSystem;
  66474. /**
  66475. * Not supported by GPUParticleSystem
  66476. * @param gradient defines the gradient to use (between 0 and 1)
  66477. * @param color defines the color to affect to the specified gradient
  66478. * @returns the current particle system
  66479. */
  66480. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66481. /**
  66482. * Not supported by GPUParticleSystem
  66483. * @param gradient defines the gradient to remove
  66484. * @returns the current particle system
  66485. */
  66486. removeRampGradient(): IParticleSystem;
  66487. /**
  66488. * Not supported by GPUParticleSystem
  66489. * @returns the list of ramp gradients
  66490. */
  66491. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66492. /**
  66493. * Not supported by GPUParticleSystem
  66494. * Gets or sets a boolean indicating that ramp gradients must be used
  66495. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66496. */
  66497. get useRampGradients(): boolean;
  66498. set useRampGradients(value: boolean);
  66499. /**
  66500. * Not supported by GPUParticleSystem
  66501. * @param gradient defines the gradient to use (between 0 and 1)
  66502. * @param factor defines the life time factor to affect to the specified gradient
  66503. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66504. * @returns the current particle system
  66505. */
  66506. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66507. /**
  66508. * Not supported by GPUParticleSystem
  66509. * @param gradient defines the gradient to remove
  66510. * @returns the current particle system
  66511. */
  66512. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66513. /**
  66514. * Instantiates a GPU particle system.
  66515. * 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.
  66516. * @param name The name of the particle system
  66517. * @param options The options used to create the system
  66518. * @param scene The scene the particle system belongs to
  66519. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66520. * @param customEffect a custom effect used to change the way particles are rendered by default
  66521. */
  66522. constructor(name: string, options: Partial<{
  66523. capacity: number;
  66524. randomTextureSize: number;
  66525. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66526. protected _reset(): void;
  66527. private _createUpdateVAO;
  66528. private _createRenderVAO;
  66529. private _initialize;
  66530. /** @hidden */
  66531. _recreateUpdateEffect(): void;
  66532. private _getEffect;
  66533. /**
  66534. * Fill the defines array according to the current settings of the particle system
  66535. * @param defines Array to be updated
  66536. * @param blendMode blend mode to take into account when updating the array
  66537. */
  66538. fillDefines(defines: Array<string>, blendMode?: number): void;
  66539. /**
  66540. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66541. * @param uniforms Uniforms array to fill
  66542. * @param attributes Attributes array to fill
  66543. * @param samplers Samplers array to fill
  66544. */
  66545. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66546. /** @hidden */
  66547. _recreateRenderEffect(): Effect;
  66548. /**
  66549. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66550. * @param preWarm defines if we are in the pre-warmimg phase
  66551. */
  66552. animate(preWarm?: boolean): void;
  66553. private _createFactorGradientTexture;
  66554. private _createSizeGradientTexture;
  66555. private _createAngularSpeedGradientTexture;
  66556. private _createVelocityGradientTexture;
  66557. private _createLimitVelocityGradientTexture;
  66558. private _createDragGradientTexture;
  66559. private _createColorGradientTexture;
  66560. /**
  66561. * Renders the particle system in its current state
  66562. * @param preWarm defines if the system should only update the particles but not render them
  66563. * @returns the current number of particles
  66564. */
  66565. render(preWarm?: boolean): number;
  66566. /**
  66567. * Rebuilds the particle system
  66568. */
  66569. rebuild(): void;
  66570. private _releaseBuffers;
  66571. private _releaseVAOs;
  66572. /**
  66573. * Disposes the particle system and free the associated resources
  66574. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66575. */
  66576. dispose(disposeTexture?: boolean): void;
  66577. /**
  66578. * Clones the particle system.
  66579. * @param name The name of the cloned object
  66580. * @param newEmitter The new emitter to use
  66581. * @returns the cloned particle system
  66582. */
  66583. clone(name: string, newEmitter: any): GPUParticleSystem;
  66584. /**
  66585. * Serializes the particle system to a JSON object
  66586. * @param serializeTexture defines if the texture must be serialized as well
  66587. * @returns the JSON object
  66588. */
  66589. serialize(serializeTexture?: boolean): any;
  66590. /**
  66591. * Parses a JSON object to create a GPU particle system.
  66592. * @param parsedParticleSystem The JSON object to parse
  66593. * @param scene The scene to create the particle system in
  66594. * @param rootUrl The root url to use to load external dependencies like texture
  66595. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66596. * @returns the parsed GPU particle system
  66597. */
  66598. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66599. }
  66600. }
  66601. declare module BABYLON {
  66602. /**
  66603. * Represents a set of particle systems working together to create a specific effect
  66604. */
  66605. export class ParticleSystemSet implements IDisposable {
  66606. /**
  66607. * Gets or sets base Assets URL
  66608. */
  66609. static BaseAssetsUrl: string;
  66610. private _emitterCreationOptions;
  66611. private _emitterNode;
  66612. /**
  66613. * Gets the particle system list
  66614. */
  66615. systems: IParticleSystem[];
  66616. /**
  66617. * Gets the emitter node used with this set
  66618. */
  66619. get emitterNode(): Nullable<TransformNode>;
  66620. /**
  66621. * Creates a new emitter mesh as a sphere
  66622. * @param options defines the options used to create the sphere
  66623. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66624. * @param scene defines the hosting scene
  66625. */
  66626. setEmitterAsSphere(options: {
  66627. diameter: number;
  66628. segments: number;
  66629. color: Color3;
  66630. }, renderingGroupId: number, scene: Scene): void;
  66631. /**
  66632. * Starts all particle systems of the set
  66633. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66634. */
  66635. start(emitter?: AbstractMesh): void;
  66636. /**
  66637. * Release all associated resources
  66638. */
  66639. dispose(): void;
  66640. /**
  66641. * Serialize the set into a JSON compatible object
  66642. * @param serializeTexture defines if the texture must be serialized as well
  66643. * @returns a JSON compatible representation of the set
  66644. */
  66645. serialize(serializeTexture?: boolean): any;
  66646. /**
  66647. * Parse a new ParticleSystemSet from a serialized source
  66648. * @param data defines a JSON compatible representation of the set
  66649. * @param scene defines the hosting scene
  66650. * @param gpu defines if we want GPU particles or CPU particles
  66651. * @returns a new ParticleSystemSet
  66652. */
  66653. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66654. }
  66655. }
  66656. declare module BABYLON {
  66657. /**
  66658. * This class is made for on one-liner static method to help creating particle system set.
  66659. */
  66660. export class ParticleHelper {
  66661. /**
  66662. * Gets or sets base Assets URL
  66663. */
  66664. static BaseAssetsUrl: string;
  66665. /** Define the Url to load snippets */
  66666. static SnippetUrl: string;
  66667. /**
  66668. * Create a default particle system that you can tweak
  66669. * @param emitter defines the emitter to use
  66670. * @param capacity defines the system capacity (default is 500 particles)
  66671. * @param scene defines the hosting scene
  66672. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66673. * @returns the new Particle system
  66674. */
  66675. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66676. /**
  66677. * This is the main static method (one-liner) of this helper to create different particle systems
  66678. * @param type This string represents the type to the particle system to create
  66679. * @param scene The scene where the particle system should live
  66680. * @param gpu If the system will use gpu
  66681. * @returns the ParticleSystemSet created
  66682. */
  66683. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66684. /**
  66685. * Static function used to export a particle system to a ParticleSystemSet variable.
  66686. * Please note that the emitter shape is not exported
  66687. * @param systems defines the particle systems to export
  66688. * @returns the created particle system set
  66689. */
  66690. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66691. /**
  66692. * Creates a particle system from a snippet saved in a remote file
  66693. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66694. * @param url defines the url to load from
  66695. * @param scene defines the hosting scene
  66696. * @param gpu If the system will use gpu
  66697. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66698. * @returns a promise that will resolve to the new particle system
  66699. */
  66700. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66701. /**
  66702. * Creates a particle system from a snippet saved by the particle system editor
  66703. * @param snippetId defines the snippet to load
  66704. * @param scene defines the hosting scene
  66705. * @param gpu If the system will use gpu
  66706. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66707. * @returns a promise that will resolve to the new particle system
  66708. */
  66709. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66710. }
  66711. }
  66712. declare module BABYLON {
  66713. interface Engine {
  66714. /**
  66715. * Create an effect to use with particle systems.
  66716. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66717. * the particle system for which you want to create a custom effect in the last parameter
  66718. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66719. * @param uniformsNames defines a list of attribute names
  66720. * @param samplers defines an array of string used to represent textures
  66721. * @param defines defines the string containing the defines to use to compile the shaders
  66722. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66723. * @param onCompiled defines a function to call when the effect creation is successful
  66724. * @param onError defines a function to call when the effect creation has failed
  66725. * @param particleSystem the particle system you want to create the effect for
  66726. * @returns the new Effect
  66727. */
  66728. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66729. }
  66730. interface Mesh {
  66731. /**
  66732. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66733. * @returns an array of IParticleSystem
  66734. */
  66735. getEmittedParticleSystems(): IParticleSystem[];
  66736. /**
  66737. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66738. * @returns an array of IParticleSystem
  66739. */
  66740. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66741. }
  66742. }
  66743. declare module BABYLON {
  66744. /** Defines the 4 color options */
  66745. export enum PointColor {
  66746. /** color value */
  66747. Color = 2,
  66748. /** uv value */
  66749. UV = 1,
  66750. /** random value */
  66751. Random = 0,
  66752. /** stated value */
  66753. Stated = 3
  66754. }
  66755. /**
  66756. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66757. * 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.
  66758. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66759. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66760. *
  66761. * Full documentation here : TO BE ENTERED
  66762. */
  66763. export class PointsCloudSystem implements IDisposable {
  66764. /**
  66765. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66766. * Example : var p = SPS.particles[i];
  66767. */
  66768. particles: CloudPoint[];
  66769. /**
  66770. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66771. */
  66772. nbParticles: number;
  66773. /**
  66774. * This a counter for your own usage. It's not set by any SPS functions.
  66775. */
  66776. counter: number;
  66777. /**
  66778. * The PCS name. This name is also given to the underlying mesh.
  66779. */
  66780. name: string;
  66781. /**
  66782. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66783. */
  66784. mesh: Mesh;
  66785. /**
  66786. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66787. * Please read :
  66788. */
  66789. vars: any;
  66790. /**
  66791. * @hidden
  66792. */
  66793. _size: number;
  66794. private _scene;
  66795. private _promises;
  66796. private _positions;
  66797. private _indices;
  66798. private _normals;
  66799. private _colors;
  66800. private _uvs;
  66801. private _indices32;
  66802. private _positions32;
  66803. private _colors32;
  66804. private _uvs32;
  66805. private _updatable;
  66806. private _isVisibilityBoxLocked;
  66807. private _alwaysVisible;
  66808. private _groups;
  66809. private _groupCounter;
  66810. private _computeParticleColor;
  66811. private _computeParticleTexture;
  66812. private _computeParticleRotation;
  66813. private _computeBoundingBox;
  66814. private _isReady;
  66815. /**
  66816. * Creates a PCS (Points Cloud System) object
  66817. * @param name (String) is the PCS name, this will be the underlying mesh name
  66818. * @param pointSize (number) is the size for each point
  66819. * @param scene (Scene) is the scene in which the PCS is added
  66820. * @param options defines the options of the PCS e.g.
  66821. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66822. */
  66823. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66824. updatable?: boolean;
  66825. });
  66826. /**
  66827. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66828. * If no points were added to the PCS, the returned mesh is just a single point.
  66829. * @returns a promise for the created mesh
  66830. */
  66831. buildMeshAsync(): Promise<Mesh>;
  66832. /**
  66833. * @hidden
  66834. */
  66835. private _buildMesh;
  66836. private _addParticle;
  66837. private _randomUnitVector;
  66838. private _getColorIndicesForCoord;
  66839. private _setPointsColorOrUV;
  66840. private _colorFromTexture;
  66841. private _calculateDensity;
  66842. /**
  66843. * Adds points to the PCS in random positions within a unit sphere
  66844. * @param nb (positive integer) the number of particles to be created from this model
  66845. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66846. * @returns the number of groups in the system
  66847. */
  66848. addPoints(nb: number, pointFunction?: any): number;
  66849. /**
  66850. * Adds points to the PCS from the surface of the model shape
  66851. * @param mesh is any Mesh object that will be used as a surface model for the points
  66852. * @param nb (positive integer) the number of particles to be created from this model
  66853. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66854. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66855. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66856. * @returns the number of groups in the system
  66857. */
  66858. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66859. /**
  66860. * Adds points to the PCS inside the model shape
  66861. * @param mesh is any Mesh object that will be used as a surface model for the points
  66862. * @param nb (positive integer) the number of particles to be created from this model
  66863. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66864. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66865. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66866. * @returns the number of groups in the system
  66867. */
  66868. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66869. /**
  66870. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66871. * This method calls `updateParticle()` for each particle of the SPS.
  66872. * For an animated SPS, it is usually called within the render loop.
  66873. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66874. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66875. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66876. * @returns the PCS.
  66877. */
  66878. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66879. /**
  66880. * Disposes the PCS.
  66881. */
  66882. dispose(): void;
  66883. /**
  66884. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66885. * doc :
  66886. * @returns the PCS.
  66887. */
  66888. refreshVisibleSize(): PointsCloudSystem;
  66889. /**
  66890. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66891. * @param size the size (float) of the visibility box
  66892. * note : this doesn't lock the PCS mesh bounding box.
  66893. * doc :
  66894. */
  66895. setVisibilityBox(size: number): void;
  66896. /**
  66897. * Gets whether the PCS is always visible or not
  66898. * doc :
  66899. */
  66900. get isAlwaysVisible(): boolean;
  66901. /**
  66902. * Sets the PCS as always visible or not
  66903. * doc :
  66904. */
  66905. set isAlwaysVisible(val: boolean);
  66906. /**
  66907. * Tells to `setParticles()` to compute the particle rotations or not
  66908. * Default value : false. The PCS is faster when it's set to false
  66909. * Note : particle rotations are only applied to parent particles
  66910. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66911. */
  66912. set computeParticleRotation(val: boolean);
  66913. /**
  66914. * Tells to `setParticles()` to compute the particle colors or not.
  66915. * Default value : true. The PCS is faster when it's set to false.
  66916. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66917. */
  66918. set computeParticleColor(val: boolean);
  66919. set computeParticleTexture(val: boolean);
  66920. /**
  66921. * Gets if `setParticles()` computes the particle colors or not.
  66922. * Default value : false. The PCS is faster when it's set to false.
  66923. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66924. */
  66925. get computeParticleColor(): boolean;
  66926. /**
  66927. * Gets if `setParticles()` computes the particle textures or not.
  66928. * Default value : false. The PCS is faster when it's set to false.
  66929. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66930. */
  66931. get computeParticleTexture(): boolean;
  66932. /**
  66933. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66934. */
  66935. set computeBoundingBox(val: boolean);
  66936. /**
  66937. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66938. */
  66939. get computeBoundingBox(): boolean;
  66940. /**
  66941. * This function does nothing. It may be overwritten to set all the particle first values.
  66942. * The PCS doesn't call this function, you may have to call it by your own.
  66943. * doc :
  66944. */
  66945. initParticles(): void;
  66946. /**
  66947. * This function does nothing. It may be overwritten to recycle a particle
  66948. * The PCS doesn't call this function, you can to call it
  66949. * doc :
  66950. * @param particle The particle to recycle
  66951. * @returns the recycled particle
  66952. */
  66953. recycleParticle(particle: CloudPoint): CloudPoint;
  66954. /**
  66955. * Updates a particle : this function should be overwritten by the user.
  66956. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66957. * doc :
  66958. * @example : just set a particle position or velocity and recycle conditions
  66959. * @param particle The particle to update
  66960. * @returns the updated particle
  66961. */
  66962. updateParticle(particle: CloudPoint): CloudPoint;
  66963. /**
  66964. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66965. * This does nothing and may be overwritten by the user.
  66966. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66967. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66968. * @param update the boolean update value actually passed to setParticles()
  66969. */
  66970. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66971. /**
  66972. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66973. * This will be passed three parameters.
  66974. * This does nothing and may be overwritten by the user.
  66975. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66976. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66977. * @param update the boolean update value actually passed to setParticles()
  66978. */
  66979. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66980. }
  66981. }
  66982. declare module BABYLON {
  66983. /**
  66984. * Represents one particle of a points cloud system.
  66985. */
  66986. export class CloudPoint {
  66987. /**
  66988. * particle global index
  66989. */
  66990. idx: number;
  66991. /**
  66992. * The color of the particle
  66993. */
  66994. color: Nullable<Color4>;
  66995. /**
  66996. * The world space position of the particle.
  66997. */
  66998. position: Vector3;
  66999. /**
  67000. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67001. */
  67002. rotation: Vector3;
  67003. /**
  67004. * The world space rotation quaternion of the particle.
  67005. */
  67006. rotationQuaternion: Nullable<Quaternion>;
  67007. /**
  67008. * The uv of the particle.
  67009. */
  67010. uv: Nullable<Vector2>;
  67011. /**
  67012. * The current speed of the particle.
  67013. */
  67014. velocity: Vector3;
  67015. /**
  67016. * The pivot point in the particle local space.
  67017. */
  67018. pivot: Vector3;
  67019. /**
  67020. * Must the particle be translated from its pivot point in its local space ?
  67021. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67022. * Default : false
  67023. */
  67024. translateFromPivot: boolean;
  67025. /**
  67026. * Index of this particle in the global "positions" array (Internal use)
  67027. * @hidden
  67028. */
  67029. _pos: number;
  67030. /**
  67031. * @hidden Index of this particle in the global "indices" array (Internal use)
  67032. */
  67033. _ind: number;
  67034. /**
  67035. * Group this particle belongs to
  67036. */
  67037. _group: PointsGroup;
  67038. /**
  67039. * Group id of this particle
  67040. */
  67041. groupId: number;
  67042. /**
  67043. * Index of the particle in its group id (Internal use)
  67044. */
  67045. idxInGroup: number;
  67046. /**
  67047. * @hidden Particle BoundingInfo object (Internal use)
  67048. */
  67049. _boundingInfo: BoundingInfo;
  67050. /**
  67051. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67052. */
  67053. _pcs: PointsCloudSystem;
  67054. /**
  67055. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67056. */
  67057. _stillInvisible: boolean;
  67058. /**
  67059. * @hidden Last computed particle rotation matrix
  67060. */
  67061. _rotationMatrix: number[];
  67062. /**
  67063. * Parent particle Id, if any.
  67064. * Default null.
  67065. */
  67066. parentId: Nullable<number>;
  67067. /**
  67068. * @hidden Internal global position in the PCS.
  67069. */
  67070. _globalPosition: Vector3;
  67071. /**
  67072. * Creates a Point Cloud object.
  67073. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67074. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67075. * @param group (PointsGroup) is the group the particle belongs to
  67076. * @param groupId (integer) is the group identifier in the PCS.
  67077. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67078. * @param pcs defines the PCS it is associated to
  67079. */
  67080. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67081. /**
  67082. * get point size
  67083. */
  67084. get size(): Vector3;
  67085. /**
  67086. * Set point size
  67087. */
  67088. set size(scale: Vector3);
  67089. /**
  67090. * Legacy support, changed quaternion to rotationQuaternion
  67091. */
  67092. get quaternion(): Nullable<Quaternion>;
  67093. /**
  67094. * Legacy support, changed quaternion to rotationQuaternion
  67095. */
  67096. set quaternion(q: Nullable<Quaternion>);
  67097. /**
  67098. * Returns a boolean. True if the particle intersects a mesh, else false
  67099. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67100. * @param target is the object (point or mesh) what the intersection is computed against
  67101. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67102. * @returns true if it intersects
  67103. */
  67104. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67105. /**
  67106. * get the rotation matrix of the particle
  67107. * @hidden
  67108. */
  67109. getRotationMatrix(m: Matrix): void;
  67110. }
  67111. /**
  67112. * Represents a group of points in a points cloud system
  67113. * * PCS internal tool, don't use it manually.
  67114. */
  67115. export class PointsGroup {
  67116. /**
  67117. * The group id
  67118. * @hidden
  67119. */
  67120. groupID: number;
  67121. /**
  67122. * image data for group (internal use)
  67123. * @hidden
  67124. */
  67125. _groupImageData: Nullable<ArrayBufferView>;
  67126. /**
  67127. * Image Width (internal use)
  67128. * @hidden
  67129. */
  67130. _groupImgWidth: number;
  67131. /**
  67132. * Image Height (internal use)
  67133. * @hidden
  67134. */
  67135. _groupImgHeight: number;
  67136. /**
  67137. * Custom position function (internal use)
  67138. * @hidden
  67139. */
  67140. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67141. /**
  67142. * density per facet for surface points
  67143. * @hidden
  67144. */
  67145. _groupDensity: number[];
  67146. /**
  67147. * Only when points are colored by texture carries pointer to texture list array
  67148. * @hidden
  67149. */
  67150. _textureNb: number;
  67151. /**
  67152. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67153. * PCS internal tool, don't use it manually.
  67154. * @hidden
  67155. */
  67156. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67157. }
  67158. }
  67159. declare module BABYLON {
  67160. interface Scene {
  67161. /** @hidden (Backing field) */
  67162. _physicsEngine: Nullable<IPhysicsEngine>;
  67163. /** @hidden */
  67164. _physicsTimeAccumulator: number;
  67165. /**
  67166. * Gets the current physics engine
  67167. * @returns a IPhysicsEngine or null if none attached
  67168. */
  67169. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67170. /**
  67171. * Enables physics to the current scene
  67172. * @param gravity defines the scene's gravity for the physics engine
  67173. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67174. * @return a boolean indicating if the physics engine was initialized
  67175. */
  67176. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67177. /**
  67178. * Disables and disposes the physics engine associated with the scene
  67179. */
  67180. disablePhysicsEngine(): void;
  67181. /**
  67182. * Gets a boolean indicating if there is an active physics engine
  67183. * @returns a boolean indicating if there is an active physics engine
  67184. */
  67185. isPhysicsEnabled(): boolean;
  67186. /**
  67187. * Deletes a physics compound impostor
  67188. * @param compound defines the compound to delete
  67189. */
  67190. deleteCompoundImpostor(compound: any): void;
  67191. /**
  67192. * An event triggered when physic simulation is about to be run
  67193. */
  67194. onBeforePhysicsObservable: Observable<Scene>;
  67195. /**
  67196. * An event triggered when physic simulation has been done
  67197. */
  67198. onAfterPhysicsObservable: Observable<Scene>;
  67199. }
  67200. interface AbstractMesh {
  67201. /** @hidden */
  67202. _physicsImpostor: Nullable<PhysicsImpostor>;
  67203. /**
  67204. * Gets or sets impostor used for physic simulation
  67205. * @see http://doc.babylonjs.com/features/physics_engine
  67206. */
  67207. physicsImpostor: Nullable<PhysicsImpostor>;
  67208. /**
  67209. * Gets the current physics impostor
  67210. * @see http://doc.babylonjs.com/features/physics_engine
  67211. * @returns a physics impostor or null
  67212. */
  67213. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67214. /** Apply a physic impulse to the mesh
  67215. * @param force defines the force to apply
  67216. * @param contactPoint defines where to apply the force
  67217. * @returns the current mesh
  67218. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67219. */
  67220. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67221. /**
  67222. * Creates a physic joint between two meshes
  67223. * @param otherMesh defines the other mesh to use
  67224. * @param pivot1 defines the pivot to use on this mesh
  67225. * @param pivot2 defines the pivot to use on the other mesh
  67226. * @param options defines additional options (can be plugin dependent)
  67227. * @returns the current mesh
  67228. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67229. */
  67230. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67231. /** @hidden */
  67232. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67233. }
  67234. /**
  67235. * Defines the physics engine scene component responsible to manage a physics engine
  67236. */
  67237. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67238. /**
  67239. * The component name helpful to identify the component in the list of scene components.
  67240. */
  67241. readonly name: string;
  67242. /**
  67243. * The scene the component belongs to.
  67244. */
  67245. scene: Scene;
  67246. /**
  67247. * Creates a new instance of the component for the given scene
  67248. * @param scene Defines the scene to register the component in
  67249. */
  67250. constructor(scene: Scene);
  67251. /**
  67252. * Registers the component in a given scene
  67253. */
  67254. register(): void;
  67255. /**
  67256. * Rebuilds the elements related to this component in case of
  67257. * context lost for instance.
  67258. */
  67259. rebuild(): void;
  67260. /**
  67261. * Disposes the component and the associated ressources
  67262. */
  67263. dispose(): void;
  67264. }
  67265. }
  67266. declare module BABYLON {
  67267. /**
  67268. * A helper for physics simulations
  67269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67270. */
  67271. export class PhysicsHelper {
  67272. private _scene;
  67273. private _physicsEngine;
  67274. /**
  67275. * Initializes the Physics helper
  67276. * @param scene Babylon.js scene
  67277. */
  67278. constructor(scene: Scene);
  67279. /**
  67280. * Applies a radial explosion impulse
  67281. * @param origin the origin of the explosion
  67282. * @param radiusOrEventOptions the radius or the options of radial explosion
  67283. * @param strength the explosion strength
  67284. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67285. * @returns A physics radial explosion event, or null
  67286. */
  67287. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67288. /**
  67289. * Applies a radial explosion force
  67290. * @param origin the origin of the explosion
  67291. * @param radiusOrEventOptions the radius or the options of radial explosion
  67292. * @param strength the explosion strength
  67293. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67294. * @returns A physics radial explosion event, or null
  67295. */
  67296. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67297. /**
  67298. * Creates a gravitational field
  67299. * @param origin the origin of the explosion
  67300. * @param radiusOrEventOptions the radius or the options of radial explosion
  67301. * @param strength the explosion strength
  67302. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67303. * @returns A physics gravitational field event, or null
  67304. */
  67305. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67306. /**
  67307. * Creates a physics updraft event
  67308. * @param origin the origin of the updraft
  67309. * @param radiusOrEventOptions the radius or the options of the updraft
  67310. * @param strength the strength of the updraft
  67311. * @param height the height of the updraft
  67312. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67313. * @returns A physics updraft event, or null
  67314. */
  67315. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67316. /**
  67317. * Creates a physics vortex event
  67318. * @param origin the of the vortex
  67319. * @param radiusOrEventOptions the radius or the options of the vortex
  67320. * @param strength the strength of the vortex
  67321. * @param height the height of the vortex
  67322. * @returns a Physics vortex event, or null
  67323. * A physics vortex event or null
  67324. */
  67325. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67326. }
  67327. /**
  67328. * Represents a physics radial explosion event
  67329. */
  67330. class PhysicsRadialExplosionEvent {
  67331. private _scene;
  67332. private _options;
  67333. private _sphere;
  67334. private _dataFetched;
  67335. /**
  67336. * Initializes a radial explosioin event
  67337. * @param _scene BabylonJS scene
  67338. * @param _options The options for the vortex event
  67339. */
  67340. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67341. /**
  67342. * Returns the data related to the radial explosion event (sphere).
  67343. * @returns The radial explosion event data
  67344. */
  67345. getData(): PhysicsRadialExplosionEventData;
  67346. /**
  67347. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67348. * @param impostor A physics imposter
  67349. * @param origin the origin of the explosion
  67350. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67351. */
  67352. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67353. /**
  67354. * Triggers affecterd impostors callbacks
  67355. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67356. */
  67357. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67358. /**
  67359. * Disposes the sphere.
  67360. * @param force Specifies if the sphere should be disposed by force
  67361. */
  67362. dispose(force?: boolean): void;
  67363. /*** Helpers ***/
  67364. private _prepareSphere;
  67365. private _intersectsWithSphere;
  67366. }
  67367. /**
  67368. * Represents a gravitational field event
  67369. */
  67370. class PhysicsGravitationalFieldEvent {
  67371. private _physicsHelper;
  67372. private _scene;
  67373. private _origin;
  67374. private _options;
  67375. private _tickCallback;
  67376. private _sphere;
  67377. private _dataFetched;
  67378. /**
  67379. * Initializes the physics gravitational field event
  67380. * @param _physicsHelper A physics helper
  67381. * @param _scene BabylonJS scene
  67382. * @param _origin The origin position of the gravitational field event
  67383. * @param _options The options for the vortex event
  67384. */
  67385. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67386. /**
  67387. * Returns the data related to the gravitational field event (sphere).
  67388. * @returns A gravitational field event
  67389. */
  67390. getData(): PhysicsGravitationalFieldEventData;
  67391. /**
  67392. * Enables the gravitational field.
  67393. */
  67394. enable(): void;
  67395. /**
  67396. * Disables the gravitational field.
  67397. */
  67398. disable(): void;
  67399. /**
  67400. * Disposes the sphere.
  67401. * @param force The force to dispose from the gravitational field event
  67402. */
  67403. dispose(force?: boolean): void;
  67404. private _tick;
  67405. }
  67406. /**
  67407. * Represents a physics updraft event
  67408. */
  67409. class PhysicsUpdraftEvent {
  67410. private _scene;
  67411. private _origin;
  67412. private _options;
  67413. private _physicsEngine;
  67414. private _originTop;
  67415. private _originDirection;
  67416. private _tickCallback;
  67417. private _cylinder;
  67418. private _cylinderPosition;
  67419. private _dataFetched;
  67420. /**
  67421. * Initializes the physics updraft event
  67422. * @param _scene BabylonJS scene
  67423. * @param _origin The origin position of the updraft
  67424. * @param _options The options for the updraft event
  67425. */
  67426. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67427. /**
  67428. * Returns the data related to the updraft event (cylinder).
  67429. * @returns A physics updraft event
  67430. */
  67431. getData(): PhysicsUpdraftEventData;
  67432. /**
  67433. * Enables the updraft.
  67434. */
  67435. enable(): void;
  67436. /**
  67437. * Disables the updraft.
  67438. */
  67439. disable(): void;
  67440. /**
  67441. * Disposes the cylinder.
  67442. * @param force Specifies if the updraft should be disposed by force
  67443. */
  67444. dispose(force?: boolean): void;
  67445. private getImpostorHitData;
  67446. private _tick;
  67447. /*** Helpers ***/
  67448. private _prepareCylinder;
  67449. private _intersectsWithCylinder;
  67450. }
  67451. /**
  67452. * Represents a physics vortex event
  67453. */
  67454. class PhysicsVortexEvent {
  67455. private _scene;
  67456. private _origin;
  67457. private _options;
  67458. private _physicsEngine;
  67459. private _originTop;
  67460. private _tickCallback;
  67461. private _cylinder;
  67462. private _cylinderPosition;
  67463. private _dataFetched;
  67464. /**
  67465. * Initializes the physics vortex event
  67466. * @param _scene The BabylonJS scene
  67467. * @param _origin The origin position of the vortex
  67468. * @param _options The options for the vortex event
  67469. */
  67470. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67471. /**
  67472. * Returns the data related to the vortex event (cylinder).
  67473. * @returns The physics vortex event data
  67474. */
  67475. getData(): PhysicsVortexEventData;
  67476. /**
  67477. * Enables the vortex.
  67478. */
  67479. enable(): void;
  67480. /**
  67481. * Disables the cortex.
  67482. */
  67483. disable(): void;
  67484. /**
  67485. * Disposes the sphere.
  67486. * @param force
  67487. */
  67488. dispose(force?: boolean): void;
  67489. private getImpostorHitData;
  67490. private _tick;
  67491. /*** Helpers ***/
  67492. private _prepareCylinder;
  67493. private _intersectsWithCylinder;
  67494. }
  67495. /**
  67496. * Options fot the radial explosion event
  67497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67498. */
  67499. export class PhysicsRadialExplosionEventOptions {
  67500. /**
  67501. * The radius of the sphere for the radial explosion.
  67502. */
  67503. radius: number;
  67504. /**
  67505. * The strenth of the explosion.
  67506. */
  67507. strength: number;
  67508. /**
  67509. * The strenght of the force in correspondence to the distance of the affected object
  67510. */
  67511. falloff: PhysicsRadialImpulseFalloff;
  67512. /**
  67513. * Sphere options for the radial explosion.
  67514. */
  67515. sphere: {
  67516. segments: number;
  67517. diameter: number;
  67518. };
  67519. /**
  67520. * Sphere options for the radial explosion.
  67521. */
  67522. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67523. }
  67524. /**
  67525. * Options fot the updraft event
  67526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67527. */
  67528. export class PhysicsUpdraftEventOptions {
  67529. /**
  67530. * The radius of the cylinder for the vortex
  67531. */
  67532. radius: number;
  67533. /**
  67534. * The strenth of the updraft.
  67535. */
  67536. strength: number;
  67537. /**
  67538. * The height of the cylinder for the updraft.
  67539. */
  67540. height: number;
  67541. /**
  67542. * The mode for the the updraft.
  67543. */
  67544. updraftMode: PhysicsUpdraftMode;
  67545. }
  67546. /**
  67547. * Options fot the vortex event
  67548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67549. */
  67550. export class PhysicsVortexEventOptions {
  67551. /**
  67552. * The radius of the cylinder for the vortex
  67553. */
  67554. radius: number;
  67555. /**
  67556. * The strenth of the vortex.
  67557. */
  67558. strength: number;
  67559. /**
  67560. * The height of the cylinder for the vortex.
  67561. */
  67562. height: number;
  67563. /**
  67564. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67565. */
  67566. centripetalForceThreshold: number;
  67567. /**
  67568. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67569. */
  67570. centripetalForceMultiplier: number;
  67571. /**
  67572. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67573. */
  67574. centrifugalForceMultiplier: number;
  67575. /**
  67576. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67577. */
  67578. updraftForceMultiplier: number;
  67579. }
  67580. /**
  67581. * The strenght of the force in correspondence to the distance of the affected object
  67582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67583. */
  67584. export enum PhysicsRadialImpulseFalloff {
  67585. /** Defines that impulse is constant in strength across it's whole radius */
  67586. Constant = 0,
  67587. /** Defines that impulse gets weaker if it's further from the origin */
  67588. Linear = 1
  67589. }
  67590. /**
  67591. * The strength of the force in correspondence to the distance of the affected object
  67592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67593. */
  67594. export enum PhysicsUpdraftMode {
  67595. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67596. Center = 0,
  67597. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67598. Perpendicular = 1
  67599. }
  67600. /**
  67601. * Interface for a physics hit data
  67602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67603. */
  67604. export interface PhysicsHitData {
  67605. /**
  67606. * The force applied at the contact point
  67607. */
  67608. force: Vector3;
  67609. /**
  67610. * The contact point
  67611. */
  67612. contactPoint: Vector3;
  67613. /**
  67614. * The distance from the origin to the contact point
  67615. */
  67616. distanceFromOrigin: number;
  67617. }
  67618. /**
  67619. * Interface for radial explosion event data
  67620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67621. */
  67622. export interface PhysicsRadialExplosionEventData {
  67623. /**
  67624. * A sphere used for the radial explosion event
  67625. */
  67626. sphere: Mesh;
  67627. }
  67628. /**
  67629. * Interface for gravitational field event data
  67630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67631. */
  67632. export interface PhysicsGravitationalFieldEventData {
  67633. /**
  67634. * A sphere mesh used for the gravitational field event
  67635. */
  67636. sphere: Mesh;
  67637. }
  67638. /**
  67639. * Interface for updraft event data
  67640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67641. */
  67642. export interface PhysicsUpdraftEventData {
  67643. /**
  67644. * A cylinder used for the updraft event
  67645. */
  67646. cylinder: Mesh;
  67647. }
  67648. /**
  67649. * Interface for vortex event data
  67650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67651. */
  67652. export interface PhysicsVortexEventData {
  67653. /**
  67654. * A cylinder used for the vortex event
  67655. */
  67656. cylinder: Mesh;
  67657. }
  67658. /**
  67659. * Interface for an affected physics impostor
  67660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67661. */
  67662. export interface PhysicsAffectedImpostorWithData {
  67663. /**
  67664. * The impostor affected by the effect
  67665. */
  67666. impostor: PhysicsImpostor;
  67667. /**
  67668. * The data about the hit/horce from the explosion
  67669. */
  67670. hitData: PhysicsHitData;
  67671. }
  67672. }
  67673. declare module BABYLON {
  67674. /** @hidden */
  67675. export var blackAndWhitePixelShader: {
  67676. name: string;
  67677. shader: string;
  67678. };
  67679. }
  67680. declare module BABYLON {
  67681. /**
  67682. * Post process used to render in black and white
  67683. */
  67684. export class BlackAndWhitePostProcess extends PostProcess {
  67685. /**
  67686. * Linear about to convert he result to black and white (default: 1)
  67687. */
  67688. degree: number;
  67689. /**
  67690. * Creates a black and white post process
  67691. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67692. * @param name The name of the effect.
  67693. * @param options The required width/height ratio to downsize to before computing the render pass.
  67694. * @param camera The camera to apply the render pass to.
  67695. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67696. * @param engine The engine which the post process will be applied. (default: current engine)
  67697. * @param reusable If the post process can be reused on the same frame. (default: false)
  67698. */
  67699. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67700. }
  67701. }
  67702. declare module BABYLON {
  67703. /**
  67704. * This represents a set of one or more post processes in Babylon.
  67705. * A post process can be used to apply a shader to a texture after it is rendered.
  67706. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67707. */
  67708. export class PostProcessRenderEffect {
  67709. private _postProcesses;
  67710. private _getPostProcesses;
  67711. private _singleInstance;
  67712. private _cameras;
  67713. private _indicesForCamera;
  67714. /**
  67715. * Name of the effect
  67716. * @hidden
  67717. */
  67718. _name: string;
  67719. /**
  67720. * Instantiates a post process render effect.
  67721. * A post process can be used to apply a shader to a texture after it is rendered.
  67722. * @param engine The engine the effect is tied to
  67723. * @param name The name of the effect
  67724. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67725. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67726. */
  67727. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67728. /**
  67729. * Checks if all the post processes in the effect are supported.
  67730. */
  67731. get isSupported(): boolean;
  67732. /**
  67733. * Updates the current state of the effect
  67734. * @hidden
  67735. */
  67736. _update(): void;
  67737. /**
  67738. * Attaches the effect on cameras
  67739. * @param cameras The camera to attach to.
  67740. * @hidden
  67741. */
  67742. _attachCameras(cameras: Camera): void;
  67743. /**
  67744. * Attaches the effect on cameras
  67745. * @param cameras The camera to attach to.
  67746. * @hidden
  67747. */
  67748. _attachCameras(cameras: Camera[]): void;
  67749. /**
  67750. * Detaches the effect on cameras
  67751. * @param cameras The camera to detatch from.
  67752. * @hidden
  67753. */
  67754. _detachCameras(cameras: Camera): void;
  67755. /**
  67756. * Detatches the effect on cameras
  67757. * @param cameras The camera to detatch from.
  67758. * @hidden
  67759. */
  67760. _detachCameras(cameras: Camera[]): void;
  67761. /**
  67762. * Enables the effect on given cameras
  67763. * @param cameras The camera to enable.
  67764. * @hidden
  67765. */
  67766. _enable(cameras: Camera): void;
  67767. /**
  67768. * Enables the effect on given cameras
  67769. * @param cameras The camera to enable.
  67770. * @hidden
  67771. */
  67772. _enable(cameras: Nullable<Camera[]>): void;
  67773. /**
  67774. * Disables the effect on the given cameras
  67775. * @param cameras The camera to disable.
  67776. * @hidden
  67777. */
  67778. _disable(cameras: Camera): void;
  67779. /**
  67780. * Disables the effect on the given cameras
  67781. * @param cameras The camera to disable.
  67782. * @hidden
  67783. */
  67784. _disable(cameras: Nullable<Camera[]>): void;
  67785. /**
  67786. * Gets a list of the post processes contained in the effect.
  67787. * @param camera The camera to get the post processes on.
  67788. * @returns The list of the post processes in the effect.
  67789. */
  67790. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67791. }
  67792. }
  67793. declare module BABYLON {
  67794. /** @hidden */
  67795. export var extractHighlightsPixelShader: {
  67796. name: string;
  67797. shader: string;
  67798. };
  67799. }
  67800. declare module BABYLON {
  67801. /**
  67802. * 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.
  67803. */
  67804. export class ExtractHighlightsPostProcess extends PostProcess {
  67805. /**
  67806. * The luminance threshold, pixels below this value will be set to black.
  67807. */
  67808. threshold: number;
  67809. /** @hidden */
  67810. _exposure: number;
  67811. /**
  67812. * Post process which has the input texture to be used when performing highlight extraction
  67813. * @hidden
  67814. */
  67815. _inputPostProcess: Nullable<PostProcess>;
  67816. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67817. }
  67818. }
  67819. declare module BABYLON {
  67820. /** @hidden */
  67821. export var bloomMergePixelShader: {
  67822. name: string;
  67823. shader: string;
  67824. };
  67825. }
  67826. declare module BABYLON {
  67827. /**
  67828. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67829. */
  67830. export class BloomMergePostProcess extends PostProcess {
  67831. /** Weight of the bloom to be added to the original input. */
  67832. weight: number;
  67833. /**
  67834. * Creates a new instance of @see BloomMergePostProcess
  67835. * @param name The name of the effect.
  67836. * @param originalFromInput Post process which's input will be used for the merge.
  67837. * @param blurred Blurred highlights post process which's output will be used.
  67838. * @param weight Weight of the bloom to be added to the original input.
  67839. * @param options The required width/height ratio to downsize to before computing the render pass.
  67840. * @param camera The camera to apply the render pass to.
  67841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67842. * @param engine The engine which the post process will be applied. (default: current engine)
  67843. * @param reusable If the post process can be reused on the same frame. (default: false)
  67844. * @param textureType Type of textures used when performing the post process. (default: 0)
  67845. * @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)
  67846. */
  67847. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67848. /** Weight of the bloom to be added to the original input. */
  67849. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67850. }
  67851. }
  67852. declare module BABYLON {
  67853. /**
  67854. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67855. */
  67856. export class BloomEffect extends PostProcessRenderEffect {
  67857. private bloomScale;
  67858. /**
  67859. * @hidden Internal
  67860. */
  67861. _effects: Array<PostProcess>;
  67862. /**
  67863. * @hidden Internal
  67864. */
  67865. _downscale: ExtractHighlightsPostProcess;
  67866. private _blurX;
  67867. private _blurY;
  67868. private _merge;
  67869. /**
  67870. * The luminance threshold to find bright areas of the image to bloom.
  67871. */
  67872. get threshold(): number;
  67873. set threshold(value: number);
  67874. /**
  67875. * The strength of the bloom.
  67876. */
  67877. get weight(): number;
  67878. set weight(value: number);
  67879. /**
  67880. * Specifies the size of the bloom blur kernel, relative to the final output size
  67881. */
  67882. get kernel(): number;
  67883. set kernel(value: number);
  67884. /**
  67885. * Creates a new instance of @see BloomEffect
  67886. * @param scene The scene the effect belongs to.
  67887. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67888. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67889. * @param bloomWeight The the strength of bloom.
  67890. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67891. * @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)
  67892. */
  67893. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67894. /**
  67895. * Disposes each of the internal effects for a given camera.
  67896. * @param camera The camera to dispose the effect on.
  67897. */
  67898. disposeEffects(camera: Camera): void;
  67899. /**
  67900. * @hidden Internal
  67901. */
  67902. _updateEffects(): void;
  67903. /**
  67904. * Internal
  67905. * @returns if all the contained post processes are ready.
  67906. * @hidden
  67907. */
  67908. _isReady(): boolean;
  67909. }
  67910. }
  67911. declare module BABYLON {
  67912. /** @hidden */
  67913. export var chromaticAberrationPixelShader: {
  67914. name: string;
  67915. shader: string;
  67916. };
  67917. }
  67918. declare module BABYLON {
  67919. /**
  67920. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67921. */
  67922. export class ChromaticAberrationPostProcess extends PostProcess {
  67923. /**
  67924. * The amount of seperation of rgb channels (default: 30)
  67925. */
  67926. aberrationAmount: number;
  67927. /**
  67928. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67929. */
  67930. radialIntensity: number;
  67931. /**
  67932. * 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))
  67933. */
  67934. direction: Vector2;
  67935. /**
  67936. * 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))
  67937. */
  67938. centerPosition: Vector2;
  67939. /**
  67940. * Creates a new instance ChromaticAberrationPostProcess
  67941. * @param name The name of the effect.
  67942. * @param screenWidth The width of the screen to apply the effect on.
  67943. * @param screenHeight The height of the screen to apply the effect on.
  67944. * @param options The required width/height ratio to downsize to before computing the render pass.
  67945. * @param camera The camera to apply the render pass to.
  67946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67947. * @param engine The engine which the post process will be applied. (default: current engine)
  67948. * @param reusable If the post process can be reused on the same frame. (default: false)
  67949. * @param textureType Type of textures used when performing the post process. (default: 0)
  67950. * @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)
  67951. */
  67952. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67953. }
  67954. }
  67955. declare module BABYLON {
  67956. /** @hidden */
  67957. export var circleOfConfusionPixelShader: {
  67958. name: string;
  67959. shader: string;
  67960. };
  67961. }
  67962. declare module BABYLON {
  67963. /**
  67964. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67965. */
  67966. export class CircleOfConfusionPostProcess extends PostProcess {
  67967. /**
  67968. * 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.
  67969. */
  67970. lensSize: number;
  67971. /**
  67972. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67973. */
  67974. fStop: number;
  67975. /**
  67976. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67977. */
  67978. focusDistance: number;
  67979. /**
  67980. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67981. */
  67982. focalLength: number;
  67983. private _depthTexture;
  67984. /**
  67985. * Creates a new instance CircleOfConfusionPostProcess
  67986. * @param name The name of the effect.
  67987. * @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.
  67988. * @param options The required width/height ratio to downsize to before computing the render pass.
  67989. * @param camera The camera to apply the render pass to.
  67990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67991. * @param engine The engine which the post process will be applied. (default: current engine)
  67992. * @param reusable If the post process can be reused on the same frame. (default: false)
  67993. * @param textureType Type of textures used when performing the post process. (default: 0)
  67994. * @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)
  67995. */
  67996. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67997. /**
  67998. * 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.
  67999. */
  68000. set depthTexture(value: RenderTargetTexture);
  68001. }
  68002. }
  68003. declare module BABYLON {
  68004. /** @hidden */
  68005. export var colorCorrectionPixelShader: {
  68006. name: string;
  68007. shader: string;
  68008. };
  68009. }
  68010. declare module BABYLON {
  68011. /**
  68012. *
  68013. * This post-process allows the modification of rendered colors by using
  68014. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68015. *
  68016. * The object needs to be provided an url to a texture containing the color
  68017. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68018. * Use an image editing software to tweak the LUT to match your needs.
  68019. *
  68020. * For an example of a color LUT, see here:
  68021. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68022. * For explanations on color grading, see here:
  68023. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68024. *
  68025. */
  68026. export class ColorCorrectionPostProcess extends PostProcess {
  68027. private _colorTableTexture;
  68028. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68029. }
  68030. }
  68031. declare module BABYLON {
  68032. /** @hidden */
  68033. export var convolutionPixelShader: {
  68034. name: string;
  68035. shader: string;
  68036. };
  68037. }
  68038. declare module BABYLON {
  68039. /**
  68040. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68041. * input texture to perform effects such as edge detection or sharpening
  68042. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68043. */
  68044. export class ConvolutionPostProcess extends PostProcess {
  68045. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68046. kernel: number[];
  68047. /**
  68048. * Creates a new instance ConvolutionPostProcess
  68049. * @param name The name of the effect.
  68050. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68051. * @param options The required width/height ratio to downsize to before computing the render pass.
  68052. * @param camera The camera to apply the render pass to.
  68053. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68054. * @param engine The engine which the post process will be applied. (default: current engine)
  68055. * @param reusable If the post process can be reused on the same frame. (default: false)
  68056. * @param textureType Type of textures used when performing the post process. (default: 0)
  68057. */
  68058. constructor(name: string,
  68059. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68060. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68061. /**
  68062. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68063. */
  68064. static EdgeDetect0Kernel: number[];
  68065. /**
  68066. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68067. */
  68068. static EdgeDetect1Kernel: number[];
  68069. /**
  68070. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68071. */
  68072. static EdgeDetect2Kernel: number[];
  68073. /**
  68074. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68075. */
  68076. static SharpenKernel: number[];
  68077. /**
  68078. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68079. */
  68080. static EmbossKernel: number[];
  68081. /**
  68082. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68083. */
  68084. static GaussianKernel: number[];
  68085. }
  68086. }
  68087. declare module BABYLON {
  68088. /**
  68089. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68090. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68091. * based on samples that have a large difference in distance than the center pixel.
  68092. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68093. */
  68094. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68095. direction: Vector2;
  68096. /**
  68097. * Creates a new instance CircleOfConfusionPostProcess
  68098. * @param name The name of the effect.
  68099. * @param scene The scene the effect belongs to.
  68100. * @param direction The direction the blur should be applied.
  68101. * @param kernel The size of the kernel used to blur.
  68102. * @param options The required width/height ratio to downsize to before computing the render pass.
  68103. * @param camera The camera to apply the render pass to.
  68104. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68105. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68107. * @param engine The engine which the post process will be applied. (default: current engine)
  68108. * @param reusable If the post process can be reused on the same frame. (default: false)
  68109. * @param textureType Type of textures used when performing the post process. (default: 0)
  68110. * @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)
  68111. */
  68112. 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);
  68113. }
  68114. }
  68115. declare module BABYLON {
  68116. /** @hidden */
  68117. export var depthOfFieldMergePixelShader: {
  68118. name: string;
  68119. shader: string;
  68120. };
  68121. }
  68122. declare module BABYLON {
  68123. /**
  68124. * Options to be set when merging outputs from the default pipeline.
  68125. */
  68126. export class DepthOfFieldMergePostProcessOptions {
  68127. /**
  68128. * The original image to merge on top of
  68129. */
  68130. originalFromInput: PostProcess;
  68131. /**
  68132. * Parameters to perform the merge of the depth of field effect
  68133. */
  68134. depthOfField?: {
  68135. circleOfConfusion: PostProcess;
  68136. blurSteps: Array<PostProcess>;
  68137. };
  68138. /**
  68139. * Parameters to perform the merge of bloom effect
  68140. */
  68141. bloom?: {
  68142. blurred: PostProcess;
  68143. weight: number;
  68144. };
  68145. }
  68146. /**
  68147. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68148. */
  68149. export class DepthOfFieldMergePostProcess extends PostProcess {
  68150. private blurSteps;
  68151. /**
  68152. * Creates a new instance of DepthOfFieldMergePostProcess
  68153. * @param name The name of the effect.
  68154. * @param originalFromInput Post process which's input will be used for the merge.
  68155. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68156. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68157. * @param options The required width/height ratio to downsize to before computing the render pass.
  68158. * @param camera The camera to apply the render pass to.
  68159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68160. * @param engine The engine which the post process will be applied. (default: current engine)
  68161. * @param reusable If the post process can be reused on the same frame. (default: false)
  68162. * @param textureType Type of textures used when performing the post process. (default: 0)
  68163. * @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)
  68164. */
  68165. 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);
  68166. /**
  68167. * Updates the effect with the current post process compile time values and recompiles the shader.
  68168. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68169. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68170. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68171. * @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
  68172. * @param onCompiled Called when the shader has been compiled.
  68173. * @param onError Called if there is an error when compiling a shader.
  68174. */
  68175. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68176. }
  68177. }
  68178. declare module BABYLON {
  68179. /**
  68180. * Specifies the level of max blur that should be applied when using the depth of field effect
  68181. */
  68182. export enum DepthOfFieldEffectBlurLevel {
  68183. /**
  68184. * Subtle blur
  68185. */
  68186. Low = 0,
  68187. /**
  68188. * Medium blur
  68189. */
  68190. Medium = 1,
  68191. /**
  68192. * Large blur
  68193. */
  68194. High = 2
  68195. }
  68196. /**
  68197. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68198. */
  68199. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68200. private _circleOfConfusion;
  68201. /**
  68202. * @hidden Internal, blurs from high to low
  68203. */
  68204. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68205. private _depthOfFieldBlurY;
  68206. private _dofMerge;
  68207. /**
  68208. * @hidden Internal post processes in depth of field effect
  68209. */
  68210. _effects: Array<PostProcess>;
  68211. /**
  68212. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68213. */
  68214. set focalLength(value: number);
  68215. get focalLength(): number;
  68216. /**
  68217. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68218. */
  68219. set fStop(value: number);
  68220. get fStop(): number;
  68221. /**
  68222. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68223. */
  68224. set focusDistance(value: number);
  68225. get focusDistance(): number;
  68226. /**
  68227. * 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.
  68228. */
  68229. set lensSize(value: number);
  68230. get lensSize(): number;
  68231. /**
  68232. * Creates a new instance DepthOfFieldEffect
  68233. * @param scene The scene the effect belongs to.
  68234. * @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.
  68235. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68236. * @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)
  68237. */
  68238. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68239. /**
  68240. * Get the current class name of the current effet
  68241. * @returns "DepthOfFieldEffect"
  68242. */
  68243. getClassName(): string;
  68244. /**
  68245. * 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.
  68246. */
  68247. set depthTexture(value: RenderTargetTexture);
  68248. /**
  68249. * Disposes each of the internal effects for a given camera.
  68250. * @param camera The camera to dispose the effect on.
  68251. */
  68252. disposeEffects(camera: Camera): void;
  68253. /**
  68254. * @hidden Internal
  68255. */
  68256. _updateEffects(): void;
  68257. /**
  68258. * Internal
  68259. * @returns if all the contained post processes are ready.
  68260. * @hidden
  68261. */
  68262. _isReady(): boolean;
  68263. }
  68264. }
  68265. declare module BABYLON {
  68266. /** @hidden */
  68267. export var displayPassPixelShader: {
  68268. name: string;
  68269. shader: string;
  68270. };
  68271. }
  68272. declare module BABYLON {
  68273. /**
  68274. * DisplayPassPostProcess which produces an output the same as it's input
  68275. */
  68276. export class DisplayPassPostProcess extends PostProcess {
  68277. /**
  68278. * Creates the DisplayPassPostProcess
  68279. * @param name The name of the effect.
  68280. * @param options The required width/height ratio to downsize to before computing the render pass.
  68281. * @param camera The camera to apply the render pass to.
  68282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68283. * @param engine The engine which the post process will be applied. (default: current engine)
  68284. * @param reusable If the post process can be reused on the same frame. (default: false)
  68285. */
  68286. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68287. }
  68288. }
  68289. declare module BABYLON {
  68290. /** @hidden */
  68291. export var filterPixelShader: {
  68292. name: string;
  68293. shader: string;
  68294. };
  68295. }
  68296. declare module BABYLON {
  68297. /**
  68298. * Applies a kernel filter to the image
  68299. */
  68300. export class FilterPostProcess extends PostProcess {
  68301. /** The matrix to be applied to the image */
  68302. kernelMatrix: Matrix;
  68303. /**
  68304. *
  68305. * @param name The name of the effect.
  68306. * @param kernelMatrix The matrix to be applied to the image
  68307. * @param options The required width/height ratio to downsize to before computing the render pass.
  68308. * @param camera The camera to apply the render pass to.
  68309. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68310. * @param engine The engine which the post process will be applied. (default: current engine)
  68311. * @param reusable If the post process can be reused on the same frame. (default: false)
  68312. */
  68313. constructor(name: string,
  68314. /** The matrix to be applied to the image */
  68315. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68316. }
  68317. }
  68318. declare module BABYLON {
  68319. /** @hidden */
  68320. export var fxaaPixelShader: {
  68321. name: string;
  68322. shader: string;
  68323. };
  68324. }
  68325. declare module BABYLON {
  68326. /** @hidden */
  68327. export var fxaaVertexShader: {
  68328. name: string;
  68329. shader: string;
  68330. };
  68331. }
  68332. declare module BABYLON {
  68333. /**
  68334. * Fxaa post process
  68335. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68336. */
  68337. export class FxaaPostProcess extends PostProcess {
  68338. /** @hidden */
  68339. texelWidth: number;
  68340. /** @hidden */
  68341. texelHeight: number;
  68342. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68343. private _getDefines;
  68344. }
  68345. }
  68346. declare module BABYLON {
  68347. /** @hidden */
  68348. export var grainPixelShader: {
  68349. name: string;
  68350. shader: string;
  68351. };
  68352. }
  68353. declare module BABYLON {
  68354. /**
  68355. * The GrainPostProcess adds noise to the image at mid luminance levels
  68356. */
  68357. export class GrainPostProcess extends PostProcess {
  68358. /**
  68359. * The intensity of the grain added (default: 30)
  68360. */
  68361. intensity: number;
  68362. /**
  68363. * If the grain should be randomized on every frame
  68364. */
  68365. animated: boolean;
  68366. /**
  68367. * Creates a new instance of @see GrainPostProcess
  68368. * @param name The name of the effect.
  68369. * @param options The required width/height ratio to downsize to before computing the render pass.
  68370. * @param camera The camera to apply the render pass to.
  68371. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68372. * @param engine The engine which the post process will be applied. (default: current engine)
  68373. * @param reusable If the post process can be reused on the same frame. (default: false)
  68374. * @param textureType Type of textures used when performing the post process. (default: 0)
  68375. * @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)
  68376. */
  68377. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68378. }
  68379. }
  68380. declare module BABYLON {
  68381. /** @hidden */
  68382. export var highlightsPixelShader: {
  68383. name: string;
  68384. shader: string;
  68385. };
  68386. }
  68387. declare module BABYLON {
  68388. /**
  68389. * Extracts highlights from the image
  68390. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68391. */
  68392. export class HighlightsPostProcess extends PostProcess {
  68393. /**
  68394. * Extracts highlights from the image
  68395. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68396. * @param name The name of the effect.
  68397. * @param options The required width/height ratio to downsize to before computing the render pass.
  68398. * @param camera The camera to apply the render pass to.
  68399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68400. * @param engine The engine which the post process will be applied. (default: current engine)
  68401. * @param reusable If the post process can be reused on the same frame. (default: false)
  68402. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68403. */
  68404. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68405. }
  68406. }
  68407. declare module BABYLON {
  68408. /** @hidden */
  68409. export var mrtFragmentDeclaration: {
  68410. name: string;
  68411. shader: string;
  68412. };
  68413. }
  68414. declare module BABYLON {
  68415. /** @hidden */
  68416. export var geometryPixelShader: {
  68417. name: string;
  68418. shader: string;
  68419. };
  68420. }
  68421. declare module BABYLON {
  68422. /** @hidden */
  68423. export var geometryVertexShader: {
  68424. name: string;
  68425. shader: string;
  68426. };
  68427. }
  68428. declare module BABYLON {
  68429. /** @hidden */
  68430. interface ISavedTransformationMatrix {
  68431. world: Matrix;
  68432. viewProjection: Matrix;
  68433. }
  68434. /**
  68435. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68436. */
  68437. export class GeometryBufferRenderer {
  68438. /**
  68439. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68440. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68441. */
  68442. static readonly POSITION_TEXTURE_TYPE: number;
  68443. /**
  68444. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68445. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68446. */
  68447. static readonly VELOCITY_TEXTURE_TYPE: number;
  68448. /**
  68449. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68450. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68451. */
  68452. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68453. /**
  68454. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68455. * in order to compute objects velocities when enableVelocity is set to "true"
  68456. * @hidden
  68457. */
  68458. _previousTransformationMatrices: {
  68459. [index: number]: ISavedTransformationMatrix;
  68460. };
  68461. /**
  68462. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68463. * in order to compute objects velocities when enableVelocity is set to "true"
  68464. * @hidden
  68465. */
  68466. _previousBonesTransformationMatrices: {
  68467. [index: number]: Float32Array;
  68468. };
  68469. /**
  68470. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68471. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68472. */
  68473. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68474. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68475. renderTransparentMeshes: boolean;
  68476. private _scene;
  68477. private _multiRenderTarget;
  68478. private _ratio;
  68479. private _enablePosition;
  68480. private _enableVelocity;
  68481. private _enableReflectivity;
  68482. private _positionIndex;
  68483. private _velocityIndex;
  68484. private _reflectivityIndex;
  68485. protected _effect: Effect;
  68486. protected _cachedDefines: string;
  68487. /**
  68488. * Set the render list (meshes to be rendered) used in the G buffer.
  68489. */
  68490. set renderList(meshes: Mesh[]);
  68491. /**
  68492. * Gets wether or not G buffer are supported by the running hardware.
  68493. * This requires draw buffer supports
  68494. */
  68495. get isSupported(): boolean;
  68496. /**
  68497. * Returns the index of the given texture type in the G-Buffer textures array
  68498. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68499. * @returns the index of the given texture type in the G-Buffer textures array
  68500. */
  68501. getTextureIndex(textureType: number): number;
  68502. /**
  68503. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68504. */
  68505. get enablePosition(): boolean;
  68506. /**
  68507. * Sets whether or not objects positions are enabled for the G buffer.
  68508. */
  68509. set enablePosition(enable: boolean);
  68510. /**
  68511. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68512. */
  68513. get enableVelocity(): boolean;
  68514. /**
  68515. * Sets wether or not objects velocities are enabled for the G buffer.
  68516. */
  68517. set enableVelocity(enable: boolean);
  68518. /**
  68519. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68520. */
  68521. get enableReflectivity(): boolean;
  68522. /**
  68523. * Sets wether or not objects roughness are enabled for the G buffer.
  68524. */
  68525. set enableReflectivity(enable: boolean);
  68526. /**
  68527. * Gets the scene associated with the buffer.
  68528. */
  68529. get scene(): Scene;
  68530. /**
  68531. * Gets the ratio used by the buffer during its creation.
  68532. * How big is the buffer related to the main canvas.
  68533. */
  68534. get ratio(): number;
  68535. /** @hidden */
  68536. static _SceneComponentInitialization: (scene: Scene) => void;
  68537. /**
  68538. * Creates a new G Buffer for the scene
  68539. * @param scene The scene the buffer belongs to
  68540. * @param ratio How big is the buffer related to the main canvas.
  68541. */
  68542. constructor(scene: Scene, ratio?: number);
  68543. /**
  68544. * Checks wether everything is ready to render a submesh to the G buffer.
  68545. * @param subMesh the submesh to check readiness for
  68546. * @param useInstances is the mesh drawn using instance or not
  68547. * @returns true if ready otherwise false
  68548. */
  68549. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68550. /**
  68551. * Gets the current underlying G Buffer.
  68552. * @returns the buffer
  68553. */
  68554. getGBuffer(): MultiRenderTarget;
  68555. /**
  68556. * Gets the number of samples used to render the buffer (anti aliasing).
  68557. */
  68558. get samples(): number;
  68559. /**
  68560. * Sets the number of samples used to render the buffer (anti aliasing).
  68561. */
  68562. set samples(value: number);
  68563. /**
  68564. * Disposes the renderer and frees up associated resources.
  68565. */
  68566. dispose(): void;
  68567. protected _createRenderTargets(): void;
  68568. private _copyBonesTransformationMatrices;
  68569. }
  68570. }
  68571. declare module BABYLON {
  68572. interface Scene {
  68573. /** @hidden (Backing field) */
  68574. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68575. /**
  68576. * Gets or Sets the current geometry buffer associated to the scene.
  68577. */
  68578. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68579. /**
  68580. * Enables a GeometryBufferRender and associates it with the scene
  68581. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68582. * @returns the GeometryBufferRenderer
  68583. */
  68584. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68585. /**
  68586. * Disables the GeometryBufferRender associated with the scene
  68587. */
  68588. disableGeometryBufferRenderer(): void;
  68589. }
  68590. /**
  68591. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68592. * in several rendering techniques.
  68593. */
  68594. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68595. /**
  68596. * The component name helpful to identify the component in the list of scene components.
  68597. */
  68598. readonly name: string;
  68599. /**
  68600. * The scene the component belongs to.
  68601. */
  68602. scene: Scene;
  68603. /**
  68604. * Creates a new instance of the component for the given scene
  68605. * @param scene Defines the scene to register the component in
  68606. */
  68607. constructor(scene: Scene);
  68608. /**
  68609. * Registers the component in a given scene
  68610. */
  68611. register(): void;
  68612. /**
  68613. * Rebuilds the elements related to this component in case of
  68614. * context lost for instance.
  68615. */
  68616. rebuild(): void;
  68617. /**
  68618. * Disposes the component and the associated ressources
  68619. */
  68620. dispose(): void;
  68621. private _gatherRenderTargets;
  68622. }
  68623. }
  68624. declare module BABYLON {
  68625. /** @hidden */
  68626. export var motionBlurPixelShader: {
  68627. name: string;
  68628. shader: string;
  68629. };
  68630. }
  68631. declare module BABYLON {
  68632. /**
  68633. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68634. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68635. * As an example, all you have to do is to create the post-process:
  68636. * var mb = new BABYLON.MotionBlurPostProcess(
  68637. * 'mb', // The name of the effect.
  68638. * scene, // The scene containing the objects to blur according to their velocity.
  68639. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68640. * camera // The camera to apply the render pass to.
  68641. * );
  68642. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68643. */
  68644. export class MotionBlurPostProcess extends PostProcess {
  68645. /**
  68646. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68647. */
  68648. motionStrength: number;
  68649. /**
  68650. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68651. */
  68652. get motionBlurSamples(): number;
  68653. /**
  68654. * Sets the number of iterations to be used for motion blur quality
  68655. */
  68656. set motionBlurSamples(samples: number);
  68657. private _motionBlurSamples;
  68658. private _geometryBufferRenderer;
  68659. /**
  68660. * Creates a new instance MotionBlurPostProcess
  68661. * @param name The name of the effect.
  68662. * @param scene The scene containing the objects to blur according to their velocity.
  68663. * @param options The required width/height ratio to downsize to before computing the render pass.
  68664. * @param camera The camera to apply the render pass to.
  68665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68666. * @param engine The engine which the post process will be applied. (default: current engine)
  68667. * @param reusable If the post process can be reused on the same frame. (default: false)
  68668. * @param textureType Type of textures used when performing the post process. (default: 0)
  68669. * @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)
  68670. */
  68671. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68672. /**
  68673. * Excludes the given skinned mesh from computing bones velocities.
  68674. * 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.
  68675. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68676. */
  68677. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68678. /**
  68679. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68680. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68681. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68682. */
  68683. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68684. /**
  68685. * Disposes the post process.
  68686. * @param camera The camera to dispose the post process on.
  68687. */
  68688. dispose(camera?: Camera): void;
  68689. }
  68690. }
  68691. declare module BABYLON {
  68692. /** @hidden */
  68693. export var refractionPixelShader: {
  68694. name: string;
  68695. shader: string;
  68696. };
  68697. }
  68698. declare module BABYLON {
  68699. /**
  68700. * Post process which applies a refractin texture
  68701. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68702. */
  68703. export class RefractionPostProcess extends PostProcess {
  68704. /** the base color of the refraction (used to taint the rendering) */
  68705. color: Color3;
  68706. /** simulated refraction depth */
  68707. depth: number;
  68708. /** the coefficient of the base color (0 to remove base color tainting) */
  68709. colorLevel: number;
  68710. private _refTexture;
  68711. private _ownRefractionTexture;
  68712. /**
  68713. * Gets or sets the refraction texture
  68714. * Please note that you are responsible for disposing the texture if you set it manually
  68715. */
  68716. get refractionTexture(): Texture;
  68717. set refractionTexture(value: Texture);
  68718. /**
  68719. * Initializes the RefractionPostProcess
  68720. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68721. * @param name The name of the effect.
  68722. * @param refractionTextureUrl Url of the refraction texture to use
  68723. * @param color the base color of the refraction (used to taint the rendering)
  68724. * @param depth simulated refraction depth
  68725. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68726. * @param camera The camera to apply the render pass to.
  68727. * @param options The required width/height ratio to downsize to before computing the render pass.
  68728. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68729. * @param engine The engine which the post process will be applied. (default: current engine)
  68730. * @param reusable If the post process can be reused on the same frame. (default: false)
  68731. */
  68732. constructor(name: string, refractionTextureUrl: string,
  68733. /** the base color of the refraction (used to taint the rendering) */
  68734. color: Color3,
  68735. /** simulated refraction depth */
  68736. depth: number,
  68737. /** the coefficient of the base color (0 to remove base color tainting) */
  68738. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68739. /**
  68740. * Disposes of the post process
  68741. * @param camera Camera to dispose post process on
  68742. */
  68743. dispose(camera: Camera): void;
  68744. }
  68745. }
  68746. declare module BABYLON {
  68747. /** @hidden */
  68748. export var sharpenPixelShader: {
  68749. name: string;
  68750. shader: string;
  68751. };
  68752. }
  68753. declare module BABYLON {
  68754. /**
  68755. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68756. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68757. */
  68758. export class SharpenPostProcess extends PostProcess {
  68759. /**
  68760. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68761. */
  68762. colorAmount: number;
  68763. /**
  68764. * How much sharpness should be applied (default: 0.3)
  68765. */
  68766. edgeAmount: number;
  68767. /**
  68768. * Creates a new instance ConvolutionPostProcess
  68769. * @param name The name of the effect.
  68770. * @param options The required width/height ratio to downsize to before computing the render pass.
  68771. * @param camera The camera to apply the render pass to.
  68772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68773. * @param engine The engine which the post process will be applied. (default: current engine)
  68774. * @param reusable If the post process can be reused on the same frame. (default: false)
  68775. * @param textureType Type of textures used when performing the post process. (default: 0)
  68776. * @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)
  68777. */
  68778. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68779. }
  68780. }
  68781. declare module BABYLON {
  68782. /**
  68783. * PostProcessRenderPipeline
  68784. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68785. */
  68786. export class PostProcessRenderPipeline {
  68787. private engine;
  68788. private _renderEffects;
  68789. private _renderEffectsForIsolatedPass;
  68790. /**
  68791. * List of inspectable custom properties (used by the Inspector)
  68792. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68793. */
  68794. inspectableCustomProperties: IInspectable[];
  68795. /**
  68796. * @hidden
  68797. */
  68798. protected _cameras: Camera[];
  68799. /** @hidden */
  68800. _name: string;
  68801. /**
  68802. * Gets pipeline name
  68803. */
  68804. get name(): string;
  68805. /** Gets the list of attached cameras */
  68806. get cameras(): Camera[];
  68807. /**
  68808. * Initializes a PostProcessRenderPipeline
  68809. * @param engine engine to add the pipeline to
  68810. * @param name name of the pipeline
  68811. */
  68812. constructor(engine: Engine, name: string);
  68813. /**
  68814. * Gets the class name
  68815. * @returns "PostProcessRenderPipeline"
  68816. */
  68817. getClassName(): string;
  68818. /**
  68819. * If all the render effects in the pipeline are supported
  68820. */
  68821. get isSupported(): boolean;
  68822. /**
  68823. * Adds an effect to the pipeline
  68824. * @param renderEffect the effect to add
  68825. */
  68826. addEffect(renderEffect: PostProcessRenderEffect): void;
  68827. /** @hidden */
  68828. _rebuild(): void;
  68829. /** @hidden */
  68830. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68831. /** @hidden */
  68832. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68833. /** @hidden */
  68834. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68835. /** @hidden */
  68836. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68837. /** @hidden */
  68838. _attachCameras(cameras: Camera, unique: boolean): void;
  68839. /** @hidden */
  68840. _attachCameras(cameras: Camera[], unique: boolean): void;
  68841. /** @hidden */
  68842. _detachCameras(cameras: Camera): void;
  68843. /** @hidden */
  68844. _detachCameras(cameras: Nullable<Camera[]>): void;
  68845. /** @hidden */
  68846. _update(): void;
  68847. /** @hidden */
  68848. _reset(): void;
  68849. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68850. /**
  68851. * Disposes of the pipeline
  68852. */
  68853. dispose(): void;
  68854. }
  68855. }
  68856. declare module BABYLON {
  68857. /**
  68858. * PostProcessRenderPipelineManager class
  68859. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68860. */
  68861. export class PostProcessRenderPipelineManager {
  68862. private _renderPipelines;
  68863. /**
  68864. * Initializes a PostProcessRenderPipelineManager
  68865. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68866. */
  68867. constructor();
  68868. /**
  68869. * Gets the list of supported render pipelines
  68870. */
  68871. get supportedPipelines(): PostProcessRenderPipeline[];
  68872. /**
  68873. * Adds a pipeline to the manager
  68874. * @param renderPipeline The pipeline to add
  68875. */
  68876. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68877. /**
  68878. * Attaches a camera to the pipeline
  68879. * @param renderPipelineName The name of the pipeline to attach to
  68880. * @param cameras the camera to attach
  68881. * @param unique if the camera can be attached multiple times to the pipeline
  68882. */
  68883. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68884. /**
  68885. * Detaches a camera from the pipeline
  68886. * @param renderPipelineName The name of the pipeline to detach from
  68887. * @param cameras the camera to detach
  68888. */
  68889. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68890. /**
  68891. * Enables an effect by name on a pipeline
  68892. * @param renderPipelineName the name of the pipeline to enable the effect in
  68893. * @param renderEffectName the name of the effect to enable
  68894. * @param cameras the cameras that the effect should be enabled on
  68895. */
  68896. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68897. /**
  68898. * Disables an effect by name on a pipeline
  68899. * @param renderPipelineName the name of the pipeline to disable the effect in
  68900. * @param renderEffectName the name of the effect to disable
  68901. * @param cameras the cameras that the effect should be disabled on
  68902. */
  68903. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68904. /**
  68905. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68906. */
  68907. update(): void;
  68908. /** @hidden */
  68909. _rebuild(): void;
  68910. /**
  68911. * Disposes of the manager and pipelines
  68912. */
  68913. dispose(): void;
  68914. }
  68915. }
  68916. declare module BABYLON {
  68917. interface Scene {
  68918. /** @hidden (Backing field) */
  68919. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68920. /**
  68921. * Gets the postprocess render pipeline manager
  68922. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68923. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68924. */
  68925. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68926. }
  68927. /**
  68928. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68929. */
  68930. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68931. /**
  68932. * The component name helpfull to identify the component in the list of scene components.
  68933. */
  68934. readonly name: string;
  68935. /**
  68936. * The scene the component belongs to.
  68937. */
  68938. scene: Scene;
  68939. /**
  68940. * Creates a new instance of the component for the given scene
  68941. * @param scene Defines the scene to register the component in
  68942. */
  68943. constructor(scene: Scene);
  68944. /**
  68945. * Registers the component in a given scene
  68946. */
  68947. register(): void;
  68948. /**
  68949. * Rebuilds the elements related to this component in case of
  68950. * context lost for instance.
  68951. */
  68952. rebuild(): void;
  68953. /**
  68954. * Disposes the component and the associated ressources
  68955. */
  68956. dispose(): void;
  68957. private _gatherRenderTargets;
  68958. }
  68959. }
  68960. declare module BABYLON {
  68961. /**
  68962. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68963. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68964. */
  68965. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68966. private _scene;
  68967. private _camerasToBeAttached;
  68968. /**
  68969. * ID of the sharpen post process,
  68970. */
  68971. private readonly SharpenPostProcessId;
  68972. /**
  68973. * @ignore
  68974. * ID of the image processing post process;
  68975. */
  68976. readonly ImageProcessingPostProcessId: string;
  68977. /**
  68978. * @ignore
  68979. * ID of the Fast Approximate Anti-Aliasing post process;
  68980. */
  68981. readonly FxaaPostProcessId: string;
  68982. /**
  68983. * ID of the chromatic aberration post process,
  68984. */
  68985. private readonly ChromaticAberrationPostProcessId;
  68986. /**
  68987. * ID of the grain post process
  68988. */
  68989. private readonly GrainPostProcessId;
  68990. /**
  68991. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68992. */
  68993. sharpen: SharpenPostProcess;
  68994. private _sharpenEffect;
  68995. private bloom;
  68996. /**
  68997. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68998. */
  68999. depthOfField: DepthOfFieldEffect;
  69000. /**
  69001. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69002. */
  69003. fxaa: FxaaPostProcess;
  69004. /**
  69005. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69006. */
  69007. imageProcessing: ImageProcessingPostProcess;
  69008. /**
  69009. * Chromatic aberration post process which will shift rgb colors in the image
  69010. */
  69011. chromaticAberration: ChromaticAberrationPostProcess;
  69012. private _chromaticAberrationEffect;
  69013. /**
  69014. * Grain post process which add noise to the image
  69015. */
  69016. grain: GrainPostProcess;
  69017. private _grainEffect;
  69018. /**
  69019. * Glow post process which adds a glow to emissive areas of the image
  69020. */
  69021. private _glowLayer;
  69022. /**
  69023. * Animations which can be used to tweak settings over a period of time
  69024. */
  69025. animations: Animation[];
  69026. private _imageProcessingConfigurationObserver;
  69027. private _sharpenEnabled;
  69028. private _bloomEnabled;
  69029. private _depthOfFieldEnabled;
  69030. private _depthOfFieldBlurLevel;
  69031. private _fxaaEnabled;
  69032. private _imageProcessingEnabled;
  69033. private _defaultPipelineTextureType;
  69034. private _bloomScale;
  69035. private _chromaticAberrationEnabled;
  69036. private _grainEnabled;
  69037. private _buildAllowed;
  69038. /**
  69039. * Gets active scene
  69040. */
  69041. get scene(): Scene;
  69042. /**
  69043. * Enable or disable the sharpen process from the pipeline
  69044. */
  69045. set sharpenEnabled(enabled: boolean);
  69046. get sharpenEnabled(): boolean;
  69047. private _resizeObserver;
  69048. private _hardwareScaleLevel;
  69049. private _bloomKernel;
  69050. /**
  69051. * Specifies the size of the bloom blur kernel, relative to the final output size
  69052. */
  69053. get bloomKernel(): number;
  69054. set bloomKernel(value: number);
  69055. /**
  69056. * Specifies the weight of the bloom in the final rendering
  69057. */
  69058. private _bloomWeight;
  69059. /**
  69060. * Specifies the luma threshold for the area that will be blurred by the bloom
  69061. */
  69062. private _bloomThreshold;
  69063. private _hdr;
  69064. /**
  69065. * The strength of the bloom.
  69066. */
  69067. set bloomWeight(value: number);
  69068. get bloomWeight(): number;
  69069. /**
  69070. * The strength of the bloom.
  69071. */
  69072. set bloomThreshold(value: number);
  69073. get bloomThreshold(): number;
  69074. /**
  69075. * The scale of the bloom, lower value will provide better performance.
  69076. */
  69077. set bloomScale(value: number);
  69078. get bloomScale(): number;
  69079. /**
  69080. * Enable or disable the bloom from the pipeline
  69081. */
  69082. set bloomEnabled(enabled: boolean);
  69083. get bloomEnabled(): boolean;
  69084. private _rebuildBloom;
  69085. /**
  69086. * If the depth of field is enabled.
  69087. */
  69088. get depthOfFieldEnabled(): boolean;
  69089. set depthOfFieldEnabled(enabled: boolean);
  69090. /**
  69091. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69092. */
  69093. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69094. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69095. /**
  69096. * If the anti aliasing is enabled.
  69097. */
  69098. set fxaaEnabled(enabled: boolean);
  69099. get fxaaEnabled(): boolean;
  69100. private _samples;
  69101. /**
  69102. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69103. */
  69104. set samples(sampleCount: number);
  69105. get samples(): number;
  69106. /**
  69107. * If image processing is enabled.
  69108. */
  69109. set imageProcessingEnabled(enabled: boolean);
  69110. get imageProcessingEnabled(): boolean;
  69111. /**
  69112. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69113. */
  69114. set glowLayerEnabled(enabled: boolean);
  69115. get glowLayerEnabled(): boolean;
  69116. /**
  69117. * Gets the glow layer (or null if not defined)
  69118. */
  69119. get glowLayer(): Nullable<GlowLayer>;
  69120. /**
  69121. * Enable or disable the chromaticAberration process from the pipeline
  69122. */
  69123. set chromaticAberrationEnabled(enabled: boolean);
  69124. get chromaticAberrationEnabled(): boolean;
  69125. /**
  69126. * Enable or disable the grain process from the pipeline
  69127. */
  69128. set grainEnabled(enabled: boolean);
  69129. get grainEnabled(): boolean;
  69130. /**
  69131. * @constructor
  69132. * @param name - The rendering pipeline name (default: "")
  69133. * @param hdr - If high dynamic range textures should be used (default: true)
  69134. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69135. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69136. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69137. */
  69138. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69139. /**
  69140. * Get the class name
  69141. * @returns "DefaultRenderingPipeline"
  69142. */
  69143. getClassName(): string;
  69144. /**
  69145. * Force the compilation of the entire pipeline.
  69146. */
  69147. prepare(): void;
  69148. private _hasCleared;
  69149. private _prevPostProcess;
  69150. private _prevPrevPostProcess;
  69151. private _setAutoClearAndTextureSharing;
  69152. private _depthOfFieldSceneObserver;
  69153. private _buildPipeline;
  69154. private _disposePostProcesses;
  69155. /**
  69156. * Adds a camera to the pipeline
  69157. * @param camera the camera to be added
  69158. */
  69159. addCamera(camera: Camera): void;
  69160. /**
  69161. * Removes a camera from the pipeline
  69162. * @param camera the camera to remove
  69163. */
  69164. removeCamera(camera: Camera): void;
  69165. /**
  69166. * Dispose of the pipeline and stop all post processes
  69167. */
  69168. dispose(): void;
  69169. /**
  69170. * Serialize the rendering pipeline (Used when exporting)
  69171. * @returns the serialized object
  69172. */
  69173. serialize(): any;
  69174. /**
  69175. * Parse the serialized pipeline
  69176. * @param source Source pipeline.
  69177. * @param scene The scene to load the pipeline to.
  69178. * @param rootUrl The URL of the serialized pipeline.
  69179. * @returns An instantiated pipeline from the serialized object.
  69180. */
  69181. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69182. }
  69183. }
  69184. declare module BABYLON {
  69185. /** @hidden */
  69186. export var lensHighlightsPixelShader: {
  69187. name: string;
  69188. shader: string;
  69189. };
  69190. }
  69191. declare module BABYLON {
  69192. /** @hidden */
  69193. export var depthOfFieldPixelShader: {
  69194. name: string;
  69195. shader: string;
  69196. };
  69197. }
  69198. declare module BABYLON {
  69199. /**
  69200. * BABYLON.JS Chromatic Aberration GLSL Shader
  69201. * Author: Olivier Guyot
  69202. * Separates very slightly R, G and B colors on the edges of the screen
  69203. * Inspired by Francois Tarlier & Martins Upitis
  69204. */
  69205. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69206. /**
  69207. * @ignore
  69208. * The chromatic aberration PostProcess id in the pipeline
  69209. */
  69210. LensChromaticAberrationEffect: string;
  69211. /**
  69212. * @ignore
  69213. * The highlights enhancing PostProcess id in the pipeline
  69214. */
  69215. HighlightsEnhancingEffect: string;
  69216. /**
  69217. * @ignore
  69218. * The depth-of-field PostProcess id in the pipeline
  69219. */
  69220. LensDepthOfFieldEffect: string;
  69221. private _scene;
  69222. private _depthTexture;
  69223. private _grainTexture;
  69224. private _chromaticAberrationPostProcess;
  69225. private _highlightsPostProcess;
  69226. private _depthOfFieldPostProcess;
  69227. private _edgeBlur;
  69228. private _grainAmount;
  69229. private _chromaticAberration;
  69230. private _distortion;
  69231. private _highlightsGain;
  69232. private _highlightsThreshold;
  69233. private _dofDistance;
  69234. private _dofAperture;
  69235. private _dofDarken;
  69236. private _dofPentagon;
  69237. private _blurNoise;
  69238. /**
  69239. * @constructor
  69240. *
  69241. * Effect parameters are as follow:
  69242. * {
  69243. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69244. * edge_blur: number; // from 0 to x (1 for realism)
  69245. * distortion: number; // from 0 to x (1 for realism)
  69246. * grain_amount: number; // from 0 to 1
  69247. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69248. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69249. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69250. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69251. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69252. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69253. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69254. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69255. * }
  69256. * Note: if an effect parameter is unset, effect is disabled
  69257. *
  69258. * @param name The rendering pipeline name
  69259. * @param parameters - An object containing all parameters (see above)
  69260. * @param scene The scene linked to this pipeline
  69261. * @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)
  69262. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69263. */
  69264. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69265. /**
  69266. * Get the class name
  69267. * @returns "LensRenderingPipeline"
  69268. */
  69269. getClassName(): string;
  69270. /**
  69271. * Gets associated scene
  69272. */
  69273. get scene(): Scene;
  69274. /**
  69275. * Gets or sets the edge blur
  69276. */
  69277. get edgeBlur(): number;
  69278. set edgeBlur(value: number);
  69279. /**
  69280. * Gets or sets the grain amount
  69281. */
  69282. get grainAmount(): number;
  69283. set grainAmount(value: number);
  69284. /**
  69285. * Gets or sets the chromatic aberration amount
  69286. */
  69287. get chromaticAberration(): number;
  69288. set chromaticAberration(value: number);
  69289. /**
  69290. * Gets or sets the depth of field aperture
  69291. */
  69292. get dofAperture(): number;
  69293. set dofAperture(value: number);
  69294. /**
  69295. * Gets or sets the edge distortion
  69296. */
  69297. get edgeDistortion(): number;
  69298. set edgeDistortion(value: number);
  69299. /**
  69300. * Gets or sets the depth of field distortion
  69301. */
  69302. get dofDistortion(): number;
  69303. set dofDistortion(value: number);
  69304. /**
  69305. * Gets or sets the darken out of focus amount
  69306. */
  69307. get darkenOutOfFocus(): number;
  69308. set darkenOutOfFocus(value: number);
  69309. /**
  69310. * Gets or sets a boolean indicating if blur noise is enabled
  69311. */
  69312. get blurNoise(): boolean;
  69313. set blurNoise(value: boolean);
  69314. /**
  69315. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69316. */
  69317. get pentagonBokeh(): boolean;
  69318. set pentagonBokeh(value: boolean);
  69319. /**
  69320. * Gets or sets the highlight grain amount
  69321. */
  69322. get highlightsGain(): number;
  69323. set highlightsGain(value: number);
  69324. /**
  69325. * Gets or sets the highlight threshold
  69326. */
  69327. get highlightsThreshold(): number;
  69328. set highlightsThreshold(value: number);
  69329. /**
  69330. * Sets the amount of blur at the edges
  69331. * @param amount blur amount
  69332. */
  69333. setEdgeBlur(amount: number): void;
  69334. /**
  69335. * Sets edge blur to 0
  69336. */
  69337. disableEdgeBlur(): void;
  69338. /**
  69339. * Sets the amout of grain
  69340. * @param amount Amount of grain
  69341. */
  69342. setGrainAmount(amount: number): void;
  69343. /**
  69344. * Set grain amount to 0
  69345. */
  69346. disableGrain(): void;
  69347. /**
  69348. * Sets the chromatic aberration amount
  69349. * @param amount amount of chromatic aberration
  69350. */
  69351. setChromaticAberration(amount: number): void;
  69352. /**
  69353. * Sets chromatic aberration amount to 0
  69354. */
  69355. disableChromaticAberration(): void;
  69356. /**
  69357. * Sets the EdgeDistortion amount
  69358. * @param amount amount of EdgeDistortion
  69359. */
  69360. setEdgeDistortion(amount: number): void;
  69361. /**
  69362. * Sets edge distortion to 0
  69363. */
  69364. disableEdgeDistortion(): void;
  69365. /**
  69366. * Sets the FocusDistance amount
  69367. * @param amount amount of FocusDistance
  69368. */
  69369. setFocusDistance(amount: number): void;
  69370. /**
  69371. * Disables depth of field
  69372. */
  69373. disableDepthOfField(): void;
  69374. /**
  69375. * Sets the Aperture amount
  69376. * @param amount amount of Aperture
  69377. */
  69378. setAperture(amount: number): void;
  69379. /**
  69380. * Sets the DarkenOutOfFocus amount
  69381. * @param amount amount of DarkenOutOfFocus
  69382. */
  69383. setDarkenOutOfFocus(amount: number): void;
  69384. private _pentagonBokehIsEnabled;
  69385. /**
  69386. * Creates a pentagon bokeh effect
  69387. */
  69388. enablePentagonBokeh(): void;
  69389. /**
  69390. * Disables the pentagon bokeh effect
  69391. */
  69392. disablePentagonBokeh(): void;
  69393. /**
  69394. * Enables noise blur
  69395. */
  69396. enableNoiseBlur(): void;
  69397. /**
  69398. * Disables noise blur
  69399. */
  69400. disableNoiseBlur(): void;
  69401. /**
  69402. * Sets the HighlightsGain amount
  69403. * @param amount amount of HighlightsGain
  69404. */
  69405. setHighlightsGain(amount: number): void;
  69406. /**
  69407. * Sets the HighlightsThreshold amount
  69408. * @param amount amount of HighlightsThreshold
  69409. */
  69410. setHighlightsThreshold(amount: number): void;
  69411. /**
  69412. * Disables highlights
  69413. */
  69414. disableHighlights(): void;
  69415. /**
  69416. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69417. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69418. */
  69419. dispose(disableDepthRender?: boolean): void;
  69420. private _createChromaticAberrationPostProcess;
  69421. private _createHighlightsPostProcess;
  69422. private _createDepthOfFieldPostProcess;
  69423. private _createGrainTexture;
  69424. }
  69425. }
  69426. declare module BABYLON {
  69427. /** @hidden */
  69428. export var ssao2PixelShader: {
  69429. name: string;
  69430. shader: string;
  69431. };
  69432. }
  69433. declare module BABYLON {
  69434. /** @hidden */
  69435. export var ssaoCombinePixelShader: {
  69436. name: string;
  69437. shader: string;
  69438. };
  69439. }
  69440. declare module BABYLON {
  69441. /**
  69442. * Render pipeline to produce ssao effect
  69443. */
  69444. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69445. /**
  69446. * @ignore
  69447. * The PassPostProcess id in the pipeline that contains the original scene color
  69448. */
  69449. SSAOOriginalSceneColorEffect: string;
  69450. /**
  69451. * @ignore
  69452. * The SSAO PostProcess id in the pipeline
  69453. */
  69454. SSAORenderEffect: string;
  69455. /**
  69456. * @ignore
  69457. * The horizontal blur PostProcess id in the pipeline
  69458. */
  69459. SSAOBlurHRenderEffect: string;
  69460. /**
  69461. * @ignore
  69462. * The vertical blur PostProcess id in the pipeline
  69463. */
  69464. SSAOBlurVRenderEffect: string;
  69465. /**
  69466. * @ignore
  69467. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69468. */
  69469. SSAOCombineRenderEffect: string;
  69470. /**
  69471. * The output strength of the SSAO post-process. Default value is 1.0.
  69472. */
  69473. totalStrength: number;
  69474. /**
  69475. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69476. */
  69477. maxZ: number;
  69478. /**
  69479. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69480. */
  69481. minZAspect: number;
  69482. private _samples;
  69483. /**
  69484. * Number of samples used for the SSAO calculations. Default value is 8
  69485. */
  69486. set samples(n: number);
  69487. get samples(): number;
  69488. private _textureSamples;
  69489. /**
  69490. * Number of samples to use for antialiasing
  69491. */
  69492. set textureSamples(n: number);
  69493. get textureSamples(): number;
  69494. /**
  69495. * Ratio object used for SSAO ratio and blur ratio
  69496. */
  69497. private _ratio;
  69498. /**
  69499. * Dynamically generated sphere sampler.
  69500. */
  69501. private _sampleSphere;
  69502. /**
  69503. * Blur filter offsets
  69504. */
  69505. private _samplerOffsets;
  69506. private _expensiveBlur;
  69507. /**
  69508. * If bilateral blur should be used
  69509. */
  69510. set expensiveBlur(b: boolean);
  69511. get expensiveBlur(): boolean;
  69512. /**
  69513. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69514. */
  69515. radius: number;
  69516. /**
  69517. * The base color of the SSAO post-process
  69518. * The final result is "base + ssao" between [0, 1]
  69519. */
  69520. base: number;
  69521. /**
  69522. * Support test.
  69523. */
  69524. static get IsSupported(): boolean;
  69525. private _scene;
  69526. private _depthTexture;
  69527. private _normalTexture;
  69528. private _randomTexture;
  69529. private _originalColorPostProcess;
  69530. private _ssaoPostProcess;
  69531. private _blurHPostProcess;
  69532. private _blurVPostProcess;
  69533. private _ssaoCombinePostProcess;
  69534. /**
  69535. * Gets active scene
  69536. */
  69537. get scene(): Scene;
  69538. /**
  69539. * @constructor
  69540. * @param name The rendering pipeline name
  69541. * @param scene The scene linked to this pipeline
  69542. * @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 }
  69543. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69544. */
  69545. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69546. /**
  69547. * Get the class name
  69548. * @returns "SSAO2RenderingPipeline"
  69549. */
  69550. getClassName(): string;
  69551. /**
  69552. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69553. */
  69554. dispose(disableGeometryBufferRenderer?: boolean): void;
  69555. private _createBlurPostProcess;
  69556. /** @hidden */
  69557. _rebuild(): void;
  69558. private _bits;
  69559. private _radicalInverse_VdC;
  69560. private _hammersley;
  69561. private _hemisphereSample_uniform;
  69562. private _generateHemisphere;
  69563. private _createSSAOPostProcess;
  69564. private _createSSAOCombinePostProcess;
  69565. private _createRandomTexture;
  69566. /**
  69567. * Serialize the rendering pipeline (Used when exporting)
  69568. * @returns the serialized object
  69569. */
  69570. serialize(): any;
  69571. /**
  69572. * Parse the serialized pipeline
  69573. * @param source Source pipeline.
  69574. * @param scene The scene to load the pipeline to.
  69575. * @param rootUrl The URL of the serialized pipeline.
  69576. * @returns An instantiated pipeline from the serialized object.
  69577. */
  69578. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69579. }
  69580. }
  69581. declare module BABYLON {
  69582. /** @hidden */
  69583. export var ssaoPixelShader: {
  69584. name: string;
  69585. shader: string;
  69586. };
  69587. }
  69588. declare module BABYLON {
  69589. /**
  69590. * Render pipeline to produce ssao effect
  69591. */
  69592. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69593. /**
  69594. * @ignore
  69595. * The PassPostProcess id in the pipeline that contains the original scene color
  69596. */
  69597. SSAOOriginalSceneColorEffect: string;
  69598. /**
  69599. * @ignore
  69600. * The SSAO PostProcess id in the pipeline
  69601. */
  69602. SSAORenderEffect: string;
  69603. /**
  69604. * @ignore
  69605. * The horizontal blur PostProcess id in the pipeline
  69606. */
  69607. SSAOBlurHRenderEffect: string;
  69608. /**
  69609. * @ignore
  69610. * The vertical blur PostProcess id in the pipeline
  69611. */
  69612. SSAOBlurVRenderEffect: string;
  69613. /**
  69614. * @ignore
  69615. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69616. */
  69617. SSAOCombineRenderEffect: string;
  69618. /**
  69619. * The output strength of the SSAO post-process. Default value is 1.0.
  69620. */
  69621. totalStrength: number;
  69622. /**
  69623. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69624. */
  69625. radius: number;
  69626. /**
  69627. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69628. * Must not be equal to fallOff and superior to fallOff.
  69629. * Default value is 0.0075
  69630. */
  69631. area: number;
  69632. /**
  69633. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69634. * Must not be equal to area and inferior to area.
  69635. * Default value is 0.000001
  69636. */
  69637. fallOff: number;
  69638. /**
  69639. * The base color of the SSAO post-process
  69640. * The final result is "base + ssao" between [0, 1]
  69641. */
  69642. base: number;
  69643. private _scene;
  69644. private _depthTexture;
  69645. private _randomTexture;
  69646. private _originalColorPostProcess;
  69647. private _ssaoPostProcess;
  69648. private _blurHPostProcess;
  69649. private _blurVPostProcess;
  69650. private _ssaoCombinePostProcess;
  69651. private _firstUpdate;
  69652. /**
  69653. * Gets active scene
  69654. */
  69655. get scene(): Scene;
  69656. /**
  69657. * @constructor
  69658. * @param name - The rendering pipeline name
  69659. * @param scene - The scene linked to this pipeline
  69660. * @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 }
  69661. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69662. */
  69663. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69664. /**
  69665. * Get the class name
  69666. * @returns "SSAORenderingPipeline"
  69667. */
  69668. getClassName(): string;
  69669. /**
  69670. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69671. */
  69672. dispose(disableDepthRender?: boolean): void;
  69673. private _createBlurPostProcess;
  69674. /** @hidden */
  69675. _rebuild(): void;
  69676. private _createSSAOPostProcess;
  69677. private _createSSAOCombinePostProcess;
  69678. private _createRandomTexture;
  69679. }
  69680. }
  69681. declare module BABYLON {
  69682. /** @hidden */
  69683. export var screenSpaceReflectionPixelShader: {
  69684. name: string;
  69685. shader: string;
  69686. };
  69687. }
  69688. declare module BABYLON {
  69689. /**
  69690. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69691. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69692. */
  69693. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69694. /**
  69695. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69696. */
  69697. threshold: number;
  69698. /**
  69699. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69700. */
  69701. strength: number;
  69702. /**
  69703. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69704. */
  69705. reflectionSpecularFalloffExponent: number;
  69706. /**
  69707. * 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]
  69708. */
  69709. step: number;
  69710. /**
  69711. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69712. */
  69713. roughnessFactor: number;
  69714. private _geometryBufferRenderer;
  69715. private _enableSmoothReflections;
  69716. private _reflectionSamples;
  69717. private _smoothSteps;
  69718. /**
  69719. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69720. * @param name The name of the effect.
  69721. * @param scene The scene containing the objects to calculate reflections.
  69722. * @param options The required width/height ratio to downsize to before computing the render pass.
  69723. * @param camera The camera to apply the render pass to.
  69724. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69725. * @param engine The engine which the post process will be applied. (default: current engine)
  69726. * @param reusable If the post process can be reused on the same frame. (default: false)
  69727. * @param textureType Type of textures used when performing the post process. (default: 0)
  69728. * @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)
  69729. */
  69730. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69731. /**
  69732. * Gets wether or not smoothing reflections is enabled.
  69733. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69734. */
  69735. get enableSmoothReflections(): boolean;
  69736. /**
  69737. * Sets wether or not smoothing reflections is enabled.
  69738. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69739. */
  69740. set enableSmoothReflections(enabled: boolean);
  69741. /**
  69742. * Gets the number of samples taken while computing reflections. More samples count is high,
  69743. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69744. */
  69745. get reflectionSamples(): number;
  69746. /**
  69747. * Sets the number of samples taken while computing reflections. More samples count is high,
  69748. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69749. */
  69750. set reflectionSamples(samples: number);
  69751. /**
  69752. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69753. * more the post-process will require GPU power and can generate a drop in FPS.
  69754. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69755. */
  69756. get smoothSteps(): number;
  69757. set smoothSteps(steps: number);
  69758. private _updateEffectDefines;
  69759. }
  69760. }
  69761. declare module BABYLON {
  69762. /** @hidden */
  69763. export var standardPixelShader: {
  69764. name: string;
  69765. shader: string;
  69766. };
  69767. }
  69768. declare module BABYLON {
  69769. /**
  69770. * Standard rendering pipeline
  69771. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69772. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69773. */
  69774. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69775. /**
  69776. * Public members
  69777. */
  69778. /**
  69779. * Post-process which contains the original scene color before the pipeline applies all the effects
  69780. */
  69781. originalPostProcess: Nullable<PostProcess>;
  69782. /**
  69783. * Post-process used to down scale an image x4
  69784. */
  69785. downSampleX4PostProcess: Nullable<PostProcess>;
  69786. /**
  69787. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69788. */
  69789. brightPassPostProcess: Nullable<PostProcess>;
  69790. /**
  69791. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69792. */
  69793. blurHPostProcesses: PostProcess[];
  69794. /**
  69795. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69796. */
  69797. blurVPostProcesses: PostProcess[];
  69798. /**
  69799. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69800. */
  69801. textureAdderPostProcess: Nullable<PostProcess>;
  69802. /**
  69803. * Post-process used to create volumetric lighting effect
  69804. */
  69805. volumetricLightPostProcess: Nullable<PostProcess>;
  69806. /**
  69807. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69808. */
  69809. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69810. /**
  69811. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69812. */
  69813. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69814. /**
  69815. * Post-process used to merge the volumetric light effect and the real scene color
  69816. */
  69817. volumetricLightMergePostProces: Nullable<PostProcess>;
  69818. /**
  69819. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69820. */
  69821. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69822. /**
  69823. * Base post-process used to calculate the average luminance of the final image for HDR
  69824. */
  69825. luminancePostProcess: Nullable<PostProcess>;
  69826. /**
  69827. * Post-processes used to create down sample post-processes in order to get
  69828. * the average luminance of the final image for HDR
  69829. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69830. */
  69831. luminanceDownSamplePostProcesses: PostProcess[];
  69832. /**
  69833. * Post-process used to create a HDR effect (light adaptation)
  69834. */
  69835. hdrPostProcess: Nullable<PostProcess>;
  69836. /**
  69837. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69838. */
  69839. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69840. /**
  69841. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69842. */
  69843. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69844. /**
  69845. * Post-process used to merge the final HDR post-process and the real scene color
  69846. */
  69847. hdrFinalPostProcess: Nullable<PostProcess>;
  69848. /**
  69849. * Post-process used to create a lens flare effect
  69850. */
  69851. lensFlarePostProcess: Nullable<PostProcess>;
  69852. /**
  69853. * Post-process that merges the result of the lens flare post-process and the real scene color
  69854. */
  69855. lensFlareComposePostProcess: Nullable<PostProcess>;
  69856. /**
  69857. * Post-process used to create a motion blur effect
  69858. */
  69859. motionBlurPostProcess: Nullable<PostProcess>;
  69860. /**
  69861. * Post-process used to create a depth of field effect
  69862. */
  69863. depthOfFieldPostProcess: Nullable<PostProcess>;
  69864. /**
  69865. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69866. */
  69867. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69868. /**
  69869. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69870. */
  69871. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69872. /**
  69873. * Represents the brightness threshold in order to configure the illuminated surfaces
  69874. */
  69875. brightThreshold: number;
  69876. /**
  69877. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69878. */
  69879. blurWidth: number;
  69880. /**
  69881. * Sets if the blur for highlighted surfaces must be only horizontal
  69882. */
  69883. horizontalBlur: boolean;
  69884. /**
  69885. * Gets the overall exposure used by the pipeline
  69886. */
  69887. get exposure(): number;
  69888. /**
  69889. * Sets the overall exposure used by the pipeline
  69890. */
  69891. set exposure(value: number);
  69892. /**
  69893. * Texture used typically to simulate "dirty" on camera lens
  69894. */
  69895. lensTexture: Nullable<Texture>;
  69896. /**
  69897. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69898. */
  69899. volumetricLightCoefficient: number;
  69900. /**
  69901. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69902. */
  69903. volumetricLightPower: number;
  69904. /**
  69905. * Used the set the blur intensity to smooth the volumetric lights
  69906. */
  69907. volumetricLightBlurScale: number;
  69908. /**
  69909. * Light (spot or directional) used to generate the volumetric lights rays
  69910. * The source light must have a shadow generate so the pipeline can get its
  69911. * depth map
  69912. */
  69913. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69914. /**
  69915. * For eye adaptation, represents the minimum luminance the eye can see
  69916. */
  69917. hdrMinimumLuminance: number;
  69918. /**
  69919. * For eye adaptation, represents the decrease luminance speed
  69920. */
  69921. hdrDecreaseRate: number;
  69922. /**
  69923. * For eye adaptation, represents the increase luminance speed
  69924. */
  69925. hdrIncreaseRate: number;
  69926. /**
  69927. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69928. */
  69929. get hdrAutoExposure(): boolean;
  69930. /**
  69931. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69932. */
  69933. set hdrAutoExposure(value: boolean);
  69934. /**
  69935. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69936. */
  69937. lensColorTexture: Nullable<Texture>;
  69938. /**
  69939. * The overall strengh for the lens flare effect
  69940. */
  69941. lensFlareStrength: number;
  69942. /**
  69943. * Dispersion coefficient for lens flare ghosts
  69944. */
  69945. lensFlareGhostDispersal: number;
  69946. /**
  69947. * Main lens flare halo width
  69948. */
  69949. lensFlareHaloWidth: number;
  69950. /**
  69951. * Based on the lens distortion effect, defines how much the lens flare result
  69952. * is distorted
  69953. */
  69954. lensFlareDistortionStrength: number;
  69955. /**
  69956. * Configures the blur intensity used for for lens flare (halo)
  69957. */
  69958. lensFlareBlurWidth: number;
  69959. /**
  69960. * Lens star texture must be used to simulate rays on the flares and is available
  69961. * in the documentation
  69962. */
  69963. lensStarTexture: Nullable<Texture>;
  69964. /**
  69965. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69966. * flare effect by taking account of the dirt texture
  69967. */
  69968. lensFlareDirtTexture: Nullable<Texture>;
  69969. /**
  69970. * Represents the focal length for the depth of field effect
  69971. */
  69972. depthOfFieldDistance: number;
  69973. /**
  69974. * Represents the blur intensity for the blurred part of the depth of field effect
  69975. */
  69976. depthOfFieldBlurWidth: number;
  69977. /**
  69978. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69979. */
  69980. get motionStrength(): number;
  69981. /**
  69982. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69983. */
  69984. set motionStrength(strength: number);
  69985. /**
  69986. * Gets wether or not the motion blur post-process is object based or screen based.
  69987. */
  69988. get objectBasedMotionBlur(): boolean;
  69989. /**
  69990. * Sets wether or not the motion blur post-process should be object based or screen based
  69991. */
  69992. set objectBasedMotionBlur(value: boolean);
  69993. /**
  69994. * List of animations for the pipeline (IAnimatable implementation)
  69995. */
  69996. animations: Animation[];
  69997. /**
  69998. * Private members
  69999. */
  70000. private _scene;
  70001. private _currentDepthOfFieldSource;
  70002. private _basePostProcess;
  70003. private _fixedExposure;
  70004. private _currentExposure;
  70005. private _hdrAutoExposure;
  70006. private _hdrCurrentLuminance;
  70007. private _motionStrength;
  70008. private _isObjectBasedMotionBlur;
  70009. private _floatTextureType;
  70010. private _camerasToBeAttached;
  70011. private _ratio;
  70012. private _bloomEnabled;
  70013. private _depthOfFieldEnabled;
  70014. private _vlsEnabled;
  70015. private _lensFlareEnabled;
  70016. private _hdrEnabled;
  70017. private _motionBlurEnabled;
  70018. private _fxaaEnabled;
  70019. private _screenSpaceReflectionsEnabled;
  70020. private _motionBlurSamples;
  70021. private _volumetricLightStepsCount;
  70022. private _samples;
  70023. /**
  70024. * @ignore
  70025. * Specifies if the bloom pipeline is enabled
  70026. */
  70027. get BloomEnabled(): boolean;
  70028. set BloomEnabled(enabled: boolean);
  70029. /**
  70030. * @ignore
  70031. * Specifies if the depth of field pipeline is enabed
  70032. */
  70033. get DepthOfFieldEnabled(): boolean;
  70034. set DepthOfFieldEnabled(enabled: boolean);
  70035. /**
  70036. * @ignore
  70037. * Specifies if the lens flare pipeline is enabed
  70038. */
  70039. get LensFlareEnabled(): boolean;
  70040. set LensFlareEnabled(enabled: boolean);
  70041. /**
  70042. * @ignore
  70043. * Specifies if the HDR pipeline is enabled
  70044. */
  70045. get HDREnabled(): boolean;
  70046. set HDREnabled(enabled: boolean);
  70047. /**
  70048. * @ignore
  70049. * Specifies if the volumetric lights scattering effect is enabled
  70050. */
  70051. get VLSEnabled(): boolean;
  70052. set VLSEnabled(enabled: boolean);
  70053. /**
  70054. * @ignore
  70055. * Specifies if the motion blur effect is enabled
  70056. */
  70057. get MotionBlurEnabled(): boolean;
  70058. set MotionBlurEnabled(enabled: boolean);
  70059. /**
  70060. * Specifies if anti-aliasing is enabled
  70061. */
  70062. get fxaaEnabled(): boolean;
  70063. set fxaaEnabled(enabled: boolean);
  70064. /**
  70065. * Specifies if screen space reflections are enabled.
  70066. */
  70067. get screenSpaceReflectionsEnabled(): boolean;
  70068. set screenSpaceReflectionsEnabled(enabled: boolean);
  70069. /**
  70070. * Specifies the number of steps used to calculate the volumetric lights
  70071. * Typically in interval [50, 200]
  70072. */
  70073. get volumetricLightStepsCount(): number;
  70074. set volumetricLightStepsCount(count: number);
  70075. /**
  70076. * Specifies the number of samples used for the motion blur effect
  70077. * Typically in interval [16, 64]
  70078. */
  70079. get motionBlurSamples(): number;
  70080. set motionBlurSamples(samples: number);
  70081. /**
  70082. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70083. */
  70084. get samples(): number;
  70085. set samples(sampleCount: number);
  70086. /**
  70087. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70088. * @constructor
  70089. * @param name The rendering pipeline name
  70090. * @param scene The scene linked to this pipeline
  70091. * @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)
  70092. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70093. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70094. */
  70095. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70096. private _buildPipeline;
  70097. private _createDownSampleX4PostProcess;
  70098. private _createBrightPassPostProcess;
  70099. private _createBlurPostProcesses;
  70100. private _createTextureAdderPostProcess;
  70101. private _createVolumetricLightPostProcess;
  70102. private _createLuminancePostProcesses;
  70103. private _createHdrPostProcess;
  70104. private _createLensFlarePostProcess;
  70105. private _createDepthOfFieldPostProcess;
  70106. private _createMotionBlurPostProcess;
  70107. private _getDepthTexture;
  70108. private _disposePostProcesses;
  70109. /**
  70110. * Dispose of the pipeline and stop all post processes
  70111. */
  70112. dispose(): void;
  70113. /**
  70114. * Serialize the rendering pipeline (Used when exporting)
  70115. * @returns the serialized object
  70116. */
  70117. serialize(): any;
  70118. /**
  70119. * Parse the serialized pipeline
  70120. * @param source Source pipeline.
  70121. * @param scene The scene to load the pipeline to.
  70122. * @param rootUrl The URL of the serialized pipeline.
  70123. * @returns An instantiated pipeline from the serialized object.
  70124. */
  70125. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70126. /**
  70127. * Luminance steps
  70128. */
  70129. static LuminanceSteps: number;
  70130. }
  70131. }
  70132. declare module BABYLON {
  70133. /** @hidden */
  70134. export var stereoscopicInterlacePixelShader: {
  70135. name: string;
  70136. shader: string;
  70137. };
  70138. }
  70139. declare module BABYLON {
  70140. /**
  70141. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70142. */
  70143. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70144. private _stepSize;
  70145. private _passedProcess;
  70146. /**
  70147. * Initializes a StereoscopicInterlacePostProcessI
  70148. * @param name The name of the effect.
  70149. * @param rigCameras The rig cameras to be appled to the post process
  70150. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70151. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70152. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70153. * @param engine The engine which the post process will be applied. (default: current engine)
  70154. * @param reusable If the post process can be reused on the same frame. (default: false)
  70155. */
  70156. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70157. }
  70158. /**
  70159. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70160. */
  70161. export class StereoscopicInterlacePostProcess extends PostProcess {
  70162. private _stepSize;
  70163. private _passedProcess;
  70164. /**
  70165. * Initializes a StereoscopicInterlacePostProcess
  70166. * @param name The name of the effect.
  70167. * @param rigCameras The rig cameras to be appled to the post process
  70168. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70170. * @param engine The engine which the post process will be applied. (default: current engine)
  70171. * @param reusable If the post process can be reused on the same frame. (default: false)
  70172. */
  70173. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70174. }
  70175. }
  70176. declare module BABYLON {
  70177. /** @hidden */
  70178. export var tonemapPixelShader: {
  70179. name: string;
  70180. shader: string;
  70181. };
  70182. }
  70183. declare module BABYLON {
  70184. /** Defines operator used for tonemapping */
  70185. export enum TonemappingOperator {
  70186. /** Hable */
  70187. Hable = 0,
  70188. /** Reinhard */
  70189. Reinhard = 1,
  70190. /** HejiDawson */
  70191. HejiDawson = 2,
  70192. /** Photographic */
  70193. Photographic = 3
  70194. }
  70195. /**
  70196. * Defines a post process to apply tone mapping
  70197. */
  70198. export class TonemapPostProcess extends PostProcess {
  70199. private _operator;
  70200. /** Defines the required exposure adjustement */
  70201. exposureAdjustment: number;
  70202. /**
  70203. * Creates a new TonemapPostProcess
  70204. * @param name defines the name of the postprocess
  70205. * @param _operator defines the operator to use
  70206. * @param exposureAdjustment defines the required exposure adjustement
  70207. * @param camera defines the camera to use (can be null)
  70208. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70209. * @param engine defines the hosting engine (can be ignore if camera is set)
  70210. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70211. */
  70212. constructor(name: string, _operator: TonemappingOperator,
  70213. /** Defines the required exposure adjustement */
  70214. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70215. }
  70216. }
  70217. declare module BABYLON {
  70218. /** @hidden */
  70219. export var volumetricLightScatteringPixelShader: {
  70220. name: string;
  70221. shader: string;
  70222. };
  70223. }
  70224. declare module BABYLON {
  70225. /** @hidden */
  70226. export var volumetricLightScatteringPassVertexShader: {
  70227. name: string;
  70228. shader: string;
  70229. };
  70230. }
  70231. declare module BABYLON {
  70232. /** @hidden */
  70233. export var volumetricLightScatteringPassPixelShader: {
  70234. name: string;
  70235. shader: string;
  70236. };
  70237. }
  70238. declare module BABYLON {
  70239. /**
  70240. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70241. */
  70242. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70243. private _volumetricLightScatteringPass;
  70244. private _volumetricLightScatteringRTT;
  70245. private _viewPort;
  70246. private _screenCoordinates;
  70247. private _cachedDefines;
  70248. /**
  70249. * If not undefined, the mesh position is computed from the attached node position
  70250. */
  70251. attachedNode: {
  70252. position: Vector3;
  70253. };
  70254. /**
  70255. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70256. */
  70257. customMeshPosition: Vector3;
  70258. /**
  70259. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70260. */
  70261. useCustomMeshPosition: boolean;
  70262. /**
  70263. * If the post-process should inverse the light scattering direction
  70264. */
  70265. invert: boolean;
  70266. /**
  70267. * The internal mesh used by the post-process
  70268. */
  70269. mesh: Mesh;
  70270. /**
  70271. * @hidden
  70272. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70273. */
  70274. get useDiffuseColor(): boolean;
  70275. set useDiffuseColor(useDiffuseColor: boolean);
  70276. /**
  70277. * Array containing the excluded meshes not rendered in the internal pass
  70278. */
  70279. excludedMeshes: AbstractMesh[];
  70280. /**
  70281. * Controls the overall intensity of the post-process
  70282. */
  70283. exposure: number;
  70284. /**
  70285. * Dissipates each sample's contribution in range [0, 1]
  70286. */
  70287. decay: number;
  70288. /**
  70289. * Controls the overall intensity of each sample
  70290. */
  70291. weight: number;
  70292. /**
  70293. * Controls the density of each sample
  70294. */
  70295. density: number;
  70296. /**
  70297. * @constructor
  70298. * @param name The post-process name
  70299. * @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)
  70300. * @param camera The camera that the post-process will be attached to
  70301. * @param mesh The mesh used to create the light scattering
  70302. * @param samples The post-process quality, default 100
  70303. * @param samplingModeThe post-process filtering mode
  70304. * @param engine The babylon engine
  70305. * @param reusable If the post-process is reusable
  70306. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70307. */
  70308. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70309. /**
  70310. * Returns the string "VolumetricLightScatteringPostProcess"
  70311. * @returns "VolumetricLightScatteringPostProcess"
  70312. */
  70313. getClassName(): string;
  70314. private _isReady;
  70315. /**
  70316. * Sets the new light position for light scattering effect
  70317. * @param position The new custom light position
  70318. */
  70319. setCustomMeshPosition(position: Vector3): void;
  70320. /**
  70321. * Returns the light position for light scattering effect
  70322. * @return Vector3 The custom light position
  70323. */
  70324. getCustomMeshPosition(): Vector3;
  70325. /**
  70326. * Disposes the internal assets and detaches the post-process from the camera
  70327. */
  70328. dispose(camera: Camera): void;
  70329. /**
  70330. * Returns the render target texture used by the post-process
  70331. * @return the render target texture used by the post-process
  70332. */
  70333. getPass(): RenderTargetTexture;
  70334. private _meshExcluded;
  70335. private _createPass;
  70336. private _updateMeshScreenCoordinates;
  70337. /**
  70338. * Creates a default mesh for the Volumeric Light Scattering post-process
  70339. * @param name The mesh name
  70340. * @param scene The scene where to create the mesh
  70341. * @return the default mesh
  70342. */
  70343. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70344. }
  70345. }
  70346. declare module BABYLON {
  70347. interface Scene {
  70348. /** @hidden (Backing field) */
  70349. _boundingBoxRenderer: BoundingBoxRenderer;
  70350. /** @hidden (Backing field) */
  70351. _forceShowBoundingBoxes: boolean;
  70352. /**
  70353. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70354. */
  70355. forceShowBoundingBoxes: boolean;
  70356. /**
  70357. * Gets the bounding box renderer associated with the scene
  70358. * @returns a BoundingBoxRenderer
  70359. */
  70360. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70361. }
  70362. interface AbstractMesh {
  70363. /** @hidden (Backing field) */
  70364. _showBoundingBox: boolean;
  70365. /**
  70366. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70367. */
  70368. showBoundingBox: boolean;
  70369. }
  70370. /**
  70371. * Component responsible of rendering the bounding box of the meshes in a scene.
  70372. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70373. */
  70374. export class BoundingBoxRenderer implements ISceneComponent {
  70375. /**
  70376. * The component name helpfull to identify the component in the list of scene components.
  70377. */
  70378. readonly name: string;
  70379. /**
  70380. * The scene the component belongs to.
  70381. */
  70382. scene: Scene;
  70383. /**
  70384. * Color of the bounding box lines placed in front of an object
  70385. */
  70386. frontColor: Color3;
  70387. /**
  70388. * Color of the bounding box lines placed behind an object
  70389. */
  70390. backColor: Color3;
  70391. /**
  70392. * Defines if the renderer should show the back lines or not
  70393. */
  70394. showBackLines: boolean;
  70395. /**
  70396. * Observable raised before rendering a bounding box
  70397. */
  70398. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70399. /**
  70400. * Observable raised after rendering a bounding box
  70401. */
  70402. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70403. /**
  70404. * @hidden
  70405. */
  70406. renderList: SmartArray<BoundingBox>;
  70407. private _colorShader;
  70408. private _vertexBuffers;
  70409. private _indexBuffer;
  70410. private _fillIndexBuffer;
  70411. private _fillIndexData;
  70412. /**
  70413. * Instantiates a new bounding box renderer in a scene.
  70414. * @param scene the scene the renderer renders in
  70415. */
  70416. constructor(scene: Scene);
  70417. /**
  70418. * Registers the component in a given scene
  70419. */
  70420. register(): void;
  70421. private _evaluateSubMesh;
  70422. private _activeMesh;
  70423. private _prepareRessources;
  70424. private _createIndexBuffer;
  70425. /**
  70426. * Rebuilds the elements related to this component in case of
  70427. * context lost for instance.
  70428. */
  70429. rebuild(): void;
  70430. /**
  70431. * @hidden
  70432. */
  70433. reset(): void;
  70434. /**
  70435. * Render the bounding boxes of a specific rendering group
  70436. * @param renderingGroupId defines the rendering group to render
  70437. */
  70438. render(renderingGroupId: number): void;
  70439. /**
  70440. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70441. * @param mesh Define the mesh to render the occlusion bounding box for
  70442. */
  70443. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70444. /**
  70445. * Dispose and release the resources attached to this renderer.
  70446. */
  70447. dispose(): void;
  70448. }
  70449. }
  70450. declare module BABYLON {
  70451. interface Scene {
  70452. /** @hidden (Backing field) */
  70453. _depthRenderer: {
  70454. [id: string]: DepthRenderer;
  70455. };
  70456. /**
  70457. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70458. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70459. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70460. * @returns the created depth renderer
  70461. */
  70462. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70463. /**
  70464. * Disables a depth renderer for a given camera
  70465. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70466. */
  70467. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70468. }
  70469. /**
  70470. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70471. * in several rendering techniques.
  70472. */
  70473. export class DepthRendererSceneComponent implements ISceneComponent {
  70474. /**
  70475. * The component name helpfull to identify the component in the list of scene components.
  70476. */
  70477. readonly name: string;
  70478. /**
  70479. * The scene the component belongs to.
  70480. */
  70481. scene: Scene;
  70482. /**
  70483. * Creates a new instance of the component for the given scene
  70484. * @param scene Defines the scene to register the component in
  70485. */
  70486. constructor(scene: Scene);
  70487. /**
  70488. * Registers the component in a given scene
  70489. */
  70490. register(): void;
  70491. /**
  70492. * Rebuilds the elements related to this component in case of
  70493. * context lost for instance.
  70494. */
  70495. rebuild(): void;
  70496. /**
  70497. * Disposes the component and the associated ressources
  70498. */
  70499. dispose(): void;
  70500. private _gatherRenderTargets;
  70501. private _gatherActiveCameraRenderTargets;
  70502. }
  70503. }
  70504. declare module BABYLON {
  70505. /** @hidden */
  70506. export var outlinePixelShader: {
  70507. name: string;
  70508. shader: string;
  70509. };
  70510. }
  70511. declare module BABYLON {
  70512. /** @hidden */
  70513. export var outlineVertexShader: {
  70514. name: string;
  70515. shader: string;
  70516. };
  70517. }
  70518. declare module BABYLON {
  70519. interface Scene {
  70520. /** @hidden */
  70521. _outlineRenderer: OutlineRenderer;
  70522. /**
  70523. * Gets the outline renderer associated with the scene
  70524. * @returns a OutlineRenderer
  70525. */
  70526. getOutlineRenderer(): OutlineRenderer;
  70527. }
  70528. interface AbstractMesh {
  70529. /** @hidden (Backing field) */
  70530. _renderOutline: boolean;
  70531. /**
  70532. * Gets or sets a boolean indicating if the outline must be rendered as well
  70533. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70534. */
  70535. renderOutline: boolean;
  70536. /** @hidden (Backing field) */
  70537. _renderOverlay: boolean;
  70538. /**
  70539. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70540. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70541. */
  70542. renderOverlay: boolean;
  70543. }
  70544. /**
  70545. * This class is responsible to draw bothe outline/overlay of meshes.
  70546. * It should not be used directly but through the available method on mesh.
  70547. */
  70548. export class OutlineRenderer implements ISceneComponent {
  70549. /**
  70550. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70551. */
  70552. private static _StencilReference;
  70553. /**
  70554. * The name of the component. Each component must have a unique name.
  70555. */
  70556. name: string;
  70557. /**
  70558. * The scene the component belongs to.
  70559. */
  70560. scene: Scene;
  70561. /**
  70562. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70563. */
  70564. zOffset: number;
  70565. private _engine;
  70566. private _effect;
  70567. private _cachedDefines;
  70568. private _savedDepthWrite;
  70569. /**
  70570. * Instantiates a new outline renderer. (There could be only one per scene).
  70571. * @param scene Defines the scene it belongs to
  70572. */
  70573. constructor(scene: Scene);
  70574. /**
  70575. * Register the component to one instance of a scene.
  70576. */
  70577. register(): void;
  70578. /**
  70579. * Rebuilds the elements related to this component in case of
  70580. * context lost for instance.
  70581. */
  70582. rebuild(): void;
  70583. /**
  70584. * Disposes the component and the associated ressources.
  70585. */
  70586. dispose(): void;
  70587. /**
  70588. * Renders the outline in the canvas.
  70589. * @param subMesh Defines the sumesh to render
  70590. * @param batch Defines the batch of meshes in case of instances
  70591. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70592. */
  70593. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70594. /**
  70595. * Returns whether or not the outline renderer is ready for a given submesh.
  70596. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70597. * @param subMesh Defines the submesh to check readyness for
  70598. * @param useInstances Defines wheter wee are trying to render instances or not
  70599. * @returns true if ready otherwise false
  70600. */
  70601. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70602. private _beforeRenderingMesh;
  70603. private _afterRenderingMesh;
  70604. }
  70605. }
  70606. declare module BABYLON {
  70607. /**
  70608. * Defines the basic options interface of a Sprite Frame Source Size.
  70609. */
  70610. export interface ISpriteJSONSpriteSourceSize {
  70611. /**
  70612. * number of the original width of the Frame
  70613. */
  70614. w: number;
  70615. /**
  70616. * number of the original height of the Frame
  70617. */
  70618. h: number;
  70619. }
  70620. /**
  70621. * Defines the basic options interface of a Sprite Frame Data.
  70622. */
  70623. export interface ISpriteJSONSpriteFrameData {
  70624. /**
  70625. * number of the x offset of the Frame
  70626. */
  70627. x: number;
  70628. /**
  70629. * number of the y offset of the Frame
  70630. */
  70631. y: number;
  70632. /**
  70633. * number of the width of the Frame
  70634. */
  70635. w: number;
  70636. /**
  70637. * number of the height of the Frame
  70638. */
  70639. h: number;
  70640. }
  70641. /**
  70642. * Defines the basic options interface of a JSON Sprite.
  70643. */
  70644. export interface ISpriteJSONSprite {
  70645. /**
  70646. * string name of the Frame
  70647. */
  70648. filename: string;
  70649. /**
  70650. * ISpriteJSONSpriteFrame basic object of the frame data
  70651. */
  70652. frame: ISpriteJSONSpriteFrameData;
  70653. /**
  70654. * boolean to flag is the frame was rotated.
  70655. */
  70656. rotated: boolean;
  70657. /**
  70658. * boolean to flag is the frame was trimmed.
  70659. */
  70660. trimmed: boolean;
  70661. /**
  70662. * ISpriteJSONSpriteFrame basic object of the source data
  70663. */
  70664. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70665. /**
  70666. * ISpriteJSONSpriteFrame basic object of the source data
  70667. */
  70668. sourceSize: ISpriteJSONSpriteSourceSize;
  70669. }
  70670. /**
  70671. * Defines the basic options interface of a JSON atlas.
  70672. */
  70673. export interface ISpriteJSONAtlas {
  70674. /**
  70675. * Array of objects that contain the frame data.
  70676. */
  70677. frames: Array<ISpriteJSONSprite>;
  70678. /**
  70679. * object basic object containing the sprite meta data.
  70680. */
  70681. meta?: object;
  70682. }
  70683. }
  70684. declare module BABYLON {
  70685. /** @hidden */
  70686. export var spriteMapPixelShader: {
  70687. name: string;
  70688. shader: string;
  70689. };
  70690. }
  70691. declare module BABYLON {
  70692. /** @hidden */
  70693. export var spriteMapVertexShader: {
  70694. name: string;
  70695. shader: string;
  70696. };
  70697. }
  70698. declare module BABYLON {
  70699. /**
  70700. * Defines the basic options interface of a SpriteMap
  70701. */
  70702. export interface ISpriteMapOptions {
  70703. /**
  70704. * Vector2 of the number of cells in the grid.
  70705. */
  70706. stageSize?: Vector2;
  70707. /**
  70708. * Vector2 of the size of the output plane in World Units.
  70709. */
  70710. outputSize?: Vector2;
  70711. /**
  70712. * Vector3 of the position of the output plane in World Units.
  70713. */
  70714. outputPosition?: Vector3;
  70715. /**
  70716. * Vector3 of the rotation of the output plane.
  70717. */
  70718. outputRotation?: Vector3;
  70719. /**
  70720. * number of layers that the system will reserve in resources.
  70721. */
  70722. layerCount?: number;
  70723. /**
  70724. * number of max animation frames a single cell will reserve in resources.
  70725. */
  70726. maxAnimationFrames?: number;
  70727. /**
  70728. * number cell index of the base tile when the system compiles.
  70729. */
  70730. baseTile?: number;
  70731. /**
  70732. * boolean flip the sprite after its been repositioned by the framing data.
  70733. */
  70734. flipU?: boolean;
  70735. /**
  70736. * Vector3 scalar of the global RGB values of the SpriteMap.
  70737. */
  70738. colorMultiply?: Vector3;
  70739. }
  70740. /**
  70741. * Defines the IDisposable interface in order to be cleanable from resources.
  70742. */
  70743. export interface ISpriteMap extends IDisposable {
  70744. /**
  70745. * String name of the SpriteMap.
  70746. */
  70747. name: string;
  70748. /**
  70749. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70750. */
  70751. atlasJSON: ISpriteJSONAtlas;
  70752. /**
  70753. * Texture of the SpriteMap.
  70754. */
  70755. spriteSheet: Texture;
  70756. /**
  70757. * The parameters to initialize the SpriteMap with.
  70758. */
  70759. options: ISpriteMapOptions;
  70760. }
  70761. /**
  70762. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70763. */
  70764. export class SpriteMap implements ISpriteMap {
  70765. /** The Name of the spriteMap */
  70766. name: string;
  70767. /** The JSON file with the frame and meta data */
  70768. atlasJSON: ISpriteJSONAtlas;
  70769. /** The systems Sprite Sheet Texture */
  70770. spriteSheet: Texture;
  70771. /** Arguments passed with the Constructor */
  70772. options: ISpriteMapOptions;
  70773. /** Public Sprite Storage array, parsed from atlasJSON */
  70774. sprites: Array<ISpriteJSONSprite>;
  70775. /** Returns the Number of Sprites in the System */
  70776. get spriteCount(): number;
  70777. /** Returns the Position of Output Plane*/
  70778. get position(): Vector3;
  70779. /** Returns the Position of Output Plane*/
  70780. set position(v: Vector3);
  70781. /** Returns the Rotation of Output Plane*/
  70782. get rotation(): Vector3;
  70783. /** Returns the Rotation of Output Plane*/
  70784. set rotation(v: Vector3);
  70785. /** Sets the AnimationMap*/
  70786. get animationMap(): RawTexture;
  70787. /** Sets the AnimationMap*/
  70788. set animationMap(v: RawTexture);
  70789. /** Scene that the SpriteMap was created in */
  70790. private _scene;
  70791. /** Texture Buffer of Float32 that holds tile frame data*/
  70792. private _frameMap;
  70793. /** Texture Buffers of Float32 that holds tileMap data*/
  70794. private _tileMaps;
  70795. /** Texture Buffer of Float32 that holds Animation Data*/
  70796. private _animationMap;
  70797. /** Custom ShaderMaterial Central to the System*/
  70798. private _material;
  70799. /** Custom ShaderMaterial Central to the System*/
  70800. private _output;
  70801. /** Systems Time Ticker*/
  70802. private _time;
  70803. /**
  70804. * Creates a new SpriteMap
  70805. * @param name defines the SpriteMaps Name
  70806. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70807. * @param spriteSheet is the Texture that the Sprites are on.
  70808. * @param options a basic deployment configuration
  70809. * @param scene The Scene that the map is deployed on
  70810. */
  70811. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70812. /**
  70813. * Returns tileID location
  70814. * @returns Vector2 the cell position ID
  70815. */
  70816. getTileID(): Vector2;
  70817. /**
  70818. * Gets the UV location of the mouse over the SpriteMap.
  70819. * @returns Vector2 the UV position of the mouse interaction
  70820. */
  70821. getMousePosition(): Vector2;
  70822. /**
  70823. * Creates the "frame" texture Buffer
  70824. * -------------------------------------
  70825. * Structure of frames
  70826. * "filename": "Falling-Water-2.png",
  70827. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70828. * "rotated": true,
  70829. * "trimmed": true,
  70830. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70831. * "sourceSize": {"w":32,"h":32}
  70832. * @returns RawTexture of the frameMap
  70833. */
  70834. private _createFrameBuffer;
  70835. /**
  70836. * Creates the tileMap texture Buffer
  70837. * @param buffer normally and array of numbers, or a false to generate from scratch
  70838. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70839. * @returns RawTexture of the tileMap
  70840. */
  70841. private _createTileBuffer;
  70842. /**
  70843. * Modifies the data of the tileMaps
  70844. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70845. * @param pos is the iVector2 Coordinates of the Tile
  70846. * @param tile The SpriteIndex of the new Tile
  70847. */
  70848. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70849. /**
  70850. * Creates the animationMap texture Buffer
  70851. * @param buffer normally and array of numbers, or a false to generate from scratch
  70852. * @returns RawTexture of the animationMap
  70853. */
  70854. private _createTileAnimationBuffer;
  70855. /**
  70856. * Modifies the data of the animationMap
  70857. * @param cellID is the Index of the Sprite
  70858. * @param _frame is the target Animation frame
  70859. * @param toCell is the Target Index of the next frame of the animation
  70860. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70861. * @param speed is a global scalar of the time variable on the map.
  70862. */
  70863. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70864. /**
  70865. * Exports the .tilemaps file
  70866. */
  70867. saveTileMaps(): void;
  70868. /**
  70869. * Imports the .tilemaps file
  70870. * @param url of the .tilemaps file
  70871. */
  70872. loadTileMaps(url: string): void;
  70873. /**
  70874. * Release associated resources
  70875. */
  70876. dispose(): void;
  70877. }
  70878. }
  70879. declare module BABYLON {
  70880. /**
  70881. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70882. * @see http://doc.babylonjs.com/babylon101/sprites
  70883. */
  70884. export class SpritePackedManager extends SpriteManager {
  70885. /** defines the packed manager's name */
  70886. name: string;
  70887. /**
  70888. * Creates a new sprite manager from a packed sprite sheet
  70889. * @param name defines the manager's name
  70890. * @param imgUrl defines the sprite sheet url
  70891. * @param capacity defines the maximum allowed number of sprites
  70892. * @param scene defines the hosting scene
  70893. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70894. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70895. * @param samplingMode defines the smapling mode to use with spritesheet
  70896. * @param fromPacked set to true; do not alter
  70897. */
  70898. constructor(
  70899. /** defines the packed manager's name */
  70900. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70901. }
  70902. }
  70903. declare module BABYLON {
  70904. /**
  70905. * Defines the list of states available for a task inside a AssetsManager
  70906. */
  70907. export enum AssetTaskState {
  70908. /**
  70909. * Initialization
  70910. */
  70911. INIT = 0,
  70912. /**
  70913. * Running
  70914. */
  70915. RUNNING = 1,
  70916. /**
  70917. * Done
  70918. */
  70919. DONE = 2,
  70920. /**
  70921. * Error
  70922. */
  70923. ERROR = 3
  70924. }
  70925. /**
  70926. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70927. */
  70928. export abstract class AbstractAssetTask {
  70929. /**
  70930. * Task name
  70931. */ name: string;
  70932. /**
  70933. * Callback called when the task is successful
  70934. */
  70935. onSuccess: (task: any) => void;
  70936. /**
  70937. * Callback called when the task is not successful
  70938. */
  70939. onError: (task: any, message?: string, exception?: any) => void;
  70940. /**
  70941. * Creates a new AssetsManager
  70942. * @param name defines the name of the task
  70943. */
  70944. constructor(
  70945. /**
  70946. * Task name
  70947. */ name: string);
  70948. private _isCompleted;
  70949. private _taskState;
  70950. private _errorObject;
  70951. /**
  70952. * Get if the task is completed
  70953. */
  70954. get isCompleted(): boolean;
  70955. /**
  70956. * Gets the current state of the task
  70957. */
  70958. get taskState(): AssetTaskState;
  70959. /**
  70960. * Gets the current error object (if task is in error)
  70961. */
  70962. get errorObject(): {
  70963. message?: string;
  70964. exception?: any;
  70965. };
  70966. /**
  70967. * Internal only
  70968. * @hidden
  70969. */
  70970. _setErrorObject(message?: string, exception?: any): void;
  70971. /**
  70972. * Execute the current task
  70973. * @param scene defines the scene where you want your assets to be loaded
  70974. * @param onSuccess is a callback called when the task is successfully executed
  70975. * @param onError is a callback called if an error occurs
  70976. */
  70977. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70978. /**
  70979. * Execute the current task
  70980. * @param scene defines the scene where you want your assets to be loaded
  70981. * @param onSuccess is a callback called when the task is successfully executed
  70982. * @param onError is a callback called if an error occurs
  70983. */
  70984. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70985. /**
  70986. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70987. * This can be used with failed tasks that have the reason for failure fixed.
  70988. */
  70989. reset(): void;
  70990. private onErrorCallback;
  70991. private onDoneCallback;
  70992. }
  70993. /**
  70994. * Define the interface used by progress events raised during assets loading
  70995. */
  70996. export interface IAssetsProgressEvent {
  70997. /**
  70998. * Defines the number of remaining tasks to process
  70999. */
  71000. remainingCount: number;
  71001. /**
  71002. * Defines the total number of tasks
  71003. */
  71004. totalCount: number;
  71005. /**
  71006. * Defines the task that was just processed
  71007. */
  71008. task: AbstractAssetTask;
  71009. }
  71010. /**
  71011. * Class used to share progress information about assets loading
  71012. */
  71013. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71014. /**
  71015. * Defines the number of remaining tasks to process
  71016. */
  71017. remainingCount: number;
  71018. /**
  71019. * Defines the total number of tasks
  71020. */
  71021. totalCount: number;
  71022. /**
  71023. * Defines the task that was just processed
  71024. */
  71025. task: AbstractAssetTask;
  71026. /**
  71027. * Creates a AssetsProgressEvent
  71028. * @param remainingCount defines the number of remaining tasks to process
  71029. * @param totalCount defines the total number of tasks
  71030. * @param task defines the task that was just processed
  71031. */
  71032. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71033. }
  71034. /**
  71035. * Define a task used by AssetsManager to load meshes
  71036. */
  71037. export class MeshAssetTask extends AbstractAssetTask {
  71038. /**
  71039. * Defines the name of the task
  71040. */
  71041. name: string;
  71042. /**
  71043. * Defines the list of mesh's names you want to load
  71044. */
  71045. meshesNames: any;
  71046. /**
  71047. * Defines the root url to use as a base to load your meshes and associated resources
  71048. */
  71049. rootUrl: string;
  71050. /**
  71051. * Defines the filename or File of the scene to load from
  71052. */
  71053. sceneFilename: string | File;
  71054. /**
  71055. * Gets the list of loaded meshes
  71056. */
  71057. loadedMeshes: Array<AbstractMesh>;
  71058. /**
  71059. * Gets the list of loaded particle systems
  71060. */
  71061. loadedParticleSystems: Array<IParticleSystem>;
  71062. /**
  71063. * Gets the list of loaded skeletons
  71064. */
  71065. loadedSkeletons: Array<Skeleton>;
  71066. /**
  71067. * Gets the list of loaded animation groups
  71068. */
  71069. loadedAnimationGroups: Array<AnimationGroup>;
  71070. /**
  71071. * Callback called when the task is successful
  71072. */
  71073. onSuccess: (task: MeshAssetTask) => void;
  71074. /**
  71075. * Callback called when the task is successful
  71076. */
  71077. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71078. /**
  71079. * Creates a new MeshAssetTask
  71080. * @param name defines the name of the task
  71081. * @param meshesNames defines the list of mesh's names you want to load
  71082. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71083. * @param sceneFilename defines the filename or File of the scene to load from
  71084. */
  71085. constructor(
  71086. /**
  71087. * Defines the name of the task
  71088. */
  71089. name: string,
  71090. /**
  71091. * Defines the list of mesh's names you want to load
  71092. */
  71093. meshesNames: any,
  71094. /**
  71095. * Defines the root url to use as a base to load your meshes and associated resources
  71096. */
  71097. rootUrl: string,
  71098. /**
  71099. * Defines the filename or File of the scene to load from
  71100. */
  71101. sceneFilename: string | File);
  71102. /**
  71103. * Execute the current task
  71104. * @param scene defines the scene where you want your assets to be loaded
  71105. * @param onSuccess is a callback called when the task is successfully executed
  71106. * @param onError is a callback called if an error occurs
  71107. */
  71108. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71109. }
  71110. /**
  71111. * Define a task used by AssetsManager to load text content
  71112. */
  71113. export class TextFileAssetTask extends AbstractAssetTask {
  71114. /**
  71115. * Defines the name of the task
  71116. */
  71117. name: string;
  71118. /**
  71119. * Defines the location of the file to load
  71120. */
  71121. url: string;
  71122. /**
  71123. * Gets the loaded text string
  71124. */
  71125. text: string;
  71126. /**
  71127. * Callback called when the task is successful
  71128. */
  71129. onSuccess: (task: TextFileAssetTask) => void;
  71130. /**
  71131. * Callback called when the task is successful
  71132. */
  71133. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71134. /**
  71135. * Creates a new TextFileAssetTask object
  71136. * @param name defines the name of the task
  71137. * @param url defines the location of the file to load
  71138. */
  71139. constructor(
  71140. /**
  71141. * Defines the name of the task
  71142. */
  71143. name: string,
  71144. /**
  71145. * Defines the location of the file to load
  71146. */
  71147. url: string);
  71148. /**
  71149. * Execute the current task
  71150. * @param scene defines the scene where you want your assets to be loaded
  71151. * @param onSuccess is a callback called when the task is successfully executed
  71152. * @param onError is a callback called if an error occurs
  71153. */
  71154. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71155. }
  71156. /**
  71157. * Define a task used by AssetsManager to load binary data
  71158. */
  71159. export class BinaryFileAssetTask extends AbstractAssetTask {
  71160. /**
  71161. * Defines the name of the task
  71162. */
  71163. name: string;
  71164. /**
  71165. * Defines the location of the file to load
  71166. */
  71167. url: string;
  71168. /**
  71169. * Gets the lodaded data (as an array buffer)
  71170. */
  71171. data: ArrayBuffer;
  71172. /**
  71173. * Callback called when the task is successful
  71174. */
  71175. onSuccess: (task: BinaryFileAssetTask) => void;
  71176. /**
  71177. * Callback called when the task is successful
  71178. */
  71179. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71180. /**
  71181. * Creates a new BinaryFileAssetTask object
  71182. * @param name defines the name of the new task
  71183. * @param url defines the location of the file to load
  71184. */
  71185. constructor(
  71186. /**
  71187. * Defines the name of the task
  71188. */
  71189. name: string,
  71190. /**
  71191. * Defines the location of the file to load
  71192. */
  71193. url: string);
  71194. /**
  71195. * Execute the current task
  71196. * @param scene defines the scene where you want your assets to be loaded
  71197. * @param onSuccess is a callback called when the task is successfully executed
  71198. * @param onError is a callback called if an error occurs
  71199. */
  71200. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71201. }
  71202. /**
  71203. * Define a task used by AssetsManager to load images
  71204. */
  71205. export class ImageAssetTask extends AbstractAssetTask {
  71206. /**
  71207. * Defines the name of the task
  71208. */
  71209. name: string;
  71210. /**
  71211. * Defines the location of the image to load
  71212. */
  71213. url: string;
  71214. /**
  71215. * Gets the loaded images
  71216. */
  71217. image: HTMLImageElement;
  71218. /**
  71219. * Callback called when the task is successful
  71220. */
  71221. onSuccess: (task: ImageAssetTask) => void;
  71222. /**
  71223. * Callback called when the task is successful
  71224. */
  71225. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71226. /**
  71227. * Creates a new ImageAssetTask
  71228. * @param name defines the name of the task
  71229. * @param url defines the location of the image to load
  71230. */
  71231. constructor(
  71232. /**
  71233. * Defines the name of the task
  71234. */
  71235. name: string,
  71236. /**
  71237. * Defines the location of the image to load
  71238. */
  71239. url: string);
  71240. /**
  71241. * Execute the current task
  71242. * @param scene defines the scene where you want your assets to be loaded
  71243. * @param onSuccess is a callback called when the task is successfully executed
  71244. * @param onError is a callback called if an error occurs
  71245. */
  71246. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71247. }
  71248. /**
  71249. * Defines the interface used by texture loading tasks
  71250. */
  71251. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71252. /**
  71253. * Gets the loaded texture
  71254. */
  71255. texture: TEX;
  71256. }
  71257. /**
  71258. * Define a task used by AssetsManager to load 2D textures
  71259. */
  71260. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71261. /**
  71262. * Defines the name of the task
  71263. */
  71264. name: string;
  71265. /**
  71266. * Defines the location of the file to load
  71267. */
  71268. url: string;
  71269. /**
  71270. * Defines if mipmap should not be generated (default is false)
  71271. */
  71272. noMipmap?: boolean | undefined;
  71273. /**
  71274. * Defines if texture must be inverted on Y axis (default is true)
  71275. */
  71276. invertY: boolean;
  71277. /**
  71278. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71279. */
  71280. samplingMode: number;
  71281. /**
  71282. * Gets the loaded texture
  71283. */
  71284. texture: Texture;
  71285. /**
  71286. * Callback called when the task is successful
  71287. */
  71288. onSuccess: (task: TextureAssetTask) => void;
  71289. /**
  71290. * Callback called when the task is successful
  71291. */
  71292. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71293. /**
  71294. * Creates a new TextureAssetTask object
  71295. * @param name defines the name of the task
  71296. * @param url defines the location of the file to load
  71297. * @param noMipmap defines if mipmap should not be generated (default is false)
  71298. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71299. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71300. */
  71301. constructor(
  71302. /**
  71303. * Defines the name of the task
  71304. */
  71305. name: string,
  71306. /**
  71307. * Defines the location of the file to load
  71308. */
  71309. url: string,
  71310. /**
  71311. * Defines if mipmap should not be generated (default is false)
  71312. */
  71313. noMipmap?: boolean | undefined,
  71314. /**
  71315. * Defines if texture must be inverted on Y axis (default is true)
  71316. */
  71317. invertY?: boolean,
  71318. /**
  71319. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71320. */
  71321. samplingMode?: number);
  71322. /**
  71323. * Execute the current task
  71324. * @param scene defines the scene where you want your assets to be loaded
  71325. * @param onSuccess is a callback called when the task is successfully executed
  71326. * @param onError is a callback called if an error occurs
  71327. */
  71328. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71329. }
  71330. /**
  71331. * Define a task used by AssetsManager to load cube textures
  71332. */
  71333. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71334. /**
  71335. * Defines the name of the task
  71336. */
  71337. name: string;
  71338. /**
  71339. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71340. */
  71341. url: string;
  71342. /**
  71343. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71344. */
  71345. extensions?: string[] | undefined;
  71346. /**
  71347. * Defines if mipmaps should not be generated (default is false)
  71348. */
  71349. noMipmap?: boolean | undefined;
  71350. /**
  71351. * Defines the explicit list of files (undefined by default)
  71352. */
  71353. files?: string[] | undefined;
  71354. /**
  71355. * Gets the loaded texture
  71356. */
  71357. texture: CubeTexture;
  71358. /**
  71359. * Callback called when the task is successful
  71360. */
  71361. onSuccess: (task: CubeTextureAssetTask) => void;
  71362. /**
  71363. * Callback called when the task is successful
  71364. */
  71365. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71366. /**
  71367. * Creates a new CubeTextureAssetTask
  71368. * @param name defines the name of the task
  71369. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71370. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71371. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71372. * @param files defines the explicit list of files (undefined by default)
  71373. */
  71374. constructor(
  71375. /**
  71376. * Defines the name of the task
  71377. */
  71378. name: string,
  71379. /**
  71380. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71381. */
  71382. url: string,
  71383. /**
  71384. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71385. */
  71386. extensions?: string[] | undefined,
  71387. /**
  71388. * Defines if mipmaps should not be generated (default is false)
  71389. */
  71390. noMipmap?: boolean | undefined,
  71391. /**
  71392. * Defines the explicit list of files (undefined by default)
  71393. */
  71394. files?: string[] | undefined);
  71395. /**
  71396. * Execute the current task
  71397. * @param scene defines the scene where you want your assets to be loaded
  71398. * @param onSuccess is a callback called when the task is successfully executed
  71399. * @param onError is a callback called if an error occurs
  71400. */
  71401. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71402. }
  71403. /**
  71404. * Define a task used by AssetsManager to load HDR cube textures
  71405. */
  71406. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71407. /**
  71408. * Defines the name of the task
  71409. */
  71410. name: string;
  71411. /**
  71412. * Defines the location of the file to load
  71413. */
  71414. url: string;
  71415. /**
  71416. * Defines the desired size (the more it increases the longer the generation will be)
  71417. */
  71418. size: number;
  71419. /**
  71420. * Defines if mipmaps should not be generated (default is false)
  71421. */
  71422. noMipmap: boolean;
  71423. /**
  71424. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71425. */
  71426. generateHarmonics: boolean;
  71427. /**
  71428. * 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)
  71429. */
  71430. gammaSpace: boolean;
  71431. /**
  71432. * Internal Use Only
  71433. */
  71434. reserved: boolean;
  71435. /**
  71436. * Gets the loaded texture
  71437. */
  71438. texture: HDRCubeTexture;
  71439. /**
  71440. * Callback called when the task is successful
  71441. */
  71442. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71443. /**
  71444. * Callback called when the task is successful
  71445. */
  71446. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71447. /**
  71448. * Creates a new HDRCubeTextureAssetTask object
  71449. * @param name defines the name of the task
  71450. * @param url defines the location of the file to load
  71451. * @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.
  71452. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71453. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71454. * @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)
  71455. * @param reserved Internal use only
  71456. */
  71457. constructor(
  71458. /**
  71459. * Defines the name of the task
  71460. */
  71461. name: string,
  71462. /**
  71463. * Defines the location of the file to load
  71464. */
  71465. url: string,
  71466. /**
  71467. * Defines the desired size (the more it increases the longer the generation will be)
  71468. */
  71469. size: number,
  71470. /**
  71471. * Defines if mipmaps should not be generated (default is false)
  71472. */
  71473. noMipmap?: boolean,
  71474. /**
  71475. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71476. */
  71477. generateHarmonics?: boolean,
  71478. /**
  71479. * 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)
  71480. */
  71481. gammaSpace?: boolean,
  71482. /**
  71483. * Internal Use Only
  71484. */
  71485. reserved?: boolean);
  71486. /**
  71487. * Execute the current task
  71488. * @param scene defines the scene where you want your assets to be loaded
  71489. * @param onSuccess is a callback called when the task is successfully executed
  71490. * @param onError is a callback called if an error occurs
  71491. */
  71492. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71493. }
  71494. /**
  71495. * Define a task used by AssetsManager to load Equirectangular cube textures
  71496. */
  71497. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71498. /**
  71499. * Defines the name of the task
  71500. */
  71501. name: string;
  71502. /**
  71503. * Defines the location of the file to load
  71504. */
  71505. url: string;
  71506. /**
  71507. * Defines the desired size (the more it increases the longer the generation will be)
  71508. */
  71509. size: number;
  71510. /**
  71511. * Defines if mipmaps should not be generated (default is false)
  71512. */
  71513. noMipmap: boolean;
  71514. /**
  71515. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71516. * but the standard material would require them in Gamma space) (default is true)
  71517. */
  71518. gammaSpace: boolean;
  71519. /**
  71520. * Gets the loaded texture
  71521. */
  71522. texture: EquiRectangularCubeTexture;
  71523. /**
  71524. * Callback called when the task is successful
  71525. */
  71526. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71527. /**
  71528. * Callback called when the task is successful
  71529. */
  71530. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71531. /**
  71532. * Creates a new EquiRectangularCubeTextureAssetTask object
  71533. * @param name defines the name of the task
  71534. * @param url defines the location of the file to load
  71535. * @param size defines the desired size (the more it increases the longer the generation will be)
  71536. * If the size is omitted this implies you are using a preprocessed cubemap.
  71537. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71538. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71539. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71540. * (default is true)
  71541. */
  71542. constructor(
  71543. /**
  71544. * Defines the name of the task
  71545. */
  71546. name: string,
  71547. /**
  71548. * Defines the location of the file to load
  71549. */
  71550. url: string,
  71551. /**
  71552. * Defines the desired size (the more it increases the longer the generation will be)
  71553. */
  71554. size: number,
  71555. /**
  71556. * Defines if mipmaps should not be generated (default is false)
  71557. */
  71558. noMipmap?: boolean,
  71559. /**
  71560. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71561. * but the standard material would require them in Gamma space) (default is true)
  71562. */
  71563. gammaSpace?: boolean);
  71564. /**
  71565. * Execute the current task
  71566. * @param scene defines the scene where you want your assets to be loaded
  71567. * @param onSuccess is a callback called when the task is successfully executed
  71568. * @param onError is a callback called if an error occurs
  71569. */
  71570. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71571. }
  71572. /**
  71573. * This class can be used to easily import assets into a scene
  71574. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71575. */
  71576. export class AssetsManager {
  71577. private _scene;
  71578. private _isLoading;
  71579. protected _tasks: AbstractAssetTask[];
  71580. protected _waitingTasksCount: number;
  71581. protected _totalTasksCount: number;
  71582. /**
  71583. * Callback called when all tasks are processed
  71584. */
  71585. onFinish: (tasks: AbstractAssetTask[]) => void;
  71586. /**
  71587. * Callback called when a task is successful
  71588. */
  71589. onTaskSuccess: (task: AbstractAssetTask) => void;
  71590. /**
  71591. * Callback called when a task had an error
  71592. */
  71593. onTaskError: (task: AbstractAssetTask) => void;
  71594. /**
  71595. * Callback called when a task is done (whatever the result is)
  71596. */
  71597. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71598. /**
  71599. * Observable called when all tasks are processed
  71600. */
  71601. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71602. /**
  71603. * Observable called when a task had an error
  71604. */
  71605. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71606. /**
  71607. * Observable called when all tasks were executed
  71608. */
  71609. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71610. /**
  71611. * Observable called when a task is done (whatever the result is)
  71612. */
  71613. onProgressObservable: Observable<IAssetsProgressEvent>;
  71614. /**
  71615. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71616. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71617. */
  71618. useDefaultLoadingScreen: boolean;
  71619. /**
  71620. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71621. * when all assets have been downloaded.
  71622. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71623. */
  71624. autoHideLoadingUI: boolean;
  71625. /**
  71626. * Creates a new AssetsManager
  71627. * @param scene defines the scene to work on
  71628. */
  71629. constructor(scene: Scene);
  71630. /**
  71631. * Add a MeshAssetTask to the list of active tasks
  71632. * @param taskName defines the name of the new task
  71633. * @param meshesNames defines the name of meshes to load
  71634. * @param rootUrl defines the root url to use to locate files
  71635. * @param sceneFilename defines the filename of the scene file
  71636. * @returns a new MeshAssetTask object
  71637. */
  71638. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71639. /**
  71640. * Add a TextFileAssetTask to the list of active tasks
  71641. * @param taskName defines the name of the new task
  71642. * @param url defines the url of the file to load
  71643. * @returns a new TextFileAssetTask object
  71644. */
  71645. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71646. /**
  71647. * Add a BinaryFileAssetTask to the list of active tasks
  71648. * @param taskName defines the name of the new task
  71649. * @param url defines the url of the file to load
  71650. * @returns a new BinaryFileAssetTask object
  71651. */
  71652. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71653. /**
  71654. * Add a ImageAssetTask to the list of active tasks
  71655. * @param taskName defines the name of the new task
  71656. * @param url defines the url of the file to load
  71657. * @returns a new ImageAssetTask object
  71658. */
  71659. addImageTask(taskName: string, url: string): ImageAssetTask;
  71660. /**
  71661. * Add a TextureAssetTask to the list of active tasks
  71662. * @param taskName defines the name of the new task
  71663. * @param url defines the url of the file to load
  71664. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71665. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71666. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71667. * @returns a new TextureAssetTask object
  71668. */
  71669. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71670. /**
  71671. * Add a CubeTextureAssetTask to the list of active tasks
  71672. * @param taskName defines the name of the new task
  71673. * @param url defines the url of the file to load
  71674. * @param extensions defines the extension to use to load the cube map (can be null)
  71675. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71676. * @param files defines the list of files to load (can be null)
  71677. * @returns a new CubeTextureAssetTask object
  71678. */
  71679. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71680. /**
  71681. *
  71682. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71683. * @param taskName defines the name of the new task
  71684. * @param url defines the url of the file to load
  71685. * @param size defines the size you want for the cubemap (can be null)
  71686. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71687. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71688. * @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)
  71689. * @param reserved Internal use only
  71690. * @returns a new HDRCubeTextureAssetTask object
  71691. */
  71692. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71693. /**
  71694. *
  71695. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71696. * @param taskName defines the name of the new task
  71697. * @param url defines the url of the file to load
  71698. * @param size defines the size you want for the cubemap (can be null)
  71699. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71700. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71701. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71702. * @returns a new EquiRectangularCubeTextureAssetTask object
  71703. */
  71704. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71705. /**
  71706. * Remove a task from the assets manager.
  71707. * @param task the task to remove
  71708. */
  71709. removeTask(task: AbstractAssetTask): void;
  71710. private _decreaseWaitingTasksCount;
  71711. private _runTask;
  71712. /**
  71713. * Reset the AssetsManager and remove all tasks
  71714. * @return the current instance of the AssetsManager
  71715. */
  71716. reset(): AssetsManager;
  71717. /**
  71718. * Start the loading process
  71719. * @return the current instance of the AssetsManager
  71720. */
  71721. load(): AssetsManager;
  71722. /**
  71723. * Start the loading process as an async operation
  71724. * @return a promise returning the list of failed tasks
  71725. */
  71726. loadAsync(): Promise<void>;
  71727. }
  71728. }
  71729. declare module BABYLON {
  71730. /**
  71731. * Wrapper class for promise with external resolve and reject.
  71732. */
  71733. export class Deferred<T> {
  71734. /**
  71735. * The promise associated with this deferred object.
  71736. */
  71737. readonly promise: Promise<T>;
  71738. private _resolve;
  71739. private _reject;
  71740. /**
  71741. * The resolve method of the promise associated with this deferred object.
  71742. */
  71743. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71744. /**
  71745. * The reject method of the promise associated with this deferred object.
  71746. */
  71747. get reject(): (reason?: any) => void;
  71748. /**
  71749. * Constructor for this deferred object.
  71750. */
  71751. constructor();
  71752. }
  71753. }
  71754. declare module BABYLON {
  71755. /**
  71756. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71757. */
  71758. export class MeshExploder {
  71759. private _centerMesh;
  71760. private _meshes;
  71761. private _meshesOrigins;
  71762. private _toCenterVectors;
  71763. private _scaledDirection;
  71764. private _newPosition;
  71765. private _centerPosition;
  71766. /**
  71767. * Explodes meshes from a center mesh.
  71768. * @param meshes The meshes to explode.
  71769. * @param centerMesh The mesh to be center of explosion.
  71770. */
  71771. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71772. private _setCenterMesh;
  71773. /**
  71774. * Get class name
  71775. * @returns "MeshExploder"
  71776. */
  71777. getClassName(): string;
  71778. /**
  71779. * "Exploded meshes"
  71780. * @returns Array of meshes with the centerMesh at index 0.
  71781. */
  71782. getMeshes(): Array<Mesh>;
  71783. /**
  71784. * Explodes meshes giving a specific direction
  71785. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71786. */
  71787. explode(direction?: number): void;
  71788. }
  71789. }
  71790. declare module BABYLON {
  71791. /**
  71792. * Class used to help managing file picking and drag'n'drop
  71793. */
  71794. export class FilesInput {
  71795. /**
  71796. * List of files ready to be loaded
  71797. */
  71798. static get FilesToLoad(): {
  71799. [key: string]: File;
  71800. };
  71801. /**
  71802. * Callback called when a file is processed
  71803. */
  71804. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71805. private _engine;
  71806. private _currentScene;
  71807. private _sceneLoadedCallback;
  71808. private _progressCallback;
  71809. private _additionalRenderLoopLogicCallback;
  71810. private _textureLoadingCallback;
  71811. private _startingProcessingFilesCallback;
  71812. private _onReloadCallback;
  71813. private _errorCallback;
  71814. private _elementToMonitor;
  71815. private _sceneFileToLoad;
  71816. private _filesToLoad;
  71817. /**
  71818. * Creates a new FilesInput
  71819. * @param engine defines the rendering engine
  71820. * @param scene defines the hosting scene
  71821. * @param sceneLoadedCallback callback called when scene is loaded
  71822. * @param progressCallback callback called to track progress
  71823. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71824. * @param textureLoadingCallback callback called when a texture is loading
  71825. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71826. * @param onReloadCallback callback called when a reload is requested
  71827. * @param errorCallback callback call if an error occurs
  71828. */
  71829. 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);
  71830. private _dragEnterHandler;
  71831. private _dragOverHandler;
  71832. private _dropHandler;
  71833. /**
  71834. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71835. * @param elementToMonitor defines the DOM element to track
  71836. */
  71837. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71838. /**
  71839. * Release all associated resources
  71840. */
  71841. dispose(): void;
  71842. private renderFunction;
  71843. private drag;
  71844. private drop;
  71845. private _traverseFolder;
  71846. private _processFiles;
  71847. /**
  71848. * Load files from a drop event
  71849. * @param event defines the drop event to use as source
  71850. */
  71851. loadFiles(event: any): void;
  71852. private _processReload;
  71853. /**
  71854. * Reload the current scene from the loaded files
  71855. */
  71856. reload(): void;
  71857. }
  71858. }
  71859. declare module BABYLON {
  71860. /**
  71861. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71862. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71863. */
  71864. export class SceneOptimization {
  71865. /**
  71866. * Defines the priority of this optimization (0 by default which means first in the list)
  71867. */
  71868. priority: number;
  71869. /**
  71870. * Gets a string describing the action executed by the current optimization
  71871. * @returns description string
  71872. */
  71873. getDescription(): string;
  71874. /**
  71875. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71876. * @param scene defines the current scene where to apply this optimization
  71877. * @param optimizer defines the current optimizer
  71878. * @returns true if everything that can be done was applied
  71879. */
  71880. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71881. /**
  71882. * Creates the SceneOptimization object
  71883. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71884. * @param desc defines the description associated with the optimization
  71885. */
  71886. constructor(
  71887. /**
  71888. * Defines the priority of this optimization (0 by default which means first in the list)
  71889. */
  71890. priority?: number);
  71891. }
  71892. /**
  71893. * Defines an optimization used to reduce the size of render target textures
  71894. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71895. */
  71896. export class TextureOptimization extends SceneOptimization {
  71897. /**
  71898. * Defines the priority of this optimization (0 by default which means first in the list)
  71899. */
  71900. priority: number;
  71901. /**
  71902. * 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
  71903. */
  71904. maximumSize: number;
  71905. /**
  71906. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71907. */
  71908. step: number;
  71909. /**
  71910. * Gets a string describing the action executed by the current optimization
  71911. * @returns description string
  71912. */
  71913. getDescription(): string;
  71914. /**
  71915. * Creates the TextureOptimization object
  71916. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71917. * @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
  71918. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71919. */
  71920. constructor(
  71921. /**
  71922. * Defines the priority of this optimization (0 by default which means first in the list)
  71923. */
  71924. priority?: number,
  71925. /**
  71926. * 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
  71927. */
  71928. maximumSize?: number,
  71929. /**
  71930. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71931. */
  71932. step?: number);
  71933. /**
  71934. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71935. * @param scene defines the current scene where to apply this optimization
  71936. * @param optimizer defines the current optimizer
  71937. * @returns true if everything that can be done was applied
  71938. */
  71939. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71940. }
  71941. /**
  71942. * Defines an optimization used to increase or decrease the rendering resolution
  71943. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71944. */
  71945. export class HardwareScalingOptimization extends SceneOptimization {
  71946. /**
  71947. * Defines the priority of this optimization (0 by default which means first in the list)
  71948. */
  71949. priority: number;
  71950. /**
  71951. * Defines the maximum scale to use (2 by default)
  71952. */
  71953. maximumScale: number;
  71954. /**
  71955. * Defines the step to use between two passes (0.5 by default)
  71956. */
  71957. step: number;
  71958. private _currentScale;
  71959. private _directionOffset;
  71960. /**
  71961. * Gets a string describing the action executed by the current optimization
  71962. * @return description string
  71963. */
  71964. getDescription(): string;
  71965. /**
  71966. * Creates the HardwareScalingOptimization object
  71967. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71968. * @param maximumScale defines the maximum scale to use (2 by default)
  71969. * @param step defines the step to use between two passes (0.5 by default)
  71970. */
  71971. constructor(
  71972. /**
  71973. * Defines the priority of this optimization (0 by default which means first in the list)
  71974. */
  71975. priority?: number,
  71976. /**
  71977. * Defines the maximum scale to use (2 by default)
  71978. */
  71979. maximumScale?: number,
  71980. /**
  71981. * Defines the step to use between two passes (0.5 by default)
  71982. */
  71983. step?: number);
  71984. /**
  71985. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71986. * @param scene defines the current scene where to apply this optimization
  71987. * @param optimizer defines the current optimizer
  71988. * @returns true if everything that can be done was applied
  71989. */
  71990. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71991. }
  71992. /**
  71993. * Defines an optimization used to remove shadows
  71994. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71995. */
  71996. export class ShadowsOptimization extends SceneOptimization {
  71997. /**
  71998. * Gets a string describing the action executed by the current optimization
  71999. * @return description string
  72000. */
  72001. getDescription(): string;
  72002. /**
  72003. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72004. * @param scene defines the current scene where to apply this optimization
  72005. * @param optimizer defines the current optimizer
  72006. * @returns true if everything that can be done was applied
  72007. */
  72008. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72009. }
  72010. /**
  72011. * Defines an optimization used to turn post-processes off
  72012. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72013. */
  72014. export class PostProcessesOptimization extends SceneOptimization {
  72015. /**
  72016. * Gets a string describing the action executed by the current optimization
  72017. * @return description string
  72018. */
  72019. getDescription(): string;
  72020. /**
  72021. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72022. * @param scene defines the current scene where to apply this optimization
  72023. * @param optimizer defines the current optimizer
  72024. * @returns true if everything that can be done was applied
  72025. */
  72026. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72027. }
  72028. /**
  72029. * Defines an optimization used to turn lens flares off
  72030. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72031. */
  72032. export class LensFlaresOptimization extends SceneOptimization {
  72033. /**
  72034. * Gets a string describing the action executed by the current optimization
  72035. * @return description string
  72036. */
  72037. getDescription(): string;
  72038. /**
  72039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72040. * @param scene defines the current scene where to apply this optimization
  72041. * @param optimizer defines the current optimizer
  72042. * @returns true if everything that can be done was applied
  72043. */
  72044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72045. }
  72046. /**
  72047. * Defines an optimization based on user defined callback.
  72048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72049. */
  72050. export class CustomOptimization extends SceneOptimization {
  72051. /**
  72052. * Callback called to apply the custom optimization.
  72053. */
  72054. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72055. /**
  72056. * Callback called to get custom description
  72057. */
  72058. onGetDescription: () => string;
  72059. /**
  72060. * Gets a string describing the action executed by the current optimization
  72061. * @returns description string
  72062. */
  72063. getDescription(): string;
  72064. /**
  72065. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72066. * @param scene defines the current scene where to apply this optimization
  72067. * @param optimizer defines the current optimizer
  72068. * @returns true if everything that can be done was applied
  72069. */
  72070. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72071. }
  72072. /**
  72073. * Defines an optimization used to turn particles off
  72074. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72075. */
  72076. export class ParticlesOptimization extends SceneOptimization {
  72077. /**
  72078. * Gets a string describing the action executed by the current optimization
  72079. * @return description string
  72080. */
  72081. getDescription(): string;
  72082. /**
  72083. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72084. * @param scene defines the current scene where to apply this optimization
  72085. * @param optimizer defines the current optimizer
  72086. * @returns true if everything that can be done was applied
  72087. */
  72088. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72089. }
  72090. /**
  72091. * Defines an optimization used to turn render targets off
  72092. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72093. */
  72094. export class RenderTargetsOptimization extends SceneOptimization {
  72095. /**
  72096. * Gets a string describing the action executed by the current optimization
  72097. * @return description string
  72098. */
  72099. getDescription(): string;
  72100. /**
  72101. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72102. * @param scene defines the current scene where to apply this optimization
  72103. * @param optimizer defines the current optimizer
  72104. * @returns true if everything that can be done was applied
  72105. */
  72106. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72107. }
  72108. /**
  72109. * Defines an optimization used to merge meshes with compatible materials
  72110. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72111. */
  72112. export class MergeMeshesOptimization extends SceneOptimization {
  72113. private static _UpdateSelectionTree;
  72114. /**
  72115. * Gets or sets a boolean which defines if optimization octree has to be updated
  72116. */
  72117. static get UpdateSelectionTree(): boolean;
  72118. /**
  72119. * Gets or sets a boolean which defines if optimization octree has to be updated
  72120. */
  72121. static set UpdateSelectionTree(value: boolean);
  72122. /**
  72123. * Gets a string describing the action executed by the current optimization
  72124. * @return description string
  72125. */
  72126. getDescription(): string;
  72127. private _canBeMerged;
  72128. /**
  72129. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72130. * @param scene defines the current scene where to apply this optimization
  72131. * @param optimizer defines the current optimizer
  72132. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72133. * @returns true if everything that can be done was applied
  72134. */
  72135. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72136. }
  72137. /**
  72138. * Defines a list of options used by SceneOptimizer
  72139. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72140. */
  72141. export class SceneOptimizerOptions {
  72142. /**
  72143. * Defines the target frame rate to reach (60 by default)
  72144. */
  72145. targetFrameRate: number;
  72146. /**
  72147. * Defines the interval between two checkes (2000ms by default)
  72148. */
  72149. trackerDuration: number;
  72150. /**
  72151. * Gets the list of optimizations to apply
  72152. */
  72153. optimizations: SceneOptimization[];
  72154. /**
  72155. * Creates a new list of options used by SceneOptimizer
  72156. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72157. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72158. */
  72159. constructor(
  72160. /**
  72161. * Defines the target frame rate to reach (60 by default)
  72162. */
  72163. targetFrameRate?: number,
  72164. /**
  72165. * Defines the interval between two checkes (2000ms by default)
  72166. */
  72167. trackerDuration?: number);
  72168. /**
  72169. * Add a new optimization
  72170. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72171. * @returns the current SceneOptimizerOptions
  72172. */
  72173. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72174. /**
  72175. * Add a new custom optimization
  72176. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72177. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72178. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72179. * @returns the current SceneOptimizerOptions
  72180. */
  72181. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72182. /**
  72183. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72184. * @param targetFrameRate defines the target frame rate (60 by default)
  72185. * @returns a SceneOptimizerOptions object
  72186. */
  72187. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72188. /**
  72189. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72190. * @param targetFrameRate defines the target frame rate (60 by default)
  72191. * @returns a SceneOptimizerOptions object
  72192. */
  72193. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72194. /**
  72195. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72196. * @param targetFrameRate defines the target frame rate (60 by default)
  72197. * @returns a SceneOptimizerOptions object
  72198. */
  72199. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72200. }
  72201. /**
  72202. * Class used to run optimizations in order to reach a target frame rate
  72203. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72204. */
  72205. export class SceneOptimizer implements IDisposable {
  72206. private _isRunning;
  72207. private _options;
  72208. private _scene;
  72209. private _currentPriorityLevel;
  72210. private _targetFrameRate;
  72211. private _trackerDuration;
  72212. private _currentFrameRate;
  72213. private _sceneDisposeObserver;
  72214. private _improvementMode;
  72215. /**
  72216. * Defines an observable called when the optimizer reaches the target frame rate
  72217. */
  72218. onSuccessObservable: Observable<SceneOptimizer>;
  72219. /**
  72220. * Defines an observable called when the optimizer enables an optimization
  72221. */
  72222. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72223. /**
  72224. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72225. */
  72226. onFailureObservable: Observable<SceneOptimizer>;
  72227. /**
  72228. * Gets a boolean indicating if the optimizer is in improvement mode
  72229. */
  72230. get isInImprovementMode(): boolean;
  72231. /**
  72232. * Gets the current priority level (0 at start)
  72233. */
  72234. get currentPriorityLevel(): number;
  72235. /**
  72236. * Gets the current frame rate checked by the SceneOptimizer
  72237. */
  72238. get currentFrameRate(): number;
  72239. /**
  72240. * Gets or sets the current target frame rate (60 by default)
  72241. */
  72242. get targetFrameRate(): number;
  72243. /**
  72244. * Gets or sets the current target frame rate (60 by default)
  72245. */
  72246. set targetFrameRate(value: number);
  72247. /**
  72248. * Gets or sets the current interval between two checks (every 2000ms by default)
  72249. */
  72250. get trackerDuration(): number;
  72251. /**
  72252. * Gets or sets the current interval between two checks (every 2000ms by default)
  72253. */
  72254. set trackerDuration(value: number);
  72255. /**
  72256. * Gets the list of active optimizations
  72257. */
  72258. get optimizations(): SceneOptimization[];
  72259. /**
  72260. * Creates a new SceneOptimizer
  72261. * @param scene defines the scene to work on
  72262. * @param options defines the options to use with the SceneOptimizer
  72263. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72264. * @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)
  72265. */
  72266. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72267. /**
  72268. * Stops the current optimizer
  72269. */
  72270. stop(): void;
  72271. /**
  72272. * Reset the optimizer to initial step (current priority level = 0)
  72273. */
  72274. reset(): void;
  72275. /**
  72276. * Start the optimizer. By default it will try to reach a specific framerate
  72277. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72278. */
  72279. start(): void;
  72280. private _checkCurrentState;
  72281. /**
  72282. * Release all resources
  72283. */
  72284. dispose(): void;
  72285. /**
  72286. * Helper function to create a SceneOptimizer with one single line of code
  72287. * @param scene defines the scene to work on
  72288. * @param options defines the options to use with the SceneOptimizer
  72289. * @param onSuccess defines a callback to call on success
  72290. * @param onFailure defines a callback to call on failure
  72291. * @returns the new SceneOptimizer object
  72292. */
  72293. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72294. }
  72295. }
  72296. declare module BABYLON {
  72297. /**
  72298. * Class used to serialize a scene into a string
  72299. */
  72300. export class SceneSerializer {
  72301. /**
  72302. * Clear cache used by a previous serialization
  72303. */
  72304. static ClearCache(): void;
  72305. /**
  72306. * Serialize a scene into a JSON compatible object
  72307. * @param scene defines the scene to serialize
  72308. * @returns a JSON compatible object
  72309. */
  72310. static Serialize(scene: Scene): any;
  72311. /**
  72312. * Serialize a mesh into a JSON compatible object
  72313. * @param toSerialize defines the mesh to serialize
  72314. * @param withParents defines if parents must be serialized as well
  72315. * @param withChildren defines if children must be serialized as well
  72316. * @returns a JSON compatible object
  72317. */
  72318. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72319. }
  72320. }
  72321. declare module BABYLON {
  72322. /**
  72323. * Class used to host texture specific utilities
  72324. */
  72325. export class TextureTools {
  72326. /**
  72327. * Uses the GPU to create a copy texture rescaled at a given size
  72328. * @param texture Texture to copy from
  72329. * @param width defines the desired width
  72330. * @param height defines the desired height
  72331. * @param useBilinearMode defines if bilinear mode has to be used
  72332. * @return the generated texture
  72333. */
  72334. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72335. }
  72336. }
  72337. declare module BABYLON {
  72338. /**
  72339. * This represents the different options available for the video capture.
  72340. */
  72341. export interface VideoRecorderOptions {
  72342. /** Defines the mime type of the video. */
  72343. mimeType: string;
  72344. /** Defines the FPS the video should be recorded at. */
  72345. fps: number;
  72346. /** Defines the chunk size for the recording data. */
  72347. recordChunckSize: number;
  72348. /** The audio tracks to attach to the recording. */
  72349. audioTracks?: MediaStreamTrack[];
  72350. }
  72351. /**
  72352. * This can help with recording videos from BabylonJS.
  72353. * This is based on the available WebRTC functionalities of the browser.
  72354. *
  72355. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72356. */
  72357. export class VideoRecorder {
  72358. private static readonly _defaultOptions;
  72359. /**
  72360. * Returns whether or not the VideoRecorder is available in your browser.
  72361. * @param engine Defines the Babylon Engine.
  72362. * @returns true if supported otherwise false.
  72363. */
  72364. static IsSupported(engine: Engine): boolean;
  72365. private readonly _options;
  72366. private _canvas;
  72367. private _mediaRecorder;
  72368. private _recordedChunks;
  72369. private _fileName;
  72370. private _resolve;
  72371. private _reject;
  72372. /**
  72373. * True when a recording is already in progress.
  72374. */
  72375. get isRecording(): boolean;
  72376. /**
  72377. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72378. * @param engine Defines the BabylonJS Engine you wish to record.
  72379. * @param options Defines options that can be used to customize the capture.
  72380. */
  72381. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72382. /**
  72383. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72384. */
  72385. stopRecording(): void;
  72386. /**
  72387. * Starts recording the canvas for a max duration specified in parameters.
  72388. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72389. * If null no automatic download will start and you can rely on the promise to get the data back.
  72390. * @param maxDuration Defines the maximum recording time in seconds.
  72391. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72392. * @return A promise callback at the end of the recording with the video data in Blob.
  72393. */
  72394. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72395. /**
  72396. * Releases internal resources used during the recording.
  72397. */
  72398. dispose(): void;
  72399. private _handleDataAvailable;
  72400. private _handleError;
  72401. private _handleStop;
  72402. }
  72403. }
  72404. declare module BABYLON {
  72405. /**
  72406. * Class containing a set of static utilities functions for screenshots
  72407. */
  72408. export class ScreenshotTools {
  72409. /**
  72410. * Captures a screenshot of the current rendering
  72411. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72412. * @param engine defines the rendering engine
  72413. * @param camera defines the source camera
  72414. * @param size This parameter can be set to a single number or to an object with the
  72415. * following (optional) properties: precision, width, height. If a single number is passed,
  72416. * it will be used for both width and height. If an object is passed, the screenshot size
  72417. * will be derived from the parameters. The precision property is a multiplier allowing
  72418. * rendering at a higher or lower resolution
  72419. * @param successCallback defines the callback receives a single parameter which contains the
  72420. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72421. * src parameter of an <img> to display it
  72422. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72423. * Check your browser for supported MIME types
  72424. */
  72425. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72426. /**
  72427. * Captures a screenshot of the current rendering
  72428. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72429. * @param engine defines the rendering engine
  72430. * @param camera defines the source camera
  72431. * @param size This parameter can be set to a single number or to an object with the
  72432. * following (optional) properties: precision, width, height. If a single number is passed,
  72433. * it will be used for both width and height. If an object is passed, the screenshot size
  72434. * will be derived from the parameters. The precision property is a multiplier allowing
  72435. * rendering at a higher or lower resolution
  72436. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72437. * Check your browser for supported MIME types
  72438. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72439. * to the src parameter of an <img> to display it
  72440. */
  72441. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72442. /**
  72443. * Generates an image screenshot from the specified camera.
  72444. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72445. * @param engine The engine to use for rendering
  72446. * @param camera The camera to use for rendering
  72447. * @param size This parameter can be set to a single number or to an object with the
  72448. * following (optional) properties: precision, width, height. If a single number is passed,
  72449. * it will be used for both width and height. If an object is passed, the screenshot size
  72450. * will be derived from the parameters. The precision property is a multiplier allowing
  72451. * rendering at a higher or lower resolution
  72452. * @param successCallback The callback receives a single parameter which contains the
  72453. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72454. * src parameter of an <img> to display it
  72455. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72456. * Check your browser for supported MIME types
  72457. * @param samples Texture samples (default: 1)
  72458. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72459. * @param fileName A name for for the downloaded file.
  72460. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72461. */
  72462. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72463. /**
  72464. * Generates an image screenshot from the specified camera.
  72465. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72466. * @param engine The engine to use for rendering
  72467. * @param camera The camera to use for rendering
  72468. * @param size This parameter can be set to a single number or to an object with the
  72469. * following (optional) properties: precision, width, height. If a single number is passed,
  72470. * it will be used for both width and height. If an object is passed, the screenshot size
  72471. * will be derived from the parameters. The precision property is a multiplier allowing
  72472. * rendering at a higher or lower resolution
  72473. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72474. * Check your browser for supported MIME types
  72475. * @param samples Texture samples (default: 1)
  72476. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72477. * @param fileName A name for for the downloaded file.
  72478. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72479. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72480. * to the src parameter of an <img> to display it
  72481. */
  72482. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72483. /**
  72484. * Gets height and width for screenshot size
  72485. * @private
  72486. */
  72487. private static _getScreenshotSize;
  72488. }
  72489. }
  72490. declare module BABYLON {
  72491. /**
  72492. * Interface for a data buffer
  72493. */
  72494. export interface IDataBuffer {
  72495. /**
  72496. * Reads bytes from the data buffer.
  72497. * @param byteOffset The byte offset to read
  72498. * @param byteLength The byte length to read
  72499. * @returns A promise that resolves when the bytes are read
  72500. */
  72501. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72502. /**
  72503. * The byte length of the buffer.
  72504. */
  72505. readonly byteLength: number;
  72506. }
  72507. /**
  72508. * Utility class for reading from a data buffer
  72509. */
  72510. export class DataReader {
  72511. /**
  72512. * The data buffer associated with this data reader.
  72513. */
  72514. readonly buffer: IDataBuffer;
  72515. /**
  72516. * The current byte offset from the beginning of the data buffer.
  72517. */
  72518. byteOffset: number;
  72519. private _dataView;
  72520. private _dataByteOffset;
  72521. /**
  72522. * Constructor
  72523. * @param buffer The buffer to read
  72524. */
  72525. constructor(buffer: IDataBuffer);
  72526. /**
  72527. * Loads the given byte length.
  72528. * @param byteLength The byte length to load
  72529. * @returns A promise that resolves when the load is complete
  72530. */
  72531. loadAsync(byteLength: number): Promise<void>;
  72532. /**
  72533. * Read a unsigned 32-bit integer from the currently loaded data range.
  72534. * @returns The 32-bit integer read
  72535. */
  72536. readUint32(): number;
  72537. /**
  72538. * Read a byte array from the currently loaded data range.
  72539. * @param byteLength The byte length to read
  72540. * @returns The byte array read
  72541. */
  72542. readUint8Array(byteLength: number): Uint8Array;
  72543. /**
  72544. * Read a string from the currently loaded data range.
  72545. * @param byteLength The byte length to read
  72546. * @returns The string read
  72547. */
  72548. readString(byteLength: number): string;
  72549. /**
  72550. * Skips the given byte length the currently loaded data range.
  72551. * @param byteLength The byte length to skip
  72552. */
  72553. skipBytes(byteLength: number): void;
  72554. }
  72555. }
  72556. declare module BABYLON {
  72557. /**
  72558. * Class for storing data to local storage if available or in-memory storage otherwise
  72559. */
  72560. export class DataStorage {
  72561. private static _Storage;
  72562. private static _GetStorage;
  72563. /**
  72564. * Reads a string from the data storage
  72565. * @param key The key to read
  72566. * @param defaultValue The value if the key doesn't exist
  72567. * @returns The string value
  72568. */
  72569. static ReadString(key: string, defaultValue: string): string;
  72570. /**
  72571. * Writes a string to the data storage
  72572. * @param key The key to write
  72573. * @param value The value to write
  72574. */
  72575. static WriteString(key: string, value: string): void;
  72576. /**
  72577. * Reads a boolean from the data storage
  72578. * @param key The key to read
  72579. * @param defaultValue The value if the key doesn't exist
  72580. * @returns The boolean value
  72581. */
  72582. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72583. /**
  72584. * Writes a boolean to the data storage
  72585. * @param key The key to write
  72586. * @param value The value to write
  72587. */
  72588. static WriteBoolean(key: string, value: boolean): void;
  72589. /**
  72590. * Reads a number from the data storage
  72591. * @param key The key to read
  72592. * @param defaultValue The value if the key doesn't exist
  72593. * @returns The number value
  72594. */
  72595. static ReadNumber(key: string, defaultValue: number): number;
  72596. /**
  72597. * Writes a number to the data storage
  72598. * @param key The key to write
  72599. * @param value The value to write
  72600. */
  72601. static WriteNumber(key: string, value: number): void;
  72602. }
  72603. }
  72604. declare module BABYLON {
  72605. /**
  72606. * An interface for all Hit test features
  72607. */
  72608. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  72609. /**
  72610. * Triggered when new babylon (transformed) hit test results are available
  72611. */
  72612. onHitTestResultObservable: Observable<T[]>;
  72613. }
  72614. /**
  72615. * Options used for hit testing
  72616. */
  72617. export interface IWebXRLegacyHitTestOptions {
  72618. /**
  72619. * Only test when user interacted with the scene. Default - hit test every frame
  72620. */
  72621. testOnPointerDownOnly?: boolean;
  72622. /**
  72623. * The node to use to transform the local results to world coordinates
  72624. */
  72625. worldParentNode?: TransformNode;
  72626. }
  72627. /**
  72628. * Interface defining the babylon result of raycasting/hit-test
  72629. */
  72630. export interface IWebXRLegacyHitResult {
  72631. /**
  72632. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72633. */
  72634. transformationMatrix: Matrix;
  72635. /**
  72636. * The native hit test result
  72637. */
  72638. xrHitResult: XRHitResult | XRHitTestResult;
  72639. }
  72640. /**
  72641. * The currently-working hit-test module.
  72642. * Hit test (or Ray-casting) is used to interact with the real world.
  72643. * For further information read here - https://github.com/immersive-web/hit-test
  72644. */
  72645. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  72646. /**
  72647. * options to use when constructing this feature
  72648. */
  72649. readonly options: IWebXRLegacyHitTestOptions;
  72650. private _direction;
  72651. private _mat;
  72652. private _onSelectEnabled;
  72653. private _origin;
  72654. /**
  72655. * The module's name
  72656. */
  72657. static readonly Name: string;
  72658. /**
  72659. * The (Babylon) version of this module.
  72660. * This is an integer representing the implementation version.
  72661. * This number does not correspond to the WebXR specs version
  72662. */
  72663. static readonly Version: number;
  72664. /**
  72665. * Populated with the last native XR Hit Results
  72666. */
  72667. lastNativeXRHitResults: XRHitResult[];
  72668. /**
  72669. * Triggered when new babylon (transformed) hit test results are available
  72670. */
  72671. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72672. /**
  72673. * Creates a new instance of the (legacy version) hit test feature
  72674. * @param _xrSessionManager an instance of WebXRSessionManager
  72675. * @param options options to use when constructing this feature
  72676. */
  72677. constructor(_xrSessionManager: WebXRSessionManager,
  72678. /**
  72679. * options to use when constructing this feature
  72680. */
  72681. options?: IWebXRLegacyHitTestOptions);
  72682. /**
  72683. * execute a hit test with an XR Ray
  72684. *
  72685. * @param xrSession a native xrSession that will execute this hit test
  72686. * @param xrRay the ray (position and direction) to use for ray-casting
  72687. * @param referenceSpace native XR reference space to use for the hit-test
  72688. * @param filter filter function that will filter the results
  72689. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72690. */
  72691. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72692. /**
  72693. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72694. * @param event the (select) event to use to select with
  72695. * @param referenceSpace the reference space to use for this hit test
  72696. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72697. */
  72698. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72699. /**
  72700. * attach this feature
  72701. * Will usually be called by the features manager
  72702. *
  72703. * @returns true if successful.
  72704. */
  72705. attach(): boolean;
  72706. /**
  72707. * detach this feature.
  72708. * Will usually be called by the features manager
  72709. *
  72710. * @returns true if successful.
  72711. */
  72712. detach(): boolean;
  72713. /**
  72714. * Dispose this feature and all of the resources attached
  72715. */
  72716. dispose(): void;
  72717. protected _onXRFrame(frame: XRFrame): void;
  72718. private _onHitTestResults;
  72719. private _onSelect;
  72720. }
  72721. }
  72722. declare module BABYLON {
  72723. /**
  72724. * Options used for hit testing (version 2)
  72725. */
  72726. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72727. /**
  72728. * Do not create a permanent hit test. Will usually be used when only
  72729. * transient inputs are needed.
  72730. */
  72731. disablePermanentHitTest?: boolean;
  72732. /**
  72733. * Enable transient (for example touch-based) hit test inspections
  72734. */
  72735. enableTransientHitTest?: boolean;
  72736. /**
  72737. * Offset ray for the permanent hit test
  72738. */
  72739. offsetRay?: Vector3;
  72740. /**
  72741. * Offset ray for the transient hit test
  72742. */
  72743. transientOffsetRay?: Vector3;
  72744. /**
  72745. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72746. */
  72747. useReferenceSpace?: boolean;
  72748. }
  72749. /**
  72750. * Interface defining the babylon result of hit-test
  72751. */
  72752. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72753. /**
  72754. * The input source that generated this hit test (if transient)
  72755. */
  72756. inputSource?: XRInputSource;
  72757. /**
  72758. * Is this a transient hit test
  72759. */
  72760. isTransient?: boolean;
  72761. /**
  72762. * Position of the hit test result
  72763. */
  72764. position: Vector3;
  72765. /**
  72766. * Rotation of the hit test result
  72767. */
  72768. rotationQuaternion: Quaternion;
  72769. /**
  72770. * The native hit test result
  72771. */
  72772. xrHitResult: XRHitTestResult;
  72773. }
  72774. /**
  72775. * The currently-working hit-test module.
  72776. * Hit test (or Ray-casting) is used to interact with the real world.
  72777. * For further information read here - https://github.com/immersive-web/hit-test
  72778. *
  72779. * Tested on chrome (mobile) 80.
  72780. */
  72781. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  72782. /**
  72783. * options to use when constructing this feature
  72784. */
  72785. readonly options: IWebXRHitTestOptions;
  72786. private _tmpMat;
  72787. private _tmpPos;
  72788. private _tmpQuat;
  72789. private _transientXrHitTestSource;
  72790. private _xrHitTestSource;
  72791. private initHitTestSource;
  72792. /**
  72793. * The module's name
  72794. */
  72795. static readonly Name: string;
  72796. /**
  72797. * The (Babylon) version of this module.
  72798. * This is an integer representing the implementation version.
  72799. * This number does not correspond to the WebXR specs version
  72800. */
  72801. static readonly Version: number;
  72802. /**
  72803. * When set to true, each hit test will have its own position/rotation objects
  72804. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72805. * the developers will clone them or copy them as they see fit.
  72806. */
  72807. autoCloneTransformation: boolean;
  72808. /**
  72809. * Triggered when new babylon (transformed) hit test results are available
  72810. */
  72811. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72812. /**
  72813. * Use this to temporarily pause hit test checks.
  72814. */
  72815. paused: boolean;
  72816. /**
  72817. * Creates a new instance of the hit test feature
  72818. * @param _xrSessionManager an instance of WebXRSessionManager
  72819. * @param options options to use when constructing this feature
  72820. */
  72821. constructor(_xrSessionManager: WebXRSessionManager,
  72822. /**
  72823. * options to use when constructing this feature
  72824. */
  72825. options?: IWebXRHitTestOptions);
  72826. /**
  72827. * attach this feature
  72828. * Will usually be called by the features manager
  72829. *
  72830. * @returns true if successful.
  72831. */
  72832. attach(): boolean;
  72833. /**
  72834. * detach this feature.
  72835. * Will usually be called by the features manager
  72836. *
  72837. * @returns true if successful.
  72838. */
  72839. detach(): boolean;
  72840. /**
  72841. * Dispose this feature and all of the resources attached
  72842. */
  72843. dispose(): void;
  72844. protected _onXRFrame(frame: XRFrame): void;
  72845. private _processWebXRHitTestResult;
  72846. }
  72847. }
  72848. declare module BABYLON {
  72849. /**
  72850. * Configuration options of the anchor system
  72851. */
  72852. export interface IWebXRAnchorSystemOptions {
  72853. /**
  72854. * a node that will be used to convert local to world coordinates
  72855. */
  72856. worldParentNode?: TransformNode;
  72857. /**
  72858. * If set to true a reference of the created anchors will be kept until the next session starts
  72859. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  72860. */
  72861. doNotRemoveAnchorsOnSessionEnded?: boolean;
  72862. }
  72863. /**
  72864. * A babylon container for an XR Anchor
  72865. */
  72866. export interface IWebXRAnchor {
  72867. /**
  72868. * A babylon-assigned ID for this anchor
  72869. */
  72870. id: number;
  72871. /**
  72872. * Transformation matrix to apply to an object attached to this anchor
  72873. */
  72874. transformationMatrix: Matrix;
  72875. /**
  72876. * The native anchor object
  72877. */
  72878. xrAnchor: XRAnchor;
  72879. /**
  72880. * if defined, this object will be constantly updated by the anchor's position and rotation
  72881. */
  72882. attachedNode?: TransformNode;
  72883. }
  72884. /**
  72885. * An implementation of the anchor system for WebXR.
  72886. * For further information see https://github.com/immersive-web/anchors/
  72887. */
  72888. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72889. private _options;
  72890. private _lastFrameDetected;
  72891. private _trackedAnchors;
  72892. private _referenceSpaceForFrameAnchors;
  72893. private _futureAnchors;
  72894. /**
  72895. * The module's name
  72896. */
  72897. static readonly Name: string;
  72898. /**
  72899. * The (Babylon) version of this module.
  72900. * This is an integer representing the implementation version.
  72901. * This number does not correspond to the WebXR specs version
  72902. */
  72903. static readonly Version: number;
  72904. /**
  72905. * Observers registered here will be executed when a new anchor was added to the session
  72906. */
  72907. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72908. /**
  72909. * Observers registered here will be executed when an anchor was removed from the session
  72910. */
  72911. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72912. /**
  72913. * Observers registered here will be executed when an existing anchor updates
  72914. * This can execute N times every frame
  72915. */
  72916. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72917. /**
  72918. * Set the reference space to use for anchor creation, when not using a hit test.
  72919. * Will default to the session's reference space if not defined
  72920. */
  72921. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  72922. /**
  72923. * constructs a new anchor system
  72924. * @param _xrSessionManager an instance of WebXRSessionManager
  72925. * @param _options configuration object for this feature
  72926. */
  72927. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72928. private _tmpVector;
  72929. private _tmpQuaternion;
  72930. private _populateTmpTransformation;
  72931. /**
  72932. * Create a new anchor point using a hit test result at a specific point in the scene
  72933. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72934. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72935. *
  72936. * @param hitTestResult The hit test result to use for this anchor creation
  72937. * @param position an optional position offset for this anchor
  72938. * @param rotationQuaternion an optional rotation offset for this anchor
  72939. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72940. */
  72941. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  72942. /**
  72943. * Add a new anchor at a specific position and rotation
  72944. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  72945. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  72946. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72947. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72948. *
  72949. * @param position the position in which to add an anchor
  72950. * @param rotationQuaternion an optional rotation for the anchor transformation
  72951. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  72952. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72953. */
  72954. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  72955. /**
  72956. * detach this feature.
  72957. * Will usually be called by the features manager
  72958. *
  72959. * @returns true if successful.
  72960. */
  72961. detach(): boolean;
  72962. /**
  72963. * Dispose this feature and all of the resources attached
  72964. */
  72965. dispose(): void;
  72966. protected _onXRFrame(frame: XRFrame): void;
  72967. /**
  72968. * avoiding using Array.find for global support.
  72969. * @param xrAnchor the plane to find in the array
  72970. */
  72971. private _findIndexInAnchorArray;
  72972. private _updateAnchorWithXRFrame;
  72973. private _createAnchorAtTransformation;
  72974. }
  72975. }
  72976. declare module BABYLON {
  72977. /**
  72978. * Options used in the plane detector module
  72979. */
  72980. export interface IWebXRPlaneDetectorOptions {
  72981. /**
  72982. * The node to use to transform the local results to world coordinates
  72983. */
  72984. worldParentNode?: TransformNode;
  72985. /**
  72986. * If set to true a reference of the created planes will be kept until the next session starts
  72987. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  72988. */
  72989. doNotRemovePlanesOnSessionEnded?: boolean;
  72990. }
  72991. /**
  72992. * A babylon interface for a WebXR plane.
  72993. * A Plane is actually a polygon, built from N points in space
  72994. *
  72995. * Supported in chrome 79, not supported in canary 81 ATM
  72996. */
  72997. export interface IWebXRPlane {
  72998. /**
  72999. * a babylon-assigned ID for this polygon
  73000. */
  73001. id: number;
  73002. /**
  73003. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73004. */
  73005. polygonDefinition: Array<Vector3>;
  73006. /**
  73007. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73008. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73009. */
  73010. transformationMatrix: Matrix;
  73011. /**
  73012. * the native xr-plane object
  73013. */
  73014. xrPlane: XRPlane;
  73015. }
  73016. /**
  73017. * The plane detector is used to detect planes in the real world when in AR
  73018. * For more information see https://github.com/immersive-web/real-world-geometry/
  73019. */
  73020. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73021. private _options;
  73022. private _detectedPlanes;
  73023. private _enabled;
  73024. private _lastFrameDetected;
  73025. /**
  73026. * The module's name
  73027. */
  73028. static readonly Name: string;
  73029. /**
  73030. * The (Babylon) version of this module.
  73031. * This is an integer representing the implementation version.
  73032. * This number does not correspond to the WebXR specs version
  73033. */
  73034. static readonly Version: number;
  73035. /**
  73036. * Observers registered here will be executed when a new plane was added to the session
  73037. */
  73038. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73039. /**
  73040. * Observers registered here will be executed when a plane is no longer detected in the session
  73041. */
  73042. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73043. /**
  73044. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73045. * This can execute N times every frame
  73046. */
  73047. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73048. /**
  73049. * construct a new Plane Detector
  73050. * @param _xrSessionManager an instance of xr Session manager
  73051. * @param _options configuration to use when constructing this feature
  73052. */
  73053. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73054. /**
  73055. * detach this feature.
  73056. * Will usually be called by the features manager
  73057. *
  73058. * @returns true if successful.
  73059. */
  73060. detach(): boolean;
  73061. /**
  73062. * Dispose this feature and all of the resources attached
  73063. */
  73064. dispose(): void;
  73065. protected _onXRFrame(frame: XRFrame): void;
  73066. private _init;
  73067. private _updatePlaneWithXRPlane;
  73068. /**
  73069. * avoiding using Array.find for global support.
  73070. * @param xrPlane the plane to find in the array
  73071. */
  73072. private findIndexInPlaneArray;
  73073. }
  73074. }
  73075. declare module BABYLON {
  73076. /**
  73077. * Options interface for the background remover plugin
  73078. */
  73079. export interface IWebXRBackgroundRemoverOptions {
  73080. /**
  73081. * Further background meshes to disable when entering AR
  73082. */
  73083. backgroundMeshes?: AbstractMesh[];
  73084. /**
  73085. * flags to configure the removal of the environment helper.
  73086. * If not set, the entire background will be removed. If set, flags should be set as well.
  73087. */
  73088. environmentHelperRemovalFlags?: {
  73089. /**
  73090. * Should the skybox be removed (default false)
  73091. */
  73092. skyBox?: boolean;
  73093. /**
  73094. * Should the ground be removed (default false)
  73095. */
  73096. ground?: boolean;
  73097. };
  73098. /**
  73099. * don't disable the environment helper
  73100. */
  73101. ignoreEnvironmentHelper?: boolean;
  73102. }
  73103. /**
  73104. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73105. */
  73106. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73107. /**
  73108. * read-only options to be used in this module
  73109. */
  73110. readonly options: IWebXRBackgroundRemoverOptions;
  73111. /**
  73112. * The module's name
  73113. */
  73114. static readonly Name: string;
  73115. /**
  73116. * The (Babylon) version of this module.
  73117. * This is an integer representing the implementation version.
  73118. * This number does not correspond to the WebXR specs version
  73119. */
  73120. static readonly Version: number;
  73121. /**
  73122. * registered observers will be triggered when the background state changes
  73123. */
  73124. onBackgroundStateChangedObservable: Observable<boolean>;
  73125. /**
  73126. * constructs a new background remover module
  73127. * @param _xrSessionManager the session manager for this module
  73128. * @param options read-only options to be used in this module
  73129. */
  73130. constructor(_xrSessionManager: WebXRSessionManager,
  73131. /**
  73132. * read-only options to be used in this module
  73133. */
  73134. options?: IWebXRBackgroundRemoverOptions);
  73135. /**
  73136. * attach this feature
  73137. * Will usually be called by the features manager
  73138. *
  73139. * @returns true if successful.
  73140. */
  73141. attach(): boolean;
  73142. /**
  73143. * detach this feature.
  73144. * Will usually be called by the features manager
  73145. *
  73146. * @returns true if successful.
  73147. */
  73148. detach(): boolean;
  73149. /**
  73150. * Dispose this feature and all of the resources attached
  73151. */
  73152. dispose(): void;
  73153. protected _onXRFrame(_xrFrame: XRFrame): void;
  73154. private _setBackgroundState;
  73155. }
  73156. }
  73157. declare module BABYLON {
  73158. /**
  73159. * Options for the controller physics feature
  73160. */
  73161. export class IWebXRControllerPhysicsOptions {
  73162. /**
  73163. * Should the headset get its own impostor
  73164. */
  73165. enableHeadsetImpostor?: boolean;
  73166. /**
  73167. * Optional parameters for the headset impostor
  73168. */
  73169. headsetImpostorParams?: {
  73170. /**
  73171. * The type of impostor to create. Default is sphere
  73172. */
  73173. impostorType: number;
  73174. /**
  73175. * the size of the impostor. Defaults to 10cm
  73176. */
  73177. impostorSize?: number | {
  73178. width: number;
  73179. height: number;
  73180. depth: number;
  73181. };
  73182. /**
  73183. * Friction definitions
  73184. */
  73185. friction?: number;
  73186. /**
  73187. * Restitution
  73188. */
  73189. restitution?: number;
  73190. };
  73191. /**
  73192. * The physics properties of the future impostors
  73193. */
  73194. physicsProperties?: {
  73195. /**
  73196. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73197. * Note that this requires a physics engine that supports mesh impostors!
  73198. */
  73199. useControllerMesh?: boolean;
  73200. /**
  73201. * The type of impostor to create. Default is sphere
  73202. */
  73203. impostorType?: number;
  73204. /**
  73205. * the size of the impostor. Defaults to 10cm
  73206. */
  73207. impostorSize?: number | {
  73208. width: number;
  73209. height: number;
  73210. depth: number;
  73211. };
  73212. /**
  73213. * Friction definitions
  73214. */
  73215. friction?: number;
  73216. /**
  73217. * Restitution
  73218. */
  73219. restitution?: number;
  73220. };
  73221. /**
  73222. * the xr input to use with this pointer selection
  73223. */
  73224. xrInput: WebXRInput;
  73225. }
  73226. /**
  73227. * Add physics impostor to your webxr controllers,
  73228. * including naive calculation of their linear and angular velocity
  73229. */
  73230. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73231. private readonly _options;
  73232. private _attachController;
  73233. private _controllers;
  73234. private _debugMode;
  73235. private _delta;
  73236. private _headsetImpostor?;
  73237. private _headsetMesh?;
  73238. private _lastTimestamp;
  73239. private _tmpQuaternion;
  73240. private _tmpVector;
  73241. /**
  73242. * The module's name
  73243. */
  73244. static readonly Name: string;
  73245. /**
  73246. * The (Babylon) version of this module.
  73247. * This is an integer representing the implementation version.
  73248. * This number does not correspond to the webxr specs version
  73249. */
  73250. static readonly Version: number;
  73251. /**
  73252. * Construct a new Controller Physics Feature
  73253. * @param _xrSessionManager the corresponding xr session manager
  73254. * @param _options options to create this feature with
  73255. */
  73256. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73257. /**
  73258. * @hidden
  73259. * enable debugging - will show console outputs and the impostor mesh
  73260. */
  73261. _enablePhysicsDebug(): void;
  73262. /**
  73263. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73264. * @param xrController the controller to add
  73265. */
  73266. addController(xrController: WebXRInputSource): void;
  73267. /**
  73268. * attach this feature
  73269. * Will usually be called by the features manager
  73270. *
  73271. * @returns true if successful.
  73272. */
  73273. attach(): boolean;
  73274. /**
  73275. * detach this feature.
  73276. * Will usually be called by the features manager
  73277. *
  73278. * @returns true if successful.
  73279. */
  73280. detach(): boolean;
  73281. /**
  73282. * Get the headset impostor, if enabled
  73283. * @returns the impostor
  73284. */
  73285. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73286. /**
  73287. * Get the physics impostor of a specific controller.
  73288. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73289. * @param controller the controller or the controller id of which to get the impostor
  73290. * @returns the impostor or null
  73291. */
  73292. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73293. /**
  73294. * Update the physics properties provided in the constructor
  73295. * @param newProperties the new properties object
  73296. */
  73297. setPhysicsProperties(newProperties: {
  73298. impostorType?: number;
  73299. impostorSize?: number | {
  73300. width: number;
  73301. height: number;
  73302. depth: number;
  73303. };
  73304. friction?: number;
  73305. restitution?: number;
  73306. }): void;
  73307. protected _onXRFrame(_xrFrame: any): void;
  73308. private _detachController;
  73309. }
  73310. }
  73311. declare module BABYLON {
  73312. /**
  73313. * The motion controller class for all microsoft mixed reality controllers
  73314. */
  73315. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73316. protected readonly _mapping: {
  73317. defaultButton: {
  73318. valueNodeName: string;
  73319. unpressedNodeName: string;
  73320. pressedNodeName: string;
  73321. };
  73322. defaultAxis: {
  73323. valueNodeName: string;
  73324. minNodeName: string;
  73325. maxNodeName: string;
  73326. };
  73327. buttons: {
  73328. "xr-standard-trigger": {
  73329. rootNodeName: string;
  73330. componentProperty: string;
  73331. states: string[];
  73332. };
  73333. "xr-standard-squeeze": {
  73334. rootNodeName: string;
  73335. componentProperty: string;
  73336. states: string[];
  73337. };
  73338. "xr-standard-touchpad": {
  73339. rootNodeName: string;
  73340. labelAnchorNodeName: string;
  73341. touchPointNodeName: string;
  73342. };
  73343. "xr-standard-thumbstick": {
  73344. rootNodeName: string;
  73345. componentProperty: string;
  73346. states: string[];
  73347. };
  73348. };
  73349. axes: {
  73350. "xr-standard-touchpad": {
  73351. "x-axis": {
  73352. rootNodeName: string;
  73353. };
  73354. "y-axis": {
  73355. rootNodeName: string;
  73356. };
  73357. };
  73358. "xr-standard-thumbstick": {
  73359. "x-axis": {
  73360. rootNodeName: string;
  73361. };
  73362. "y-axis": {
  73363. rootNodeName: string;
  73364. };
  73365. };
  73366. };
  73367. };
  73368. /**
  73369. * The base url used to load the left and right controller models
  73370. */
  73371. static MODEL_BASE_URL: string;
  73372. /**
  73373. * The name of the left controller model file
  73374. */
  73375. static MODEL_LEFT_FILENAME: string;
  73376. /**
  73377. * The name of the right controller model file
  73378. */
  73379. static MODEL_RIGHT_FILENAME: string;
  73380. profileId: string;
  73381. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73382. protected _getFilenameAndPath(): {
  73383. filename: string;
  73384. path: string;
  73385. };
  73386. protected _getModelLoadingConstraints(): boolean;
  73387. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73388. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73389. protected _updateModel(): void;
  73390. }
  73391. }
  73392. declare module BABYLON {
  73393. /**
  73394. * The motion controller class for oculus touch (quest, rift).
  73395. * This class supports legacy mapping as well the standard xr mapping
  73396. */
  73397. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73398. private _forceLegacyControllers;
  73399. private _modelRootNode;
  73400. /**
  73401. * The base url used to load the left and right controller models
  73402. */
  73403. static MODEL_BASE_URL: string;
  73404. /**
  73405. * The name of the left controller model file
  73406. */
  73407. static MODEL_LEFT_FILENAME: string;
  73408. /**
  73409. * The name of the right controller model file
  73410. */
  73411. static MODEL_RIGHT_FILENAME: string;
  73412. /**
  73413. * Base Url for the Quest controller model.
  73414. */
  73415. static QUEST_MODEL_BASE_URL: string;
  73416. profileId: string;
  73417. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73418. protected _getFilenameAndPath(): {
  73419. filename: string;
  73420. path: string;
  73421. };
  73422. protected _getModelLoadingConstraints(): boolean;
  73423. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73424. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73425. protected _updateModel(): void;
  73426. /**
  73427. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73428. * between the touch and touch 2.
  73429. */
  73430. private _isQuest;
  73431. }
  73432. }
  73433. declare module BABYLON {
  73434. /**
  73435. * The motion controller class for the standard HTC-Vive controllers
  73436. */
  73437. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73438. private _modelRootNode;
  73439. /**
  73440. * The base url used to load the left and right controller models
  73441. */
  73442. static MODEL_BASE_URL: string;
  73443. /**
  73444. * File name for the controller model.
  73445. */
  73446. static MODEL_FILENAME: string;
  73447. profileId: string;
  73448. /**
  73449. * Create a new Vive motion controller object
  73450. * @param scene the scene to use to create this controller
  73451. * @param gamepadObject the corresponding gamepad object
  73452. * @param handedness the handedness of the controller
  73453. */
  73454. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73455. protected _getFilenameAndPath(): {
  73456. filename: string;
  73457. path: string;
  73458. };
  73459. protected _getModelLoadingConstraints(): boolean;
  73460. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73461. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73462. protected _updateModel(): void;
  73463. }
  73464. }
  73465. declare module BABYLON {
  73466. /**
  73467. * A cursor which tracks a point on a path
  73468. */
  73469. export class PathCursor {
  73470. private path;
  73471. /**
  73472. * Stores path cursor callbacks for when an onchange event is triggered
  73473. */
  73474. private _onchange;
  73475. /**
  73476. * The value of the path cursor
  73477. */
  73478. value: number;
  73479. /**
  73480. * The animation array of the path cursor
  73481. */
  73482. animations: Animation[];
  73483. /**
  73484. * Initializes the path cursor
  73485. * @param path The path to track
  73486. */
  73487. constructor(path: Path2);
  73488. /**
  73489. * Gets the cursor point on the path
  73490. * @returns A point on the path cursor at the cursor location
  73491. */
  73492. getPoint(): Vector3;
  73493. /**
  73494. * Moves the cursor ahead by the step amount
  73495. * @param step The amount to move the cursor forward
  73496. * @returns This path cursor
  73497. */
  73498. moveAhead(step?: number): PathCursor;
  73499. /**
  73500. * Moves the cursor behind by the step amount
  73501. * @param step The amount to move the cursor back
  73502. * @returns This path cursor
  73503. */
  73504. moveBack(step?: number): PathCursor;
  73505. /**
  73506. * Moves the cursor by the step amount
  73507. * If the step amount is greater than one, an exception is thrown
  73508. * @param step The amount to move the cursor
  73509. * @returns This path cursor
  73510. */
  73511. move(step: number): PathCursor;
  73512. /**
  73513. * Ensures that the value is limited between zero and one
  73514. * @returns This path cursor
  73515. */
  73516. private ensureLimits;
  73517. /**
  73518. * Runs onchange callbacks on change (used by the animation engine)
  73519. * @returns This path cursor
  73520. */
  73521. private raiseOnChange;
  73522. /**
  73523. * Executes a function on change
  73524. * @param f A path cursor onchange callback
  73525. * @returns This path cursor
  73526. */
  73527. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73528. }
  73529. }
  73530. declare module BABYLON {
  73531. /** @hidden */
  73532. export var blurPixelShader: {
  73533. name: string;
  73534. shader: string;
  73535. };
  73536. }
  73537. declare module BABYLON {
  73538. /** @hidden */
  73539. export var pointCloudVertexDeclaration: {
  73540. name: string;
  73541. shader: string;
  73542. };
  73543. }
  73544. // Mixins
  73545. interface Window {
  73546. mozIndexedDB: IDBFactory;
  73547. webkitIndexedDB: IDBFactory;
  73548. msIndexedDB: IDBFactory;
  73549. webkitURL: typeof URL;
  73550. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  73551. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  73552. WebGLRenderingContext: WebGLRenderingContext;
  73553. MSGesture: MSGesture;
  73554. CANNON: any;
  73555. AudioContext: AudioContext;
  73556. webkitAudioContext: AudioContext;
  73557. PointerEvent: any;
  73558. Math: Math;
  73559. Uint8Array: Uint8ArrayConstructor;
  73560. Float32Array: Float32ArrayConstructor;
  73561. mozURL: typeof URL;
  73562. msURL: typeof URL;
  73563. VRFrameData: any; // WebVR, from specs 1.1
  73564. DracoDecoderModule: any;
  73565. setImmediate(handler: (...args: any[]) => void): number;
  73566. }
  73567. interface HTMLCanvasElement {
  73568. requestPointerLock(): void;
  73569. msRequestPointerLock?(): void;
  73570. mozRequestPointerLock?(): void;
  73571. webkitRequestPointerLock?(): void;
  73572. /** Track wether a record is in progress */
  73573. isRecording: boolean;
  73574. /** Capture Stream method defined by some browsers */
  73575. captureStream(fps?: number): MediaStream;
  73576. }
  73577. interface CanvasRenderingContext2D {
  73578. msImageSmoothingEnabled: boolean;
  73579. }
  73580. interface MouseEvent {
  73581. mozMovementX: number;
  73582. mozMovementY: number;
  73583. webkitMovementX: number;
  73584. webkitMovementY: number;
  73585. msMovementX: number;
  73586. msMovementY: number;
  73587. }
  73588. interface Navigator {
  73589. mozGetVRDevices: (any: any) => any;
  73590. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73591. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73592. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73593. webkitGetGamepads(): Gamepad[];
  73594. msGetGamepads(): Gamepad[];
  73595. webkitGamepads(): Gamepad[];
  73596. }
  73597. interface HTMLVideoElement {
  73598. mozSrcObject: any;
  73599. }
  73600. interface Math {
  73601. fround(x: number): number;
  73602. imul(a: number, b: number): number;
  73603. }
  73604. interface WebGLRenderingContext {
  73605. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  73606. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  73607. vertexAttribDivisor(index: number, divisor: number): void;
  73608. createVertexArray(): any;
  73609. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  73610. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  73611. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  73612. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  73613. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  73614. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  73615. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  73616. // Queries
  73617. createQuery(): WebGLQuery;
  73618. deleteQuery(query: WebGLQuery): void;
  73619. beginQuery(target: number, query: WebGLQuery): void;
  73620. endQuery(target: number): void;
  73621. getQueryParameter(query: WebGLQuery, pname: number): any;
  73622. getQuery(target: number, pname: number): any;
  73623. MAX_SAMPLES: number;
  73624. RGBA8: number;
  73625. READ_FRAMEBUFFER: number;
  73626. DRAW_FRAMEBUFFER: number;
  73627. UNIFORM_BUFFER: number;
  73628. HALF_FLOAT_OES: number;
  73629. RGBA16F: number;
  73630. RGBA32F: number;
  73631. R32F: number;
  73632. RG32F: number;
  73633. RGB32F: number;
  73634. R16F: number;
  73635. RG16F: number;
  73636. RGB16F: number;
  73637. RED: number;
  73638. RG: number;
  73639. R8: number;
  73640. RG8: number;
  73641. UNSIGNED_INT_24_8: number;
  73642. DEPTH24_STENCIL8: number;
  73643. MIN: number;
  73644. MAX: number;
  73645. /* Multiple Render Targets */
  73646. drawBuffers(buffers: number[]): void;
  73647. readBuffer(src: number): void;
  73648. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73649. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73650. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73651. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73652. // Occlusion Query
  73653. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73654. ANY_SAMPLES_PASSED: number;
  73655. QUERY_RESULT_AVAILABLE: number;
  73656. QUERY_RESULT: number;
  73657. }
  73658. interface WebGLProgram {
  73659. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73660. }
  73661. interface EXT_disjoint_timer_query {
  73662. QUERY_COUNTER_BITS_EXT: number;
  73663. TIME_ELAPSED_EXT: number;
  73664. TIMESTAMP_EXT: number;
  73665. GPU_DISJOINT_EXT: number;
  73666. QUERY_RESULT_EXT: number;
  73667. QUERY_RESULT_AVAILABLE_EXT: number;
  73668. queryCounterEXT(query: WebGLQuery, target: number): void;
  73669. createQueryEXT(): WebGLQuery;
  73670. beginQueryEXT(target: number, query: WebGLQuery): void;
  73671. endQueryEXT(target: number): void;
  73672. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73673. deleteQueryEXT(query: WebGLQuery): void;
  73674. }
  73675. interface WebGLUniformLocation {
  73676. _currentState: any;
  73677. }
  73678. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73679. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73680. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73681. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73682. interface WebGLRenderingContext {
  73683. readonly RASTERIZER_DISCARD: number;
  73684. readonly DEPTH_COMPONENT24: number;
  73685. readonly TEXTURE_3D: number;
  73686. readonly TEXTURE_2D_ARRAY: number;
  73687. readonly TEXTURE_COMPARE_FUNC: number;
  73688. readonly TEXTURE_COMPARE_MODE: number;
  73689. readonly COMPARE_REF_TO_TEXTURE: number;
  73690. readonly TEXTURE_WRAP_R: number;
  73691. readonly HALF_FLOAT: number;
  73692. readonly RGB8: number;
  73693. readonly RED_INTEGER: number;
  73694. readonly RG_INTEGER: number;
  73695. readonly RGB_INTEGER: number;
  73696. readonly RGBA_INTEGER: number;
  73697. readonly R8_SNORM: number;
  73698. readonly RG8_SNORM: number;
  73699. readonly RGB8_SNORM: number;
  73700. readonly RGBA8_SNORM: number;
  73701. readonly R8I: number;
  73702. readonly RG8I: number;
  73703. readonly RGB8I: number;
  73704. readonly RGBA8I: number;
  73705. readonly R8UI: number;
  73706. readonly RG8UI: number;
  73707. readonly RGB8UI: number;
  73708. readonly RGBA8UI: number;
  73709. readonly R16I: number;
  73710. readonly RG16I: number;
  73711. readonly RGB16I: number;
  73712. readonly RGBA16I: number;
  73713. readonly R16UI: number;
  73714. readonly RG16UI: number;
  73715. readonly RGB16UI: number;
  73716. readonly RGBA16UI: number;
  73717. readonly R32I: number;
  73718. readonly RG32I: number;
  73719. readonly RGB32I: number;
  73720. readonly RGBA32I: number;
  73721. readonly R32UI: number;
  73722. readonly RG32UI: number;
  73723. readonly RGB32UI: number;
  73724. readonly RGBA32UI: number;
  73725. readonly RGB10_A2UI: number;
  73726. readonly R11F_G11F_B10F: number;
  73727. readonly RGB9_E5: number;
  73728. readonly RGB10_A2: number;
  73729. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73730. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73731. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73732. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73733. readonly DEPTH_COMPONENT32F: number;
  73734. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73735. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73736. 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;
  73737. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73738. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73739. readonly TRANSFORM_FEEDBACK: number;
  73740. readonly INTERLEAVED_ATTRIBS: number;
  73741. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73742. createTransformFeedback(): WebGLTransformFeedback;
  73743. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73744. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73745. beginTransformFeedback(primitiveMode: number): void;
  73746. endTransformFeedback(): void;
  73747. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73748. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73749. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73750. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73751. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73752. }
  73753. interface ImageBitmap {
  73754. readonly width: number;
  73755. readonly height: number;
  73756. close(): void;
  73757. }
  73758. interface WebGLQuery extends WebGLObject {
  73759. }
  73760. declare var WebGLQuery: {
  73761. prototype: WebGLQuery;
  73762. new(): WebGLQuery;
  73763. };
  73764. interface WebGLSampler extends WebGLObject {
  73765. }
  73766. declare var WebGLSampler: {
  73767. prototype: WebGLSampler;
  73768. new(): WebGLSampler;
  73769. };
  73770. interface WebGLSync extends WebGLObject {
  73771. }
  73772. declare var WebGLSync: {
  73773. prototype: WebGLSync;
  73774. new(): WebGLSync;
  73775. };
  73776. interface WebGLTransformFeedback extends WebGLObject {
  73777. }
  73778. declare var WebGLTransformFeedback: {
  73779. prototype: WebGLTransformFeedback;
  73780. new(): WebGLTransformFeedback;
  73781. };
  73782. interface WebGLVertexArrayObject extends WebGLObject {
  73783. }
  73784. declare var WebGLVertexArrayObject: {
  73785. prototype: WebGLVertexArrayObject;
  73786. new(): WebGLVertexArrayObject;
  73787. };
  73788. // Type definitions for WebVR API
  73789. // Project: https://w3c.github.io/webvr/
  73790. // Definitions by: six a <https://github.com/lostfictions>
  73791. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73792. interface VRDisplay extends EventTarget {
  73793. /**
  73794. * Dictionary of capabilities describing the VRDisplay.
  73795. */
  73796. readonly capabilities: VRDisplayCapabilities;
  73797. /**
  73798. * z-depth defining the far plane of the eye view frustum
  73799. * enables mapping of values in the render target depth
  73800. * attachment to scene coordinates. Initially set to 10000.0.
  73801. */
  73802. depthFar: number;
  73803. /**
  73804. * z-depth defining the near plane of the eye view frustum
  73805. * enables mapping of values in the render target depth
  73806. * attachment to scene coordinates. Initially set to 0.01.
  73807. */
  73808. depthNear: number;
  73809. /**
  73810. * An identifier for this distinct VRDisplay. Used as an
  73811. * association point in the Gamepad API.
  73812. */
  73813. readonly displayId: number;
  73814. /**
  73815. * A display name, a user-readable name identifying it.
  73816. */
  73817. readonly displayName: string;
  73818. readonly isConnected: boolean;
  73819. readonly isPresenting: boolean;
  73820. /**
  73821. * If this VRDisplay supports room-scale experiences, the optional
  73822. * stage attribute contains details on the room-scale parameters.
  73823. */
  73824. readonly stageParameters: VRStageParameters | null;
  73825. /**
  73826. * Passing the value returned by `requestAnimationFrame` to
  73827. * `cancelAnimationFrame` will unregister the callback.
  73828. * @param handle Define the hanle of the request to cancel
  73829. */
  73830. cancelAnimationFrame(handle: number): void;
  73831. /**
  73832. * Stops presenting to the VRDisplay.
  73833. * @returns a promise to know when it stopped
  73834. */
  73835. exitPresent(): Promise<void>;
  73836. /**
  73837. * Return the current VREyeParameters for the given eye.
  73838. * @param whichEye Define the eye we want the parameter for
  73839. * @returns the eye parameters
  73840. */
  73841. getEyeParameters(whichEye: string): VREyeParameters;
  73842. /**
  73843. * Populates the passed VRFrameData with the information required to render
  73844. * the current frame.
  73845. * @param frameData Define the data structure to populate
  73846. * @returns true if ok otherwise false
  73847. */
  73848. getFrameData(frameData: VRFrameData): boolean;
  73849. /**
  73850. * Get the layers currently being presented.
  73851. * @returns the list of VR layers
  73852. */
  73853. getLayers(): VRLayer[];
  73854. /**
  73855. * Return a VRPose containing the future predicted pose of the VRDisplay
  73856. * when the current frame will be presented. The value returned will not
  73857. * change until JavaScript has returned control to the browser.
  73858. *
  73859. * The VRPose will contain the position, orientation, velocity,
  73860. * and acceleration of each of these properties.
  73861. * @returns the pose object
  73862. */
  73863. getPose(): VRPose;
  73864. /**
  73865. * Return the current instantaneous pose of the VRDisplay, with no
  73866. * prediction applied.
  73867. * @returns the current instantaneous pose
  73868. */
  73869. getImmediatePose(): VRPose;
  73870. /**
  73871. * The callback passed to `requestAnimationFrame` will be called
  73872. * any time a new frame should be rendered. When the VRDisplay is
  73873. * presenting the callback will be called at the native refresh
  73874. * rate of the HMD. When not presenting this function acts
  73875. * identically to how window.requestAnimationFrame acts. Content should
  73876. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73877. * asynchronously from other displays and at differing refresh rates.
  73878. * @param callback Define the eaction to run next frame
  73879. * @returns the request handle it
  73880. */
  73881. requestAnimationFrame(callback: FrameRequestCallback): number;
  73882. /**
  73883. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73884. * Repeat calls while already presenting will update the VRLayers being displayed.
  73885. * @param layers Define the list of layer to present
  73886. * @returns a promise to know when the request has been fulfilled
  73887. */
  73888. requestPresent(layers: VRLayer[]): Promise<void>;
  73889. /**
  73890. * Reset the pose for this display, treating its current position and
  73891. * orientation as the "origin/zero" values. VRPose.position,
  73892. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73893. * updated when calling resetPose(). This should be called in only
  73894. * sitting-space experiences.
  73895. */
  73896. resetPose(): void;
  73897. /**
  73898. * The VRLayer provided to the VRDisplay will be captured and presented
  73899. * in the HMD. Calling this function has the same effect on the source
  73900. * canvas as any other operation that uses its source image, and canvases
  73901. * created without preserveDrawingBuffer set to true will be cleared.
  73902. * @param pose Define the pose to submit
  73903. */
  73904. submitFrame(pose?: VRPose): void;
  73905. }
  73906. declare var VRDisplay: {
  73907. prototype: VRDisplay;
  73908. new(): VRDisplay;
  73909. };
  73910. interface VRLayer {
  73911. leftBounds?: number[] | Float32Array | null;
  73912. rightBounds?: number[] | Float32Array | null;
  73913. source?: HTMLCanvasElement | null;
  73914. }
  73915. interface VRDisplayCapabilities {
  73916. readonly canPresent: boolean;
  73917. readonly hasExternalDisplay: boolean;
  73918. readonly hasOrientation: boolean;
  73919. readonly hasPosition: boolean;
  73920. readonly maxLayers: number;
  73921. }
  73922. interface VREyeParameters {
  73923. /** @deprecated */
  73924. readonly fieldOfView: VRFieldOfView;
  73925. readonly offset: Float32Array;
  73926. readonly renderHeight: number;
  73927. readonly renderWidth: number;
  73928. }
  73929. interface VRFieldOfView {
  73930. readonly downDegrees: number;
  73931. readonly leftDegrees: number;
  73932. readonly rightDegrees: number;
  73933. readonly upDegrees: number;
  73934. }
  73935. interface VRFrameData {
  73936. readonly leftProjectionMatrix: Float32Array;
  73937. readonly leftViewMatrix: Float32Array;
  73938. readonly pose: VRPose;
  73939. readonly rightProjectionMatrix: Float32Array;
  73940. readonly rightViewMatrix: Float32Array;
  73941. readonly timestamp: number;
  73942. }
  73943. interface VRPose {
  73944. readonly angularAcceleration: Float32Array | null;
  73945. readonly angularVelocity: Float32Array | null;
  73946. readonly linearAcceleration: Float32Array | null;
  73947. readonly linearVelocity: Float32Array | null;
  73948. readonly orientation: Float32Array | null;
  73949. readonly position: Float32Array | null;
  73950. readonly timestamp: number;
  73951. }
  73952. interface VRStageParameters {
  73953. sittingToStandingTransform?: Float32Array;
  73954. sizeX?: number;
  73955. sizeY?: number;
  73956. }
  73957. interface Navigator {
  73958. getVRDisplays(): Promise<VRDisplay[]>;
  73959. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73960. }
  73961. interface Window {
  73962. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73963. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73964. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73965. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73966. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73967. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73968. }
  73969. interface Gamepad {
  73970. readonly displayId: number;
  73971. }
  73972. type XRSessionMode =
  73973. | "inline"
  73974. | "immersive-vr"
  73975. | "immersive-ar";
  73976. type XRReferenceSpaceType =
  73977. | "viewer"
  73978. | "local"
  73979. | "local-floor"
  73980. | "bounded-floor"
  73981. | "unbounded";
  73982. type XREnvironmentBlendMode =
  73983. | "opaque"
  73984. | "additive"
  73985. | "alpha-blend";
  73986. type XRVisibilityState =
  73987. | "visible"
  73988. | "visible-blurred"
  73989. | "hidden";
  73990. type XRHandedness =
  73991. | "none"
  73992. | "left"
  73993. | "right";
  73994. type XRTargetRayMode =
  73995. | "gaze"
  73996. | "tracked-pointer"
  73997. | "screen";
  73998. type XREye =
  73999. | "none"
  74000. | "left"
  74001. | "right";
  74002. type XREventType =
  74003. | "devicechange"
  74004. | "visibilitychange"
  74005. | "end"
  74006. | "inputsourceschange"
  74007. | "select"
  74008. | "selectstart"
  74009. | "selectend"
  74010. | "squeeze"
  74011. | "squeezestart"
  74012. | "squeezeend"
  74013. | "reset";
  74014. interface XRSpace extends EventTarget {
  74015. }
  74016. interface XRRenderState {
  74017. depthNear?: number;
  74018. depthFar?: number;
  74019. inlineVerticalFieldOfView?: number;
  74020. baseLayer?: XRWebGLLayer;
  74021. }
  74022. interface XRInputSource {
  74023. handedness: XRHandedness;
  74024. targetRayMode: XRTargetRayMode;
  74025. targetRaySpace: XRSpace;
  74026. gripSpace: XRSpace | undefined;
  74027. gamepad: Gamepad | undefined;
  74028. profiles: Array<string>;
  74029. }
  74030. interface XRSessionInit {
  74031. optionalFeatures?: string[];
  74032. requiredFeatures?: string[];
  74033. }
  74034. interface XRSession {
  74035. addEventListener: Function;
  74036. removeEventListener: Function;
  74037. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74038. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74039. requestAnimationFrame: Function;
  74040. end(): Promise<void>;
  74041. renderState: XRRenderState;
  74042. inputSources: Array<XRInputSource>;
  74043. // hit test
  74044. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74045. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74046. // legacy AR hit test
  74047. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74048. // legacy plane detection
  74049. updateWorldTrackingState(options: {
  74050. planeDetectionState?: { enabled: boolean; }
  74051. }): void;
  74052. }
  74053. interface XRReferenceSpace extends XRSpace {
  74054. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74055. onreset: any;
  74056. }
  74057. type XRPlaneSet = Set<XRPlane>;
  74058. type XRAnchorSet = Set<XRAnchor>;
  74059. interface XRFrame {
  74060. session: XRSession;
  74061. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74062. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74063. // AR
  74064. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74065. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74066. // Anchors
  74067. trackedAnchors?: XRAnchorSet;
  74068. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74069. // Planes
  74070. worldInformation: {
  74071. detectedPlanes?: XRPlaneSet;
  74072. };
  74073. }
  74074. interface XRViewerPose extends XRPose {
  74075. views: Array<XRView>;
  74076. }
  74077. interface XRPose {
  74078. transform: XRRigidTransform;
  74079. emulatedPosition: boolean;
  74080. }
  74081. interface XRWebGLLayerOptions {
  74082. antialias?: boolean;
  74083. depth?: boolean;
  74084. stencil?: boolean;
  74085. alpha?: boolean;
  74086. multiview?: boolean;
  74087. framebufferScaleFactor?: number;
  74088. }
  74089. declare var XRWebGLLayer: {
  74090. prototype: XRWebGLLayer;
  74091. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74092. };
  74093. interface XRWebGLLayer {
  74094. framebuffer: WebGLFramebuffer;
  74095. framebufferWidth: number;
  74096. framebufferHeight: number;
  74097. getViewport: Function;
  74098. }
  74099. declare class XRRigidTransform {
  74100. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74101. position: DOMPointReadOnly;
  74102. orientation: DOMPointReadOnly;
  74103. matrix: Float32Array;
  74104. inverse: XRRigidTransform;
  74105. }
  74106. interface XRView {
  74107. eye: XREye;
  74108. projectionMatrix: Float32Array;
  74109. transform: XRRigidTransform;
  74110. }
  74111. interface XRInputSourceChangeEvent {
  74112. session: XRSession;
  74113. removed: Array<XRInputSource>;
  74114. added: Array<XRInputSource>;
  74115. }
  74116. interface XRInputSourceEvent extends Event {
  74117. readonly frame: XRFrame;
  74118. readonly inputSource: XRInputSource;
  74119. }
  74120. // Experimental(er) features
  74121. declare class XRRay {
  74122. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74123. origin: DOMPointReadOnly;
  74124. direction: DOMPointReadOnly;
  74125. matrix: Float32Array;
  74126. }
  74127. declare enum XRHitTestTrackableType {
  74128. "point",
  74129. "plane"
  74130. }
  74131. interface XRHitResult {
  74132. hitMatrix: Float32Array;
  74133. }
  74134. interface XRTransientInputHitTestResult {
  74135. readonly inputSource: XRInputSource;
  74136. readonly results: Array<XRHitTestResult>;
  74137. }
  74138. interface XRHitTestResult {
  74139. getPose(baseSpace: XRSpace): XRPose | undefined;
  74140. // When anchor system is enabled
  74141. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74142. }
  74143. interface XRHitTestSource {
  74144. cancel(): void;
  74145. }
  74146. interface XRTransientInputHitTestSource {
  74147. cancel(): void;
  74148. }
  74149. interface XRHitTestOptionsInit {
  74150. space: XRSpace;
  74151. entityTypes?: Array<XRHitTestTrackableType>;
  74152. offsetRay?: XRRay;
  74153. }
  74154. interface XRTransientInputHitTestOptionsInit {
  74155. profile: string;
  74156. entityTypes?: Array<XRHitTestTrackableType>;
  74157. offsetRay?: XRRay;
  74158. }
  74159. interface XRAnchor {
  74160. anchorSpace: XRSpace;
  74161. delete(): void;
  74162. }
  74163. interface XRPlane {
  74164. orientation: "Horizontal" | "Vertical";
  74165. planeSpace: XRSpace;
  74166. polygon: Array<DOMPointReadOnly>;
  74167. lastChangedTime: number;
  74168. }