babylon.d.ts 3.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module BABYLON {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static get LogCache(): string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static set LogLevels(level: number);
  363. }
  364. }
  365. declare module BABYLON {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module BABYLON {
  377. /**
  378. * Helper to manipulate strings
  379. */
  380. export class StringTools {
  381. /**
  382. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  383. * @param str Source string
  384. * @param suffix Suffix to search for in the source string
  385. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  386. */
  387. static EndsWith(str: string, suffix: string): boolean;
  388. /**
  389. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  390. * @param str Source string
  391. * @param suffix Suffix to search for in the source string
  392. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  393. */
  394. static StartsWith(str: string, suffix: string): boolean;
  395. /**
  396. * Decodes a buffer into a string
  397. * @param buffer The buffer to decode
  398. * @returns The decoded string
  399. */
  400. static Decode(buffer: Uint8Array | Uint16Array): string;
  401. /**
  402. * Encode a buffer to a base64 string
  403. * @param buffer defines the buffer to encode
  404. * @returns the encoded string
  405. */
  406. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  407. /**
  408. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  409. * @param num the number to convert and pad
  410. * @param length the expected length of the string
  411. * @returns the padded string
  412. */
  413. static PadNumber(num: number, length: number): string;
  414. }
  415. }
  416. declare module BABYLON {
  417. /**
  418. * Class containing a set of static utilities functions for deep copy.
  419. */
  420. export class DeepCopier {
  421. /**
  422. * Tries to copy an object by duplicating every property
  423. * @param source defines the source object
  424. * @param destination defines the target object
  425. * @param doNotCopyList defines a list of properties to avoid
  426. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  427. */
  428. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  429. }
  430. }
  431. declare module BABYLON {
  432. /**
  433. * Class containing a set of static utilities functions for precision date
  434. */
  435. export class PrecisionDate {
  436. /**
  437. * Gets either window.performance.now() if supported or Date.now() else
  438. */
  439. static get Now(): number;
  440. }
  441. }
  442. declare module BABYLON {
  443. /** @hidden */
  444. export class _DevTools {
  445. static WarnImport(name: string): string;
  446. }
  447. }
  448. declare module BABYLON {
  449. /**
  450. * Interface used to define the mechanism to get data from the network
  451. */
  452. export interface IWebRequest {
  453. /**
  454. * Returns client's response url
  455. */
  456. responseURL: string;
  457. /**
  458. * Returns client's status
  459. */
  460. status: number;
  461. /**
  462. * Returns client's status as a text
  463. */
  464. statusText: string;
  465. }
  466. }
  467. declare module BABYLON {
  468. /**
  469. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  470. */
  471. export class WebRequest implements IWebRequest {
  472. private _xhr;
  473. /**
  474. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  475. * i.e. when loading files, where the server/service expects an Authorization header
  476. */
  477. static CustomRequestHeaders: {
  478. [key: string]: string;
  479. };
  480. /**
  481. * Add callback functions in this array to update all the requests before they get sent to the network
  482. */
  483. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  484. private _injectCustomRequestHeaders;
  485. /**
  486. * Gets or sets a function to be called when loading progress changes
  487. */
  488. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  489. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  490. /**
  491. * Returns client's state
  492. */
  493. get readyState(): number;
  494. /**
  495. * Returns client's status
  496. */
  497. get status(): number;
  498. /**
  499. * Returns client's status as a text
  500. */
  501. get statusText(): string;
  502. /**
  503. * Returns client's response
  504. */
  505. get response(): any;
  506. /**
  507. * Returns client's response url
  508. */
  509. get responseURL(): string;
  510. /**
  511. * Returns client's response as text
  512. */
  513. get responseText(): string;
  514. /**
  515. * Gets or sets the expected response type
  516. */
  517. get responseType(): XMLHttpRequestResponseType;
  518. set responseType(value: XMLHttpRequestResponseType);
  519. /** @hidden */
  520. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  521. /** @hidden */
  522. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  523. /**
  524. * Cancels any network activity
  525. */
  526. abort(): void;
  527. /**
  528. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  529. * @param body defines an optional request body
  530. */
  531. send(body?: Document | BodyInit | null): void;
  532. /**
  533. * Sets the request method, request URL
  534. * @param method defines the method to use (GET, POST, etc..)
  535. * @param url defines the url to connect with
  536. */
  537. open(method: string, url: string): void;
  538. /**
  539. * Sets the value of a request header.
  540. * @param name The name of the header whose value is to be set
  541. * @param value The value to set as the body of the header
  542. */
  543. setRequestHeader(name: string, value: string): void;
  544. /**
  545. * Get the string containing the text of a particular header's value.
  546. * @param name The name of the header
  547. * @returns The string containing the text of the given header name
  548. */
  549. getResponseHeader(name: string): Nullable<string>;
  550. }
  551. }
  552. declare module BABYLON {
  553. /**
  554. * File request interface
  555. */
  556. export interface IFileRequest {
  557. /**
  558. * Raised when the request is complete (success or error).
  559. */
  560. onCompleteObservable: Observable<IFileRequest>;
  561. /**
  562. * Aborts the request for a file.
  563. */
  564. abort: () => void;
  565. }
  566. }
  567. declare module BABYLON {
  568. /**
  569. * Define options used to create a render target texture
  570. */
  571. export class RenderTargetCreationOptions {
  572. /**
  573. * Specifies is mipmaps must be generated
  574. */
  575. generateMipMaps?: boolean;
  576. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  577. generateDepthBuffer?: boolean;
  578. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  579. generateStencilBuffer?: boolean;
  580. /** Defines texture type (int by default) */
  581. type?: number;
  582. /** Defines sampling mode (trilinear by default) */
  583. samplingMode?: number;
  584. /** Defines format (RGBA by default) */
  585. format?: number;
  586. }
  587. }
  588. declare module BABYLON {
  589. /** Defines the cross module used constants to avoid circular dependncies */
  590. export class Constants {
  591. /** Defines that alpha blending is disabled */
  592. static readonly ALPHA_DISABLE: number;
  593. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  594. static readonly ALPHA_ADD: number;
  595. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  596. static readonly ALPHA_COMBINE: number;
  597. /** Defines that alpha blending is DEST - SRC * DEST */
  598. static readonly ALPHA_SUBTRACT: number;
  599. /** Defines that alpha blending is SRC * DEST */
  600. static readonly ALPHA_MULTIPLY: number;
  601. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  602. static readonly ALPHA_MAXIMIZED: number;
  603. /** Defines that alpha blending is SRC + DEST */
  604. static readonly ALPHA_ONEONE: number;
  605. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  606. static readonly ALPHA_PREMULTIPLIED: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  609. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  612. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  613. static readonly ALPHA_INTERPOLATE: number;
  614. /**
  615. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  616. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  617. */
  618. static readonly ALPHA_SCREENMODE: number;
  619. /**
  620. * Defines that alpha blending is SRC + DST
  621. * Alpha will be set to SRC ALPHA + DST ALPHA
  622. */
  623. static readonly ALPHA_ONEONE_ONEONE: number;
  624. /**
  625. * Defines that alpha blending is SRC * DST ALPHA + DST
  626. * Alpha will be set to 0
  627. */
  628. static readonly ALPHA_ALPHATOCOLOR: number;
  629. /**
  630. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  631. */
  632. static readonly ALPHA_REVERSEONEMINUS: number;
  633. /**
  634. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  635. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  636. */
  637. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST
  640. * Alpha will be set to SRC ALPHA
  641. */
  642. static readonly ALPHA_ONEONE_ONEZERO: number;
  643. /**
  644. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  645. * Alpha will be set to DST ALPHA
  646. */
  647. static readonly ALPHA_EXCLUSION: number;
  648. /** Defines that alpha blending equation a SUM */
  649. static readonly ALPHA_EQUATION_ADD: number;
  650. /** Defines that alpha blending equation a SUBSTRACTION */
  651. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  652. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  653. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  654. /** Defines that alpha blending equation a MAX operation */
  655. static readonly ALPHA_EQUATION_MAX: number;
  656. /** Defines that alpha blending equation a MIN operation */
  657. static readonly ALPHA_EQUATION_MIN: number;
  658. /**
  659. * Defines that alpha blending equation a DARKEN operation:
  660. * It takes the min of the src and sums the alpha channels.
  661. */
  662. static readonly ALPHA_EQUATION_DARKEN: number;
  663. /** Defines that the ressource is not delayed*/
  664. static readonly DELAYLOADSTATE_NONE: number;
  665. /** Defines that the ressource was successfully delay loaded */
  666. static readonly DELAYLOADSTATE_LOADED: number;
  667. /** Defines that the ressource is currently delay loading */
  668. static readonly DELAYLOADSTATE_LOADING: number;
  669. /** Defines that the ressource is delayed and has not started loading */
  670. static readonly DELAYLOADSTATE_NOTLOADED: number;
  671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  672. static readonly NEVER: number;
  673. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  674. static readonly ALWAYS: number;
  675. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  676. static readonly LESS: number;
  677. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  678. static readonly EQUAL: number;
  679. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  680. static readonly LEQUAL: number;
  681. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  682. static readonly GREATER: number;
  683. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  684. static readonly GEQUAL: number;
  685. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  686. static readonly NOTEQUAL: number;
  687. /** Passed to stencilOperation to specify that stencil value must be kept */
  688. static readonly KEEP: number;
  689. /** Passed to stencilOperation to specify that stencil value must be replaced */
  690. static readonly REPLACE: number;
  691. /** Passed to stencilOperation to specify that stencil value must be incremented */
  692. static readonly INCR: number;
  693. /** Passed to stencilOperation to specify that stencil value must be decremented */
  694. static readonly DECR: number;
  695. /** Passed to stencilOperation to specify that stencil value must be inverted */
  696. static readonly INVERT: number;
  697. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  698. static readonly INCR_WRAP: number;
  699. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  700. static readonly DECR_WRAP: number;
  701. /** Texture is not repeating outside of 0..1 UVs */
  702. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  703. /** Texture is repeating outside of 0..1 UVs */
  704. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  705. /** Texture is repeating and mirrored */
  706. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  707. /** ALPHA */
  708. static readonly TEXTUREFORMAT_ALPHA: number;
  709. /** LUMINANCE */
  710. static readonly TEXTUREFORMAT_LUMINANCE: number;
  711. /** LUMINANCE_ALPHA */
  712. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  713. /** RGB */
  714. static readonly TEXTUREFORMAT_RGB: number;
  715. /** RGBA */
  716. static readonly TEXTUREFORMAT_RGBA: number;
  717. /** RED */
  718. static readonly TEXTUREFORMAT_RED: number;
  719. /** RED (2nd reference) */
  720. static readonly TEXTUREFORMAT_R: number;
  721. /** RG */
  722. static readonly TEXTUREFORMAT_RG: number;
  723. /** RED_INTEGER */
  724. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  725. /** RED_INTEGER (2nd reference) */
  726. static readonly TEXTUREFORMAT_R_INTEGER: number;
  727. /** RG_INTEGER */
  728. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  729. /** RGB_INTEGER */
  730. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  731. /** RGBA_INTEGER */
  732. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  733. /** UNSIGNED_BYTE */
  734. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  735. /** UNSIGNED_BYTE (2nd reference) */
  736. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  737. /** FLOAT */
  738. static readonly TEXTURETYPE_FLOAT: number;
  739. /** HALF_FLOAT */
  740. static readonly TEXTURETYPE_HALF_FLOAT: number;
  741. /** BYTE */
  742. static readonly TEXTURETYPE_BYTE: number;
  743. /** SHORT */
  744. static readonly TEXTURETYPE_SHORT: number;
  745. /** UNSIGNED_SHORT */
  746. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  747. /** INT */
  748. static readonly TEXTURETYPE_INT: number;
  749. /** UNSIGNED_INT */
  750. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  751. /** UNSIGNED_SHORT_4_4_4_4 */
  752. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  753. /** UNSIGNED_SHORT_5_5_5_1 */
  754. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  755. /** UNSIGNED_SHORT_5_6_5 */
  756. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  757. /** UNSIGNED_INT_2_10_10_10_REV */
  758. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  759. /** UNSIGNED_INT_24_8 */
  760. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  761. /** UNSIGNED_INT_10F_11F_11F_REV */
  762. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  763. /** UNSIGNED_INT_5_9_9_9_REV */
  764. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  765. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  766. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  767. /** nearest is mag = nearest and min = nearest and no mip */
  768. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  769. /** mag = nearest and min = nearest and mip = none */
  770. static readonly TEXTURE_NEAREST_NEAREST: number;
  771. /** Bilinear is mag = linear and min = linear and no mip */
  772. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  773. /** mag = linear and min = linear and mip = none */
  774. static readonly TEXTURE_LINEAR_LINEAR: number;
  775. /** Trilinear is mag = linear and min = linear and mip = linear */
  776. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  777. /** Trilinear is mag = linear and min = linear and mip = linear */
  778. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  779. /** mag = nearest and min = nearest and mip = nearest */
  780. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  781. /** mag = nearest and min = linear and mip = nearest */
  782. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  783. /** mag = nearest and min = linear and mip = linear */
  784. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  785. /** mag = nearest and min = linear and mip = none */
  786. static readonly TEXTURE_NEAREST_LINEAR: number;
  787. /** nearest is mag = nearest and min = nearest and mip = linear */
  788. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  789. /** mag = linear and min = nearest and mip = nearest */
  790. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  791. /** mag = linear and min = nearest and mip = linear */
  792. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  793. /** Bilinear is mag = linear and min = linear and mip = nearest */
  794. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  795. /** mag = linear and min = nearest and mip = none */
  796. static readonly TEXTURE_LINEAR_NEAREST: number;
  797. /** Explicit coordinates mode */
  798. static readonly TEXTURE_EXPLICIT_MODE: number;
  799. /** Spherical coordinates mode */
  800. static readonly TEXTURE_SPHERICAL_MODE: number;
  801. /** Planar coordinates mode */
  802. static readonly TEXTURE_PLANAR_MODE: number;
  803. /** Cubic coordinates mode */
  804. static readonly TEXTURE_CUBIC_MODE: number;
  805. /** Projection coordinates mode */
  806. static readonly TEXTURE_PROJECTION_MODE: number;
  807. /** Skybox coordinates mode */
  808. static readonly TEXTURE_SKYBOX_MODE: number;
  809. /** Inverse Cubic coordinates mode */
  810. static readonly TEXTURE_INVCUBIC_MODE: number;
  811. /** Equirectangular coordinates mode */
  812. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  813. /** Equirectangular Fixed coordinates mode */
  814. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  815. /** Equirectangular Fixed Mirrored coordinates mode */
  816. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  817. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  818. static readonly SCALEMODE_FLOOR: number;
  819. /** Defines that texture rescaling will look for the nearest power of 2 size */
  820. static readonly SCALEMODE_NEAREST: number;
  821. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  822. static readonly SCALEMODE_CEILING: number;
  823. /**
  824. * The dirty texture flag value
  825. */
  826. static readonly MATERIAL_TextureDirtyFlag: number;
  827. /**
  828. * The dirty light flag value
  829. */
  830. static readonly MATERIAL_LightDirtyFlag: number;
  831. /**
  832. * The dirty fresnel flag value
  833. */
  834. static readonly MATERIAL_FresnelDirtyFlag: number;
  835. /**
  836. * The dirty attribute flag value
  837. */
  838. static readonly MATERIAL_AttributesDirtyFlag: number;
  839. /**
  840. * The dirty misc flag value
  841. */
  842. static readonly MATERIAL_MiscDirtyFlag: number;
  843. /**
  844. * The all dirty flag value
  845. */
  846. static readonly MATERIAL_AllDirtyFlag: number;
  847. /**
  848. * Returns the triangle fill mode
  849. */
  850. static readonly MATERIAL_TriangleFillMode: number;
  851. /**
  852. * Returns the wireframe mode
  853. */
  854. static readonly MATERIAL_WireFrameFillMode: number;
  855. /**
  856. * Returns the point fill mode
  857. */
  858. static readonly MATERIAL_PointFillMode: number;
  859. /**
  860. * Returns the point list draw mode
  861. */
  862. static readonly MATERIAL_PointListDrawMode: number;
  863. /**
  864. * Returns the line list draw mode
  865. */
  866. static readonly MATERIAL_LineListDrawMode: number;
  867. /**
  868. * Returns the line loop draw mode
  869. */
  870. static readonly MATERIAL_LineLoopDrawMode: number;
  871. /**
  872. * Returns the line strip draw mode
  873. */
  874. static readonly MATERIAL_LineStripDrawMode: number;
  875. /**
  876. * Returns the triangle strip draw mode
  877. */
  878. static readonly MATERIAL_TriangleStripDrawMode: number;
  879. /**
  880. * Returns the triangle fan draw mode
  881. */
  882. static readonly MATERIAL_TriangleFanDrawMode: number;
  883. /**
  884. * Stores the clock-wise side orientation
  885. */
  886. static readonly MATERIAL_ClockWiseSideOrientation: number;
  887. /**
  888. * Stores the counter clock-wise side orientation
  889. */
  890. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  891. /**
  892. * Nothing
  893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  894. */
  895. static readonly ACTION_NothingTrigger: number;
  896. /**
  897. * On pick
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_OnPickTrigger: number;
  901. /**
  902. * On left pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnLeftPickTrigger: number;
  906. /**
  907. * On right pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnRightPickTrigger: number;
  911. /**
  912. * On center pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnCenterPickTrigger: number;
  916. /**
  917. * On pick down
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnPickDownTrigger: number;
  921. /**
  922. * On double pick
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnDoublePickTrigger: number;
  926. /**
  927. * On pick up
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnPickUpTrigger: number;
  931. /**
  932. * On pick out.
  933. * This trigger will only be raised if you also declared a OnPickDown
  934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  935. */
  936. static readonly ACTION_OnPickOutTrigger: number;
  937. /**
  938. * On long press
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnLongPressTrigger: number;
  942. /**
  943. * On pointer over
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnPointerOverTrigger: number;
  947. /**
  948. * On pointer out
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOutTrigger: number;
  952. /**
  953. * On every frame
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnEveryFrameTrigger: number;
  957. /**
  958. * On intersection enter
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnIntersectionEnterTrigger: number;
  962. /**
  963. * On intersection exit
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionExitTrigger: number;
  967. /**
  968. * On key down
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnKeyDownTrigger: number;
  972. /**
  973. * On key up
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyUpTrigger: number;
  977. /**
  978. * Billboard mode will only apply to Y axis
  979. */
  980. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  981. /**
  982. * Billboard mode will apply to all axes
  983. */
  984. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  985. /**
  986. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  987. */
  988. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  989. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  990. * Test order :
  991. * Is the bounding sphere outside the frustum ?
  992. * If not, are the bounding box vertices outside the frustum ?
  993. * It not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  996. /** Culling strategy : Bounding Sphere Only.
  997. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  998. * It's also less accurate than the standard because some not visible objects can still be selected.
  999. * Test : is the bounding sphere outside the frustum ?
  1000. * If not, then the cullable object is in the frustum.
  1001. */
  1002. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1003. /** Culling strategy : Optimistic Inclusion.
  1004. * This in an inclusion test first, then the standard exclusion test.
  1005. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1006. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1007. * Anyway, it's as accurate as the standard strategy.
  1008. * Test :
  1009. * Is the cullable object bounding sphere center in the frustum ?
  1010. * If not, apply the default culling strategy.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1013. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1014. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1015. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1016. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1017. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1018. * Test :
  1019. * Is the cullable object bounding sphere center in the frustum ?
  1020. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1023. /**
  1024. * No logging while loading
  1025. */
  1026. static readonly SCENELOADER_NO_LOGGING: number;
  1027. /**
  1028. * Minimal logging while loading
  1029. */
  1030. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1031. /**
  1032. * Summary logging while loading
  1033. */
  1034. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1035. /**
  1036. * Detailled logging while loading
  1037. */
  1038. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1039. }
  1040. }
  1041. declare module BABYLON {
  1042. /**
  1043. * This represents the required contract to create a new type of texture loader.
  1044. */
  1045. export interface IInternalTextureLoader {
  1046. /**
  1047. * Defines wether the loader supports cascade loading the different faces.
  1048. */
  1049. supportCascades: boolean;
  1050. /**
  1051. * This returns if the loader support the current file information.
  1052. * @param extension defines the file extension of the file being loaded
  1053. * @returns true if the loader can load the specified file
  1054. */
  1055. canLoad(extension: string): boolean;
  1056. /**
  1057. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1058. * @param data contains the texture data
  1059. * @param texture defines the BabylonJS internal texture
  1060. * @param createPolynomials will be true if polynomials have been requested
  1061. * @param onLoad defines the callback to trigger once the texture is ready
  1062. * @param onError defines the callback to trigger in case of error
  1063. */
  1064. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1065. /**
  1066. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1067. * @param data contains the texture data
  1068. * @param texture defines the BabylonJS internal texture
  1069. * @param callback defines the method to call once ready to upload
  1070. */
  1071. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1072. }
  1073. }
  1074. declare module BABYLON {
  1075. /**
  1076. * Class used to store and describe the pipeline context associated with an effect
  1077. */
  1078. export interface IPipelineContext {
  1079. /**
  1080. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1081. */
  1082. isAsync: boolean;
  1083. /**
  1084. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1085. */
  1086. isReady: boolean;
  1087. /** @hidden */
  1088. _getVertexShaderCode(): string | null;
  1089. /** @hidden */
  1090. _getFragmentShaderCode(): string | null;
  1091. /** @hidden */
  1092. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1093. }
  1094. }
  1095. declare module BABYLON {
  1096. /**
  1097. * Class used to store gfx data (like WebGLBuffer)
  1098. */
  1099. export class DataBuffer {
  1100. /**
  1101. * Gets or sets the number of objects referencing this buffer
  1102. */
  1103. references: number;
  1104. /** Gets or sets the size of the underlying buffer */
  1105. capacity: number;
  1106. /**
  1107. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1108. */
  1109. is32Bits: boolean;
  1110. /**
  1111. * Gets the underlying buffer
  1112. */
  1113. get underlyingResource(): any;
  1114. }
  1115. }
  1116. declare module BABYLON {
  1117. /** @hidden */
  1118. export interface IShaderProcessor {
  1119. attributeProcessor?: (attribute: string) => string;
  1120. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1121. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1122. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1123. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1124. lineProcessor?: (line: string, isFragment: boolean) => string;
  1125. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1126. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface ProcessingOptions {
  1132. defines: string[];
  1133. indexParameters: any;
  1134. isFragment: boolean;
  1135. shouldUseHighPrecisionShader: boolean;
  1136. supportsUniformBuffers: boolean;
  1137. shadersRepository: string;
  1138. includesShadersStore: {
  1139. [key: string]: string;
  1140. };
  1141. processor?: IShaderProcessor;
  1142. version: string;
  1143. platformName: string;
  1144. lookForClosingBracketForUniformBuffer?: boolean;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export class ShaderCodeNode {
  1150. line: string;
  1151. children: ShaderCodeNode[];
  1152. additionalDefineKey?: string;
  1153. additionalDefineValue?: string;
  1154. isValid(preprocessors: {
  1155. [key: string]: string;
  1156. }): boolean;
  1157. process(preprocessors: {
  1158. [key: string]: string;
  1159. }, options: ProcessingOptions): string;
  1160. }
  1161. }
  1162. declare module BABYLON {
  1163. /** @hidden */
  1164. export class ShaderCodeCursor {
  1165. private _lines;
  1166. lineIndex: number;
  1167. get currentLine(): string;
  1168. get canRead(): boolean;
  1169. set lines(value: string[]);
  1170. }
  1171. }
  1172. declare module BABYLON {
  1173. /** @hidden */
  1174. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1175. process(preprocessors: {
  1176. [key: string]: string;
  1177. }, options: ProcessingOptions): string;
  1178. }
  1179. }
  1180. declare module BABYLON {
  1181. /** @hidden */
  1182. export class ShaderDefineExpression {
  1183. isTrue(preprocessors: {
  1184. [key: string]: string;
  1185. }): boolean;
  1186. private static OperatorPriority;
  1187. private static Stack;
  1188. static postfixToInfix(postfix: string[]): string;
  1189. static infixToPostfix(infix: string): string[];
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeTestNode extends ShaderCodeNode {
  1195. testExpression: ShaderDefineExpression;
  1196. isValid(preprocessors: {
  1197. [key: string]: string;
  1198. }): boolean;
  1199. }
  1200. }
  1201. declare module BABYLON {
  1202. /** @hidden */
  1203. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1204. define: string;
  1205. not: boolean;
  1206. constructor(define: string, not?: boolean);
  1207. isTrue(preprocessors: {
  1208. [key: string]: string;
  1209. }): boolean;
  1210. }
  1211. }
  1212. declare module BABYLON {
  1213. /** @hidden */
  1214. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1215. leftOperand: ShaderDefineExpression;
  1216. rightOperand: ShaderDefineExpression;
  1217. isTrue(preprocessors: {
  1218. [key: string]: string;
  1219. }): boolean;
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1225. leftOperand: ShaderDefineExpression;
  1226. rightOperand: ShaderDefineExpression;
  1227. isTrue(preprocessors: {
  1228. [key: string]: string;
  1229. }): boolean;
  1230. }
  1231. }
  1232. declare module BABYLON {
  1233. /** @hidden */
  1234. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1235. define: string;
  1236. operand: string;
  1237. testValue: string;
  1238. constructor(define: string, operand: string, testValue: string);
  1239. isTrue(preprocessors: {
  1240. [key: string]: string;
  1241. }): boolean;
  1242. }
  1243. }
  1244. declare module BABYLON {
  1245. /**
  1246. * Class used to enable access to offline support
  1247. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1248. */
  1249. export interface IOfflineProvider {
  1250. /**
  1251. * Gets a boolean indicating if scene must be saved in the database
  1252. */
  1253. enableSceneOffline: boolean;
  1254. /**
  1255. * Gets a boolean indicating if textures must be saved in the database
  1256. */
  1257. enableTexturesOffline: boolean;
  1258. /**
  1259. * Open the offline support and make it available
  1260. * @param successCallback defines the callback to call on success
  1261. * @param errorCallback defines the callback to call on error
  1262. */
  1263. open(successCallback: () => void, errorCallback: () => void): void;
  1264. /**
  1265. * Loads an image from the offline support
  1266. * @param url defines the url to load from
  1267. * @param image defines the target DOM image
  1268. */
  1269. loadImage(url: string, image: HTMLImageElement): void;
  1270. /**
  1271. * Loads a file from offline support
  1272. * @param url defines the URL to load from
  1273. * @param sceneLoaded defines a callback to call on success
  1274. * @param progressCallBack defines a callback to call when progress changed
  1275. * @param errorCallback defines a callback to call on error
  1276. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1277. */
  1278. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1279. }
  1280. }
  1281. declare module BABYLON {
  1282. /**
  1283. * Class used to help managing file picking and drag'n'drop
  1284. * File Storage
  1285. */
  1286. export class FilesInputStore {
  1287. /**
  1288. * List of files ready to be loaded
  1289. */
  1290. static FilesToLoad: {
  1291. [key: string]: File;
  1292. };
  1293. }
  1294. }
  1295. declare module BABYLON {
  1296. /**
  1297. * Class used to define a retry strategy when error happens while loading assets
  1298. */
  1299. export class RetryStrategy {
  1300. /**
  1301. * Function used to defines an exponential back off strategy
  1302. * @param maxRetries defines the maximum number of retries (3 by default)
  1303. * @param baseInterval defines the interval between retries
  1304. * @returns the strategy function to use
  1305. */
  1306. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1307. }
  1308. }
  1309. declare module BABYLON {
  1310. /**
  1311. * @ignore
  1312. * Application error to support additional information when loading a file
  1313. */
  1314. export abstract class BaseError extends Error {
  1315. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1316. }
  1317. }
  1318. declare module BABYLON {
  1319. /** @ignore */
  1320. export class LoadFileError extends BaseError {
  1321. request?: WebRequest;
  1322. file?: File;
  1323. /**
  1324. * Creates a new LoadFileError
  1325. * @param message defines the message of the error
  1326. * @param request defines the optional web request
  1327. * @param file defines the optional file
  1328. */
  1329. constructor(message: string, object?: WebRequest | File);
  1330. }
  1331. /** @ignore */
  1332. export class RequestFileError extends BaseError {
  1333. request: WebRequest;
  1334. /**
  1335. * Creates a new LoadFileError
  1336. * @param message defines the message of the error
  1337. * @param request defines the optional web request
  1338. */
  1339. constructor(message: string, request: WebRequest);
  1340. }
  1341. /** @ignore */
  1342. export class ReadFileError extends BaseError {
  1343. file: File;
  1344. /**
  1345. * Creates a new ReadFileError
  1346. * @param message defines the message of the error
  1347. * @param file defines the optional file
  1348. */
  1349. constructor(message: string, file: File);
  1350. }
  1351. /**
  1352. * @hidden
  1353. */
  1354. export class FileTools {
  1355. /**
  1356. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1357. */
  1358. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1359. /**
  1360. * Gets or sets the base URL to use to load assets
  1361. */
  1362. static BaseUrl: string;
  1363. /**
  1364. * Default behaviour for cors in the application.
  1365. * It can be a string if the expected behavior is identical in the entire app.
  1366. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1367. */
  1368. static CorsBehavior: string | ((url: string | string[]) => string);
  1369. /**
  1370. * Gets or sets a function used to pre-process url before using them to load assets
  1371. */
  1372. static PreprocessUrl: (url: string) => string;
  1373. /**
  1374. * Removes unwanted characters from an url
  1375. * @param url defines the url to clean
  1376. * @returns the cleaned url
  1377. */
  1378. private static _CleanUrl;
  1379. /**
  1380. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1381. * @param url define the url we are trying
  1382. * @param element define the dom element where to configure the cors policy
  1383. */
  1384. static SetCorsBehavior(url: string | string[], element: {
  1385. crossOrigin: string | null;
  1386. }): void;
  1387. /**
  1388. * Loads an image as an HTMLImageElement.
  1389. * @param input url string, ArrayBuffer, or Blob to load
  1390. * @param onLoad callback called when the image successfully loads
  1391. * @param onError callback called when the image fails to load
  1392. * @param offlineProvider offline provider for caching
  1393. * @param mimeType optional mime type
  1394. * @returns the HTMLImageElement of the loaded image
  1395. */
  1396. 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>;
  1397. /**
  1398. * Reads a file from a File object
  1399. * @param file defines the file to load
  1400. * @param onSuccess defines the callback to call when data is loaded
  1401. * @param onProgress defines the callback to call during loading process
  1402. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1403. * @param onError defines the callback to call when an error occurs
  1404. * @returns a file request object
  1405. */
  1406. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1407. /**
  1408. * Loads a file from a url
  1409. * @param url url to load
  1410. * @param onSuccess callback called when the file successfully loads
  1411. * @param onProgress callback called while file is loading (if the server supports this mode)
  1412. * @param offlineProvider defines the offline provider for caching
  1413. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1414. * @param onError callback called when the file fails to load
  1415. * @returns a file request object
  1416. */
  1417. 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;
  1418. /**
  1419. * Loads a file
  1420. * @param url url to load
  1421. * @param onSuccess callback called when the file successfully loads
  1422. * @param onProgress callback called while file is loading (if the server supports this mode)
  1423. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1424. * @param onError callback called when the file fails to load
  1425. * @param onOpened callback called when the web request is opened
  1426. * @returns a file request object
  1427. */
  1428. 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;
  1429. /**
  1430. * Checks if the loaded document was accessed via `file:`-Protocol.
  1431. * @returns boolean
  1432. */
  1433. static IsFileURL(): boolean;
  1434. }
  1435. }
  1436. declare module BABYLON {
  1437. /** @hidden */
  1438. export class ShaderProcessor {
  1439. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1440. private static _ProcessPrecision;
  1441. private static _ExtractOperation;
  1442. private static _BuildSubExpression;
  1443. private static _BuildExpression;
  1444. private static _MoveCursorWithinIf;
  1445. private static _MoveCursor;
  1446. private static _EvaluatePreProcessors;
  1447. private static _PreparePreProcessors;
  1448. private static _ProcessShaderConversion;
  1449. private static _ProcessIncludes;
  1450. /**
  1451. * Loads a file from a url
  1452. * @param url url to load
  1453. * @param onSuccess callback called when the file successfully loads
  1454. * @param onProgress callback called while file is loading (if the server supports this mode)
  1455. * @param offlineProvider defines the offline provider for caching
  1456. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1457. * @param onError callback called when the file fails to load
  1458. * @returns a file request object
  1459. * @hidden
  1460. */
  1461. 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;
  1462. }
  1463. }
  1464. declare module BABYLON {
  1465. /**
  1466. * @hidden
  1467. */
  1468. export interface IColor4Like {
  1469. r: float;
  1470. g: float;
  1471. b: float;
  1472. a: float;
  1473. }
  1474. /**
  1475. * @hidden
  1476. */
  1477. export interface IColor3Like {
  1478. r: float;
  1479. g: float;
  1480. b: float;
  1481. }
  1482. /**
  1483. * @hidden
  1484. */
  1485. export interface IVector4Like {
  1486. x: float;
  1487. y: float;
  1488. z: float;
  1489. w: float;
  1490. }
  1491. /**
  1492. * @hidden
  1493. */
  1494. export interface IVector3Like {
  1495. x: float;
  1496. y: float;
  1497. z: float;
  1498. }
  1499. /**
  1500. * @hidden
  1501. */
  1502. export interface IVector2Like {
  1503. x: float;
  1504. y: float;
  1505. }
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IMatrixLike {
  1510. toArray(): DeepImmutable<Float32Array>;
  1511. updateFlag: int;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IViewportLike {
  1517. x: float;
  1518. y: float;
  1519. width: float;
  1520. height: float;
  1521. }
  1522. /**
  1523. * @hidden
  1524. */
  1525. export interface IPlaneLike {
  1526. normal: IVector3Like;
  1527. d: float;
  1528. normalize(): void;
  1529. }
  1530. }
  1531. declare module BABYLON {
  1532. /**
  1533. * Interface used to define common properties for effect fallbacks
  1534. */
  1535. export interface IEffectFallbacks {
  1536. /**
  1537. * Removes the defines that should be removed when falling back.
  1538. * @param currentDefines defines the current define statements for the shader.
  1539. * @param effect defines the current effect we try to compile
  1540. * @returns The resulting defines with defines of the current rank removed.
  1541. */
  1542. reduce(currentDefines: string, effect: Effect): string;
  1543. /**
  1544. * Removes the fallback from the bound mesh.
  1545. */
  1546. unBindMesh(): void;
  1547. /**
  1548. * Checks to see if more fallbacks are still availible.
  1549. */
  1550. hasMoreFallbacks: boolean;
  1551. }
  1552. }
  1553. declare module BABYLON {
  1554. /**
  1555. * Class used to evalaute queries containing `and` and `or` operators
  1556. */
  1557. export class AndOrNotEvaluator {
  1558. /**
  1559. * Evaluate a query
  1560. * @param query defines the query to evaluate
  1561. * @param evaluateCallback defines the callback used to filter result
  1562. * @returns true if the query matches
  1563. */
  1564. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1565. private static _HandleParenthesisContent;
  1566. private static _SimplifyNegation;
  1567. }
  1568. }
  1569. declare module BABYLON {
  1570. /**
  1571. * Class used to store custom tags
  1572. */
  1573. export class Tags {
  1574. /**
  1575. * Adds support for tags on the given object
  1576. * @param obj defines the object to use
  1577. */
  1578. static EnableFor(obj: any): void;
  1579. /**
  1580. * Removes tags support
  1581. * @param obj defines the object to use
  1582. */
  1583. static DisableFor(obj: any): void;
  1584. /**
  1585. * Gets a boolean indicating if the given object has tags
  1586. * @param obj defines the object to use
  1587. * @returns a boolean
  1588. */
  1589. static HasTags(obj: any): boolean;
  1590. /**
  1591. * Gets the tags available on a given object
  1592. * @param obj defines the object to use
  1593. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1594. * @returns the tags
  1595. */
  1596. static GetTags(obj: any, asString?: boolean): any;
  1597. /**
  1598. * Adds tags to an object
  1599. * @param obj defines the object to use
  1600. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1601. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1602. */
  1603. static AddTagsTo(obj: any, tagsString: string): void;
  1604. /**
  1605. * @hidden
  1606. */
  1607. static _AddTagTo(obj: any, tag: string): void;
  1608. /**
  1609. * Removes specific tags from a specific object
  1610. * @param obj defines the object to use
  1611. * @param tagsString defines the tags to remove
  1612. */
  1613. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1614. /**
  1615. * @hidden
  1616. */
  1617. static _RemoveTagFrom(obj: any, tag: string): void;
  1618. /**
  1619. * Defines if tags hosted on an object match a given query
  1620. * @param obj defines the object to use
  1621. * @param tagsQuery defines the tag query
  1622. * @returns a boolean
  1623. */
  1624. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1625. }
  1626. }
  1627. declare module BABYLON {
  1628. /**
  1629. * Scalar computation library
  1630. */
  1631. export class Scalar {
  1632. /**
  1633. * Two pi constants convenient for computation.
  1634. */
  1635. static TwoPi: number;
  1636. /**
  1637. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1638. * @param a number
  1639. * @param b number
  1640. * @param epsilon (default = 1.401298E-45)
  1641. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1642. */
  1643. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1644. /**
  1645. * Returns a string : the upper case translation of the number i to hexadecimal.
  1646. * @param i number
  1647. * @returns the upper case translation of the number i to hexadecimal.
  1648. */
  1649. static ToHex(i: number): string;
  1650. /**
  1651. * Returns -1 if value is negative and +1 is value is positive.
  1652. * @param value the value
  1653. * @returns the value itself if it's equal to zero.
  1654. */
  1655. static Sign(value: number): number;
  1656. /**
  1657. * Returns the value itself if it's between min and max.
  1658. * Returns min if the value is lower than min.
  1659. * Returns max if the value is greater than max.
  1660. * @param value the value to clmap
  1661. * @param min the min value to clamp to (default: 0)
  1662. * @param max the max value to clamp to (default: 1)
  1663. * @returns the clamped value
  1664. */
  1665. static Clamp(value: number, min?: number, max?: number): number;
  1666. /**
  1667. * the log2 of value.
  1668. * @param value the value to compute log2 of
  1669. * @returns the log2 of value.
  1670. */
  1671. static Log2(value: number): number;
  1672. /**
  1673. * Loops the value, so that it is never larger than length and never smaller than 0.
  1674. *
  1675. * This is similar to the modulo operator but it works with floating point numbers.
  1676. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1677. * With t = 5 and length = 2.5, the result would be 0.0.
  1678. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1679. * @param value the value
  1680. * @param length the length
  1681. * @returns the looped value
  1682. */
  1683. static Repeat(value: number, length: number): number;
  1684. /**
  1685. * Normalize the value between 0.0 and 1.0 using min and max values
  1686. * @param value value to normalize
  1687. * @param min max to normalize between
  1688. * @param max min to normalize between
  1689. * @returns the normalized value
  1690. */
  1691. static Normalize(value: number, min: number, max: number): number;
  1692. /**
  1693. * Denormalize the value from 0.0 and 1.0 using min and max values
  1694. * @param normalized value to denormalize
  1695. * @param min max to denormalize between
  1696. * @param max min to denormalize between
  1697. * @returns the denormalized value
  1698. */
  1699. static Denormalize(normalized: number, min: number, max: number): number;
  1700. /**
  1701. * Calculates the shortest difference between two given angles given in degrees.
  1702. * @param current current angle in degrees
  1703. * @param target target angle in degrees
  1704. * @returns the delta
  1705. */
  1706. static DeltaAngle(current: number, target: number): number;
  1707. /**
  1708. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1709. * @param tx value
  1710. * @param length length
  1711. * @returns The returned value will move back and forth between 0 and length
  1712. */
  1713. static PingPong(tx: number, length: number): number;
  1714. /**
  1715. * Interpolates between min and max with smoothing at the limits.
  1716. *
  1717. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1718. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1719. * @param from from
  1720. * @param to to
  1721. * @param tx value
  1722. * @returns the smooth stepped value
  1723. */
  1724. static SmoothStep(from: number, to: number, tx: number): number;
  1725. /**
  1726. * Moves a value current towards target.
  1727. *
  1728. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1729. * Negative values of maxDelta pushes the value away from target.
  1730. * @param current current value
  1731. * @param target target value
  1732. * @param maxDelta max distance to move
  1733. * @returns resulting value
  1734. */
  1735. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1736. /**
  1737. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1738. *
  1739. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1740. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1741. * @param current current value
  1742. * @param target target value
  1743. * @param maxDelta max distance to move
  1744. * @returns resulting angle
  1745. */
  1746. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1747. /**
  1748. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1749. * @param start start value
  1750. * @param end target value
  1751. * @param amount amount to lerp between
  1752. * @returns the lerped value
  1753. */
  1754. static Lerp(start: number, end: number, amount: number): number;
  1755. /**
  1756. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1757. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1758. * @param start start value
  1759. * @param end target value
  1760. * @param amount amount to lerp between
  1761. * @returns the lerped value
  1762. */
  1763. static LerpAngle(start: number, end: number, amount: number): number;
  1764. /**
  1765. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1766. * @param a start value
  1767. * @param b target value
  1768. * @param value value between a and b
  1769. * @returns the inverseLerp value
  1770. */
  1771. static InverseLerp(a: number, b: number, value: number): number;
  1772. /**
  1773. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1774. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1775. * @param value1 spline value
  1776. * @param tangent1 spline value
  1777. * @param value2 spline value
  1778. * @param tangent2 spline value
  1779. * @param amount input value
  1780. * @returns hermite result
  1781. */
  1782. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1783. /**
  1784. * Returns a random float number between and min and max values
  1785. * @param min min value of random
  1786. * @param max max value of random
  1787. * @returns random value
  1788. */
  1789. static RandomRange(min: number, max: number): number;
  1790. /**
  1791. * This function returns percentage of a number in a given range.
  1792. *
  1793. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1794. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1795. * @param number to convert to percentage
  1796. * @param min min range
  1797. * @param max max range
  1798. * @returns the percentage
  1799. */
  1800. static RangeToPercent(number: number, min: number, max: number): number;
  1801. /**
  1802. * This function returns number that corresponds to the percentage in a given range.
  1803. *
  1804. * PercentToRange(0.34,0,100) will return 34.
  1805. * @param percent to convert to number
  1806. * @param min min range
  1807. * @param max max range
  1808. * @returns the number
  1809. */
  1810. static PercentToRange(percent: number, min: number, max: number): number;
  1811. /**
  1812. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1813. * @param angle The angle to normalize in radian.
  1814. * @return The converted angle.
  1815. */
  1816. static NormalizeRadians(angle: number): number;
  1817. }
  1818. }
  1819. declare module BABYLON {
  1820. /**
  1821. * Constant used to convert a value to gamma space
  1822. * @ignorenaming
  1823. */
  1824. export const ToGammaSpace: number;
  1825. /**
  1826. * Constant used to convert a value to linear space
  1827. * @ignorenaming
  1828. */
  1829. export const ToLinearSpace = 2.2;
  1830. /**
  1831. * Constant used to define the minimal number value in Babylon.js
  1832. * @ignorenaming
  1833. */
  1834. let Epsilon: number;
  1835. }
  1836. declare module BABYLON {
  1837. /**
  1838. * Class used to represent a viewport on screen
  1839. */
  1840. export class Viewport {
  1841. /** viewport left coordinate */
  1842. x: number;
  1843. /** viewport top coordinate */
  1844. y: number;
  1845. /**viewport width */
  1846. width: number;
  1847. /** viewport height */
  1848. height: number;
  1849. /**
  1850. * Creates a Viewport object located at (x, y) and sized (width, height)
  1851. * @param x defines viewport left coordinate
  1852. * @param y defines viewport top coordinate
  1853. * @param width defines the viewport width
  1854. * @param height defines the viewport height
  1855. */
  1856. constructor(
  1857. /** viewport left coordinate */
  1858. x: number,
  1859. /** viewport top coordinate */
  1860. y: number,
  1861. /**viewport width */
  1862. width: number,
  1863. /** viewport height */
  1864. height: number);
  1865. /**
  1866. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1867. * @param renderWidth defines the rendering width
  1868. * @param renderHeight defines the rendering height
  1869. * @returns a new Viewport
  1870. */
  1871. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1872. /**
  1873. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1874. * @param renderWidth defines the rendering width
  1875. * @param renderHeight defines the rendering height
  1876. * @param ref defines the target viewport
  1877. * @returns the current viewport
  1878. */
  1879. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1880. /**
  1881. * Returns a new Viewport copied from the current one
  1882. * @returns a new Viewport
  1883. */
  1884. clone(): Viewport;
  1885. }
  1886. }
  1887. declare module BABYLON {
  1888. /**
  1889. * Class containing a set of static utilities functions for arrays.
  1890. */
  1891. export class ArrayTools {
  1892. /**
  1893. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1894. * @param size the number of element to construct and put in the array
  1895. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1896. * @returns a new array filled with new objects
  1897. */
  1898. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1899. }
  1900. }
  1901. declare module BABYLON {
  1902. /**
  1903. * Class representing a vector containing 2 coordinates
  1904. */
  1905. export class Vector2 {
  1906. /** defines the first coordinate */
  1907. x: number;
  1908. /** defines the second coordinate */
  1909. y: number;
  1910. /**
  1911. * Creates a new Vector2 from the given x and y coordinates
  1912. * @param x defines the first coordinate
  1913. * @param y defines the second coordinate
  1914. */
  1915. constructor(
  1916. /** defines the first coordinate */
  1917. x?: number,
  1918. /** defines the second coordinate */
  1919. y?: number);
  1920. /**
  1921. * Gets a string with the Vector2 coordinates
  1922. * @returns a string with the Vector2 coordinates
  1923. */
  1924. toString(): string;
  1925. /**
  1926. * Gets class name
  1927. * @returns the string "Vector2"
  1928. */
  1929. getClassName(): string;
  1930. /**
  1931. * Gets current vector hash code
  1932. * @returns the Vector2 hash code as a number
  1933. */
  1934. getHashCode(): number;
  1935. /**
  1936. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1937. * @param array defines the source array
  1938. * @param index defines the offset in source array
  1939. * @returns the current Vector2
  1940. */
  1941. toArray(array: FloatArray, index?: number): Vector2;
  1942. /**
  1943. * Copy the current vector to an array
  1944. * @returns a new array with 2 elements: the Vector2 coordinates.
  1945. */
  1946. asArray(): number[];
  1947. /**
  1948. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1949. * @param source defines the source Vector2
  1950. * @returns the current updated Vector2
  1951. */
  1952. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1953. /**
  1954. * Sets the Vector2 coordinates with the given floats
  1955. * @param x defines the first coordinate
  1956. * @param y defines the second coordinate
  1957. * @returns the current updated Vector2
  1958. */
  1959. copyFromFloats(x: number, y: number): Vector2;
  1960. /**
  1961. * Sets the Vector2 coordinates with the given floats
  1962. * @param x defines the first coordinate
  1963. * @param y defines the second coordinate
  1964. * @returns the current updated Vector2
  1965. */
  1966. set(x: number, y: number): Vector2;
  1967. /**
  1968. * Add another vector with the current one
  1969. * @param otherVector defines the other vector
  1970. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1971. */
  1972. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1973. /**
  1974. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1975. * @param otherVector defines the other vector
  1976. * @param result defines the target vector
  1977. * @returns the unmodified current Vector2
  1978. */
  1979. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1980. /**
  1981. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1982. * @param otherVector defines the other vector
  1983. * @returns the current updated Vector2
  1984. */
  1985. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1986. /**
  1987. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1988. * @param otherVector defines the other vector
  1989. * @returns a new Vector2
  1990. */
  1991. addVector3(otherVector: Vector3): Vector2;
  1992. /**
  1993. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1994. * @param otherVector defines the other vector
  1995. * @returns a new Vector2
  1996. */
  1997. subtract(otherVector: Vector2): Vector2;
  1998. /**
  1999. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2000. * @param otherVector defines the other vector
  2001. * @param result defines the target vector
  2002. * @returns the unmodified current Vector2
  2003. */
  2004. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2005. /**
  2006. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2007. * @param otherVector defines the other vector
  2008. * @returns the current updated Vector2
  2009. */
  2010. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Multiplies in place the current Vector2 coordinates by the given ones
  2013. * @param otherVector defines the other vector
  2014. * @returns the current updated Vector2
  2015. */
  2016. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2017. /**
  2018. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2019. * @param otherVector defines the other vector
  2020. * @returns a new Vector2
  2021. */
  2022. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2023. /**
  2024. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2025. * @param otherVector defines the other vector
  2026. * @param result defines the target vector
  2027. * @returns the unmodified current Vector2
  2028. */
  2029. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2030. /**
  2031. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2032. * @param x defines the first coordinate
  2033. * @param y defines the second coordinate
  2034. * @returns a new Vector2
  2035. */
  2036. multiplyByFloats(x: number, y: number): Vector2;
  2037. /**
  2038. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2039. * @param otherVector defines the other vector
  2040. * @returns a new Vector2
  2041. */
  2042. divide(otherVector: Vector2): Vector2;
  2043. /**
  2044. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2045. * @param otherVector defines the other vector
  2046. * @param result defines the target vector
  2047. * @returns the unmodified current Vector2
  2048. */
  2049. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2050. /**
  2051. * Divides the current Vector2 coordinates by the given ones
  2052. * @param otherVector defines the other vector
  2053. * @returns the current updated Vector2
  2054. */
  2055. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2056. /**
  2057. * Gets a new Vector2 with current Vector2 negated coordinates
  2058. * @returns a new Vector2
  2059. */
  2060. negate(): Vector2;
  2061. /**
  2062. * Negate this vector in place
  2063. * @returns this
  2064. */
  2065. negateInPlace(): Vector2;
  2066. /**
  2067. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2068. * @param result defines the Vector3 object where to store the result
  2069. * @returns the current Vector2
  2070. */
  2071. negateToRef(result: Vector2): Vector2;
  2072. /**
  2073. * Multiply the Vector2 coordinates by scale
  2074. * @param scale defines the scaling factor
  2075. * @returns the current updated Vector2
  2076. */
  2077. scaleInPlace(scale: number): Vector2;
  2078. /**
  2079. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2080. * @param scale defines the scaling factor
  2081. * @returns a new Vector2
  2082. */
  2083. scale(scale: number): Vector2;
  2084. /**
  2085. * Scale the current Vector2 values by a factor to a given Vector2
  2086. * @param scale defines the scale factor
  2087. * @param result defines the Vector2 object where to store the result
  2088. * @returns the unmodified current Vector2
  2089. */
  2090. scaleToRef(scale: number, result: Vector2): Vector2;
  2091. /**
  2092. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2093. * @param scale defines the scale factor
  2094. * @param result defines the Vector2 object where to store the result
  2095. * @returns the unmodified current Vector2
  2096. */
  2097. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2098. /**
  2099. * Gets a boolean if two vectors are equals
  2100. * @param otherVector defines the other vector
  2101. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2102. */
  2103. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2104. /**
  2105. * Gets a boolean if two vectors are equals (using an epsilon value)
  2106. * @param otherVector defines the other vector
  2107. * @param epsilon defines the minimal distance to consider equality
  2108. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2109. */
  2110. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2111. /**
  2112. * Gets a new Vector2 from current Vector2 floored values
  2113. * @returns a new Vector2
  2114. */
  2115. floor(): Vector2;
  2116. /**
  2117. * Gets a new Vector2 from current Vector2 floored values
  2118. * @returns a new Vector2
  2119. */
  2120. fract(): Vector2;
  2121. /**
  2122. * Gets the length of the vector
  2123. * @returns the vector length (float)
  2124. */
  2125. length(): number;
  2126. /**
  2127. * Gets the vector squared length
  2128. * @returns the vector squared length (float)
  2129. */
  2130. lengthSquared(): number;
  2131. /**
  2132. * Normalize the vector
  2133. * @returns the current updated Vector2
  2134. */
  2135. normalize(): Vector2;
  2136. /**
  2137. * Gets a new Vector2 copied from the Vector2
  2138. * @returns a new Vector2
  2139. */
  2140. clone(): Vector2;
  2141. /**
  2142. * Gets a new Vector2(0, 0)
  2143. * @returns a new Vector2
  2144. */
  2145. static Zero(): Vector2;
  2146. /**
  2147. * Gets a new Vector2(1, 1)
  2148. * @returns a new Vector2
  2149. */
  2150. static One(): Vector2;
  2151. /**
  2152. * Gets a new Vector2 set from the given index element of the given array
  2153. * @param array defines the data source
  2154. * @param offset defines the offset in the data source
  2155. * @returns a new Vector2
  2156. */
  2157. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2158. /**
  2159. * Sets "result" from the given index element of the given array
  2160. * @param array defines the data source
  2161. * @param offset defines the offset in the data source
  2162. * @param result defines the target vector
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2165. /**
  2166. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2167. * @param value1 defines 1st point of control
  2168. * @param value2 defines 2nd point of control
  2169. * @param value3 defines 3rd point of control
  2170. * @param value4 defines 4th point of control
  2171. * @param amount defines the interpolation factor
  2172. * @returns a new Vector2
  2173. */
  2174. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2175. /**
  2176. * 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".
  2177. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2178. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2179. * @param value defines the value to clamp
  2180. * @param min defines the lower limit
  2181. * @param max defines the upper limit
  2182. * @returns a new Vector2
  2183. */
  2184. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2185. /**
  2186. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2187. * @param value1 defines the 1st control point
  2188. * @param tangent1 defines the outgoing tangent
  2189. * @param value2 defines the 2nd control point
  2190. * @param tangent2 defines the incoming tangent
  2191. * @param amount defines the interpolation factor
  2192. * @returns a new Vector2
  2193. */
  2194. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2195. /**
  2196. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2197. * @param start defines the start vector
  2198. * @param end defines the end vector
  2199. * @param amount defines the interpolation factor
  2200. * @returns a new Vector2
  2201. */
  2202. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2203. /**
  2204. * Gets the dot product of the vector "left" and the vector "right"
  2205. * @param left defines first vector
  2206. * @param right defines second vector
  2207. * @returns the dot product (float)
  2208. */
  2209. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2210. /**
  2211. * Returns a new Vector2 equal to the normalized given vector
  2212. * @param vector defines the vector to normalize
  2213. * @returns a new Vector2
  2214. */
  2215. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2216. /**
  2217. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2218. * @param left defines 1st vector
  2219. * @param right defines 2nd vector
  2220. * @returns a new Vector2
  2221. */
  2222. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2223. /**
  2224. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2225. * @param left defines 1st vector
  2226. * @param right defines 2nd vector
  2227. * @returns a new Vector2
  2228. */
  2229. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2232. * @param vector defines the vector to transform
  2233. * @param transformation defines the matrix to apply
  2234. * @returns a new Vector2
  2235. */
  2236. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2237. /**
  2238. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2239. * @param vector defines the vector to transform
  2240. * @param transformation defines the matrix to apply
  2241. * @param result defines the target vector
  2242. */
  2243. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2244. /**
  2245. * Determines if a given vector is included in a triangle
  2246. * @param p defines the vector to test
  2247. * @param p0 defines 1st triangle point
  2248. * @param p1 defines 2nd triangle point
  2249. * @param p2 defines 3rd triangle point
  2250. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2251. */
  2252. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2253. /**
  2254. * Gets the distance between the vectors "value1" and "value2"
  2255. * @param value1 defines first vector
  2256. * @param value2 defines second vector
  2257. * @returns the distance between vectors
  2258. */
  2259. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2260. /**
  2261. * Returns the squared distance between the vectors "value1" and "value2"
  2262. * @param value1 defines first vector
  2263. * @param value2 defines second vector
  2264. * @returns the squared distance between vectors
  2265. */
  2266. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2267. /**
  2268. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2269. * @param value1 defines first vector
  2270. * @param value2 defines second vector
  2271. * @returns a new Vector2
  2272. */
  2273. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2274. /**
  2275. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2276. * @param p defines the middle point
  2277. * @param segA defines one point of the segment
  2278. * @param segB defines the other point of the segment
  2279. * @returns the shortest distance
  2280. */
  2281. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2282. }
  2283. /**
  2284. * Class used to store (x,y,z) vector representation
  2285. * A Vector3 is the main object used in 3D geometry
  2286. * It can represent etiher the coordinates of a point the space, either a direction
  2287. * Reminder: js uses a left handed forward facing system
  2288. */
  2289. export class Vector3 {
  2290. /**
  2291. * Defines the first coordinates (on X axis)
  2292. */
  2293. x: number;
  2294. /**
  2295. * Defines the second coordinates (on Y axis)
  2296. */
  2297. y: number;
  2298. /**
  2299. * Defines the third coordinates (on Z axis)
  2300. */
  2301. z: number;
  2302. private static _UpReadOnly;
  2303. private static _ZeroReadOnly;
  2304. /**
  2305. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2306. * @param x defines the first coordinates (on X axis)
  2307. * @param y defines the second coordinates (on Y axis)
  2308. * @param z defines the third coordinates (on Z axis)
  2309. */
  2310. constructor(
  2311. /**
  2312. * Defines the first coordinates (on X axis)
  2313. */
  2314. x?: number,
  2315. /**
  2316. * Defines the second coordinates (on Y axis)
  2317. */
  2318. y?: number,
  2319. /**
  2320. * Defines the third coordinates (on Z axis)
  2321. */
  2322. z?: number);
  2323. /**
  2324. * Creates a string representation of the Vector3
  2325. * @returns a string with the Vector3 coordinates.
  2326. */
  2327. toString(): string;
  2328. /**
  2329. * Gets the class name
  2330. * @returns the string "Vector3"
  2331. */
  2332. getClassName(): string;
  2333. /**
  2334. * Creates the Vector3 hash code
  2335. * @returns a number which tends to be unique between Vector3 instances
  2336. */
  2337. getHashCode(): number;
  2338. /**
  2339. * Creates an array containing three elements : the coordinates of the Vector3
  2340. * @returns a new array of numbers
  2341. */
  2342. asArray(): number[];
  2343. /**
  2344. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2345. * @param array defines the destination array
  2346. * @param index defines the offset in the destination array
  2347. * @returns the current Vector3
  2348. */
  2349. toArray(array: FloatArray, index?: number): Vector3;
  2350. /**
  2351. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2352. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2353. */
  2354. toQuaternion(): Quaternion;
  2355. /**
  2356. * Adds the given vector to the current Vector3
  2357. * @param otherVector defines the second operand
  2358. * @returns the current updated Vector3
  2359. */
  2360. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2361. /**
  2362. * Adds the given coordinates to the current Vector3
  2363. * @param x defines the x coordinate of the operand
  2364. * @param y defines the y coordinate of the operand
  2365. * @param z defines the z coordinate of the operand
  2366. * @returns the current updated Vector3
  2367. */
  2368. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2369. /**
  2370. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2371. * @param otherVector defines the second operand
  2372. * @returns the resulting Vector3
  2373. */
  2374. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2375. /**
  2376. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2377. * @param otherVector defines the second operand
  2378. * @param result defines the Vector3 object where to store the result
  2379. * @returns the current Vector3
  2380. */
  2381. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2382. /**
  2383. * Subtract the given vector from the current Vector3
  2384. * @param otherVector defines the second operand
  2385. * @returns the current updated Vector3
  2386. */
  2387. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2388. /**
  2389. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2390. * @param otherVector defines the second operand
  2391. * @returns the resulting Vector3
  2392. */
  2393. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2394. /**
  2395. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2396. * @param otherVector defines the second operand
  2397. * @param result defines the Vector3 object where to store the result
  2398. * @returns the current Vector3
  2399. */
  2400. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2401. /**
  2402. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2403. * @param x defines the x coordinate of the operand
  2404. * @param y defines the y coordinate of the operand
  2405. * @param z defines the z coordinate of the operand
  2406. * @returns the resulting Vector3
  2407. */
  2408. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2409. /**
  2410. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2411. * @param x defines the x coordinate of the operand
  2412. * @param y defines the y coordinate of the operand
  2413. * @param z defines the z coordinate of the operand
  2414. * @param result defines the Vector3 object where to store the result
  2415. * @returns the current Vector3
  2416. */
  2417. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2418. /**
  2419. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2420. * @returns a new Vector3
  2421. */
  2422. negate(): Vector3;
  2423. /**
  2424. * Negate this vector in place
  2425. * @returns this
  2426. */
  2427. negateInPlace(): Vector3;
  2428. /**
  2429. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2430. * @param result defines the Vector3 object where to store the result
  2431. * @returns the current Vector3
  2432. */
  2433. negateToRef(result: Vector3): Vector3;
  2434. /**
  2435. * Multiplies the Vector3 coordinates by the float "scale"
  2436. * @param scale defines the multiplier factor
  2437. * @returns the current updated Vector3
  2438. */
  2439. scaleInPlace(scale: number): Vector3;
  2440. /**
  2441. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2442. * @param scale defines the multiplier factor
  2443. * @returns a new Vector3
  2444. */
  2445. scale(scale: number): Vector3;
  2446. /**
  2447. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2448. * @param scale defines the multiplier factor
  2449. * @param result defines the Vector3 object where to store the result
  2450. * @returns the current Vector3
  2451. */
  2452. scaleToRef(scale: number, result: Vector3): Vector3;
  2453. /**
  2454. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2455. * @param scale defines the scale factor
  2456. * @param result defines the Vector3 object where to store the result
  2457. * @returns the unmodified current Vector3
  2458. */
  2459. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2460. /**
  2461. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2462. * @param otherVector defines the second operand
  2463. * @returns true if both vectors are equals
  2464. */
  2465. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2466. /**
  2467. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2468. * @param otherVector defines the second operand
  2469. * @param epsilon defines the minimal distance to define values as equals
  2470. * @returns true if both vectors are distant less than epsilon
  2471. */
  2472. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2473. /**
  2474. * Returns true if the current Vector3 coordinates equals the given floats
  2475. * @param x defines the x coordinate of the operand
  2476. * @param y defines the y coordinate of the operand
  2477. * @param z defines the z coordinate of the operand
  2478. * @returns true if both vectors are equals
  2479. */
  2480. equalsToFloats(x: number, y: number, z: number): boolean;
  2481. /**
  2482. * Multiplies the current Vector3 coordinates by the given ones
  2483. * @param otherVector defines the second operand
  2484. * @returns the current updated Vector3
  2485. */
  2486. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2487. /**
  2488. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2489. * @param otherVector defines the second operand
  2490. * @returns the new Vector3
  2491. */
  2492. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2493. /**
  2494. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2495. * @param otherVector defines the second operand
  2496. * @param result defines the Vector3 object where to store the result
  2497. * @returns the current Vector3
  2498. */
  2499. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2500. /**
  2501. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2502. * @param x defines the x coordinate of the operand
  2503. * @param y defines the y coordinate of the operand
  2504. * @param z defines the z coordinate of the operand
  2505. * @returns the new Vector3
  2506. */
  2507. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2508. /**
  2509. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2510. * @param otherVector defines the second operand
  2511. * @returns the new Vector3
  2512. */
  2513. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2514. /**
  2515. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2516. * @param otherVector defines the second operand
  2517. * @param result defines the Vector3 object where to store the result
  2518. * @returns the current Vector3
  2519. */
  2520. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2521. /**
  2522. * Divides the current Vector3 coordinates by the given ones.
  2523. * @param otherVector defines the second operand
  2524. * @returns the current updated Vector3
  2525. */
  2526. divideInPlace(otherVector: Vector3): Vector3;
  2527. /**
  2528. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2529. * @param other defines the second operand
  2530. * @returns the current updated Vector3
  2531. */
  2532. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2533. /**
  2534. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2535. * @param other defines the second operand
  2536. * @returns the current updated Vector3
  2537. */
  2538. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2539. /**
  2540. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2541. * @param x defines the x coordinate of the operand
  2542. * @param y defines the y coordinate of the operand
  2543. * @param z defines the z coordinate of the operand
  2544. * @returns the current updated Vector3
  2545. */
  2546. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2547. /**
  2548. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2549. * @param x defines the x coordinate of the operand
  2550. * @param y defines the y coordinate of the operand
  2551. * @param z defines the z coordinate of the operand
  2552. * @returns the current updated Vector3
  2553. */
  2554. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2555. /**
  2556. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2557. * Check if is non uniform within a certain amount of decimal places to account for this
  2558. * @param epsilon the amount the values can differ
  2559. * @returns if the the vector is non uniform to a certain number of decimal places
  2560. */
  2561. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2562. /**
  2563. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2564. */
  2565. get isNonUniform(): boolean;
  2566. /**
  2567. * Gets a new Vector3 from current Vector3 floored values
  2568. * @returns a new Vector3
  2569. */
  2570. floor(): Vector3;
  2571. /**
  2572. * Gets a new Vector3 from current Vector3 floored values
  2573. * @returns a new Vector3
  2574. */
  2575. fract(): Vector3;
  2576. /**
  2577. * Gets the length of the Vector3
  2578. * @returns the length of the Vector3
  2579. */
  2580. length(): number;
  2581. /**
  2582. * Gets the squared length of the Vector3
  2583. * @returns squared length of the Vector3
  2584. */
  2585. lengthSquared(): number;
  2586. /**
  2587. * Normalize the current Vector3.
  2588. * Please note that this is an in place operation.
  2589. * @returns the current updated Vector3
  2590. */
  2591. normalize(): Vector3;
  2592. /**
  2593. * Reorders the x y z properties of the vector in place
  2594. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2595. * @returns the current updated vector
  2596. */
  2597. reorderInPlace(order: string): this;
  2598. /**
  2599. * Rotates the vector around 0,0,0 by a quaternion
  2600. * @param quaternion the rotation quaternion
  2601. * @param result vector to store the result
  2602. * @returns the resulting vector
  2603. */
  2604. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2605. /**
  2606. * Rotates a vector around a given point
  2607. * @param quaternion the rotation quaternion
  2608. * @param point the point to rotate around
  2609. * @param result vector to store the result
  2610. * @returns the resulting vector
  2611. */
  2612. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2613. /**
  2614. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2615. * The cross product is then orthogonal to both current and "other"
  2616. * @param other defines the right operand
  2617. * @returns the cross product
  2618. */
  2619. cross(other: Vector3): Vector3;
  2620. /**
  2621. * Normalize the current Vector3 with the given input length.
  2622. * Please note that this is an in place operation.
  2623. * @param len the length of the vector
  2624. * @returns the current updated Vector3
  2625. */
  2626. normalizeFromLength(len: number): Vector3;
  2627. /**
  2628. * Normalize the current Vector3 to a new vector
  2629. * @returns the new Vector3
  2630. */
  2631. normalizeToNew(): Vector3;
  2632. /**
  2633. * Normalize the current Vector3 to the reference
  2634. * @param reference define the Vector3 to update
  2635. * @returns the updated Vector3
  2636. */
  2637. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2638. /**
  2639. * Creates a new Vector3 copied from the current Vector3
  2640. * @returns the new Vector3
  2641. */
  2642. clone(): Vector3;
  2643. /**
  2644. * Copies the given vector coordinates to the current Vector3 ones
  2645. * @param source defines the source Vector3
  2646. * @returns the current updated Vector3
  2647. */
  2648. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2649. /**
  2650. * Copies the given floats to the current Vector3 coordinates
  2651. * @param x defines the x coordinate of the operand
  2652. * @param y defines the y coordinate of the operand
  2653. * @param z defines the z coordinate of the operand
  2654. * @returns the current updated Vector3
  2655. */
  2656. copyFromFloats(x: number, y: number, z: number): Vector3;
  2657. /**
  2658. * Copies the given floats to the current Vector3 coordinates
  2659. * @param x defines the x coordinate of the operand
  2660. * @param y defines the y coordinate of the operand
  2661. * @param z defines the z coordinate of the operand
  2662. * @returns the current updated Vector3
  2663. */
  2664. set(x: number, y: number, z: number): Vector3;
  2665. /**
  2666. * Copies the given float to the current Vector3 coordinates
  2667. * @param v defines the x, y and z coordinates of the operand
  2668. * @returns the current updated Vector3
  2669. */
  2670. setAll(v: number): Vector3;
  2671. /**
  2672. * Get the clip factor between two vectors
  2673. * @param vector0 defines the first operand
  2674. * @param vector1 defines the second operand
  2675. * @param axis defines the axis to use
  2676. * @param size defines the size along the axis
  2677. * @returns the clip factor
  2678. */
  2679. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2680. /**
  2681. * Get angle between two vectors
  2682. * @param vector0 angle between vector0 and vector1
  2683. * @param vector1 angle between vector0 and vector1
  2684. * @param normal direction of the normal
  2685. * @return the angle between vector0 and vector1
  2686. */
  2687. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2688. /**
  2689. * Returns a new Vector3 set from the index "offset" of the given array
  2690. * @param array defines the source array
  2691. * @param offset defines the offset in the source array
  2692. * @returns the new Vector3
  2693. */
  2694. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2695. /**
  2696. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2697. * @param array defines the source array
  2698. * @param offset defines the offset in the source array
  2699. * @returns the new Vector3
  2700. * @deprecated Please use FromArray instead.
  2701. */
  2702. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2703. /**
  2704. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2705. * @param array defines the source array
  2706. * @param offset defines the offset in the source array
  2707. * @param result defines the Vector3 where to store the result
  2708. */
  2709. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2710. /**
  2711. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2712. * @param array defines the source array
  2713. * @param offset defines the offset in the source array
  2714. * @param result defines the Vector3 where to store the result
  2715. * @deprecated Please use FromArrayToRef instead.
  2716. */
  2717. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2718. /**
  2719. * Sets the given vector "result" with the given floats.
  2720. * @param x defines the x coordinate of the source
  2721. * @param y defines the y coordinate of the source
  2722. * @param z defines the z coordinate of the source
  2723. * @param result defines the Vector3 where to store the result
  2724. */
  2725. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2726. /**
  2727. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2728. * @returns a new empty Vector3
  2729. */
  2730. static Zero(): Vector3;
  2731. /**
  2732. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2733. * @returns a new unit Vector3
  2734. */
  2735. static One(): Vector3;
  2736. /**
  2737. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2738. * @returns a new up Vector3
  2739. */
  2740. static Up(): Vector3;
  2741. /**
  2742. * Gets a up Vector3 that must not be updated
  2743. */
  2744. static get UpReadOnly(): DeepImmutable<Vector3>;
  2745. /**
  2746. * Gets a zero Vector3 that must not be updated
  2747. */
  2748. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2749. /**
  2750. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2751. * @returns a new down Vector3
  2752. */
  2753. static Down(): Vector3;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2756. * @returns a new forward Vector3
  2757. */
  2758. static Forward(): Vector3;
  2759. /**
  2760. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2761. * @returns a new forward Vector3
  2762. */
  2763. static Backward(): Vector3;
  2764. /**
  2765. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2766. * @returns a new right Vector3
  2767. */
  2768. static Right(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2771. * @returns a new left Vector3
  2772. */
  2773. static Left(): Vector3;
  2774. /**
  2775. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2776. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2777. * @param vector defines the Vector3 to transform
  2778. * @param transformation defines the transformation matrix
  2779. * @returns the transformed Vector3
  2780. */
  2781. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2782. /**
  2783. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2784. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2785. * @param vector defines the Vector3 to transform
  2786. * @param transformation defines the transformation matrix
  2787. * @param result defines the Vector3 where to store the result
  2788. */
  2789. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2790. /**
  2791. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2792. * This method computes tranformed coordinates only, not transformed direction vectors
  2793. * @param x define the x coordinate of the source vector
  2794. * @param y define the y coordinate of the source vector
  2795. * @param z define the z coordinate of the source vector
  2796. * @param transformation defines the transformation matrix
  2797. * @param result defines the Vector3 where to store the result
  2798. */
  2799. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2800. /**
  2801. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2802. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2803. * @param vector defines the Vector3 to transform
  2804. * @param transformation defines the transformation matrix
  2805. * @returns the new Vector3
  2806. */
  2807. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2808. /**
  2809. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2810. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2811. * @param vector defines the Vector3 to transform
  2812. * @param transformation defines the transformation matrix
  2813. * @param result defines the Vector3 where to store the result
  2814. */
  2815. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2816. /**
  2817. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2818. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2819. * @param x define the x coordinate of the source vector
  2820. * @param y define the y coordinate of the source vector
  2821. * @param z define the z coordinate of the source vector
  2822. * @param transformation defines the transformation matrix
  2823. * @param result defines the Vector3 where to store the result
  2824. */
  2825. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2826. /**
  2827. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2828. * @param value1 defines the first control point
  2829. * @param value2 defines the second control point
  2830. * @param value3 defines the third control point
  2831. * @param value4 defines the fourth control point
  2832. * @param amount defines the amount on the spline to use
  2833. * @returns the new Vector3
  2834. */
  2835. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2836. /**
  2837. * 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"
  2838. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2839. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2840. * @param value defines the current value
  2841. * @param min defines the lower range value
  2842. * @param max defines the upper range value
  2843. * @returns the new Vector3
  2844. */
  2845. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2846. /**
  2847. * 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"
  2848. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2849. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2850. * @param value defines the current value
  2851. * @param min defines the lower range value
  2852. * @param max defines the upper range value
  2853. * @param result defines the Vector3 where to store the result
  2854. */
  2855. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2856. /**
  2857. * Checks if a given vector is inside a specific range
  2858. * @param v defines the vector to test
  2859. * @param min defines the minimum range
  2860. * @param max defines the maximum range
  2861. */
  2862. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2863. /**
  2864. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2865. * @param value1 defines the first control point
  2866. * @param tangent1 defines the first tangent vector
  2867. * @param value2 defines the second control point
  2868. * @param tangent2 defines the second tangent vector
  2869. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2870. * @returns the new Vector3
  2871. */
  2872. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2873. /**
  2874. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2875. * @param start defines the start value
  2876. * @param end defines the end value
  2877. * @param amount max defines amount between both (between 0 and 1)
  2878. * @returns the new Vector3
  2879. */
  2880. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2881. /**
  2882. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2883. * @param start defines the start value
  2884. * @param end defines the end value
  2885. * @param amount max defines amount between both (between 0 and 1)
  2886. * @param result defines the Vector3 where to store the result
  2887. */
  2888. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2889. /**
  2890. * Returns the dot product (float) between the vectors "left" and "right"
  2891. * @param left defines the left operand
  2892. * @param right defines the right operand
  2893. * @returns the dot product
  2894. */
  2895. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2896. /**
  2897. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2898. * The cross product is then orthogonal to both "left" and "right"
  2899. * @param left defines the left operand
  2900. * @param right defines the right operand
  2901. * @returns the cross product
  2902. */
  2903. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2904. /**
  2905. * Sets the given vector "result" with the cross product of "left" and "right"
  2906. * The cross product is then orthogonal to both "left" and "right"
  2907. * @param left defines the left operand
  2908. * @param right defines the right operand
  2909. * @param result defines the Vector3 where to store the result
  2910. */
  2911. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2912. /**
  2913. * Returns a new Vector3 as the normalization of the given vector
  2914. * @param vector defines the Vector3 to normalize
  2915. * @returns the new Vector3
  2916. */
  2917. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2918. /**
  2919. * Sets the given vector "result" with the normalization of the given first vector
  2920. * @param vector defines the Vector3 to normalize
  2921. * @param result defines the Vector3 where to store the result
  2922. */
  2923. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2924. /**
  2925. * Project a Vector3 onto screen space
  2926. * @param vector defines the Vector3 to project
  2927. * @param world defines the world matrix to use
  2928. * @param transform defines the transform (view x projection) matrix to use
  2929. * @param viewport defines the screen viewport to use
  2930. * @returns the new Vector3
  2931. */
  2932. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2933. /** @hidden */
  2934. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2935. /**
  2936. * Unproject from screen space to object space
  2937. * @param source defines the screen space Vector3 to use
  2938. * @param viewportWidth defines the current width of the viewport
  2939. * @param viewportHeight defines the current height of the viewport
  2940. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2941. * @param transform defines the transform (view x projection) matrix to use
  2942. * @returns the new Vector3
  2943. */
  2944. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2945. /**
  2946. * Unproject from screen space to object space
  2947. * @param source defines the screen space Vector3 to use
  2948. * @param viewportWidth defines the current width of the viewport
  2949. * @param viewportHeight defines the current height of the viewport
  2950. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2951. * @param view defines the view matrix to use
  2952. * @param projection defines the projection matrix to use
  2953. * @returns the new Vector3
  2954. */
  2955. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2956. /**
  2957. * Unproject from screen space to object space
  2958. * @param source defines the screen space Vector3 to use
  2959. * @param viewportWidth defines the current width of the viewport
  2960. * @param viewportHeight defines the current height of the viewport
  2961. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2962. * @param view defines the view matrix to use
  2963. * @param projection defines the projection matrix to use
  2964. * @param result defines the Vector3 where to store the result
  2965. */
  2966. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2967. /**
  2968. * Unproject from screen space to object space
  2969. * @param sourceX defines the screen space x coordinate to use
  2970. * @param sourceY defines the screen space y coordinate to use
  2971. * @param sourceZ defines the screen space z coordinate to use
  2972. * @param viewportWidth defines the current width of the viewport
  2973. * @param viewportHeight defines the current height of the viewport
  2974. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2975. * @param view defines the view matrix to use
  2976. * @param projection defines the projection matrix to use
  2977. * @param result defines the Vector3 where to store the result
  2978. */
  2979. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2980. /**
  2981. * Gets the minimal coordinate values between two Vector3
  2982. * @param left defines the first operand
  2983. * @param right defines the second operand
  2984. * @returns the new Vector3
  2985. */
  2986. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2987. /**
  2988. * Gets the maximal coordinate values between two Vector3
  2989. * @param left defines the first operand
  2990. * @param right defines the second operand
  2991. * @returns the new Vector3
  2992. */
  2993. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2994. /**
  2995. * Returns the distance between the vectors "value1" and "value2"
  2996. * @param value1 defines the first operand
  2997. * @param value2 defines the second operand
  2998. * @returns the distance
  2999. */
  3000. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3001. /**
  3002. * Returns the squared distance between the vectors "value1" and "value2"
  3003. * @param value1 defines the first operand
  3004. * @param value2 defines the second operand
  3005. * @returns the squared distance
  3006. */
  3007. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3008. /**
  3009. * Returns a new Vector3 located at the center between "value1" and "value2"
  3010. * @param value1 defines the first operand
  3011. * @param value2 defines the second operand
  3012. * @returns the new Vector3
  3013. */
  3014. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3015. /**
  3016. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3017. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3018. * to something in order to rotate it from its local system to the given target system
  3019. * Note: axis1, axis2 and axis3 are normalized during this operation
  3020. * @param axis1 defines the first axis
  3021. * @param axis2 defines the second axis
  3022. * @param axis3 defines the third axis
  3023. * @returns a new Vector3
  3024. */
  3025. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3026. /**
  3027. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3028. * @param axis1 defines the first axis
  3029. * @param axis2 defines the second axis
  3030. * @param axis3 defines the third axis
  3031. * @param ref defines the Vector3 where to store the result
  3032. */
  3033. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3034. }
  3035. /**
  3036. * Vector4 class created for EulerAngle class conversion to Quaternion
  3037. */
  3038. export class Vector4 {
  3039. /** x value of the vector */
  3040. x: number;
  3041. /** y value of the vector */
  3042. y: number;
  3043. /** z value of the vector */
  3044. z: number;
  3045. /** w value of the vector */
  3046. w: number;
  3047. /**
  3048. * Creates a Vector4 object from the given floats.
  3049. * @param x x value of the vector
  3050. * @param y y value of the vector
  3051. * @param z z value of the vector
  3052. * @param w w value of the vector
  3053. */
  3054. constructor(
  3055. /** x value of the vector */
  3056. x: number,
  3057. /** y value of the vector */
  3058. y: number,
  3059. /** z value of the vector */
  3060. z: number,
  3061. /** w value of the vector */
  3062. w: number);
  3063. /**
  3064. * Returns the string with the Vector4 coordinates.
  3065. * @returns a string containing all the vector values
  3066. */
  3067. toString(): string;
  3068. /**
  3069. * Returns the string "Vector4".
  3070. * @returns "Vector4"
  3071. */
  3072. getClassName(): string;
  3073. /**
  3074. * Returns the Vector4 hash code.
  3075. * @returns a unique hash code
  3076. */
  3077. getHashCode(): number;
  3078. /**
  3079. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3080. * @returns the resulting array
  3081. */
  3082. asArray(): number[];
  3083. /**
  3084. * Populates the given array from the given index with the Vector4 coordinates.
  3085. * @param array array to populate
  3086. * @param index index of the array to start at (default: 0)
  3087. * @returns the Vector4.
  3088. */
  3089. toArray(array: FloatArray, index?: number): Vector4;
  3090. /**
  3091. * Adds the given vector to the current Vector4.
  3092. * @param otherVector the vector to add
  3093. * @returns the updated Vector4.
  3094. */
  3095. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3096. /**
  3097. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3098. * @param otherVector the vector to add
  3099. * @returns the resulting vector
  3100. */
  3101. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3102. /**
  3103. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3104. * @param otherVector the vector to add
  3105. * @param result the vector to store the result
  3106. * @returns the current Vector4.
  3107. */
  3108. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3109. /**
  3110. * Subtract in place the given vector from the current Vector4.
  3111. * @param otherVector the vector to subtract
  3112. * @returns the updated Vector4.
  3113. */
  3114. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3115. /**
  3116. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3117. * @param otherVector the vector to add
  3118. * @returns the new vector with the result
  3119. */
  3120. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3121. /**
  3122. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3123. * @param otherVector the vector to subtract
  3124. * @param result the vector to store the result
  3125. * @returns the current Vector4.
  3126. */
  3127. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3128. /**
  3129. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3130. */
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. * @param x value to subtract
  3134. * @param y value to subtract
  3135. * @param z value to subtract
  3136. * @param w value to subtract
  3137. * @returns new vector containing the result
  3138. */
  3139. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3140. /**
  3141. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3142. * @param x value to subtract
  3143. * @param y value to subtract
  3144. * @param z value to subtract
  3145. * @param w value to subtract
  3146. * @param result the vector to store the result in
  3147. * @returns the current Vector4.
  3148. */
  3149. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3150. /**
  3151. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3152. * @returns a new vector with the negated values
  3153. */
  3154. negate(): Vector4;
  3155. /**
  3156. * Negate this vector in place
  3157. * @returns this
  3158. */
  3159. negateInPlace(): Vector4;
  3160. /**
  3161. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3162. * @param result defines the Vector3 object where to store the result
  3163. * @returns the current Vector4
  3164. */
  3165. negateToRef(result: Vector4): Vector4;
  3166. /**
  3167. * Multiplies the current Vector4 coordinates by scale (float).
  3168. * @param scale the number to scale with
  3169. * @returns the updated Vector4.
  3170. */
  3171. scaleInPlace(scale: number): Vector4;
  3172. /**
  3173. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3174. * @param scale the number to scale with
  3175. * @returns a new vector with the result
  3176. */
  3177. scale(scale: number): Vector4;
  3178. /**
  3179. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3180. * @param scale the number to scale with
  3181. * @param result a vector to store the result in
  3182. * @returns the current Vector4.
  3183. */
  3184. scaleToRef(scale: number, result: Vector4): Vector4;
  3185. /**
  3186. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3187. * @param scale defines the scale factor
  3188. * @param result defines the Vector4 object where to store the result
  3189. * @returns the unmodified current Vector4
  3190. */
  3191. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3192. /**
  3193. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3194. * @param otherVector the vector to compare against
  3195. * @returns true if they are equal
  3196. */
  3197. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3198. /**
  3199. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3200. * @param otherVector vector to compare against
  3201. * @param epsilon (Default: very small number)
  3202. * @returns true if they are equal
  3203. */
  3204. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3205. /**
  3206. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3207. * @param x x value to compare against
  3208. * @param y y value to compare against
  3209. * @param z z value to compare against
  3210. * @param w w value to compare against
  3211. * @returns true if equal
  3212. */
  3213. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3214. /**
  3215. * Multiplies in place the current Vector4 by the given one.
  3216. * @param otherVector vector to multiple with
  3217. * @returns the updated Vector4.
  3218. */
  3219. multiplyInPlace(otherVector: Vector4): Vector4;
  3220. /**
  3221. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3222. * @param otherVector vector to multiple with
  3223. * @returns resulting new vector
  3224. */
  3225. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3226. /**
  3227. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3228. * @param otherVector vector to multiple with
  3229. * @param result vector to store the result
  3230. * @returns the current Vector4.
  3231. */
  3232. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3233. /**
  3234. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3235. * @param x x value multiply with
  3236. * @param y y value multiply with
  3237. * @param z z value multiply with
  3238. * @param w w value multiply with
  3239. * @returns resulting new vector
  3240. */
  3241. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3242. /**
  3243. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3244. * @param otherVector vector to devide with
  3245. * @returns resulting new vector
  3246. */
  3247. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3248. /**
  3249. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3250. * @param otherVector vector to devide with
  3251. * @param result vector to store the result
  3252. * @returns the current Vector4.
  3253. */
  3254. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3255. /**
  3256. * Divides the current Vector3 coordinates by the given ones.
  3257. * @param otherVector vector to devide with
  3258. * @returns the updated Vector3.
  3259. */
  3260. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3261. /**
  3262. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3263. * @param other defines the second operand
  3264. * @returns the current updated Vector4
  3265. */
  3266. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3267. /**
  3268. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3269. * @param other defines the second operand
  3270. * @returns the current updated Vector4
  3271. */
  3272. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3273. /**
  3274. * Gets a new Vector4 from current Vector4 floored values
  3275. * @returns a new Vector4
  3276. */
  3277. floor(): Vector4;
  3278. /**
  3279. * Gets a new Vector4 from current Vector3 floored values
  3280. * @returns a new Vector4
  3281. */
  3282. fract(): Vector4;
  3283. /**
  3284. * Returns the Vector4 length (float).
  3285. * @returns the length
  3286. */
  3287. length(): number;
  3288. /**
  3289. * Returns the Vector4 squared length (float).
  3290. * @returns the length squared
  3291. */
  3292. lengthSquared(): number;
  3293. /**
  3294. * Normalizes in place the Vector4.
  3295. * @returns the updated Vector4.
  3296. */
  3297. normalize(): Vector4;
  3298. /**
  3299. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3300. * @returns this converted to a new vector3
  3301. */
  3302. toVector3(): Vector3;
  3303. /**
  3304. * Returns a new Vector4 copied from the current one.
  3305. * @returns the new cloned vector
  3306. */
  3307. clone(): Vector4;
  3308. /**
  3309. * Updates the current Vector4 with the given one coordinates.
  3310. * @param source the source vector to copy from
  3311. * @returns the updated Vector4.
  3312. */
  3313. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3314. /**
  3315. * Updates the current Vector4 coordinates with the given floats.
  3316. * @param x float to copy from
  3317. * @param y float to copy from
  3318. * @param z float to copy from
  3319. * @param w float to copy from
  3320. * @returns the updated Vector4.
  3321. */
  3322. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3323. /**
  3324. * Updates the current Vector4 coordinates with the given floats.
  3325. * @param x float to set from
  3326. * @param y float to set from
  3327. * @param z float to set from
  3328. * @param w float to set from
  3329. * @returns the updated Vector4.
  3330. */
  3331. set(x: number, y: number, z: number, w: number): Vector4;
  3332. /**
  3333. * Copies the given float to the current Vector3 coordinates
  3334. * @param v defines the x, y, z and w coordinates of the operand
  3335. * @returns the current updated Vector3
  3336. */
  3337. setAll(v: number): Vector4;
  3338. /**
  3339. * Returns a new Vector4 set from the starting index of the given array.
  3340. * @param array the array to pull values from
  3341. * @param offset the offset into the array to start at
  3342. * @returns the new vector
  3343. */
  3344. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3345. /**
  3346. * Updates the given vector "result" from the starting index of the given array.
  3347. * @param array the array to pull values from
  3348. * @param offset the offset into the array to start at
  3349. * @param result the vector to store the result in
  3350. */
  3351. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3352. /**
  3353. * Updates the given vector "result" from the starting index of the given Float32Array.
  3354. * @param array the array to pull values from
  3355. * @param offset the offset into the array to start at
  3356. * @param result the vector to store the result in
  3357. */
  3358. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3359. /**
  3360. * Updates the given vector "result" coordinates from the given floats.
  3361. * @param x float to set from
  3362. * @param y float to set from
  3363. * @param z float to set from
  3364. * @param w float to set from
  3365. * @param result the vector to the floats in
  3366. */
  3367. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3368. /**
  3369. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3370. * @returns the new vector
  3371. */
  3372. static Zero(): Vector4;
  3373. /**
  3374. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3375. * @returns the new vector
  3376. */
  3377. static One(): Vector4;
  3378. /**
  3379. * Returns a new normalized Vector4 from the given one.
  3380. * @param vector the vector to normalize
  3381. * @returns the vector
  3382. */
  3383. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3384. /**
  3385. * Updates the given vector "result" from the normalization of the given one.
  3386. * @param vector the vector to normalize
  3387. * @param result the vector to store the result in
  3388. */
  3389. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3390. /**
  3391. * Returns a vector with the minimum values from the left and right vectors
  3392. * @param left left vector to minimize
  3393. * @param right right vector to minimize
  3394. * @returns a new vector with the minimum of the left and right vector values
  3395. */
  3396. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3397. /**
  3398. * Returns a vector with the maximum values from the left and right vectors
  3399. * @param left left vector to maximize
  3400. * @param right right vector to maximize
  3401. * @returns a new vector with the maximum of the left and right vector values
  3402. */
  3403. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Returns the distance (float) between the vectors "value1" and "value2".
  3406. * @param value1 value to calulate the distance between
  3407. * @param value2 value to calulate the distance between
  3408. * @return the distance between the two vectors
  3409. */
  3410. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3411. /**
  3412. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3413. * @param value1 value to calulate the distance between
  3414. * @param value2 value to calulate the distance between
  3415. * @return the distance between the two vectors squared
  3416. */
  3417. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3418. /**
  3419. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3420. * @param value1 value to calulate the center between
  3421. * @param value2 value to calulate the center between
  3422. * @return the center between the two vectors
  3423. */
  3424. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3425. /**
  3426. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3427. * This methods computes transformed normalized direction vectors only.
  3428. * @param vector the vector to transform
  3429. * @param transformation the transformation matrix to apply
  3430. * @returns the new vector
  3431. */
  3432. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3433. /**
  3434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3435. * This methods computes transformed normalized direction vectors only.
  3436. * @param vector the vector to transform
  3437. * @param transformation the transformation matrix to apply
  3438. * @param result the vector to store the result in
  3439. */
  3440. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3441. /**
  3442. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3443. * This methods computes transformed normalized direction vectors only.
  3444. * @param x value to transform
  3445. * @param y value to transform
  3446. * @param z value to transform
  3447. * @param w value to transform
  3448. * @param transformation the transformation matrix to apply
  3449. * @param result the vector to store the results in
  3450. */
  3451. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3452. /**
  3453. * Creates a new Vector4 from a Vector3
  3454. * @param source defines the source data
  3455. * @param w defines the 4th component (default is 0)
  3456. * @returns a new Vector4
  3457. */
  3458. static FromVector3(source: Vector3, w?: number): Vector4;
  3459. }
  3460. /**
  3461. * Class used to store quaternion data
  3462. * @see https://en.wikipedia.org/wiki/Quaternion
  3463. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3464. */
  3465. export class Quaternion {
  3466. /** defines the first component (0 by default) */
  3467. x: number;
  3468. /** defines the second component (0 by default) */
  3469. y: number;
  3470. /** defines the third component (0 by default) */
  3471. z: number;
  3472. /** defines the fourth component (1.0 by default) */
  3473. w: number;
  3474. /**
  3475. * Creates a new Quaternion from the given floats
  3476. * @param x defines the first component (0 by default)
  3477. * @param y defines the second component (0 by default)
  3478. * @param z defines the third component (0 by default)
  3479. * @param w defines the fourth component (1.0 by default)
  3480. */
  3481. constructor(
  3482. /** defines the first component (0 by default) */
  3483. x?: number,
  3484. /** defines the second component (0 by default) */
  3485. y?: number,
  3486. /** defines the third component (0 by default) */
  3487. z?: number,
  3488. /** defines the fourth component (1.0 by default) */
  3489. w?: number);
  3490. /**
  3491. * Gets a string representation for the current quaternion
  3492. * @returns a string with the Quaternion coordinates
  3493. */
  3494. toString(): string;
  3495. /**
  3496. * Gets the class name of the quaternion
  3497. * @returns the string "Quaternion"
  3498. */
  3499. getClassName(): string;
  3500. /**
  3501. * Gets a hash code for this quaternion
  3502. * @returns the quaternion hash code
  3503. */
  3504. getHashCode(): number;
  3505. /**
  3506. * Copy the quaternion to an array
  3507. * @returns a new array populated with 4 elements from the quaternion coordinates
  3508. */
  3509. asArray(): number[];
  3510. /**
  3511. * Check if two quaternions are equals
  3512. * @param otherQuaternion defines the second operand
  3513. * @return true if the current quaternion and the given one coordinates are strictly equals
  3514. */
  3515. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3516. /**
  3517. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3518. * @param otherQuaternion defines the other quaternion
  3519. * @param epsilon defines the minimal distance to consider equality
  3520. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3521. */
  3522. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3523. /**
  3524. * Clone the current quaternion
  3525. * @returns a new quaternion copied from the current one
  3526. */
  3527. clone(): Quaternion;
  3528. /**
  3529. * Copy a quaternion to the current one
  3530. * @param other defines the other quaternion
  3531. * @returns the updated current quaternion
  3532. */
  3533. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3534. /**
  3535. * Updates the current quaternion with the given float coordinates
  3536. * @param x defines the x coordinate
  3537. * @param y defines the y coordinate
  3538. * @param z defines the z coordinate
  3539. * @param w defines the w coordinate
  3540. * @returns the updated current quaternion
  3541. */
  3542. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3543. /**
  3544. * Updates the current quaternion from the given float coordinates
  3545. * @param x defines the x coordinate
  3546. * @param y defines the y coordinate
  3547. * @param z defines the z coordinate
  3548. * @param w defines the w coordinate
  3549. * @returns the updated current quaternion
  3550. */
  3551. set(x: number, y: number, z: number, w: number): Quaternion;
  3552. /**
  3553. * Adds two quaternions
  3554. * @param other defines the second operand
  3555. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3556. */
  3557. add(other: DeepImmutable<Quaternion>): Quaternion;
  3558. /**
  3559. * Add a quaternion to the current one
  3560. * @param other defines the quaternion to add
  3561. * @returns the current quaternion
  3562. */
  3563. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3564. /**
  3565. * Subtract two quaternions
  3566. * @param other defines the second operand
  3567. * @returns a new quaternion as the subtraction result of the given one from the current one
  3568. */
  3569. subtract(other: Quaternion): Quaternion;
  3570. /**
  3571. * Multiplies the current quaternion by a scale factor
  3572. * @param value defines the scale factor
  3573. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3574. */
  3575. scale(value: number): Quaternion;
  3576. /**
  3577. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3578. * @param scale defines the scale factor
  3579. * @param result defines the Quaternion object where to store the result
  3580. * @returns the unmodified current quaternion
  3581. */
  3582. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3583. /**
  3584. * Multiplies in place the current quaternion by a scale factor
  3585. * @param value defines the scale factor
  3586. * @returns the current modified quaternion
  3587. */
  3588. scaleInPlace(value: number): Quaternion;
  3589. /**
  3590. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3591. * @param scale defines the scale factor
  3592. * @param result defines the Quaternion object where to store the result
  3593. * @returns the unmodified current quaternion
  3594. */
  3595. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3596. /**
  3597. * Multiplies two quaternions
  3598. * @param q1 defines the second operand
  3599. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3600. */
  3601. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3602. /**
  3603. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3604. * @param q1 defines the second operand
  3605. * @param result defines the target quaternion
  3606. * @returns the current quaternion
  3607. */
  3608. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3609. /**
  3610. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3611. * @param q1 defines the second operand
  3612. * @returns the currentupdated quaternion
  3613. */
  3614. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3615. /**
  3616. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3617. * @param ref defines the target quaternion
  3618. * @returns the current quaternion
  3619. */
  3620. conjugateToRef(ref: Quaternion): Quaternion;
  3621. /**
  3622. * Conjugates in place (1-q) the current quaternion
  3623. * @returns the current updated quaternion
  3624. */
  3625. conjugateInPlace(): Quaternion;
  3626. /**
  3627. * Conjugates in place (1-q) the current quaternion
  3628. * @returns a new quaternion
  3629. */
  3630. conjugate(): Quaternion;
  3631. /**
  3632. * Gets length of current quaternion
  3633. * @returns the quaternion length (float)
  3634. */
  3635. length(): number;
  3636. /**
  3637. * Normalize in place the current quaternion
  3638. * @returns the current updated quaternion
  3639. */
  3640. normalize(): Quaternion;
  3641. /**
  3642. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3643. * @param order is a reserved parameter and is ignore for now
  3644. * @returns a new Vector3 containing the Euler angles
  3645. */
  3646. toEulerAngles(order?: string): Vector3;
  3647. /**
  3648. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3649. * @param result defines the vector which will be filled with the Euler angles
  3650. * @param order is a reserved parameter and is ignore for now
  3651. * @returns the current unchanged quaternion
  3652. */
  3653. toEulerAnglesToRef(result: Vector3): Quaternion;
  3654. /**
  3655. * Updates the given rotation matrix with the current quaternion values
  3656. * @param result defines the target matrix
  3657. * @returns the current unchanged quaternion
  3658. */
  3659. toRotationMatrix(result: Matrix): Quaternion;
  3660. /**
  3661. * Updates the current quaternion from the given rotation matrix values
  3662. * @param matrix defines the source matrix
  3663. * @returns the current updated quaternion
  3664. */
  3665. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3666. /**
  3667. * Creates a new quaternion from a rotation matrix
  3668. * @param matrix defines the source matrix
  3669. * @returns a new quaternion created from the given rotation matrix values
  3670. */
  3671. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3672. /**
  3673. * Updates the given quaternion with the given rotation matrix values
  3674. * @param matrix defines the source matrix
  3675. * @param result defines the target quaternion
  3676. */
  3677. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3678. /**
  3679. * Returns the dot product (float) between the quaternions "left" and "right"
  3680. * @param left defines the left operand
  3681. * @param right defines the right operand
  3682. * @returns the dot product
  3683. */
  3684. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3685. /**
  3686. * Checks if the two quaternions are close to each other
  3687. * @param quat0 defines the first quaternion to check
  3688. * @param quat1 defines the second quaternion to check
  3689. * @returns true if the two quaternions are close to each other
  3690. */
  3691. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3692. /**
  3693. * Creates an empty quaternion
  3694. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3695. */
  3696. static Zero(): Quaternion;
  3697. /**
  3698. * Inverse a given quaternion
  3699. * @param q defines the source quaternion
  3700. * @returns a new quaternion as the inverted current quaternion
  3701. */
  3702. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3703. /**
  3704. * Inverse a given quaternion
  3705. * @param q defines the source quaternion
  3706. * @param result the quaternion the result will be stored in
  3707. * @returns the result quaternion
  3708. */
  3709. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3710. /**
  3711. * Creates an identity quaternion
  3712. * @returns the identity quaternion
  3713. */
  3714. static Identity(): Quaternion;
  3715. /**
  3716. * Gets a boolean indicating if the given quaternion is identity
  3717. * @param quaternion defines the quaternion to check
  3718. * @returns true if the quaternion is identity
  3719. */
  3720. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3721. /**
  3722. * Creates a quaternion from a rotation around an axis
  3723. * @param axis defines the axis to use
  3724. * @param angle defines the angle to use
  3725. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3726. */
  3727. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3728. /**
  3729. * Creates a rotation around an axis and stores it into the given quaternion
  3730. * @param axis defines the axis to use
  3731. * @param angle defines the angle to use
  3732. * @param result defines the target quaternion
  3733. * @returns the target quaternion
  3734. */
  3735. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3736. /**
  3737. * Creates a new quaternion from data stored into an array
  3738. * @param array defines the data source
  3739. * @param offset defines the offset in the source array where the data starts
  3740. * @returns a new quaternion
  3741. */
  3742. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3743. /**
  3744. * Updates the given quaternion "result" from the starting index of the given array.
  3745. * @param array the array to pull values from
  3746. * @param offset the offset into the array to start at
  3747. * @param result the quaternion to store the result in
  3748. */
  3749. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3750. /**
  3751. * Create a quaternion from Euler rotation angles
  3752. * @param x Pitch
  3753. * @param y Yaw
  3754. * @param z Roll
  3755. * @returns the new Quaternion
  3756. */
  3757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3758. /**
  3759. * Updates a quaternion from Euler rotation angles
  3760. * @param x Pitch
  3761. * @param y Yaw
  3762. * @param z Roll
  3763. * @param result the quaternion to store the result
  3764. * @returns the updated quaternion
  3765. */
  3766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3767. /**
  3768. * Create a quaternion from Euler rotation vector
  3769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3770. * @returns the new Quaternion
  3771. */
  3772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3773. /**
  3774. * Updates a quaternion from Euler rotation vector
  3775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3776. * @param result the quaternion to store the result
  3777. * @returns the updated quaternion
  3778. */
  3779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3780. /**
  3781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3782. * @param yaw defines the rotation around Y axis
  3783. * @param pitch defines the rotation around X axis
  3784. * @param roll defines the rotation around Z axis
  3785. * @returns the new quaternion
  3786. */
  3787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3788. /**
  3789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3790. * @param yaw defines the rotation around Y axis
  3791. * @param pitch defines the rotation around X axis
  3792. * @param roll defines the rotation around Z axis
  3793. * @param result defines the target quaternion
  3794. */
  3795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3796. /**
  3797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3798. * @param alpha defines the rotation around first axis
  3799. * @param beta defines the rotation around second axis
  3800. * @param gamma defines the rotation around third axis
  3801. * @returns the new quaternion
  3802. */
  3803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3804. /**
  3805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3806. * @param alpha defines the rotation around first axis
  3807. * @param beta defines the rotation around second axis
  3808. * @param gamma defines the rotation around third axis
  3809. * @param result defines the target quaternion
  3810. */
  3811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3812. /**
  3813. * 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)
  3814. * @param axis1 defines the first axis
  3815. * @param axis2 defines the second axis
  3816. * @param axis3 defines the third axis
  3817. * @returns the new quaternion
  3818. */
  3819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3820. /**
  3821. * 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
  3822. * @param axis1 defines the first axis
  3823. * @param axis2 defines the second axis
  3824. * @param axis3 defines the third axis
  3825. * @param ref defines the target quaternion
  3826. */
  3827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3828. /**
  3829. * Interpolates between two quaternions
  3830. * @param left defines first quaternion
  3831. * @param right defines second quaternion
  3832. * @param amount defines the gradient to use
  3833. * @returns the new interpolated quaternion
  3834. */
  3835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3836. /**
  3837. * Interpolates between two quaternions and stores it into a target quaternion
  3838. * @param left defines first quaternion
  3839. * @param right defines second quaternion
  3840. * @param amount defines the gradient to use
  3841. * @param result defines the target quaternion
  3842. */
  3843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3844. /**
  3845. * Interpolate between two quaternions using Hermite interpolation
  3846. * @param value1 defines first quaternion
  3847. * @param tangent1 defines the incoming tangent
  3848. * @param value2 defines second quaternion
  3849. * @param tangent2 defines the outgoing tangent
  3850. * @param amount defines the target quaternion
  3851. * @returns the new interpolated quaternion
  3852. */
  3853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3854. }
  3855. /**
  3856. * Class used to store matrix data (4x4)
  3857. */
  3858. export class Matrix {
  3859. private static _updateFlagSeed;
  3860. private static _identityReadOnly;
  3861. private _isIdentity;
  3862. private _isIdentityDirty;
  3863. private _isIdentity3x2;
  3864. private _isIdentity3x2Dirty;
  3865. /**
  3866. * Gets the update flag of the matrix which is an unique number for the matrix.
  3867. * It will be incremented every time the matrix data change.
  3868. * You can use it to speed the comparison between two versions of the same matrix.
  3869. */
  3870. updateFlag: number;
  3871. private readonly _m;
  3872. /**
  3873. * Gets the internal data of the matrix
  3874. */
  3875. get m(): DeepImmutable<Float32Array>;
  3876. /** @hidden */
  3877. _markAsUpdated(): void;
  3878. /** @hidden */
  3879. private _updateIdentityStatus;
  3880. /**
  3881. * Creates an empty matrix (filled with zeros)
  3882. */
  3883. constructor();
  3884. /**
  3885. * Check if the current matrix is identity
  3886. * @returns true is the matrix is the identity matrix
  3887. */
  3888. isIdentity(): boolean;
  3889. /**
  3890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3891. * @returns true is the matrix is the identity matrix
  3892. */
  3893. isIdentityAs3x2(): boolean;
  3894. /**
  3895. * Gets the determinant of the matrix
  3896. * @returns the matrix determinant
  3897. */
  3898. determinant(): number;
  3899. /**
  3900. * Returns the matrix as a Float32Array
  3901. * @returns the matrix underlying array
  3902. */
  3903. toArray(): DeepImmutable<Float32Array>;
  3904. /**
  3905. * Returns the matrix as a Float32Array
  3906. * @returns the matrix underlying array.
  3907. */
  3908. asArray(): DeepImmutable<Float32Array>;
  3909. /**
  3910. * Inverts the current matrix in place
  3911. * @returns the current inverted matrix
  3912. */
  3913. invert(): Matrix;
  3914. /**
  3915. * Sets all the matrix elements to zero
  3916. * @returns the current matrix
  3917. */
  3918. reset(): Matrix;
  3919. /**
  3920. * Adds the current matrix with a second one
  3921. * @param other defines the matrix to add
  3922. * @returns a new matrix as the addition of the current matrix and the given one
  3923. */
  3924. add(other: DeepImmutable<Matrix>): Matrix;
  3925. /**
  3926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3927. * @param other defines the matrix to add
  3928. * @param result defines the target matrix
  3929. * @returns the current matrix
  3930. */
  3931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3932. /**
  3933. * Adds in place the given matrix to the current matrix
  3934. * @param other defines the second operand
  3935. * @returns the current updated matrix
  3936. */
  3937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3938. /**
  3939. * Sets the given matrix to the current inverted Matrix
  3940. * @param other defines the target matrix
  3941. * @returns the unmodified current matrix
  3942. */
  3943. invertToRef(other: Matrix): Matrix;
  3944. /**
  3945. * add a value at the specified position in the current Matrix
  3946. * @param index the index of the value within the matrix. between 0 and 15.
  3947. * @param value the value to be added
  3948. * @returns the current updated matrix
  3949. */
  3950. addAtIndex(index: number, value: number): Matrix;
  3951. /**
  3952. * mutiply the specified position in the current Matrix by a value
  3953. * @param index the index of the value within the matrix. between 0 and 15.
  3954. * @param value the value to be added
  3955. * @returns the current updated matrix
  3956. */
  3957. multiplyAtIndex(index: number, value: number): Matrix;
  3958. /**
  3959. * Inserts the translation vector (using 3 floats) in the current matrix
  3960. * @param x defines the 1st component of the translation
  3961. * @param y defines the 2nd component of the translation
  3962. * @param z defines the 3rd component of the translation
  3963. * @returns the current updated matrix
  3964. */
  3965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3966. /**
  3967. * Adds the translation vector (using 3 floats) in the current matrix
  3968. * @param x defines the 1st component of the translation
  3969. * @param y defines the 2nd component of the translation
  3970. * @param z defines the 3rd component of the translation
  3971. * @returns the current updated matrix
  3972. */
  3973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3974. /**
  3975. * Inserts the translation vector in the current matrix
  3976. * @param vector3 defines the translation to insert
  3977. * @returns the current updated matrix
  3978. */
  3979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3980. /**
  3981. * Gets the translation value of the current matrix
  3982. * @returns a new Vector3 as the extracted translation from the matrix
  3983. */
  3984. getTranslation(): Vector3;
  3985. /**
  3986. * Fill a Vector3 with the extracted translation from the matrix
  3987. * @param result defines the Vector3 where to store the translation
  3988. * @returns the current matrix
  3989. */
  3990. getTranslationToRef(result: Vector3): Matrix;
  3991. /**
  3992. * Remove rotation and scaling part from the matrix
  3993. * @returns the updated matrix
  3994. */
  3995. removeRotationAndScaling(): Matrix;
  3996. /**
  3997. * Multiply two matrices
  3998. * @param other defines the second operand
  3999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4000. */
  4001. multiply(other: DeepImmutable<Matrix>): Matrix;
  4002. /**
  4003. * Copy the current matrix from the given one
  4004. * @param other defines the source matrix
  4005. * @returns the current updated matrix
  4006. */
  4007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4008. /**
  4009. * Populates the given array from the starting index with the current matrix values
  4010. * @param array defines the target array
  4011. * @param offset defines the offset in the target array where to start storing values
  4012. * @returns the current matrix
  4013. */
  4014. copyToArray(array: Float32Array, offset?: number): Matrix;
  4015. /**
  4016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4017. * @param other defines the second operand
  4018. * @param result defines the matrix where to store the multiplication
  4019. * @returns the current matrix
  4020. */
  4021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4022. /**
  4023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4024. * @param other defines the second operand
  4025. * @param result defines the array where to store the multiplication
  4026. * @param offset defines the offset in the target array where to start storing values
  4027. * @returns the current matrix
  4028. */
  4029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4030. /**
  4031. * Check equality between this matrix and a second one
  4032. * @param value defines the second matrix to compare
  4033. * @returns true is the current matrix and the given one values are strictly equal
  4034. */
  4035. equals(value: DeepImmutable<Matrix>): boolean;
  4036. /**
  4037. * Clone the current matrix
  4038. * @returns a new matrix from the current matrix
  4039. */
  4040. clone(): Matrix;
  4041. /**
  4042. * Returns the name of the current matrix class
  4043. * @returns the string "Matrix"
  4044. */
  4045. getClassName(): string;
  4046. /**
  4047. * Gets the hash code of the current matrix
  4048. * @returns the hash code
  4049. */
  4050. getHashCode(): number;
  4051. /**
  4052. * Decomposes the current Matrix into a translation, rotation and scaling components
  4053. * @param scale defines the scale vector3 given as a reference to update
  4054. * @param rotation defines the rotation quaternion given as a reference to update
  4055. * @param translation defines the translation vector3 given as a reference to update
  4056. * @returns true if operation was successful
  4057. */
  4058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4059. /**
  4060. * Gets specific row of the matrix
  4061. * @param index defines the number of the row to get
  4062. * @returns the index-th row of the current matrix as a new Vector4
  4063. */
  4064. getRow(index: number): Nullable<Vector4>;
  4065. /**
  4066. * Sets the index-th row of the current matrix to the vector4 values
  4067. * @param index defines the number of the row to set
  4068. * @param row defines the target vector4
  4069. * @returns the updated current matrix
  4070. */
  4071. setRow(index: number, row: Vector4): Matrix;
  4072. /**
  4073. * Compute the transpose of the matrix
  4074. * @returns the new transposed matrix
  4075. */
  4076. transpose(): Matrix;
  4077. /**
  4078. * Compute the transpose of the matrix and store it in a given matrix
  4079. * @param result defines the target matrix
  4080. * @returns the current matrix
  4081. */
  4082. transposeToRef(result: Matrix): Matrix;
  4083. /**
  4084. * Sets the index-th row of the current matrix with the given 4 x float values
  4085. * @param index defines the row index
  4086. * @param x defines the x component to set
  4087. * @param y defines the y component to set
  4088. * @param z defines the z component to set
  4089. * @param w defines the w component to set
  4090. * @returns the updated current matrix
  4091. */
  4092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4093. /**
  4094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4095. * @param scale defines the scale factor
  4096. * @returns a new matrix
  4097. */
  4098. scale(scale: number): Matrix;
  4099. /**
  4100. * Scale the current matrix values by a factor to a given result matrix
  4101. * @param scale defines the scale factor
  4102. * @param result defines the matrix to store the result
  4103. * @returns the current matrix
  4104. */
  4105. scaleToRef(scale: number, result: Matrix): Matrix;
  4106. /**
  4107. * Scale the current matrix values by a factor and add the result to a given matrix
  4108. * @param scale defines the scale factor
  4109. * @param result defines the Matrix to store the result
  4110. * @returns the current matrix
  4111. */
  4112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4113. /**
  4114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4115. * @param ref matrix to store the result
  4116. */
  4117. toNormalMatrix(ref: Matrix): void;
  4118. /**
  4119. * Gets only rotation part of the current matrix
  4120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4121. */
  4122. getRotationMatrix(): Matrix;
  4123. /**
  4124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4125. * @param result defines the target matrix to store data to
  4126. * @returns the current matrix
  4127. */
  4128. getRotationMatrixToRef(result: Matrix): Matrix;
  4129. /**
  4130. * Toggles model matrix from being right handed to left handed in place and vice versa
  4131. */
  4132. toggleModelMatrixHandInPlace(): void;
  4133. /**
  4134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4135. */
  4136. toggleProjectionMatrixHandInPlace(): void;
  4137. /**
  4138. * Creates a matrix from an array
  4139. * @param array defines the source array
  4140. * @param offset defines an offset in the source array
  4141. * @returns a new Matrix set from the starting index of the given array
  4142. */
  4143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4144. /**
  4145. * Copy the content of an array into a given matrix
  4146. * @param array defines the source array
  4147. * @param offset defines an offset in the source array
  4148. * @param result defines the target matrix
  4149. */
  4150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4151. /**
  4152. * Stores an array into a matrix after having multiplied each component by a given factor
  4153. * @param array defines the source array
  4154. * @param offset defines the offset in the source array
  4155. * @param scale defines the scaling factor
  4156. * @param result defines the target matrix
  4157. */
  4158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4159. /**
  4160. * Gets an identity matrix that must not be updated
  4161. */
  4162. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4163. /**
  4164. * Stores a list of values (16) inside a given matrix
  4165. * @param initialM11 defines 1st value of 1st row
  4166. * @param initialM12 defines 2nd value of 1st row
  4167. * @param initialM13 defines 3rd value of 1st row
  4168. * @param initialM14 defines 4th value of 1st row
  4169. * @param initialM21 defines 1st value of 2nd row
  4170. * @param initialM22 defines 2nd value of 2nd row
  4171. * @param initialM23 defines 3rd value of 2nd row
  4172. * @param initialM24 defines 4th value of 2nd row
  4173. * @param initialM31 defines 1st value of 3rd row
  4174. * @param initialM32 defines 2nd value of 3rd row
  4175. * @param initialM33 defines 3rd value of 3rd row
  4176. * @param initialM34 defines 4th value of 3rd row
  4177. * @param initialM41 defines 1st value of 4th row
  4178. * @param initialM42 defines 2nd value of 4th row
  4179. * @param initialM43 defines 3rd value of 4th row
  4180. * @param initialM44 defines 4th value of 4th row
  4181. * @param result defines the target matrix
  4182. */
  4183. 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;
  4184. /**
  4185. * Creates new matrix from a list of values (16)
  4186. * @param initialM11 defines 1st value of 1st row
  4187. * @param initialM12 defines 2nd value of 1st row
  4188. * @param initialM13 defines 3rd value of 1st row
  4189. * @param initialM14 defines 4th value of 1st row
  4190. * @param initialM21 defines 1st value of 2nd row
  4191. * @param initialM22 defines 2nd value of 2nd row
  4192. * @param initialM23 defines 3rd value of 2nd row
  4193. * @param initialM24 defines 4th value of 2nd row
  4194. * @param initialM31 defines 1st value of 3rd row
  4195. * @param initialM32 defines 2nd value of 3rd row
  4196. * @param initialM33 defines 3rd value of 3rd row
  4197. * @param initialM34 defines 4th value of 3rd row
  4198. * @param initialM41 defines 1st value of 4th row
  4199. * @param initialM42 defines 2nd value of 4th row
  4200. * @param initialM43 defines 3rd value of 4th row
  4201. * @param initialM44 defines 4th value of 4th row
  4202. * @returns the new matrix
  4203. */
  4204. 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;
  4205. /**
  4206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4207. * @param scale defines the scale vector3
  4208. * @param rotation defines the rotation quaternion
  4209. * @param translation defines the translation vector3
  4210. * @returns a new matrix
  4211. */
  4212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4213. /**
  4214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4215. * @param scale defines the scale vector3
  4216. * @param rotation defines the rotation quaternion
  4217. * @param translation defines the translation vector3
  4218. * @param result defines the target matrix
  4219. */
  4220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4221. /**
  4222. * Creates a new identity matrix
  4223. * @returns a new identity matrix
  4224. */
  4225. static Identity(): Matrix;
  4226. /**
  4227. * Creates a new identity matrix and stores the result in a given matrix
  4228. * @param result defines the target matrix
  4229. */
  4230. static IdentityToRef(result: Matrix): void;
  4231. /**
  4232. * Creates a new zero matrix
  4233. * @returns a new zero matrix
  4234. */
  4235. static Zero(): Matrix;
  4236. /**
  4237. * Creates a new rotation matrix for "angle" radians around the X axis
  4238. * @param angle defines the angle (in radians) to use
  4239. * @return the new matrix
  4240. */
  4241. static RotationX(angle: number): Matrix;
  4242. /**
  4243. * Creates a new matrix as the invert of a given matrix
  4244. * @param source defines the source matrix
  4245. * @returns the new matrix
  4246. */
  4247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4248. /**
  4249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4250. * @param angle defines the angle (in radians) to use
  4251. * @param result defines the target matrix
  4252. */
  4253. static RotationXToRef(angle: number, result: Matrix): void;
  4254. /**
  4255. * Creates a new rotation matrix for "angle" radians around the Y axis
  4256. * @param angle defines the angle (in radians) to use
  4257. * @return the new matrix
  4258. */
  4259. static RotationY(angle: number): Matrix;
  4260. /**
  4261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4262. * @param angle defines the angle (in radians) to use
  4263. * @param result defines the target matrix
  4264. */
  4265. static RotationYToRef(angle: number, result: Matrix): void;
  4266. /**
  4267. * Creates a new rotation matrix for "angle" radians around the Z axis
  4268. * @param angle defines the angle (in radians) to use
  4269. * @return the new matrix
  4270. */
  4271. static RotationZ(angle: number): Matrix;
  4272. /**
  4273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4274. * @param angle defines the angle (in radians) to use
  4275. * @param result defines the target matrix
  4276. */
  4277. static RotationZToRef(angle: number, result: Matrix): void;
  4278. /**
  4279. * Creates a new rotation matrix for "angle" radians around the given axis
  4280. * @param axis defines the axis to use
  4281. * @param angle defines the angle (in radians) to use
  4282. * @return the new matrix
  4283. */
  4284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4285. /**
  4286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4287. * @param axis defines the axis to use
  4288. * @param angle defines the angle (in radians) to use
  4289. * @param result defines the target matrix
  4290. */
  4291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4292. /**
  4293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4295. * @param from defines the vector to align
  4296. * @param to defines the vector to align to
  4297. * @param result defines the target matrix
  4298. */
  4299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4300. /**
  4301. * Creates a rotation matrix
  4302. * @param yaw defines the yaw angle in radians (Y axis)
  4303. * @param pitch defines the pitch angle in radians (X axis)
  4304. * @param roll defines the roll angle in radians (X axis)
  4305. * @returns the new rotation matrix
  4306. */
  4307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4308. /**
  4309. * Creates a rotation matrix and stores it in a given matrix
  4310. * @param yaw defines the yaw angle in radians (Y axis)
  4311. * @param pitch defines the pitch angle in radians (X axis)
  4312. * @param roll defines the roll angle in radians (X axis)
  4313. * @param result defines the target matrix
  4314. */
  4315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4316. /**
  4317. * Creates a scaling matrix
  4318. * @param x defines the scale factor on X axis
  4319. * @param y defines the scale factor on Y axis
  4320. * @param z defines the scale factor on Z axis
  4321. * @returns the new matrix
  4322. */
  4323. static Scaling(x: number, y: number, z: number): Matrix;
  4324. /**
  4325. * Creates a scaling matrix and stores it in a given matrix
  4326. * @param x defines the scale factor on X axis
  4327. * @param y defines the scale factor on Y axis
  4328. * @param z defines the scale factor on Z axis
  4329. * @param result defines the target matrix
  4330. */
  4331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4332. /**
  4333. * Creates a translation matrix
  4334. * @param x defines the translation on X axis
  4335. * @param y defines the translation on Y axis
  4336. * @param z defines the translationon Z axis
  4337. * @returns the new matrix
  4338. */
  4339. static Translation(x: number, y: number, z: number): Matrix;
  4340. /**
  4341. * Creates a translation matrix and stores it in a given matrix
  4342. * @param x defines the translation on X axis
  4343. * @param y defines the translation on Y axis
  4344. * @param z defines the translationon Z axis
  4345. * @param result defines the target matrix
  4346. */
  4347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4348. /**
  4349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4350. * @param startValue defines the start value
  4351. * @param endValue defines the end value
  4352. * @param gradient defines the gradient factor
  4353. * @returns the new matrix
  4354. */
  4355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4356. /**
  4357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4358. * @param startValue defines the start value
  4359. * @param endValue defines the end value
  4360. * @param gradient defines the gradient factor
  4361. * @param result defines the Matrix object where to store data
  4362. */
  4363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4364. /**
  4365. * Builds a new matrix whose values are computed by:
  4366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4369. * @param startValue defines the first matrix
  4370. * @param endValue defines the second matrix
  4371. * @param gradient defines the gradient between the two matrices
  4372. * @returns the new matrix
  4373. */
  4374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4375. /**
  4376. * Update a matrix to values which are computed by:
  4377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4380. * @param startValue defines the first matrix
  4381. * @param endValue defines the second matrix
  4382. * @param gradient defines the gradient between the two matrices
  4383. * @param result defines the target matrix
  4384. */
  4385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4386. /**
  4387. * 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"
  4388. * This function works in left handed mode
  4389. * @param eye defines the final position of the entity
  4390. * @param target defines where the entity should look at
  4391. * @param up defines the up vector for the entity
  4392. * @returns the new matrix
  4393. */
  4394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4395. /**
  4396. * 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".
  4397. * This function works in left handed mode
  4398. * @param eye defines the final position of the entity
  4399. * @param target defines where the entity should look at
  4400. * @param up defines the up vector for the entity
  4401. * @param result defines the target matrix
  4402. */
  4403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4404. /**
  4405. * 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"
  4406. * This function works in right handed mode
  4407. * @param eye defines the final position of the entity
  4408. * @param target defines where the entity should look at
  4409. * @param up defines the up vector for the entity
  4410. * @returns the new matrix
  4411. */
  4412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4413. /**
  4414. * 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".
  4415. * This function works in right handed mode
  4416. * @param eye defines the final position of the entity
  4417. * @param target defines where the entity should look at
  4418. * @param up defines the up vector for the entity
  4419. * @param result defines the target matrix
  4420. */
  4421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4422. /**
  4423. * Create a left-handed orthographic projection matrix
  4424. * @param width defines the viewport width
  4425. * @param height defines the viewport height
  4426. * @param znear defines the near clip plane
  4427. * @param zfar defines the far clip plane
  4428. * @returns a new matrix as a left-handed orthographic projection matrix
  4429. */
  4430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4431. /**
  4432. * Store a left-handed orthographic projection to a given matrix
  4433. * @param width defines the viewport width
  4434. * @param height defines the viewport height
  4435. * @param znear defines the near clip plane
  4436. * @param zfar defines the far clip plane
  4437. * @param result defines the target matrix
  4438. */
  4439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4440. /**
  4441. * Create a left-handed orthographic projection matrix
  4442. * @param left defines the viewport left coordinate
  4443. * @param right defines the viewport right coordinate
  4444. * @param bottom defines the viewport bottom coordinate
  4445. * @param top defines the viewport top coordinate
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @returns a new matrix as a left-handed orthographic projection matrix
  4449. */
  4450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4451. /**
  4452. * Stores a left-handed orthographic projection into a given matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @param result defines the target matrix
  4460. */
  4461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4462. /**
  4463. * Creates a right-handed orthographic projection matrix
  4464. * @param left defines the viewport left coordinate
  4465. * @param right defines the viewport right coordinate
  4466. * @param bottom defines the viewport bottom coordinate
  4467. * @param top defines the viewport top coordinate
  4468. * @param znear defines the near clip plane
  4469. * @param zfar defines the far clip plane
  4470. * @returns a new matrix as a right-handed orthographic projection matrix
  4471. */
  4472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4473. /**
  4474. * Stores a right-handed orthographic projection into a given matrix
  4475. * @param left defines the viewport left coordinate
  4476. * @param right defines the viewport right coordinate
  4477. * @param bottom defines the viewport bottom coordinate
  4478. * @param top defines the viewport top coordinate
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @param result defines the target matrix
  4482. */
  4483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4484. /**
  4485. * Creates a left-handed perspective projection matrix
  4486. * @param width defines the viewport width
  4487. * @param height defines the viewport height
  4488. * @param znear defines the near clip plane
  4489. * @param zfar defines the far clip plane
  4490. * @returns a new matrix as a left-handed perspective projection matrix
  4491. */
  4492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4493. /**
  4494. * Creates a left-handed perspective projection matrix
  4495. * @param fov defines the horizontal field of view
  4496. * @param aspect defines the aspect ratio
  4497. * @param znear defines the near clip plane
  4498. * @param zfar defines the far clip plane
  4499. * @returns a new matrix as a left-handed perspective projection matrix
  4500. */
  4501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4502. /**
  4503. * Stores a left-handed perspective projection into a given matrix
  4504. * @param fov defines the horizontal field of view
  4505. * @param aspect defines the aspect ratio
  4506. * @param znear defines the near clip plane
  4507. * @param zfar defines the far clip plane
  4508. * @param result defines the target matrix
  4509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4510. */
  4511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4512. /**
  4513. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4514. * @param fov defines the horizontal field of view
  4515. * @param aspect defines the aspect ratio
  4516. * @param znear defines the near clip plane
  4517. * @param zfar not used as infinity is used as far clip
  4518. * @param result defines the target matrix
  4519. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4520. */
  4521. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4522. /**
  4523. * Creates a right-handed perspective projection matrix
  4524. * @param fov defines the horizontal field of view
  4525. * @param aspect defines the aspect ratio
  4526. * @param znear defines the near clip plane
  4527. * @param zfar defines the far clip plane
  4528. * @returns a new matrix as a right-handed perspective projection matrix
  4529. */
  4530. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4531. /**
  4532. * Stores a right-handed perspective projection into a given matrix
  4533. * @param fov defines the horizontal field of view
  4534. * @param aspect defines the aspect ratio
  4535. * @param znear defines the near clip plane
  4536. * @param zfar defines the far clip plane
  4537. * @param result defines the target matrix
  4538. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4539. */
  4540. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4541. /**
  4542. * Stores a right-handed perspective projection into a given matrix
  4543. * @param fov defines the horizontal field of view
  4544. * @param aspect defines the aspect ratio
  4545. * @param znear defines the near clip plane
  4546. * @param zfar not used as infinity is used as far clip
  4547. * @param result defines the target matrix
  4548. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4549. */
  4550. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4551. /**
  4552. * Stores a perspective projection for WebVR info a given matrix
  4553. * @param fov defines the field of view
  4554. * @param znear defines the near clip plane
  4555. * @param zfar defines the far clip plane
  4556. * @param result defines the target matrix
  4557. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4558. */
  4559. static PerspectiveFovWebVRToRef(fov: {
  4560. upDegrees: number;
  4561. downDegrees: number;
  4562. leftDegrees: number;
  4563. rightDegrees: number;
  4564. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4565. /**
  4566. * Computes a complete transformation matrix
  4567. * @param viewport defines the viewport to use
  4568. * @param world defines the world matrix
  4569. * @param view defines the view matrix
  4570. * @param projection defines the projection matrix
  4571. * @param zmin defines the near clip plane
  4572. * @param zmax defines the far clip plane
  4573. * @returns the transformation matrix
  4574. */
  4575. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4576. /**
  4577. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4578. * @param matrix defines the matrix to use
  4579. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4580. */
  4581. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4582. /**
  4583. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4584. * @param matrix defines the matrix to use
  4585. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4586. */
  4587. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4588. /**
  4589. * Compute the transpose of a given matrix
  4590. * @param matrix defines the matrix to transpose
  4591. * @returns the new matrix
  4592. */
  4593. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4594. /**
  4595. * Compute the transpose of a matrix and store it in a target matrix
  4596. * @param matrix defines the matrix to transpose
  4597. * @param result defines the target matrix
  4598. */
  4599. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4600. /**
  4601. * Computes a reflection matrix from a plane
  4602. * @param plane defines the reflection plane
  4603. * @returns a new matrix
  4604. */
  4605. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4606. /**
  4607. * Computes a reflection matrix from a plane
  4608. * @param plane defines the reflection plane
  4609. * @param result defines the target matrix
  4610. */
  4611. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4612. /**
  4613. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4614. * @param xaxis defines the value of the 1st axis
  4615. * @param yaxis defines the value of the 2nd axis
  4616. * @param zaxis defines the value of the 3rd axis
  4617. * @param result defines the target matrix
  4618. */
  4619. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4620. /**
  4621. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4622. * @param quat defines the quaternion to use
  4623. * @param result defines the target matrix
  4624. */
  4625. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4626. }
  4627. /**
  4628. * @hidden
  4629. */
  4630. export class TmpVectors {
  4631. static Vector2: Vector2[];
  4632. static Vector3: Vector3[];
  4633. static Vector4: Vector4[];
  4634. static Quaternion: Quaternion[];
  4635. static Matrix: Matrix[];
  4636. }
  4637. }
  4638. declare module BABYLON {
  4639. /**
  4640. * Defines potential orientation for back face culling
  4641. */
  4642. export enum Orientation {
  4643. /**
  4644. * Clockwise
  4645. */
  4646. CW = 0,
  4647. /** Counter clockwise */
  4648. CCW = 1
  4649. }
  4650. /** Class used to represent a Bezier curve */
  4651. export class BezierCurve {
  4652. /**
  4653. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4654. * @param t defines the time
  4655. * @param x1 defines the left coordinate on X axis
  4656. * @param y1 defines the left coordinate on Y axis
  4657. * @param x2 defines the right coordinate on X axis
  4658. * @param y2 defines the right coordinate on Y axis
  4659. * @returns the interpolated value
  4660. */
  4661. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4662. }
  4663. /**
  4664. * Defines angle representation
  4665. */
  4666. export class Angle {
  4667. private _radians;
  4668. /**
  4669. * Creates an Angle object of "radians" radians (float).
  4670. * @param radians the angle in radians
  4671. */
  4672. constructor(radians: number);
  4673. /**
  4674. * Get value in degrees
  4675. * @returns the Angle value in degrees (float)
  4676. */
  4677. degrees(): number;
  4678. /**
  4679. * Get value in radians
  4680. * @returns the Angle value in radians (float)
  4681. */
  4682. radians(): number;
  4683. /**
  4684. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4685. * @param a defines first vector
  4686. * @param b defines second vector
  4687. * @returns a new Angle
  4688. */
  4689. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4690. /**
  4691. * Gets a new Angle object from the given float in radians
  4692. * @param radians defines the angle value in radians
  4693. * @returns a new Angle
  4694. */
  4695. static FromRadians(radians: number): Angle;
  4696. /**
  4697. * Gets a new Angle object from the given float in degrees
  4698. * @param degrees defines the angle value in degrees
  4699. * @returns a new Angle
  4700. */
  4701. static FromDegrees(degrees: number): Angle;
  4702. }
  4703. /**
  4704. * This represents an arc in a 2d space.
  4705. */
  4706. export class Arc2 {
  4707. /** Defines the start point of the arc */
  4708. startPoint: Vector2;
  4709. /** Defines the mid point of the arc */
  4710. midPoint: Vector2;
  4711. /** Defines the end point of the arc */
  4712. endPoint: Vector2;
  4713. /**
  4714. * Defines the center point of the arc.
  4715. */
  4716. centerPoint: Vector2;
  4717. /**
  4718. * Defines the radius of the arc.
  4719. */
  4720. radius: number;
  4721. /**
  4722. * Defines the angle of the arc (from mid point to end point).
  4723. */
  4724. angle: Angle;
  4725. /**
  4726. * Defines the start angle of the arc (from start point to middle point).
  4727. */
  4728. startAngle: Angle;
  4729. /**
  4730. * Defines the orientation of the arc (clock wise/counter clock wise).
  4731. */
  4732. orientation: Orientation;
  4733. /**
  4734. * Creates an Arc object from the three given points : start, middle and end.
  4735. * @param startPoint Defines the start point of the arc
  4736. * @param midPoint Defines the midlle point of the arc
  4737. * @param endPoint Defines the end point of the arc
  4738. */
  4739. constructor(
  4740. /** Defines the start point of the arc */
  4741. startPoint: Vector2,
  4742. /** Defines the mid point of the arc */
  4743. midPoint: Vector2,
  4744. /** Defines the end point of the arc */
  4745. endPoint: Vector2);
  4746. }
  4747. /**
  4748. * Represents a 2D path made up of multiple 2D points
  4749. */
  4750. export class Path2 {
  4751. private _points;
  4752. private _length;
  4753. /**
  4754. * If the path start and end point are the same
  4755. */
  4756. closed: boolean;
  4757. /**
  4758. * Creates a Path2 object from the starting 2D coordinates x and y.
  4759. * @param x the starting points x value
  4760. * @param y the starting points y value
  4761. */
  4762. constructor(x: number, y: number);
  4763. /**
  4764. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4765. * @param x the added points x value
  4766. * @param y the added points y value
  4767. * @returns the updated Path2.
  4768. */
  4769. addLineTo(x: number, y: number): Path2;
  4770. /**
  4771. * 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.
  4772. * @param midX middle point x value
  4773. * @param midY middle point y value
  4774. * @param endX end point x value
  4775. * @param endY end point y value
  4776. * @param numberOfSegments (default: 36)
  4777. * @returns the updated Path2.
  4778. */
  4779. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4780. /**
  4781. * Closes the Path2.
  4782. * @returns the Path2.
  4783. */
  4784. close(): Path2;
  4785. /**
  4786. * Gets the sum of the distance between each sequential point in the path
  4787. * @returns the Path2 total length (float).
  4788. */
  4789. length(): number;
  4790. /**
  4791. * Gets the points which construct the path
  4792. * @returns the Path2 internal array of points.
  4793. */
  4794. getPoints(): Vector2[];
  4795. /**
  4796. * Retreives the point at the distance aways from the starting point
  4797. * @param normalizedLengthPosition the length along the path to retreive the point from
  4798. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4799. */
  4800. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4801. /**
  4802. * Creates a new path starting from an x and y position
  4803. * @param x starting x value
  4804. * @param y starting y value
  4805. * @returns a new Path2 starting at the coordinates (x, y).
  4806. */
  4807. static StartingAt(x: number, y: number): Path2;
  4808. }
  4809. /**
  4810. * Represents a 3D path made up of multiple 3D points
  4811. */
  4812. export class Path3D {
  4813. /**
  4814. * an array of Vector3, the curve axis of the Path3D
  4815. */
  4816. path: Vector3[];
  4817. private _curve;
  4818. private _distances;
  4819. private _tangents;
  4820. private _normals;
  4821. private _binormals;
  4822. private _raw;
  4823. private _alignTangentsWithPath;
  4824. private readonly _pointAtData;
  4825. /**
  4826. * new Path3D(path, normal, raw)
  4827. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4828. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4829. * @param path an array of Vector3, the curve axis of the Path3D
  4830. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4831. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4832. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4833. */
  4834. constructor(
  4835. /**
  4836. * an array of Vector3, the curve axis of the Path3D
  4837. */
  4838. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4839. /**
  4840. * Returns the Path3D array of successive Vector3 designing its curve.
  4841. * @returns the Path3D array of successive Vector3 designing its curve.
  4842. */
  4843. getCurve(): Vector3[];
  4844. /**
  4845. * Returns the Path3D array of successive Vector3 designing its curve.
  4846. * @returns the Path3D array of successive Vector3 designing its curve.
  4847. */
  4848. getPoints(): Vector3[];
  4849. /**
  4850. * @returns the computed length (float) of the path.
  4851. */
  4852. length(): number;
  4853. /**
  4854. * Returns an array populated with tangent vectors on each Path3D curve point.
  4855. * @returns an array populated with tangent vectors on each Path3D curve point.
  4856. */
  4857. getTangents(): Vector3[];
  4858. /**
  4859. * Returns an array populated with normal vectors on each Path3D curve point.
  4860. * @returns an array populated with normal vectors on each Path3D curve point.
  4861. */
  4862. getNormals(): Vector3[];
  4863. /**
  4864. * Returns an array populated with binormal vectors on each Path3D curve point.
  4865. * @returns an array populated with binormal vectors on each Path3D curve point.
  4866. */
  4867. getBinormals(): Vector3[];
  4868. /**
  4869. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4870. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4871. */
  4872. getDistances(): number[];
  4873. /**
  4874. * Returns an interpolated point along this path
  4875. * @param position the position of the point along this path, from 0.0 to 1.0
  4876. * @returns a new Vector3 as the point
  4877. */
  4878. getPointAt(position: number): Vector3;
  4879. /**
  4880. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4881. * @param position the position of the point along this path, from 0.0 to 1.0
  4882. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4883. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4884. */
  4885. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4886. /**
  4887. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4888. * @param position the position of the point along this path, from 0.0 to 1.0
  4889. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4890. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4891. */
  4892. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4893. /**
  4894. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4895. * @param position the position of the point along this path, from 0.0 to 1.0
  4896. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4897. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4898. */
  4899. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4900. /**
  4901. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4902. * @param position the position of the point along this path, from 0.0 to 1.0
  4903. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4904. */
  4905. getDistanceAt(position: number): number;
  4906. /**
  4907. * Returns the array index of the previous point of an interpolated point along this path
  4908. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4909. * @returns the array index
  4910. */
  4911. getPreviousPointIndexAt(position: number): number;
  4912. /**
  4913. * 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)
  4914. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4915. * @returns the sub position
  4916. */
  4917. getSubPositionAt(position: number): number;
  4918. /**
  4919. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4920. * @param target the vector of which to get the closest position to
  4921. * @returns the position of the closest virtual point on this path to the target vector
  4922. */
  4923. getClosestPositionTo(target: Vector3): number;
  4924. /**
  4925. * Returns a sub path (slice) of this path
  4926. * @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
  4927. * @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
  4928. * @returns a sub path (slice) of this path
  4929. */
  4930. slice(start?: number, end?: number): Path3D;
  4931. /**
  4932. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4933. * @param path path which all values are copied into the curves points
  4934. * @param firstNormal which should be projected onto the curve
  4935. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4936. * @returns the same object updated.
  4937. */
  4938. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4939. private _compute;
  4940. private _getFirstNonNullVector;
  4941. private _getLastNonNullVector;
  4942. private _normalVector;
  4943. /**
  4944. * Updates the point at data for an interpolated point along this curve
  4945. * @param position the position of the point along this curve, from 0.0 to 1.0
  4946. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4947. * @returns the (updated) point at data
  4948. */
  4949. private _updatePointAtData;
  4950. /**
  4951. * Updates the point at data from the specified parameters
  4952. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4953. * @param point the interpolated point
  4954. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4955. */
  4956. private _setPointAtData;
  4957. /**
  4958. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4959. */
  4960. private _updateInterpolationMatrix;
  4961. }
  4962. /**
  4963. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4964. * A Curve3 is designed from a series of successive Vector3.
  4965. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4966. */
  4967. export class Curve3 {
  4968. private _points;
  4969. private _length;
  4970. /**
  4971. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4972. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4973. * @param v1 (Vector3) the control point
  4974. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4975. * @param nbPoints (integer) the wanted number of points in the curve
  4976. * @returns the created Curve3
  4977. */
  4978. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4979. /**
  4980. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4981. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4982. * @param v1 (Vector3) the first control point
  4983. * @param v2 (Vector3) the second control point
  4984. * @param v3 (Vector3) the end point of the Cubic Bezier
  4985. * @param nbPoints (integer) the wanted number of points in the curve
  4986. * @returns the created Curve3
  4987. */
  4988. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4989. /**
  4990. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4991. * @param p1 (Vector3) the origin point of the Hermite Spline
  4992. * @param t1 (Vector3) the tangent vector at the origin point
  4993. * @param p2 (Vector3) the end point of the Hermite Spline
  4994. * @param t2 (Vector3) the tangent vector at the end point
  4995. * @param nbPoints (integer) the wanted number of points in the curve
  4996. * @returns the created Curve3
  4997. */
  4998. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4999. /**
  5000. * Returns a Curve3 object along a CatmullRom Spline curve :
  5001. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5002. * @param nbPoints (integer) the wanted number of points between each curve control points
  5003. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5004. * @returns the created Curve3
  5005. */
  5006. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5007. /**
  5008. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5009. * A Curve3 is designed from a series of successive Vector3.
  5010. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5011. * @param points points which make up the curve
  5012. */
  5013. constructor(points: Vector3[]);
  5014. /**
  5015. * @returns the Curve3 stored array of successive Vector3
  5016. */
  5017. getPoints(): Vector3[];
  5018. /**
  5019. * @returns the computed length (float) of the curve.
  5020. */
  5021. length(): number;
  5022. /**
  5023. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5024. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5025. * curveA and curveB keep unchanged.
  5026. * @param curve the curve to continue from this curve
  5027. * @returns the newly constructed curve
  5028. */
  5029. continue(curve: DeepImmutable<Curve3>): Curve3;
  5030. private _computeLength;
  5031. }
  5032. }
  5033. declare module BABYLON {
  5034. /**
  5035. * This represents the main contract an easing function should follow.
  5036. * Easing functions are used throughout the animation system.
  5037. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5038. */
  5039. export interface IEasingFunction {
  5040. /**
  5041. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5042. * of the easing function.
  5043. * The link below provides some of the most common examples of easing functions.
  5044. * @see https://easings.net/
  5045. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5046. * @returns the corresponding value on the curve defined by the easing function
  5047. */
  5048. ease(gradient: number): number;
  5049. }
  5050. /**
  5051. * Base class used for every default easing function.
  5052. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5053. */
  5054. export class EasingFunction implements IEasingFunction {
  5055. /**
  5056. * Interpolation follows the mathematical formula associated with the easing function.
  5057. */
  5058. static readonly EASINGMODE_EASEIN: number;
  5059. /**
  5060. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5061. */
  5062. static readonly EASINGMODE_EASEOUT: number;
  5063. /**
  5064. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5065. */
  5066. static readonly EASINGMODE_EASEINOUT: number;
  5067. private _easingMode;
  5068. /**
  5069. * Sets the easing mode of the current function.
  5070. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5071. */
  5072. setEasingMode(easingMode: number): void;
  5073. /**
  5074. * Gets the current easing mode.
  5075. * @returns the easing mode
  5076. */
  5077. getEasingMode(): number;
  5078. /**
  5079. * @hidden
  5080. */
  5081. easeInCore(gradient: number): number;
  5082. /**
  5083. * Given an input gradient between 0 and 1, this returns the corresponding value
  5084. * of the easing function.
  5085. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5086. * @returns the corresponding value on the curve defined by the easing function
  5087. */
  5088. ease(gradient: number): number;
  5089. }
  5090. /**
  5091. * Easing function with a circle shape (see link below).
  5092. * @see https://easings.net/#easeInCirc
  5093. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5094. */
  5095. export class CircleEase extends EasingFunction implements IEasingFunction {
  5096. /** @hidden */
  5097. easeInCore(gradient: number): number;
  5098. }
  5099. /**
  5100. * Easing function with a ease back shape (see link below).
  5101. * @see https://easings.net/#easeInBack
  5102. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5103. */
  5104. export class BackEase extends EasingFunction implements IEasingFunction {
  5105. /** Defines the amplitude of the function */
  5106. amplitude: number;
  5107. /**
  5108. * Instantiates a back ease easing
  5109. * @see https://easings.net/#easeInBack
  5110. * @param amplitude Defines the amplitude of the function
  5111. */
  5112. constructor(
  5113. /** Defines the amplitude of the function */
  5114. amplitude?: number);
  5115. /** @hidden */
  5116. easeInCore(gradient: number): number;
  5117. }
  5118. /**
  5119. * Easing function with a bouncing shape (see link below).
  5120. * @see https://easings.net/#easeInBounce
  5121. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5122. */
  5123. export class BounceEase extends EasingFunction implements IEasingFunction {
  5124. /** Defines the number of bounces */
  5125. bounces: number;
  5126. /** Defines the amplitude of the bounce */
  5127. bounciness: number;
  5128. /**
  5129. * Instantiates a bounce easing
  5130. * @see https://easings.net/#easeInBounce
  5131. * @param bounces Defines the number of bounces
  5132. * @param bounciness Defines the amplitude of the bounce
  5133. */
  5134. constructor(
  5135. /** Defines the number of bounces */
  5136. bounces?: number,
  5137. /** Defines the amplitude of the bounce */
  5138. bounciness?: number);
  5139. /** @hidden */
  5140. easeInCore(gradient: number): number;
  5141. }
  5142. /**
  5143. * Easing function with a power of 3 shape (see link below).
  5144. * @see https://easings.net/#easeInCubic
  5145. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5146. */
  5147. export class CubicEase extends EasingFunction implements IEasingFunction {
  5148. /** @hidden */
  5149. easeInCore(gradient: number): number;
  5150. }
  5151. /**
  5152. * Easing function with an elastic shape (see link below).
  5153. * @see https://easings.net/#easeInElastic
  5154. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5155. */
  5156. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5157. /** Defines the number of oscillations*/
  5158. oscillations: number;
  5159. /** Defines the amplitude of the oscillations*/
  5160. springiness: number;
  5161. /**
  5162. * Instantiates an elastic easing function
  5163. * @see https://easings.net/#easeInElastic
  5164. * @param oscillations Defines the number of oscillations
  5165. * @param springiness Defines the amplitude of the oscillations
  5166. */
  5167. constructor(
  5168. /** Defines the number of oscillations*/
  5169. oscillations?: number,
  5170. /** Defines the amplitude of the oscillations*/
  5171. springiness?: number);
  5172. /** @hidden */
  5173. easeInCore(gradient: number): number;
  5174. }
  5175. /**
  5176. * Easing function with an exponential shape (see link below).
  5177. * @see https://easings.net/#easeInExpo
  5178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5179. */
  5180. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5181. /** Defines the exponent of the function */
  5182. exponent: number;
  5183. /**
  5184. * Instantiates an exponential easing function
  5185. * @see https://easings.net/#easeInExpo
  5186. * @param exponent Defines the exponent of the function
  5187. */
  5188. constructor(
  5189. /** Defines the exponent of the function */
  5190. exponent?: number);
  5191. /** @hidden */
  5192. easeInCore(gradient: number): number;
  5193. }
  5194. /**
  5195. * Easing function with a power shape (see link below).
  5196. * @see https://easings.net/#easeInQuad
  5197. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5198. */
  5199. export class PowerEase extends EasingFunction implements IEasingFunction {
  5200. /** Defines the power of the function */
  5201. power: number;
  5202. /**
  5203. * Instantiates an power base easing function
  5204. * @see https://easings.net/#easeInQuad
  5205. * @param power Defines the power of the function
  5206. */
  5207. constructor(
  5208. /** Defines the power of the function */
  5209. power?: number);
  5210. /** @hidden */
  5211. easeInCore(gradient: number): number;
  5212. }
  5213. /**
  5214. * Easing function with a power of 2 shape (see link below).
  5215. * @see https://easings.net/#easeInQuad
  5216. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5217. */
  5218. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5219. /** @hidden */
  5220. easeInCore(gradient: number): number;
  5221. }
  5222. /**
  5223. * Easing function with a power of 4 shape (see link below).
  5224. * @see https://easings.net/#easeInQuart
  5225. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5226. */
  5227. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5228. /** @hidden */
  5229. easeInCore(gradient: number): number;
  5230. }
  5231. /**
  5232. * Easing function with a power of 5 shape (see link below).
  5233. * @see https://easings.net/#easeInQuint
  5234. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5235. */
  5236. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5237. /** @hidden */
  5238. easeInCore(gradient: number): number;
  5239. }
  5240. /**
  5241. * Easing function with a sin shape (see link below).
  5242. * @see https://easings.net/#easeInSine
  5243. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5244. */
  5245. export class SineEase extends EasingFunction implements IEasingFunction {
  5246. /** @hidden */
  5247. easeInCore(gradient: number): number;
  5248. }
  5249. /**
  5250. * Easing function with a bezier shape (see link below).
  5251. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5252. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5253. */
  5254. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5255. /** Defines the x component of the start tangent in the bezier curve */
  5256. x1: number;
  5257. /** Defines the y component of the start tangent in the bezier curve */
  5258. y1: number;
  5259. /** Defines the x component of the end tangent in the bezier curve */
  5260. x2: number;
  5261. /** Defines the y component of the end tangent in the bezier curve */
  5262. y2: number;
  5263. /**
  5264. * Instantiates a bezier function
  5265. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5266. * @param x1 Defines the x component of the start tangent in the bezier curve
  5267. * @param y1 Defines the y component of the start tangent in the bezier curve
  5268. * @param x2 Defines the x component of the end tangent in the bezier curve
  5269. * @param y2 Defines the y component of the end tangent in the bezier curve
  5270. */
  5271. constructor(
  5272. /** Defines the x component of the start tangent in the bezier curve */
  5273. x1?: number,
  5274. /** Defines the y component of the start tangent in the bezier curve */
  5275. y1?: number,
  5276. /** Defines the x component of the end tangent in the bezier curve */
  5277. x2?: number,
  5278. /** Defines the y component of the end tangent in the bezier curve */
  5279. y2?: number);
  5280. /** @hidden */
  5281. easeInCore(gradient: number): number;
  5282. }
  5283. }
  5284. declare module BABYLON {
  5285. /**
  5286. * Class used to hold a RBG color
  5287. */
  5288. export class Color3 {
  5289. /**
  5290. * Defines the red component (between 0 and 1, default is 0)
  5291. */
  5292. r: number;
  5293. /**
  5294. * Defines the green component (between 0 and 1, default is 0)
  5295. */
  5296. g: number;
  5297. /**
  5298. * Defines the blue component (between 0 and 1, default is 0)
  5299. */
  5300. b: number;
  5301. /**
  5302. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5303. * @param r defines the red component (between 0 and 1, default is 0)
  5304. * @param g defines the green component (between 0 and 1, default is 0)
  5305. * @param b defines the blue component (between 0 and 1, default is 0)
  5306. */
  5307. constructor(
  5308. /**
  5309. * Defines the red component (between 0 and 1, default is 0)
  5310. */
  5311. r?: number,
  5312. /**
  5313. * Defines the green component (between 0 and 1, default is 0)
  5314. */
  5315. g?: number,
  5316. /**
  5317. * Defines the blue component (between 0 and 1, default is 0)
  5318. */
  5319. b?: number);
  5320. /**
  5321. * Creates a string with the Color3 current values
  5322. * @returns the string representation of the Color3 object
  5323. */
  5324. toString(): string;
  5325. /**
  5326. * Returns the string "Color3"
  5327. * @returns "Color3"
  5328. */
  5329. getClassName(): string;
  5330. /**
  5331. * Compute the Color3 hash code
  5332. * @returns an unique number that can be used to hash Color3 objects
  5333. */
  5334. getHashCode(): number;
  5335. /**
  5336. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5337. * @param array defines the array where to store the r,g,b components
  5338. * @param index defines an optional index in the target array to define where to start storing values
  5339. * @returns the current Color3 object
  5340. */
  5341. toArray(array: FloatArray, index?: number): Color3;
  5342. /**
  5343. * Returns a new Color4 object from the current Color3 and the given alpha
  5344. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5345. * @returns a new Color4 object
  5346. */
  5347. toColor4(alpha?: number): Color4;
  5348. /**
  5349. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5350. * @returns the new array
  5351. */
  5352. asArray(): number[];
  5353. /**
  5354. * Returns the luminance value
  5355. * @returns a float value
  5356. */
  5357. toLuminance(): number;
  5358. /**
  5359. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5360. * @param otherColor defines the second operand
  5361. * @returns the new Color3 object
  5362. */
  5363. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5364. /**
  5365. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5366. * @param otherColor defines the second operand
  5367. * @param result defines the Color3 object where to store the result
  5368. * @returns the current Color3
  5369. */
  5370. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5371. /**
  5372. * Determines equality between Color3 objects
  5373. * @param otherColor defines the second operand
  5374. * @returns true if the rgb values are equal to the given ones
  5375. */
  5376. equals(otherColor: DeepImmutable<Color3>): boolean;
  5377. /**
  5378. * Determines equality between the current Color3 object and a set of r,b,g values
  5379. * @param r defines the red component to check
  5380. * @param g defines the green component to check
  5381. * @param b defines the blue component to check
  5382. * @returns true if the rgb values are equal to the given ones
  5383. */
  5384. equalsFloats(r: number, g: number, b: number): boolean;
  5385. /**
  5386. * Multiplies in place each rgb value by scale
  5387. * @param scale defines the scaling factor
  5388. * @returns the updated Color3
  5389. */
  5390. scale(scale: number): Color3;
  5391. /**
  5392. * Multiplies the rgb values by scale and stores the result into "result"
  5393. * @param scale defines the scaling factor
  5394. * @param result defines the Color3 object where to store the result
  5395. * @returns the unmodified current Color3
  5396. */
  5397. scaleToRef(scale: number, result: Color3): Color3;
  5398. /**
  5399. * Scale the current Color3 values by a factor and add the result to a given Color3
  5400. * @param scale defines the scale factor
  5401. * @param result defines color to store the result into
  5402. * @returns the unmodified current Color3
  5403. */
  5404. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5405. /**
  5406. * Clamps the rgb values by the min and max values and stores the result into "result"
  5407. * @param min defines minimum clamping value (default is 0)
  5408. * @param max defines maximum clamping value (default is 1)
  5409. * @param result defines color to store the result into
  5410. * @returns the original Color3
  5411. */
  5412. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5413. /**
  5414. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5415. * @param otherColor defines the second operand
  5416. * @returns the new Color3
  5417. */
  5418. add(otherColor: DeepImmutable<Color3>): Color3;
  5419. /**
  5420. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5421. * @param otherColor defines the second operand
  5422. * @param result defines Color3 object to store the result into
  5423. * @returns the unmodified current Color3
  5424. */
  5425. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5426. /**
  5427. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5428. * @param otherColor defines the second operand
  5429. * @returns the new Color3
  5430. */
  5431. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5432. /**
  5433. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5434. * @param otherColor defines the second operand
  5435. * @param result defines Color3 object to store the result into
  5436. * @returns the unmodified current Color3
  5437. */
  5438. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5439. /**
  5440. * Copy the current object
  5441. * @returns a new Color3 copied the current one
  5442. */
  5443. clone(): Color3;
  5444. /**
  5445. * Copies the rgb values from the source in the current Color3
  5446. * @param source defines the source Color3 object
  5447. * @returns the updated Color3 object
  5448. */
  5449. copyFrom(source: DeepImmutable<Color3>): Color3;
  5450. /**
  5451. * Updates the Color3 rgb values from the given floats
  5452. * @param r defines the red component to read from
  5453. * @param g defines the green component to read from
  5454. * @param b defines the blue component to read from
  5455. * @returns the current Color3 object
  5456. */
  5457. copyFromFloats(r: number, g: number, b: number): Color3;
  5458. /**
  5459. * Updates the Color3 rgb values from the given floats
  5460. * @param r defines the red component to read from
  5461. * @param g defines the green component to read from
  5462. * @param b defines the blue component to read from
  5463. * @returns the current Color3 object
  5464. */
  5465. set(r: number, g: number, b: number): Color3;
  5466. /**
  5467. * Compute the Color3 hexadecimal code as a string
  5468. * @returns a string containing the hexadecimal representation of the Color3 object
  5469. */
  5470. toHexString(): string;
  5471. /**
  5472. * Computes a new Color3 converted from the current one to linear space
  5473. * @returns a new Color3 object
  5474. */
  5475. toLinearSpace(): Color3;
  5476. /**
  5477. * Converts current color in rgb space to HSV values
  5478. * @returns a new color3 representing the HSV values
  5479. */
  5480. toHSV(): Color3;
  5481. /**
  5482. * Converts current color in rgb space to HSV values
  5483. * @param result defines the Color3 where to store the HSV values
  5484. */
  5485. toHSVToRef(result: Color3): void;
  5486. /**
  5487. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5488. * @param convertedColor defines the Color3 object where to store the linear space version
  5489. * @returns the unmodified Color3
  5490. */
  5491. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5492. /**
  5493. * Computes a new Color3 converted from the current one to gamma space
  5494. * @returns a new Color3 object
  5495. */
  5496. toGammaSpace(): Color3;
  5497. /**
  5498. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5499. * @param convertedColor defines the Color3 object where to store the gamma space version
  5500. * @returns the unmodified Color3
  5501. */
  5502. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5503. private static _BlackReadOnly;
  5504. /**
  5505. * Convert Hue, saturation and value to a Color3 (RGB)
  5506. * @param hue defines the hue
  5507. * @param saturation defines the saturation
  5508. * @param value defines the value
  5509. * @param result defines the Color3 where to store the RGB values
  5510. */
  5511. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5512. /**
  5513. * Creates a new Color3 from the string containing valid hexadecimal values
  5514. * @param hex defines a string containing valid hexadecimal values
  5515. * @returns a new Color3 object
  5516. */
  5517. static FromHexString(hex: string): Color3;
  5518. /**
  5519. * Creates a new Color3 from the starting index of the given array
  5520. * @param array defines the source array
  5521. * @param offset defines an offset in the source array
  5522. * @returns a new Color3 object
  5523. */
  5524. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5525. /**
  5526. * Creates a new Color3 from integer values (< 256)
  5527. * @param r defines the red component to read from (value between 0 and 255)
  5528. * @param g defines the green component to read from (value between 0 and 255)
  5529. * @param b defines the blue component to read from (value between 0 and 255)
  5530. * @returns a new Color3 object
  5531. */
  5532. static FromInts(r: number, g: number, b: number): Color3;
  5533. /**
  5534. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5535. * @param start defines the start Color3 value
  5536. * @param end defines the end Color3 value
  5537. * @param amount defines the gradient value between start and end
  5538. * @returns a new Color3 object
  5539. */
  5540. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5541. /**
  5542. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5543. * @param left defines the start value
  5544. * @param right defines the end value
  5545. * @param amount defines the gradient factor
  5546. * @param result defines the Color3 object where to store the result
  5547. */
  5548. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5549. /**
  5550. * Returns a Color3 value containing a red color
  5551. * @returns a new Color3 object
  5552. */
  5553. static Red(): Color3;
  5554. /**
  5555. * Returns a Color3 value containing a green color
  5556. * @returns a new Color3 object
  5557. */
  5558. static Green(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a blue color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Blue(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a black color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Black(): Color3;
  5569. /**
  5570. * Gets a Color3 value containing a black color that must not be updated
  5571. */
  5572. static get BlackReadOnly(): DeepImmutable<Color3>;
  5573. /**
  5574. * Returns a Color3 value containing a white color
  5575. * @returns a new Color3 object
  5576. */
  5577. static White(): Color3;
  5578. /**
  5579. * Returns a Color3 value containing a purple color
  5580. * @returns a new Color3 object
  5581. */
  5582. static Purple(): Color3;
  5583. /**
  5584. * Returns a Color3 value containing a magenta color
  5585. * @returns a new Color3 object
  5586. */
  5587. static Magenta(): Color3;
  5588. /**
  5589. * Returns a Color3 value containing a yellow color
  5590. * @returns a new Color3 object
  5591. */
  5592. static Yellow(): Color3;
  5593. /**
  5594. * Returns a Color3 value containing a gray color
  5595. * @returns a new Color3 object
  5596. */
  5597. static Gray(): Color3;
  5598. /**
  5599. * Returns a Color3 value containing a teal color
  5600. * @returns a new Color3 object
  5601. */
  5602. static Teal(): Color3;
  5603. /**
  5604. * Returns a Color3 value containing a random color
  5605. * @returns a new Color3 object
  5606. */
  5607. static Random(): Color3;
  5608. }
  5609. /**
  5610. * Class used to hold a RBGA color
  5611. */
  5612. export class Color4 {
  5613. /**
  5614. * Defines the red component (between 0 and 1, default is 0)
  5615. */
  5616. r: number;
  5617. /**
  5618. * Defines the green component (between 0 and 1, default is 0)
  5619. */
  5620. g: number;
  5621. /**
  5622. * Defines the blue component (between 0 and 1, default is 0)
  5623. */
  5624. b: number;
  5625. /**
  5626. * Defines the alpha component (between 0 and 1, default is 1)
  5627. */
  5628. a: number;
  5629. /**
  5630. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5631. * @param r defines the red component (between 0 and 1, default is 0)
  5632. * @param g defines the green component (between 0 and 1, default is 0)
  5633. * @param b defines the blue component (between 0 and 1, default is 0)
  5634. * @param a defines the alpha component (between 0 and 1, default is 1)
  5635. */
  5636. constructor(
  5637. /**
  5638. * Defines the red component (between 0 and 1, default is 0)
  5639. */
  5640. r?: number,
  5641. /**
  5642. * Defines the green component (between 0 and 1, default is 0)
  5643. */
  5644. g?: number,
  5645. /**
  5646. * Defines the blue component (between 0 and 1, default is 0)
  5647. */
  5648. b?: number,
  5649. /**
  5650. * Defines the alpha component (between 0 and 1, default is 1)
  5651. */
  5652. a?: number);
  5653. /**
  5654. * Adds in place the given Color4 values to the current Color4 object
  5655. * @param right defines the second operand
  5656. * @returns the current updated Color4 object
  5657. */
  5658. addInPlace(right: DeepImmutable<Color4>): Color4;
  5659. /**
  5660. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5661. * @returns the new array
  5662. */
  5663. asArray(): number[];
  5664. /**
  5665. * Stores from the starting index in the given array the Color4 successive values
  5666. * @param array defines the array where to store the r,g,b components
  5667. * @param index defines an optional index in the target array to define where to start storing values
  5668. * @returns the current Color4 object
  5669. */
  5670. toArray(array: number[], index?: number): Color4;
  5671. /**
  5672. * Determines equality between Color4 objects
  5673. * @param otherColor defines the second operand
  5674. * @returns true if the rgba values are equal to the given ones
  5675. */
  5676. equals(otherColor: DeepImmutable<Color4>): boolean;
  5677. /**
  5678. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5679. * @param right defines the second operand
  5680. * @returns a new Color4 object
  5681. */
  5682. add(right: DeepImmutable<Color4>): Color4;
  5683. /**
  5684. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5685. * @param right defines the second operand
  5686. * @returns a new Color4 object
  5687. */
  5688. subtract(right: DeepImmutable<Color4>): Color4;
  5689. /**
  5690. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5691. * @param right defines the second operand
  5692. * @param result defines the Color4 object where to store the result
  5693. * @returns the current Color4 object
  5694. */
  5695. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5696. /**
  5697. * Creates a new Color4 with the current Color4 values multiplied by scale
  5698. * @param scale defines the scaling factor to apply
  5699. * @returns a new Color4 object
  5700. */
  5701. scale(scale: number): Color4;
  5702. /**
  5703. * Multiplies the current Color4 values by scale and stores the result in "result"
  5704. * @param scale defines the scaling factor to apply
  5705. * @param result defines the Color4 object where to store the result
  5706. * @returns the current unmodified Color4
  5707. */
  5708. scaleToRef(scale: number, result: Color4): Color4;
  5709. /**
  5710. * Scale the current Color4 values by a factor and add the result to a given Color4
  5711. * @param scale defines the scale factor
  5712. * @param result defines the Color4 object where to store the result
  5713. * @returns the unmodified current Color4
  5714. */
  5715. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5716. /**
  5717. * Clamps the rgb values by the min and max values and stores the result into "result"
  5718. * @param min defines minimum clamping value (default is 0)
  5719. * @param max defines maximum clamping value (default is 1)
  5720. * @param result defines color to store the result into.
  5721. * @returns the cuurent Color4
  5722. */
  5723. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5724. /**
  5725. * Multipy an Color4 value by another and return a new Color4 object
  5726. * @param color defines the Color4 value to multiply by
  5727. * @returns a new Color4 object
  5728. */
  5729. multiply(color: Color4): Color4;
  5730. /**
  5731. * Multipy a Color4 value by another and push the result in a reference value
  5732. * @param color defines the Color4 value to multiply by
  5733. * @param result defines the Color4 to fill the result in
  5734. * @returns the result Color4
  5735. */
  5736. multiplyToRef(color: Color4, result: Color4): Color4;
  5737. /**
  5738. * Creates a string with the Color4 current values
  5739. * @returns the string representation of the Color4 object
  5740. */
  5741. toString(): string;
  5742. /**
  5743. * Returns the string "Color4"
  5744. * @returns "Color4"
  5745. */
  5746. getClassName(): string;
  5747. /**
  5748. * Compute the Color4 hash code
  5749. * @returns an unique number that can be used to hash Color4 objects
  5750. */
  5751. getHashCode(): number;
  5752. /**
  5753. * Creates a new Color4 copied from the current one
  5754. * @returns a new Color4 object
  5755. */
  5756. clone(): Color4;
  5757. /**
  5758. * Copies the given Color4 values into the current one
  5759. * @param source defines the source Color4 object
  5760. * @returns the current updated Color4 object
  5761. */
  5762. copyFrom(source: Color4): Color4;
  5763. /**
  5764. * Copies the given float values into the current one
  5765. * @param r defines the red component to read from
  5766. * @param g defines the green component to read from
  5767. * @param b defines the blue component to read from
  5768. * @param a defines the alpha component to read from
  5769. * @returns the current updated Color4 object
  5770. */
  5771. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5772. /**
  5773. * Copies the given float values into the current one
  5774. * @param r defines the red component to read from
  5775. * @param g defines the green component to read from
  5776. * @param b defines the blue component to read from
  5777. * @param a defines the alpha component to read from
  5778. * @returns the current updated Color4 object
  5779. */
  5780. set(r: number, g: number, b: number, a: number): Color4;
  5781. /**
  5782. * Compute the Color4 hexadecimal code as a string
  5783. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5784. * @returns a string containing the hexadecimal representation of the Color4 object
  5785. */
  5786. toHexString(returnAsColor3?: boolean): string;
  5787. /**
  5788. * Computes a new Color4 converted from the current one to linear space
  5789. * @returns a new Color4 object
  5790. */
  5791. toLinearSpace(): Color4;
  5792. /**
  5793. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5794. * @param convertedColor defines the Color4 object where to store the linear space version
  5795. * @returns the unmodified Color4
  5796. */
  5797. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5798. /**
  5799. * Computes a new Color4 converted from the current one to gamma space
  5800. * @returns a new Color4 object
  5801. */
  5802. toGammaSpace(): Color4;
  5803. /**
  5804. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5805. * @param convertedColor defines the Color4 object where to store the gamma space version
  5806. * @returns the unmodified Color4
  5807. */
  5808. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5809. /**
  5810. * Creates a new Color4 from the string containing valid hexadecimal values
  5811. * @param hex defines a string containing valid hexadecimal values
  5812. * @returns a new Color4 object
  5813. */
  5814. static FromHexString(hex: string): Color4;
  5815. /**
  5816. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5817. * @param left defines the start value
  5818. * @param right defines the end value
  5819. * @param amount defines the gradient factor
  5820. * @returns a new Color4 object
  5821. */
  5822. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5823. /**
  5824. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5825. * @param left defines the start value
  5826. * @param right defines the end value
  5827. * @param amount defines the gradient factor
  5828. * @param result defines the Color4 object where to store data
  5829. */
  5830. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5831. /**
  5832. * Creates a new Color4 from a Color3 and an alpha value
  5833. * @param color3 defines the source Color3 to read from
  5834. * @param alpha defines the alpha component (1.0 by default)
  5835. * @returns a new Color4 object
  5836. */
  5837. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5838. /**
  5839. * Creates a new Color4 from the starting index element of the given array
  5840. * @param array defines the source array to read from
  5841. * @param offset defines the offset in the source array
  5842. * @returns a new Color4 object
  5843. */
  5844. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5845. /**
  5846. * Creates a new Color3 from integer values (< 256)
  5847. * @param r defines the red component to read from (value between 0 and 255)
  5848. * @param g defines the green component to read from (value between 0 and 255)
  5849. * @param b defines the blue component to read from (value between 0 and 255)
  5850. * @param a defines the alpha component to read from (value between 0 and 255)
  5851. * @returns a new Color3 object
  5852. */
  5853. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5854. /**
  5855. * Check the content of a given array and convert it to an array containing RGBA data
  5856. * If the original array was already containing count * 4 values then it is returned directly
  5857. * @param colors defines the array to check
  5858. * @param count defines the number of RGBA data to expect
  5859. * @returns an array containing count * 4 values (RGBA)
  5860. */
  5861. static CheckColors4(colors: number[], count: number): number[];
  5862. }
  5863. /**
  5864. * @hidden
  5865. */
  5866. export class TmpColors {
  5867. static Color3: Color3[];
  5868. static Color4: Color4[];
  5869. }
  5870. }
  5871. declare module BABYLON {
  5872. /**
  5873. * Defines an interface which represents an animation key frame
  5874. */
  5875. export interface IAnimationKey {
  5876. /**
  5877. * Frame of the key frame
  5878. */
  5879. frame: number;
  5880. /**
  5881. * Value at the specifies key frame
  5882. */
  5883. value: any;
  5884. /**
  5885. * The input tangent for the cubic hermite spline
  5886. */
  5887. inTangent?: any;
  5888. /**
  5889. * The output tangent for the cubic hermite spline
  5890. */
  5891. outTangent?: any;
  5892. /**
  5893. * The animation interpolation type
  5894. */
  5895. interpolation?: AnimationKeyInterpolation;
  5896. }
  5897. /**
  5898. * Enum for the animation key frame interpolation type
  5899. */
  5900. export enum AnimationKeyInterpolation {
  5901. /**
  5902. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5903. */
  5904. STEP = 1
  5905. }
  5906. }
  5907. declare module BABYLON {
  5908. /**
  5909. * Represents the range of an animation
  5910. */
  5911. export class AnimationRange {
  5912. /**The name of the animation range**/
  5913. name: string;
  5914. /**The starting frame of the animation */
  5915. from: number;
  5916. /**The ending frame of the animation*/
  5917. to: number;
  5918. /**
  5919. * Initializes the range of an animation
  5920. * @param name The name of the animation range
  5921. * @param from The starting frame of the animation
  5922. * @param to The ending frame of the animation
  5923. */
  5924. constructor(
  5925. /**The name of the animation range**/
  5926. name: string,
  5927. /**The starting frame of the animation */
  5928. from: number,
  5929. /**The ending frame of the animation*/
  5930. to: number);
  5931. /**
  5932. * Makes a copy of the animation range
  5933. * @returns A copy of the animation range
  5934. */
  5935. clone(): AnimationRange;
  5936. }
  5937. }
  5938. declare module BABYLON {
  5939. /**
  5940. * Composed of a frame, and an action function
  5941. */
  5942. export class AnimationEvent {
  5943. /** The frame for which the event is triggered **/
  5944. frame: number;
  5945. /** The event to perform when triggered **/
  5946. action: (currentFrame: number) => void;
  5947. /** Specifies if the event should be triggered only once**/
  5948. onlyOnce?: boolean | undefined;
  5949. /**
  5950. * Specifies if the animation event is done
  5951. */
  5952. isDone: boolean;
  5953. /**
  5954. * Initializes the animation event
  5955. * @param frame The frame for which the event is triggered
  5956. * @param action The event to perform when triggered
  5957. * @param onlyOnce Specifies if the event should be triggered only once
  5958. */
  5959. constructor(
  5960. /** The frame for which the event is triggered **/
  5961. frame: number,
  5962. /** The event to perform when triggered **/
  5963. action: (currentFrame: number) => void,
  5964. /** Specifies if the event should be triggered only once**/
  5965. onlyOnce?: boolean | undefined);
  5966. /** @hidden */
  5967. _clone(): AnimationEvent;
  5968. }
  5969. }
  5970. declare module BABYLON {
  5971. /**
  5972. * Interface used to define a behavior
  5973. */
  5974. export interface Behavior<T> {
  5975. /** gets or sets behavior's name */
  5976. name: string;
  5977. /**
  5978. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5979. */
  5980. init(): void;
  5981. /**
  5982. * Called when the behavior is attached to a target
  5983. * @param target defines the target where the behavior is attached to
  5984. */
  5985. attach(target: T): void;
  5986. /**
  5987. * Called when the behavior is detached from its target
  5988. */
  5989. detach(): void;
  5990. }
  5991. /**
  5992. * Interface implemented by classes supporting behaviors
  5993. */
  5994. export interface IBehaviorAware<T> {
  5995. /**
  5996. * Attach a behavior
  5997. * @param behavior defines the behavior to attach
  5998. * @returns the current host
  5999. */
  6000. addBehavior(behavior: Behavior<T>): T;
  6001. /**
  6002. * Remove a behavior from the current object
  6003. * @param behavior defines the behavior to detach
  6004. * @returns the current host
  6005. */
  6006. removeBehavior(behavior: Behavior<T>): T;
  6007. /**
  6008. * Gets a behavior using its name to search
  6009. * @param name defines the name to search
  6010. * @returns the behavior or null if not found
  6011. */
  6012. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6013. }
  6014. }
  6015. declare module BABYLON {
  6016. /**
  6017. * Defines an array and its length.
  6018. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6019. */
  6020. export interface ISmartArrayLike<T> {
  6021. /**
  6022. * The data of the array.
  6023. */
  6024. data: Array<T>;
  6025. /**
  6026. * The active length of the array.
  6027. */
  6028. length: number;
  6029. }
  6030. /**
  6031. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6032. */
  6033. export class SmartArray<T> implements ISmartArrayLike<T> {
  6034. /**
  6035. * The full set of data from the array.
  6036. */
  6037. data: Array<T>;
  6038. /**
  6039. * The active length of the array.
  6040. */
  6041. length: number;
  6042. protected _id: number;
  6043. /**
  6044. * Instantiates a Smart Array.
  6045. * @param capacity defines the default capacity of the array.
  6046. */
  6047. constructor(capacity: number);
  6048. /**
  6049. * Pushes a value at the end of the active data.
  6050. * @param value defines the object to push in the array.
  6051. */
  6052. push(value: T): void;
  6053. /**
  6054. * Iterates over the active data and apply the lambda to them.
  6055. * @param func defines the action to apply on each value.
  6056. */
  6057. forEach(func: (content: T) => void): void;
  6058. /**
  6059. * Sorts the full sets of data.
  6060. * @param compareFn defines the comparison function to apply.
  6061. */
  6062. sort(compareFn: (a: T, b: T) => number): void;
  6063. /**
  6064. * Resets the active data to an empty array.
  6065. */
  6066. reset(): void;
  6067. /**
  6068. * Releases all the data from the array as well as the array.
  6069. */
  6070. dispose(): void;
  6071. /**
  6072. * Concats the active data with a given array.
  6073. * @param array defines the data to concatenate with.
  6074. */
  6075. concat(array: any): void;
  6076. /**
  6077. * Returns the position of a value in the active data.
  6078. * @param value defines the value to find the index for
  6079. * @returns the index if found in the active data otherwise -1
  6080. */
  6081. indexOf(value: T): number;
  6082. /**
  6083. * Returns whether an element is part of the active data.
  6084. * @param value defines the value to look for
  6085. * @returns true if found in the active data otherwise false
  6086. */
  6087. contains(value: T): boolean;
  6088. private static _GlobalId;
  6089. }
  6090. /**
  6091. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6092. * The data in this array can only be present once
  6093. */
  6094. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6095. private _duplicateId;
  6096. /**
  6097. * Pushes a value at the end of the active data.
  6098. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6099. * @param value defines the object to push in the array.
  6100. */
  6101. push(value: T): void;
  6102. /**
  6103. * Pushes a value at the end of the active data.
  6104. * If the data is already present, it won t be added again
  6105. * @param value defines the object to push in the array.
  6106. * @returns true if added false if it was already present
  6107. */
  6108. pushNoDuplicate(value: T): boolean;
  6109. /**
  6110. * Resets the active data to an empty array.
  6111. */
  6112. reset(): void;
  6113. /**
  6114. * Concats the active data with a given array.
  6115. * This ensures no dupplicate will be present in the result.
  6116. * @param array defines the data to concatenate with.
  6117. */
  6118. concatWithNoDuplicate(array: any): void;
  6119. }
  6120. }
  6121. declare module BABYLON {
  6122. /**
  6123. * @ignore
  6124. * This is a list of all the different input types that are available in the application.
  6125. * Fo instance: ArcRotateCameraGamepadInput...
  6126. */
  6127. export var CameraInputTypes: {};
  6128. /**
  6129. * This is the contract to implement in order to create a new input class.
  6130. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6131. */
  6132. export interface ICameraInput<TCamera extends Camera> {
  6133. /**
  6134. * Defines the camera the input is attached to.
  6135. */
  6136. camera: Nullable<TCamera>;
  6137. /**
  6138. * Gets the class name of the current intput.
  6139. * @returns the class name
  6140. */
  6141. getClassName(): string;
  6142. /**
  6143. * Get the friendly name associated with the input class.
  6144. * @returns the input friendly name
  6145. */
  6146. getSimpleName(): string;
  6147. /**
  6148. * Attach the input controls to a specific dom element to get the input from.
  6149. * @param element Defines the element the controls should be listened from
  6150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6151. */
  6152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6153. /**
  6154. * Detach the current controls from the specified dom element.
  6155. * @param element Defines the element to stop listening the inputs from
  6156. */
  6157. detachControl(element: Nullable<HTMLElement>): void;
  6158. /**
  6159. * Update the current camera state depending on the inputs that have been used this frame.
  6160. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6161. */
  6162. checkInputs?: () => void;
  6163. }
  6164. /**
  6165. * Represents a map of input types to input instance or input index to input instance.
  6166. */
  6167. export interface CameraInputsMap<TCamera extends Camera> {
  6168. /**
  6169. * Accessor to the input by input type.
  6170. */
  6171. [name: string]: ICameraInput<TCamera>;
  6172. /**
  6173. * Accessor to the input by input index.
  6174. */
  6175. [idx: number]: ICameraInput<TCamera>;
  6176. }
  6177. /**
  6178. * This represents the input manager used within a camera.
  6179. * It helps dealing with all the different kind of input attached to a camera.
  6180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6181. */
  6182. export class CameraInputsManager<TCamera extends Camera> {
  6183. /**
  6184. * Defines the list of inputs attahed to the camera.
  6185. */
  6186. attached: CameraInputsMap<TCamera>;
  6187. /**
  6188. * Defines the dom element the camera is collecting inputs from.
  6189. * This is null if the controls have not been attached.
  6190. */
  6191. attachedElement: Nullable<HTMLElement>;
  6192. /**
  6193. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6194. */
  6195. noPreventDefault: boolean;
  6196. /**
  6197. * Defined the camera the input manager belongs to.
  6198. */
  6199. camera: TCamera;
  6200. /**
  6201. * Update the current camera state depending on the inputs that have been used this frame.
  6202. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6203. */
  6204. checkInputs: () => void;
  6205. /**
  6206. * Instantiate a new Camera Input Manager.
  6207. * @param camera Defines the camera the input manager blongs to
  6208. */
  6209. constructor(camera: TCamera);
  6210. /**
  6211. * Add an input method to a camera
  6212. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6213. * @param input camera input method
  6214. */
  6215. add(input: ICameraInput<TCamera>): void;
  6216. /**
  6217. * Remove a specific input method from a camera
  6218. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6219. * @param inputToRemove camera input method
  6220. */
  6221. remove(inputToRemove: ICameraInput<TCamera>): void;
  6222. /**
  6223. * Remove a specific input type from a camera
  6224. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6225. * @param inputType the type of the input to remove
  6226. */
  6227. removeByType(inputType: string): void;
  6228. private _addCheckInputs;
  6229. /**
  6230. * Attach the input controls to the currently attached dom element to listen the events from.
  6231. * @param input Defines the input to attach
  6232. */
  6233. attachInput(input: ICameraInput<TCamera>): void;
  6234. /**
  6235. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6236. * @param element Defines the dom element to collect the events from
  6237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6238. */
  6239. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6240. /**
  6241. * Detach the current manager inputs controls from a specific dom element.
  6242. * @param element Defines the dom element to collect the events from
  6243. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6244. */
  6245. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6246. /**
  6247. * Rebuild the dynamic inputCheck function from the current list of
  6248. * defined inputs in the manager.
  6249. */
  6250. rebuildInputCheck(): void;
  6251. /**
  6252. * Remove all attached input methods from a camera
  6253. */
  6254. clear(): void;
  6255. /**
  6256. * Serialize the current input manager attached to a camera.
  6257. * This ensures than once parsed,
  6258. * the input associated to the camera will be identical to the current ones
  6259. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6260. */
  6261. serialize(serializedCamera: any): void;
  6262. /**
  6263. * Parses an input manager serialized JSON to restore the previous list of inputs
  6264. * and states associated to a camera.
  6265. * @param parsedCamera Defines the JSON to parse
  6266. */
  6267. parse(parsedCamera: any): void;
  6268. }
  6269. }
  6270. declare module BABYLON {
  6271. /**
  6272. * Class used to store data that will be store in GPU memory
  6273. */
  6274. export class Buffer {
  6275. private _engine;
  6276. private _buffer;
  6277. /** @hidden */
  6278. _data: Nullable<DataArray>;
  6279. private _updatable;
  6280. private _instanced;
  6281. private _divisor;
  6282. /**
  6283. * Gets the byte stride.
  6284. */
  6285. readonly byteStride: number;
  6286. /**
  6287. * Constructor
  6288. * @param engine the engine
  6289. * @param data the data to use for this buffer
  6290. * @param updatable whether the data is updatable
  6291. * @param stride the stride (optional)
  6292. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6293. * @param instanced whether the buffer is instanced (optional)
  6294. * @param useBytes set to true if the stride in in bytes (optional)
  6295. * @param divisor sets an optional divisor for instances (1 by default)
  6296. */
  6297. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6298. /**
  6299. * Create a new VertexBuffer based on the current buffer
  6300. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6301. * @param offset defines offset in the buffer (0 by default)
  6302. * @param size defines the size in floats of attributes (position is 3 for instance)
  6303. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6304. * @param instanced defines if the vertex buffer contains indexed data
  6305. * @param useBytes defines if the offset and stride are in bytes *
  6306. * @param divisor sets an optional divisor for instances (1 by default)
  6307. * @returns the new vertex buffer
  6308. */
  6309. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6310. /**
  6311. * Gets a boolean indicating if the Buffer is updatable?
  6312. * @returns true if the buffer is updatable
  6313. */
  6314. isUpdatable(): boolean;
  6315. /**
  6316. * Gets current buffer's data
  6317. * @returns a DataArray or null
  6318. */
  6319. getData(): Nullable<DataArray>;
  6320. /**
  6321. * Gets underlying native buffer
  6322. * @returns underlying native buffer
  6323. */
  6324. getBuffer(): Nullable<DataBuffer>;
  6325. /**
  6326. * Gets the stride in float32 units (i.e. byte stride / 4).
  6327. * May not be an integer if the byte stride is not divisible by 4.
  6328. * @returns the stride in float32 units
  6329. * @deprecated Please use byteStride instead.
  6330. */
  6331. getStrideSize(): number;
  6332. /**
  6333. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6334. * @param data defines the data to store
  6335. */
  6336. create(data?: Nullable<DataArray>): void;
  6337. /** @hidden */
  6338. _rebuild(): void;
  6339. /**
  6340. * Update current buffer data
  6341. * @param data defines the data to store
  6342. */
  6343. update(data: DataArray): void;
  6344. /**
  6345. * Updates the data directly.
  6346. * @param data the new data
  6347. * @param offset the new offset
  6348. * @param vertexCount the vertex count (optional)
  6349. * @param useBytes set to true if the offset is in bytes
  6350. */
  6351. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6352. /**
  6353. * Release all resources
  6354. */
  6355. dispose(): void;
  6356. }
  6357. /**
  6358. * Specialized buffer used to store vertex data
  6359. */
  6360. export class VertexBuffer {
  6361. /** @hidden */
  6362. _buffer: Buffer;
  6363. private _kind;
  6364. private _size;
  6365. private _ownsBuffer;
  6366. private _instanced;
  6367. private _instanceDivisor;
  6368. /**
  6369. * The byte type.
  6370. */
  6371. static readonly BYTE: number;
  6372. /**
  6373. * The unsigned byte type.
  6374. */
  6375. static readonly UNSIGNED_BYTE: number;
  6376. /**
  6377. * The short type.
  6378. */
  6379. static readonly SHORT: number;
  6380. /**
  6381. * The unsigned short type.
  6382. */
  6383. static readonly UNSIGNED_SHORT: number;
  6384. /**
  6385. * The integer type.
  6386. */
  6387. static readonly INT: number;
  6388. /**
  6389. * The unsigned integer type.
  6390. */
  6391. static readonly UNSIGNED_INT: number;
  6392. /**
  6393. * The float type.
  6394. */
  6395. static readonly FLOAT: number;
  6396. /**
  6397. * Gets or sets the instance divisor when in instanced mode
  6398. */
  6399. get instanceDivisor(): number;
  6400. set instanceDivisor(value: number);
  6401. /**
  6402. * Gets the byte stride.
  6403. */
  6404. readonly byteStride: number;
  6405. /**
  6406. * Gets the byte offset.
  6407. */
  6408. readonly byteOffset: number;
  6409. /**
  6410. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6411. */
  6412. readonly normalized: boolean;
  6413. /**
  6414. * Gets the data type of each component in the array.
  6415. */
  6416. readonly type: number;
  6417. /**
  6418. * Constructor
  6419. * @param engine the engine
  6420. * @param data the data to use for this vertex buffer
  6421. * @param kind the vertex buffer kind
  6422. * @param updatable whether the data is updatable
  6423. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6424. * @param stride the stride (optional)
  6425. * @param instanced whether the buffer is instanced (optional)
  6426. * @param offset the offset of the data (optional)
  6427. * @param size the number of components (optional)
  6428. * @param type the type of the component (optional)
  6429. * @param normalized whether the data contains normalized data (optional)
  6430. * @param useBytes set to true if stride and offset are in bytes (optional)
  6431. * @param divisor defines the instance divisor to use (1 by default)
  6432. */
  6433. 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);
  6434. /** @hidden */
  6435. _rebuild(): void;
  6436. /**
  6437. * Returns the kind of the VertexBuffer (string)
  6438. * @returns a string
  6439. */
  6440. getKind(): string;
  6441. /**
  6442. * Gets a boolean indicating if the VertexBuffer is updatable?
  6443. * @returns true if the buffer is updatable
  6444. */
  6445. isUpdatable(): boolean;
  6446. /**
  6447. * Gets current buffer's data
  6448. * @returns a DataArray or null
  6449. */
  6450. getData(): Nullable<DataArray>;
  6451. /**
  6452. * Gets underlying native buffer
  6453. * @returns underlying native buffer
  6454. */
  6455. getBuffer(): Nullable<DataBuffer>;
  6456. /**
  6457. * Gets the stride in float32 units (i.e. byte stride / 4).
  6458. * May not be an integer if the byte stride is not divisible by 4.
  6459. * @returns the stride in float32 units
  6460. * @deprecated Please use byteStride instead.
  6461. */
  6462. getStrideSize(): number;
  6463. /**
  6464. * Returns the offset as a multiple of the type byte length.
  6465. * @returns the offset in bytes
  6466. * @deprecated Please use byteOffset instead.
  6467. */
  6468. getOffset(): number;
  6469. /**
  6470. * Returns the number of components per vertex attribute (integer)
  6471. * @returns the size in float
  6472. */
  6473. getSize(): number;
  6474. /**
  6475. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6476. * @returns true if this buffer is instanced
  6477. */
  6478. getIsInstanced(): boolean;
  6479. /**
  6480. * Returns the instancing divisor, zero for non-instanced (integer).
  6481. * @returns a number
  6482. */
  6483. getInstanceDivisor(): number;
  6484. /**
  6485. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6486. * @param data defines the data to store
  6487. */
  6488. create(data?: DataArray): void;
  6489. /**
  6490. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6491. * This function will create a new buffer if the current one is not updatable
  6492. * @param data defines the data to store
  6493. */
  6494. update(data: DataArray): void;
  6495. /**
  6496. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6497. * Returns the directly updated WebGLBuffer.
  6498. * @param data the new data
  6499. * @param offset the new offset
  6500. * @param useBytes set to true if the offset is in bytes
  6501. */
  6502. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6503. /**
  6504. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6505. */
  6506. dispose(): void;
  6507. /**
  6508. * Enumerates each value of this vertex buffer as numbers.
  6509. * @param count the number of values to enumerate
  6510. * @param callback the callback function called for each value
  6511. */
  6512. forEach(count: number, callback: (value: number, index: number) => void): void;
  6513. /**
  6514. * Positions
  6515. */
  6516. static readonly PositionKind: string;
  6517. /**
  6518. * Normals
  6519. */
  6520. static readonly NormalKind: string;
  6521. /**
  6522. * Tangents
  6523. */
  6524. static readonly TangentKind: string;
  6525. /**
  6526. * Texture coordinates
  6527. */
  6528. static readonly UVKind: string;
  6529. /**
  6530. * Texture coordinates 2
  6531. */
  6532. static readonly UV2Kind: string;
  6533. /**
  6534. * Texture coordinates 3
  6535. */
  6536. static readonly UV3Kind: string;
  6537. /**
  6538. * Texture coordinates 4
  6539. */
  6540. static readonly UV4Kind: string;
  6541. /**
  6542. * Texture coordinates 5
  6543. */
  6544. static readonly UV5Kind: string;
  6545. /**
  6546. * Texture coordinates 6
  6547. */
  6548. static readonly UV6Kind: string;
  6549. /**
  6550. * Colors
  6551. */
  6552. static readonly ColorKind: string;
  6553. /**
  6554. * Matrix indices (for bones)
  6555. */
  6556. static readonly MatricesIndicesKind: string;
  6557. /**
  6558. * Matrix weights (for bones)
  6559. */
  6560. static readonly MatricesWeightsKind: string;
  6561. /**
  6562. * Additional matrix indices (for bones)
  6563. */
  6564. static readonly MatricesIndicesExtraKind: string;
  6565. /**
  6566. * Additional matrix weights (for bones)
  6567. */
  6568. static readonly MatricesWeightsExtraKind: string;
  6569. /**
  6570. * Deduces the stride given a kind.
  6571. * @param kind The kind string to deduce
  6572. * @returns The deduced stride
  6573. */
  6574. static DeduceStride(kind: string): number;
  6575. /**
  6576. * Gets the byte length of the given type.
  6577. * @param type the type
  6578. * @returns the number of bytes
  6579. */
  6580. static GetTypeByteLength(type: number): number;
  6581. /**
  6582. * Enumerates each value of the given parameters as numbers.
  6583. * @param data the data to enumerate
  6584. * @param byteOffset the byte offset of the data
  6585. * @param byteStride the byte stride of the data
  6586. * @param componentCount the number of components per element
  6587. * @param componentType the type of the component
  6588. * @param count the number of values to enumerate
  6589. * @param normalized whether the data is normalized
  6590. * @param callback the callback function called for each value
  6591. */
  6592. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6593. private static _GetFloatValue;
  6594. }
  6595. }
  6596. declare module BABYLON {
  6597. /**
  6598. * @hidden
  6599. */
  6600. export class IntersectionInfo {
  6601. bu: Nullable<number>;
  6602. bv: Nullable<number>;
  6603. distance: number;
  6604. faceId: number;
  6605. subMeshId: number;
  6606. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6607. }
  6608. }
  6609. declare module BABYLON {
  6610. /**
  6611. * Represens a plane by the equation ax + by + cz + d = 0
  6612. */
  6613. export class Plane {
  6614. private static _TmpMatrix;
  6615. /**
  6616. * Normal of the plane (a,b,c)
  6617. */
  6618. normal: Vector3;
  6619. /**
  6620. * d component of the plane
  6621. */
  6622. d: number;
  6623. /**
  6624. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6625. * @param a a component of the plane
  6626. * @param b b component of the plane
  6627. * @param c c component of the plane
  6628. * @param d d component of the plane
  6629. */
  6630. constructor(a: number, b: number, c: number, d: number);
  6631. /**
  6632. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6633. */
  6634. asArray(): number[];
  6635. /**
  6636. * @returns a new plane copied from the current Plane.
  6637. */
  6638. clone(): Plane;
  6639. /**
  6640. * @returns the string "Plane".
  6641. */
  6642. getClassName(): string;
  6643. /**
  6644. * @returns the Plane hash code.
  6645. */
  6646. getHashCode(): number;
  6647. /**
  6648. * Normalize the current Plane in place.
  6649. * @returns the updated Plane.
  6650. */
  6651. normalize(): Plane;
  6652. /**
  6653. * Applies a transformation the plane and returns the result
  6654. * @param transformation the transformation matrix to be applied to the plane
  6655. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6656. */
  6657. transform(transformation: DeepImmutable<Matrix>): Plane;
  6658. /**
  6659. * Calcualtte the dot product between the point and the plane normal
  6660. * @param point point to calculate the dot product with
  6661. * @returns the dot product (float) of the point coordinates and the plane normal.
  6662. */
  6663. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6664. /**
  6665. * Updates the current Plane from the plane defined by the three given points.
  6666. * @param point1 one of the points used to contruct the plane
  6667. * @param point2 one of the points used to contruct the plane
  6668. * @param point3 one of the points used to contruct the plane
  6669. * @returns the updated Plane.
  6670. */
  6671. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6672. /**
  6673. * Checks if the plane is facing a given direction
  6674. * @param direction the direction to check if the plane is facing
  6675. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6676. * @returns True is the vector "direction" is the same side than the plane normal.
  6677. */
  6678. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6679. /**
  6680. * Calculates the distance to a point
  6681. * @param point point to calculate distance to
  6682. * @returns the signed distance (float) from the given point to the Plane.
  6683. */
  6684. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6685. /**
  6686. * Creates a plane from an array
  6687. * @param array the array to create a plane from
  6688. * @returns a new Plane from the given array.
  6689. */
  6690. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6691. /**
  6692. * Creates a plane from three points
  6693. * @param point1 point used to create the plane
  6694. * @param point2 point used to create the plane
  6695. * @param point3 point used to create the plane
  6696. * @returns a new Plane defined by the three given points.
  6697. */
  6698. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6699. /**
  6700. * Creates a plane from an origin point and a normal
  6701. * @param origin origin of the plane to be constructed
  6702. * @param normal normal of the plane to be constructed
  6703. * @returns a new Plane the normal vector to this plane at the given origin point.
  6704. * Note : the vector "normal" is updated because normalized.
  6705. */
  6706. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6707. /**
  6708. * Calculates the distance from a plane and a point
  6709. * @param origin origin of the plane to be constructed
  6710. * @param normal normal of the plane to be constructed
  6711. * @param point point to calculate distance to
  6712. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6713. */
  6714. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6715. }
  6716. }
  6717. declare module BABYLON {
  6718. /**
  6719. * Class used to store bounding sphere information
  6720. */
  6721. export class BoundingSphere {
  6722. /**
  6723. * Gets the center of the bounding sphere in local space
  6724. */
  6725. readonly center: Vector3;
  6726. /**
  6727. * Radius of the bounding sphere in local space
  6728. */
  6729. radius: number;
  6730. /**
  6731. * Gets the center of the bounding sphere in world space
  6732. */
  6733. readonly centerWorld: Vector3;
  6734. /**
  6735. * Radius of the bounding sphere in world space
  6736. */
  6737. radiusWorld: number;
  6738. /**
  6739. * Gets the minimum vector in local space
  6740. */
  6741. readonly minimum: Vector3;
  6742. /**
  6743. * Gets the maximum vector in local space
  6744. */
  6745. readonly maximum: Vector3;
  6746. private _worldMatrix;
  6747. private static readonly TmpVector3;
  6748. /**
  6749. * Creates a new bounding sphere
  6750. * @param min defines the minimum vector (in local space)
  6751. * @param max defines the maximum vector (in local space)
  6752. * @param worldMatrix defines the new world matrix
  6753. */
  6754. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6755. /**
  6756. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6757. * @param min defines the new minimum vector (in local space)
  6758. * @param max defines the new maximum vector (in local space)
  6759. * @param worldMatrix defines the new world matrix
  6760. */
  6761. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6762. /**
  6763. * Scale the current bounding sphere by applying a scale factor
  6764. * @param factor defines the scale factor to apply
  6765. * @returns the current bounding box
  6766. */
  6767. scale(factor: number): BoundingSphere;
  6768. /**
  6769. * Gets the world matrix of the bounding box
  6770. * @returns a matrix
  6771. */
  6772. getWorldMatrix(): DeepImmutable<Matrix>;
  6773. /** @hidden */
  6774. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6775. /**
  6776. * Tests if the bounding sphere is intersecting the frustum planes
  6777. * @param frustumPlanes defines the frustum planes to test
  6778. * @returns true if there is an intersection
  6779. */
  6780. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6781. /**
  6782. * Tests if the bounding sphere center is in between the frustum planes.
  6783. * Used for optimistic fast inclusion.
  6784. * @param frustumPlanes defines the frustum planes to test
  6785. * @returns true if the sphere center is in between the frustum planes
  6786. */
  6787. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6788. /**
  6789. * Tests if a point is inside the bounding sphere
  6790. * @param point defines the point to test
  6791. * @returns true if the point is inside the bounding sphere
  6792. */
  6793. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6794. /**
  6795. * Checks if two sphere intersct
  6796. * @param sphere0 sphere 0
  6797. * @param sphere1 sphere 1
  6798. * @returns true if the speres intersect
  6799. */
  6800. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6801. }
  6802. }
  6803. declare module BABYLON {
  6804. /**
  6805. * Class used to store bounding box information
  6806. */
  6807. export class BoundingBox implements ICullable {
  6808. /**
  6809. * Gets the 8 vectors representing the bounding box in local space
  6810. */
  6811. readonly vectors: Vector3[];
  6812. /**
  6813. * Gets the center of the bounding box in local space
  6814. */
  6815. readonly center: Vector3;
  6816. /**
  6817. * Gets the center of the bounding box in world space
  6818. */
  6819. readonly centerWorld: Vector3;
  6820. /**
  6821. * Gets the extend size in local space
  6822. */
  6823. readonly extendSize: Vector3;
  6824. /**
  6825. * Gets the extend size in world space
  6826. */
  6827. readonly extendSizeWorld: Vector3;
  6828. /**
  6829. * Gets the OBB (object bounding box) directions
  6830. */
  6831. readonly directions: Vector3[];
  6832. /**
  6833. * Gets the 8 vectors representing the bounding box in world space
  6834. */
  6835. readonly vectorsWorld: Vector3[];
  6836. /**
  6837. * Gets the minimum vector in world space
  6838. */
  6839. readonly minimumWorld: Vector3;
  6840. /**
  6841. * Gets the maximum vector in world space
  6842. */
  6843. readonly maximumWorld: Vector3;
  6844. /**
  6845. * Gets the minimum vector in local space
  6846. */
  6847. readonly minimum: Vector3;
  6848. /**
  6849. * Gets the maximum vector in local space
  6850. */
  6851. readonly maximum: Vector3;
  6852. private _worldMatrix;
  6853. private static readonly TmpVector3;
  6854. /**
  6855. * @hidden
  6856. */
  6857. _tag: number;
  6858. /**
  6859. * Creates a new bounding box
  6860. * @param min defines the minimum vector (in local space)
  6861. * @param max defines the maximum vector (in local space)
  6862. * @param worldMatrix defines the new world matrix
  6863. */
  6864. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6865. /**
  6866. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6867. * @param min defines the new minimum vector (in local space)
  6868. * @param max defines the new maximum vector (in local space)
  6869. * @param worldMatrix defines the new world matrix
  6870. */
  6871. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6872. /**
  6873. * Scale the current bounding box by applying a scale factor
  6874. * @param factor defines the scale factor to apply
  6875. * @returns the current bounding box
  6876. */
  6877. scale(factor: number): BoundingBox;
  6878. /**
  6879. * Gets the world matrix of the bounding box
  6880. * @returns a matrix
  6881. */
  6882. getWorldMatrix(): DeepImmutable<Matrix>;
  6883. /** @hidden */
  6884. _update(world: DeepImmutable<Matrix>): void;
  6885. /**
  6886. * Tests if the bounding box is intersecting the frustum planes
  6887. * @param frustumPlanes defines the frustum planes to test
  6888. * @returns true if there is an intersection
  6889. */
  6890. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6891. /**
  6892. * Tests if the bounding box is entirely inside the frustum planes
  6893. * @param frustumPlanes defines the frustum planes to test
  6894. * @returns true if there is an inclusion
  6895. */
  6896. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6897. /**
  6898. * Tests if a point is inside the bounding box
  6899. * @param point defines the point to test
  6900. * @returns true if the point is inside the bounding box
  6901. */
  6902. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6903. /**
  6904. * Tests if the bounding box intersects with a bounding sphere
  6905. * @param sphere defines the sphere to test
  6906. * @returns true if there is an intersection
  6907. */
  6908. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6909. /**
  6910. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6911. * @param min defines the min vector to use
  6912. * @param max defines the max vector to use
  6913. * @returns true if there is an intersection
  6914. */
  6915. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6916. /**
  6917. * Tests if two bounding boxes are intersections
  6918. * @param box0 defines the first box to test
  6919. * @param box1 defines the second box to test
  6920. * @returns true if there is an intersection
  6921. */
  6922. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6923. /**
  6924. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6925. * @param minPoint defines the minimum vector of the bounding box
  6926. * @param maxPoint defines the maximum vector of the bounding box
  6927. * @param sphereCenter defines the sphere center
  6928. * @param sphereRadius defines the sphere radius
  6929. * @returns true if there is an intersection
  6930. */
  6931. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6932. /**
  6933. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6934. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6935. * @param frustumPlanes defines the frustum planes to test
  6936. * @return true if there is an inclusion
  6937. */
  6938. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6939. /**
  6940. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6941. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @return true if there is an intersection
  6944. */
  6945. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. }
  6947. }
  6948. declare module BABYLON {
  6949. /** @hidden */
  6950. export class Collider {
  6951. /** Define if a collision was found */
  6952. collisionFound: boolean;
  6953. /**
  6954. * Define last intersection point in local space
  6955. */
  6956. intersectionPoint: Vector3;
  6957. /**
  6958. * Define last collided mesh
  6959. */
  6960. collidedMesh: Nullable<AbstractMesh>;
  6961. private _collisionPoint;
  6962. private _planeIntersectionPoint;
  6963. private _tempVector;
  6964. private _tempVector2;
  6965. private _tempVector3;
  6966. private _tempVector4;
  6967. private _edge;
  6968. private _baseToVertex;
  6969. private _destinationPoint;
  6970. private _slidePlaneNormal;
  6971. private _displacementVector;
  6972. /** @hidden */
  6973. _radius: Vector3;
  6974. /** @hidden */
  6975. _retry: number;
  6976. private _velocity;
  6977. private _basePoint;
  6978. private _epsilon;
  6979. /** @hidden */
  6980. _velocityWorldLength: number;
  6981. /** @hidden */
  6982. _basePointWorld: Vector3;
  6983. private _velocityWorld;
  6984. private _normalizedVelocity;
  6985. /** @hidden */
  6986. _initialVelocity: Vector3;
  6987. /** @hidden */
  6988. _initialPosition: Vector3;
  6989. private _nearestDistance;
  6990. private _collisionMask;
  6991. get collisionMask(): number;
  6992. set collisionMask(mask: number);
  6993. /**
  6994. * Gets the plane normal used to compute the sliding response (in local space)
  6995. */
  6996. get slidePlaneNormal(): Vector3;
  6997. /** @hidden */
  6998. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6999. /** @hidden */
  7000. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7001. /** @hidden */
  7002. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7003. /** @hidden */
  7004. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7005. /** @hidden */
  7006. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7007. /** @hidden */
  7008. _getResponse(pos: Vector3, vel: Vector3): void;
  7009. }
  7010. }
  7011. declare module BABYLON {
  7012. /**
  7013. * Interface for cullable objects
  7014. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7015. */
  7016. export interface ICullable {
  7017. /**
  7018. * Checks if the object or part of the object is in the frustum
  7019. * @param frustumPlanes Camera near/planes
  7020. * @returns true if the object is in frustum otherwise false
  7021. */
  7022. isInFrustum(frustumPlanes: Plane[]): boolean;
  7023. /**
  7024. * Checks if a cullable object (mesh...) is in the camera frustum
  7025. * Unlike isInFrustum this cheks the full bounding box
  7026. * @param frustumPlanes Camera near/planes
  7027. * @returns true if the object is in frustum otherwise false
  7028. */
  7029. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7030. }
  7031. /**
  7032. * Info for a bounding data of a mesh
  7033. */
  7034. export class BoundingInfo implements ICullable {
  7035. /**
  7036. * Bounding box for the mesh
  7037. */
  7038. readonly boundingBox: BoundingBox;
  7039. /**
  7040. * Bounding sphere for the mesh
  7041. */
  7042. readonly boundingSphere: BoundingSphere;
  7043. private _isLocked;
  7044. private static readonly TmpVector3;
  7045. /**
  7046. * Constructs bounding info
  7047. * @param minimum min vector of the bounding box/sphere
  7048. * @param maximum max vector of the bounding box/sphere
  7049. * @param worldMatrix defines the new world matrix
  7050. */
  7051. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7052. /**
  7053. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7054. * @param min defines the new minimum vector (in local space)
  7055. * @param max defines the new maximum vector (in local space)
  7056. * @param worldMatrix defines the new world matrix
  7057. */
  7058. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7059. /**
  7060. * min vector of the bounding box/sphere
  7061. */
  7062. get minimum(): Vector3;
  7063. /**
  7064. * max vector of the bounding box/sphere
  7065. */
  7066. get maximum(): Vector3;
  7067. /**
  7068. * If the info is locked and won't be updated to avoid perf overhead
  7069. */
  7070. get isLocked(): boolean;
  7071. set isLocked(value: boolean);
  7072. /**
  7073. * Updates the bounding sphere and box
  7074. * @param world world matrix to be used to update
  7075. */
  7076. update(world: DeepImmutable<Matrix>): void;
  7077. /**
  7078. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7079. * @param center New center of the bounding info
  7080. * @param extend New extend of the bounding info
  7081. * @returns the current bounding info
  7082. */
  7083. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7084. /**
  7085. * Scale the current bounding info by applying a scale factor
  7086. * @param factor defines the scale factor to apply
  7087. * @returns the current bounding info
  7088. */
  7089. scale(factor: number): BoundingInfo;
  7090. /**
  7091. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7092. * @param frustumPlanes defines the frustum to test
  7093. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7094. * @returns true if the bounding info is in the frustum planes
  7095. */
  7096. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7097. /**
  7098. * Gets the world distance between the min and max points of the bounding box
  7099. */
  7100. get diagonalLength(): number;
  7101. /**
  7102. * Checks if a cullable object (mesh...) is in the camera frustum
  7103. * Unlike isInFrustum this cheks the full bounding box
  7104. * @param frustumPlanes Camera near/planes
  7105. * @returns true if the object is in frustum otherwise false
  7106. */
  7107. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7108. /** @hidden */
  7109. _checkCollision(collider: Collider): boolean;
  7110. /**
  7111. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7112. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7113. * @param point the point to check intersection with
  7114. * @returns if the point intersects
  7115. */
  7116. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7117. /**
  7118. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7119. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7120. * @param boundingInfo the bounding info to check intersection with
  7121. * @param precise if the intersection should be done using OBB
  7122. * @returns if the bounding info intersects
  7123. */
  7124. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7125. }
  7126. }
  7127. declare module BABYLON {
  7128. /**
  7129. * Extracts minimum and maximum values from a list of indexed positions
  7130. * @param positions defines the positions to use
  7131. * @param indices defines the indices to the positions
  7132. * @param indexStart defines the start index
  7133. * @param indexCount defines the end index
  7134. * @param bias defines bias value to add to the result
  7135. * @return minimum and maximum values
  7136. */
  7137. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7138. minimum: Vector3;
  7139. maximum: Vector3;
  7140. };
  7141. /**
  7142. * Extracts minimum and maximum values from a list of positions
  7143. * @param positions defines the positions to use
  7144. * @param start defines the start index in the positions array
  7145. * @param count defines the number of positions to handle
  7146. * @param bias defines bias value to add to the result
  7147. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7148. * @return minimum and maximum values
  7149. */
  7150. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7151. minimum: Vector3;
  7152. maximum: Vector3;
  7153. };
  7154. }
  7155. declare module BABYLON {
  7156. /** @hidden */
  7157. export class WebGLDataBuffer extends DataBuffer {
  7158. private _buffer;
  7159. constructor(resource: WebGLBuffer);
  7160. get underlyingResource(): any;
  7161. }
  7162. }
  7163. declare module BABYLON {
  7164. /** @hidden */
  7165. export class WebGLPipelineContext implements IPipelineContext {
  7166. engine: ThinEngine;
  7167. program: Nullable<WebGLProgram>;
  7168. context?: WebGLRenderingContext;
  7169. vertexShader?: WebGLShader;
  7170. fragmentShader?: WebGLShader;
  7171. isParallelCompiled: boolean;
  7172. onCompiled?: () => void;
  7173. transformFeedback?: WebGLTransformFeedback | null;
  7174. vertexCompilationError: Nullable<string>;
  7175. fragmentCompilationError: Nullable<string>;
  7176. programLinkError: Nullable<string>;
  7177. programValidationError: Nullable<string>;
  7178. get isAsync(): boolean;
  7179. get isReady(): boolean;
  7180. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7181. _getVertexShaderCode(): string | null;
  7182. _getFragmentShaderCode(): string | null;
  7183. }
  7184. }
  7185. declare module BABYLON {
  7186. interface ThinEngine {
  7187. /**
  7188. * Create an uniform buffer
  7189. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7190. * @param elements defines the content of the uniform buffer
  7191. * @returns the webGL uniform buffer
  7192. */
  7193. createUniformBuffer(elements: FloatArray): DataBuffer;
  7194. /**
  7195. * Create a dynamic uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param elements defines the content of the uniform buffer
  7198. * @returns the webGL uniform buffer
  7199. */
  7200. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7201. /**
  7202. * Update an existing uniform buffer
  7203. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7204. * @param uniformBuffer defines the target uniform buffer
  7205. * @param elements defines the content to update
  7206. * @param offset defines the offset in the uniform buffer where update should start
  7207. * @param count defines the size of the data to update
  7208. */
  7209. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7210. /**
  7211. * Bind an uniform buffer to the current webGL context
  7212. * @param buffer defines the buffer to bind
  7213. */
  7214. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7215. /**
  7216. * Bind a buffer to the current webGL context at a given location
  7217. * @param buffer defines the buffer to bind
  7218. * @param location defines the index where to bind the buffer
  7219. */
  7220. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7221. /**
  7222. * Bind a specific block at a given index in a specific shader program
  7223. * @param pipelineContext defines the pipeline context to use
  7224. * @param blockName defines the block name
  7225. * @param index defines the index where to bind the block
  7226. */
  7227. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7228. }
  7229. }
  7230. declare module BABYLON {
  7231. /**
  7232. * Uniform buffer objects.
  7233. *
  7234. * Handles blocks of uniform on the GPU.
  7235. *
  7236. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7237. *
  7238. * For more information, please refer to :
  7239. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7240. */
  7241. export class UniformBuffer {
  7242. private _engine;
  7243. private _buffer;
  7244. private _data;
  7245. private _bufferData;
  7246. private _dynamic?;
  7247. private _uniformLocations;
  7248. private _uniformSizes;
  7249. private _uniformLocationPointer;
  7250. private _needSync;
  7251. private _noUBO;
  7252. private _currentEffect;
  7253. /** @hidden */
  7254. _alreadyBound: boolean;
  7255. private static _MAX_UNIFORM_SIZE;
  7256. private static _tempBuffer;
  7257. /**
  7258. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7259. * This is dynamic to allow compat with webgl 1 and 2.
  7260. * You will need to pass the name of the uniform as well as the value.
  7261. */
  7262. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7263. /**
  7264. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7265. * This is dynamic to allow compat with webgl 1 and 2.
  7266. * You will need to pass the name of the uniform as well as the value.
  7267. */
  7268. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7269. /**
  7270. * Lambda to Update a single float in a uniform buffer.
  7271. * This is dynamic to allow compat with webgl 1 and 2.
  7272. * You will need to pass the name of the uniform as well as the value.
  7273. */
  7274. updateFloat: (name: string, x: number) => void;
  7275. /**
  7276. * Lambda to Update a vec2 of float in a uniform buffer.
  7277. * This is dynamic to allow compat with webgl 1 and 2.
  7278. * You will need to pass the name of the uniform as well as the value.
  7279. */
  7280. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7281. /**
  7282. * Lambda to Update a vec3 of float in a uniform buffer.
  7283. * This is dynamic to allow compat with webgl 1 and 2.
  7284. * You will need to pass the name of the uniform as well as the value.
  7285. */
  7286. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7287. /**
  7288. * Lambda to Update a vec4 of float in a uniform buffer.
  7289. * This is dynamic to allow compat with webgl 1 and 2.
  7290. * You will need to pass the name of the uniform as well as the value.
  7291. */
  7292. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7293. /**
  7294. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7295. * This is dynamic to allow compat with webgl 1 and 2.
  7296. * You will need to pass the name of the uniform as well as the value.
  7297. */
  7298. updateMatrix: (name: string, mat: Matrix) => void;
  7299. /**
  7300. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7301. * This is dynamic to allow compat with webgl 1 and 2.
  7302. * You will need to pass the name of the uniform as well as the value.
  7303. */
  7304. updateVector3: (name: string, vector: Vector3) => void;
  7305. /**
  7306. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7307. * This is dynamic to allow compat with webgl 1 and 2.
  7308. * You will need to pass the name of the uniform as well as the value.
  7309. */
  7310. updateVector4: (name: string, vector: Vector4) => void;
  7311. /**
  7312. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7313. * This is dynamic to allow compat with webgl 1 and 2.
  7314. * You will need to pass the name of the uniform as well as the value.
  7315. */
  7316. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7317. /**
  7318. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7319. * This is dynamic to allow compat with webgl 1 and 2.
  7320. * You will need to pass the name of the uniform as well as the value.
  7321. */
  7322. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7323. /**
  7324. * Instantiates a new Uniform buffer objects.
  7325. *
  7326. * Handles blocks of uniform on the GPU.
  7327. *
  7328. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7329. *
  7330. * For more information, please refer to :
  7331. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7332. * @param engine Define the engine the buffer is associated with
  7333. * @param data Define the data contained in the buffer
  7334. * @param dynamic Define if the buffer is updatable
  7335. */
  7336. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7337. /**
  7338. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7339. * or just falling back on setUniformXXX calls.
  7340. */
  7341. get useUbo(): boolean;
  7342. /**
  7343. * Indicates if the WebGL underlying uniform buffer is in sync
  7344. * with the javascript cache data.
  7345. */
  7346. get isSync(): boolean;
  7347. /**
  7348. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7349. * Also, a dynamic UniformBuffer will disable cache verification and always
  7350. * update the underlying WebGL uniform buffer to the GPU.
  7351. * @returns if Dynamic, otherwise false
  7352. */
  7353. isDynamic(): boolean;
  7354. /**
  7355. * The data cache on JS side.
  7356. * @returns the underlying data as a float array
  7357. */
  7358. getData(): Float32Array;
  7359. /**
  7360. * The underlying WebGL Uniform buffer.
  7361. * @returns the webgl buffer
  7362. */
  7363. getBuffer(): Nullable<DataBuffer>;
  7364. /**
  7365. * std140 layout specifies how to align data within an UBO structure.
  7366. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7367. * for specs.
  7368. */
  7369. private _fillAlignment;
  7370. /**
  7371. * Adds an uniform in the buffer.
  7372. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7373. * for the layout to be correct !
  7374. * @param name Name of the uniform, as used in the uniform block in the shader.
  7375. * @param size Data size, or data directly.
  7376. */
  7377. addUniform(name: string, size: number | number[]): void;
  7378. /**
  7379. * Adds a Matrix 4x4 to the uniform buffer.
  7380. * @param name Name of the uniform, as used in the uniform block in the shader.
  7381. * @param mat A 4x4 matrix.
  7382. */
  7383. addMatrix(name: string, mat: Matrix): void;
  7384. /**
  7385. * Adds a vec2 to the uniform buffer.
  7386. * @param name Name of the uniform, as used in the uniform block in the shader.
  7387. * @param x Define the x component value of the vec2
  7388. * @param y Define the y component value of the vec2
  7389. */
  7390. addFloat2(name: string, x: number, y: number): void;
  7391. /**
  7392. * Adds a vec3 to the uniform buffer.
  7393. * @param name Name of the uniform, as used in the uniform block in the shader.
  7394. * @param x Define the x component value of the vec3
  7395. * @param y Define the y component value of the vec3
  7396. * @param z Define the z component value of the vec3
  7397. */
  7398. addFloat3(name: string, x: number, y: number, z: number): void;
  7399. /**
  7400. * Adds a vec3 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. * @param color Define the vec3 from a Color
  7403. */
  7404. addColor3(name: string, color: Color3): void;
  7405. /**
  7406. * Adds a vec4 to the uniform buffer.
  7407. * @param name Name of the uniform, as used in the uniform block in the shader.
  7408. * @param color Define the rgb components from a Color
  7409. * @param alpha Define the a component of the vec4
  7410. */
  7411. addColor4(name: string, color: Color3, alpha: number): void;
  7412. /**
  7413. * Adds a vec3 to the uniform buffer.
  7414. * @param name Name of the uniform, as used in the uniform block in the shader.
  7415. * @param vector Define the vec3 components from a Vector
  7416. */
  7417. addVector3(name: string, vector: Vector3): void;
  7418. /**
  7419. * Adds a Matrix 3x3 to the uniform buffer.
  7420. * @param name Name of the uniform, as used in the uniform block in the shader.
  7421. */
  7422. addMatrix3x3(name: string): void;
  7423. /**
  7424. * Adds a Matrix 2x2 to the uniform buffer.
  7425. * @param name Name of the uniform, as used in the uniform block in the shader.
  7426. */
  7427. addMatrix2x2(name: string): void;
  7428. /**
  7429. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7430. */
  7431. create(): void;
  7432. /** @hidden */
  7433. _rebuild(): void;
  7434. /**
  7435. * Updates the WebGL Uniform Buffer on the GPU.
  7436. * If the `dynamic` flag is set to true, no cache comparison is done.
  7437. * Otherwise, the buffer will be updated only if the cache differs.
  7438. */
  7439. update(): void;
  7440. /**
  7441. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7442. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7443. * @param data Define the flattened data
  7444. * @param size Define the size of the data.
  7445. */
  7446. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7447. private _valueCache;
  7448. private _cacheMatrix;
  7449. private _updateMatrix3x3ForUniform;
  7450. private _updateMatrix3x3ForEffect;
  7451. private _updateMatrix2x2ForEffect;
  7452. private _updateMatrix2x2ForUniform;
  7453. private _updateFloatForEffect;
  7454. private _updateFloatForUniform;
  7455. private _updateFloat2ForEffect;
  7456. private _updateFloat2ForUniform;
  7457. private _updateFloat3ForEffect;
  7458. private _updateFloat3ForUniform;
  7459. private _updateFloat4ForEffect;
  7460. private _updateFloat4ForUniform;
  7461. private _updateMatrixForEffect;
  7462. private _updateMatrixForUniform;
  7463. private _updateVector3ForEffect;
  7464. private _updateVector3ForUniform;
  7465. private _updateVector4ForEffect;
  7466. private _updateVector4ForUniform;
  7467. private _updateColor3ForEffect;
  7468. private _updateColor3ForUniform;
  7469. private _updateColor4ForEffect;
  7470. private _updateColor4ForUniform;
  7471. /**
  7472. * Sets a sampler uniform on the effect.
  7473. * @param name Define the name of the sampler.
  7474. * @param texture Define the texture to set in the sampler
  7475. */
  7476. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7477. /**
  7478. * Directly updates the value of the uniform in the cache AND on the GPU.
  7479. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7480. * @param data Define the flattened data
  7481. */
  7482. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7483. /**
  7484. * Binds this uniform buffer to an effect.
  7485. * @param effect Define the effect to bind the buffer to
  7486. * @param name Name of the uniform block in the shader.
  7487. */
  7488. bindToEffect(effect: Effect, name: string): void;
  7489. /**
  7490. * Disposes the uniform buffer.
  7491. */
  7492. dispose(): void;
  7493. }
  7494. }
  7495. declare module BABYLON {
  7496. /**
  7497. * Enum that determines the text-wrapping mode to use.
  7498. */
  7499. export enum InspectableType {
  7500. /**
  7501. * Checkbox for booleans
  7502. */
  7503. Checkbox = 0,
  7504. /**
  7505. * Sliders for numbers
  7506. */
  7507. Slider = 1,
  7508. /**
  7509. * Vector3
  7510. */
  7511. Vector3 = 2,
  7512. /**
  7513. * Quaternions
  7514. */
  7515. Quaternion = 3,
  7516. /**
  7517. * Color3
  7518. */
  7519. Color3 = 4,
  7520. /**
  7521. * String
  7522. */
  7523. String = 5
  7524. }
  7525. /**
  7526. * Interface used to define custom inspectable properties.
  7527. * This interface is used by the inspector to display custom property grids
  7528. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7529. */
  7530. export interface IInspectable {
  7531. /**
  7532. * Gets the label to display
  7533. */
  7534. label: string;
  7535. /**
  7536. * Gets the name of the property to edit
  7537. */
  7538. propertyName: string;
  7539. /**
  7540. * Gets the type of the editor to use
  7541. */
  7542. type: InspectableType;
  7543. /**
  7544. * Gets the minimum value of the property when using in "slider" mode
  7545. */
  7546. min?: number;
  7547. /**
  7548. * Gets the maximum value of the property when using in "slider" mode
  7549. */
  7550. max?: number;
  7551. /**
  7552. * Gets the setp to use when using in "slider" mode
  7553. */
  7554. step?: number;
  7555. }
  7556. }
  7557. declare module BABYLON {
  7558. /**
  7559. * Class used to provide helper for timing
  7560. */
  7561. export class TimingTools {
  7562. /**
  7563. * Polyfill for setImmediate
  7564. * @param action defines the action to execute after the current execution block
  7565. */
  7566. static SetImmediate(action: () => void): void;
  7567. }
  7568. }
  7569. declare module BABYLON {
  7570. /**
  7571. * Class used to enable instatition of objects by class name
  7572. */
  7573. export class InstantiationTools {
  7574. /**
  7575. * Use this object to register external classes like custom textures or material
  7576. * to allow the laoders to instantiate them
  7577. */
  7578. static RegisteredExternalClasses: {
  7579. [key: string]: Object;
  7580. };
  7581. /**
  7582. * Tries to instantiate a new object from a given class name
  7583. * @param className defines the class name to instantiate
  7584. * @returns the new object or null if the system was not able to do the instantiation
  7585. */
  7586. static Instantiate(className: string): any;
  7587. }
  7588. }
  7589. declare module BABYLON {
  7590. /**
  7591. * Define options used to create a depth texture
  7592. */
  7593. export class DepthTextureCreationOptions {
  7594. /** Specifies whether or not a stencil should be allocated in the texture */
  7595. generateStencil?: boolean;
  7596. /** Specifies whether or not bilinear filtering is enable on the texture */
  7597. bilinearFiltering?: boolean;
  7598. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7599. comparisonFunction?: number;
  7600. /** Specifies if the created texture is a cube texture */
  7601. isCube?: boolean;
  7602. }
  7603. }
  7604. declare module BABYLON {
  7605. interface ThinEngine {
  7606. /**
  7607. * Creates a depth stencil cube texture.
  7608. * This is only available in WebGL 2.
  7609. * @param size The size of face edge in the cube texture.
  7610. * @param options The options defining the cube texture.
  7611. * @returns The cube texture
  7612. */
  7613. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7614. /**
  7615. * Creates a cube texture
  7616. * @param rootUrl defines the url where the files to load is located
  7617. * @param scene defines the current scene
  7618. * @param files defines the list of files to load (1 per face)
  7619. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7620. * @param onLoad defines an optional callback raised when the texture is loaded
  7621. * @param onError defines an optional callback raised if there is an issue to load the texture
  7622. * @param format defines the format of the data
  7623. * @param forcedExtension defines the extension to use to pick the right loader
  7624. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7625. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7626. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7627. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7628. * @returns the cube texture as an InternalTexture
  7629. */
  7630. 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;
  7631. /**
  7632. * Creates a cube texture
  7633. * @param rootUrl defines the url where the files to load is located
  7634. * @param scene defines the current scene
  7635. * @param files defines the list of files to load (1 per face)
  7636. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7637. * @param onLoad defines an optional callback raised when the texture is loaded
  7638. * @param onError defines an optional callback raised if there is an issue to load the texture
  7639. * @param format defines the format of the data
  7640. * @param forcedExtension defines the extension to use to pick the right loader
  7641. * @returns the cube texture as an InternalTexture
  7642. */
  7643. 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;
  7644. /**
  7645. * Creates a cube texture
  7646. * @param rootUrl defines the url where the files to load is located
  7647. * @param scene defines the current scene
  7648. * @param files defines the list of files to load (1 per face)
  7649. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7650. * @param onLoad defines an optional callback raised when the texture is loaded
  7651. * @param onError defines an optional callback raised if there is an issue to load the texture
  7652. * @param format defines the format of the data
  7653. * @param forcedExtension defines the extension to use to pick the right loader
  7654. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7655. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7656. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7657. * @returns the cube texture as an InternalTexture
  7658. */
  7659. 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;
  7660. /** @hidden */
  7661. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7662. /** @hidden */
  7663. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7664. /** @hidden */
  7665. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7666. /** @hidden */
  7667. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7668. /**
  7669. * @hidden
  7670. */
  7671. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7672. }
  7673. }
  7674. declare module BABYLON {
  7675. /**
  7676. * Class for creating a cube texture
  7677. */
  7678. export class CubeTexture extends BaseTexture {
  7679. private _delayedOnLoad;
  7680. /**
  7681. * Observable triggered once the texture has been loaded.
  7682. */
  7683. onLoadObservable: Observable<CubeTexture>;
  7684. /**
  7685. * The url of the texture
  7686. */
  7687. url: string;
  7688. /**
  7689. * Gets or sets the center of the bounding box associated with the cube texture.
  7690. * It must define where the camera used to render the texture was set
  7691. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7692. */
  7693. boundingBoxPosition: Vector3;
  7694. private _boundingBoxSize;
  7695. /**
  7696. * Gets or sets the size of the bounding box associated with the cube texture
  7697. * When defined, the cubemap will switch to local mode
  7698. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7699. * @example https://www.babylonjs-playground.com/#RNASML
  7700. */
  7701. set boundingBoxSize(value: Vector3);
  7702. /**
  7703. * Returns the bounding box size
  7704. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7705. */
  7706. get boundingBoxSize(): Vector3;
  7707. protected _rotationY: number;
  7708. /**
  7709. * Sets texture matrix rotation angle around Y axis in radians.
  7710. */
  7711. set rotationY(value: number);
  7712. /**
  7713. * Gets texture matrix rotation angle around Y axis radians.
  7714. */
  7715. get rotationY(): number;
  7716. /**
  7717. * Are mip maps generated for this texture or not.
  7718. */
  7719. get noMipmap(): boolean;
  7720. private _noMipmap;
  7721. private _files;
  7722. protected _forcedExtension: Nullable<string>;
  7723. private _extensions;
  7724. private _textureMatrix;
  7725. private _format;
  7726. private _createPolynomials;
  7727. /** @hidden */
  7728. _prefiltered: boolean;
  7729. /**
  7730. * Creates a cube texture from an array of image urls
  7731. * @param files defines an array of image urls
  7732. * @param scene defines the hosting scene
  7733. * @param noMipmap specifies if mip maps are not used
  7734. * @returns a cube texture
  7735. */
  7736. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7737. /**
  7738. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7739. * @param url defines the url of the prefiltered texture
  7740. * @param scene defines the scene the texture is attached to
  7741. * @param forcedExtension defines the extension of the file if different from the url
  7742. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7743. * @return the prefiltered texture
  7744. */
  7745. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7746. /**
  7747. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7748. * as prefiltered data.
  7749. * @param rootUrl defines the url of the texture or the root name of the six images
  7750. * @param scene defines the scene the texture is attached to
  7751. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7752. * @param noMipmap defines if mipmaps should be created or not
  7753. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7754. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7755. * @param onError defines a callback triggered in case of error during load
  7756. * @param format defines the internal format to use for the texture once loaded
  7757. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7758. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7759. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7760. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7761. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7762. * @return the cube texture
  7763. */
  7764. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7765. /**
  7766. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7767. */
  7768. get isPrefiltered(): boolean;
  7769. /**
  7770. * Get the current class name of the texture useful for serialization or dynamic coding.
  7771. * @returns "CubeTexture"
  7772. */
  7773. getClassName(): string;
  7774. /**
  7775. * Update the url (and optional buffer) of this texture if url was null during construction.
  7776. * @param url the url of the texture
  7777. * @param forcedExtension defines the extension to use
  7778. * @param onLoad callback called when the texture is loaded (defaults to null)
  7779. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7780. */
  7781. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7782. /**
  7783. * Delays loading of the cube texture
  7784. * @param forcedExtension defines the extension to use
  7785. */
  7786. delayLoad(forcedExtension?: string): void;
  7787. /**
  7788. * Returns the reflection texture matrix
  7789. * @returns the reflection texture matrix
  7790. */
  7791. getReflectionTextureMatrix(): Matrix;
  7792. /**
  7793. * Sets the reflection texture matrix
  7794. * @param value Reflection texture matrix
  7795. */
  7796. setReflectionTextureMatrix(value: Matrix): void;
  7797. /**
  7798. * Parses text to create a cube texture
  7799. * @param parsedTexture define the serialized text to read from
  7800. * @param scene defines the hosting scene
  7801. * @param rootUrl defines the root url of the cube texture
  7802. * @returns a cube texture
  7803. */
  7804. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7805. /**
  7806. * Makes a clone, or deep copy, of the cube texture
  7807. * @returns a new cube texture
  7808. */
  7809. clone(): CubeTexture;
  7810. }
  7811. }
  7812. declare module BABYLON {
  7813. /**
  7814. * Manages the defines for the Material
  7815. */
  7816. export class MaterialDefines {
  7817. /** @hidden */
  7818. protected _keys: string[];
  7819. private _isDirty;
  7820. /** @hidden */
  7821. _renderId: number;
  7822. /** @hidden */
  7823. _areLightsDirty: boolean;
  7824. /** @hidden */
  7825. _areLightsDisposed: boolean;
  7826. /** @hidden */
  7827. _areAttributesDirty: boolean;
  7828. /** @hidden */
  7829. _areTexturesDirty: boolean;
  7830. /** @hidden */
  7831. _areFresnelDirty: boolean;
  7832. /** @hidden */
  7833. _areMiscDirty: boolean;
  7834. /** @hidden */
  7835. _areImageProcessingDirty: boolean;
  7836. /** @hidden */
  7837. _normals: boolean;
  7838. /** @hidden */
  7839. _uvs: boolean;
  7840. /** @hidden */
  7841. _needNormals: boolean;
  7842. /** @hidden */
  7843. _needUVs: boolean;
  7844. [id: string]: any;
  7845. /**
  7846. * Specifies if the material needs to be re-calculated
  7847. */
  7848. get isDirty(): boolean;
  7849. /**
  7850. * Marks the material to indicate that it has been re-calculated
  7851. */
  7852. markAsProcessed(): void;
  7853. /**
  7854. * Marks the material to indicate that it needs to be re-calculated
  7855. */
  7856. markAsUnprocessed(): void;
  7857. /**
  7858. * Marks the material to indicate all of its defines need to be re-calculated
  7859. */
  7860. markAllAsDirty(): void;
  7861. /**
  7862. * Marks the material to indicate that image processing needs to be re-calculated
  7863. */
  7864. markAsImageProcessingDirty(): void;
  7865. /**
  7866. * Marks the material to indicate the lights need to be re-calculated
  7867. * @param disposed Defines whether the light is dirty due to dispose or not
  7868. */
  7869. markAsLightDirty(disposed?: boolean): void;
  7870. /**
  7871. * Marks the attribute state as changed
  7872. */
  7873. markAsAttributesDirty(): void;
  7874. /**
  7875. * Marks the texture state as changed
  7876. */
  7877. markAsTexturesDirty(): void;
  7878. /**
  7879. * Marks the fresnel state as changed
  7880. */
  7881. markAsFresnelDirty(): void;
  7882. /**
  7883. * Marks the misc state as changed
  7884. */
  7885. markAsMiscDirty(): void;
  7886. /**
  7887. * Rebuilds the material defines
  7888. */
  7889. rebuild(): void;
  7890. /**
  7891. * Specifies if two material defines are equal
  7892. * @param other - A material define instance to compare to
  7893. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7894. */
  7895. isEqual(other: MaterialDefines): boolean;
  7896. /**
  7897. * Clones this instance's defines to another instance
  7898. * @param other - material defines to clone values to
  7899. */
  7900. cloneTo(other: MaterialDefines): void;
  7901. /**
  7902. * Resets the material define values
  7903. */
  7904. reset(): void;
  7905. /**
  7906. * Converts the material define values to a string
  7907. * @returns - String of material define information
  7908. */
  7909. toString(): string;
  7910. }
  7911. }
  7912. declare module BABYLON {
  7913. /**
  7914. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7915. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7916. * 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;
  7917. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7918. */
  7919. export class ColorCurves {
  7920. private _dirty;
  7921. private _tempColor;
  7922. private _globalCurve;
  7923. private _highlightsCurve;
  7924. private _midtonesCurve;
  7925. private _shadowsCurve;
  7926. private _positiveCurve;
  7927. private _negativeCurve;
  7928. private _globalHue;
  7929. private _globalDensity;
  7930. private _globalSaturation;
  7931. private _globalExposure;
  7932. /**
  7933. * Gets the global Hue value.
  7934. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7935. */
  7936. get globalHue(): number;
  7937. /**
  7938. * Sets the global Hue value.
  7939. * 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).
  7940. */
  7941. set globalHue(value: number);
  7942. /**
  7943. * Gets the global Density value.
  7944. * 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.
  7945. * Values less than zero provide a filter of opposite hue.
  7946. */
  7947. get globalDensity(): number;
  7948. /**
  7949. * Sets the global Density value.
  7950. * 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.
  7951. * Values less than zero provide a filter of opposite hue.
  7952. */
  7953. set globalDensity(value: number);
  7954. /**
  7955. * Gets the global Saturation value.
  7956. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7957. */
  7958. get globalSaturation(): number;
  7959. /**
  7960. * Sets the global Saturation value.
  7961. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7962. */
  7963. set globalSaturation(value: number);
  7964. /**
  7965. * Gets the global Exposure value.
  7966. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7967. */
  7968. get globalExposure(): number;
  7969. /**
  7970. * Sets the global Exposure value.
  7971. * 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.
  7972. */
  7973. set globalExposure(value: number);
  7974. private _highlightsHue;
  7975. private _highlightsDensity;
  7976. private _highlightsSaturation;
  7977. private _highlightsExposure;
  7978. /**
  7979. * Gets the highlights Hue value.
  7980. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7981. */
  7982. get highlightsHue(): number;
  7983. /**
  7984. * Sets the highlights Hue value.
  7985. * 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).
  7986. */
  7987. set highlightsHue(value: number);
  7988. /**
  7989. * Gets the highlights Density value.
  7990. * 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.
  7991. * Values less than zero provide a filter of opposite hue.
  7992. */
  7993. get highlightsDensity(): number;
  7994. /**
  7995. * Sets the highlights Density value.
  7996. * 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.
  7997. * Values less than zero provide a filter of opposite hue.
  7998. */
  7999. set highlightsDensity(value: number);
  8000. /**
  8001. * Gets the highlights Saturation value.
  8002. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8003. */
  8004. get highlightsSaturation(): number;
  8005. /**
  8006. * Sets the highlights Saturation value.
  8007. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8008. */
  8009. set highlightsSaturation(value: number);
  8010. /**
  8011. * Gets the highlights Exposure value.
  8012. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8013. */
  8014. get highlightsExposure(): number;
  8015. /**
  8016. * Sets the highlights Exposure value.
  8017. * 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.
  8018. */
  8019. set highlightsExposure(value: number);
  8020. private _midtonesHue;
  8021. private _midtonesDensity;
  8022. private _midtonesSaturation;
  8023. private _midtonesExposure;
  8024. /**
  8025. * Gets the midtones Hue value.
  8026. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8027. */
  8028. get midtonesHue(): number;
  8029. /**
  8030. * Sets the midtones Hue value.
  8031. * 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).
  8032. */
  8033. set midtonesHue(value: number);
  8034. /**
  8035. * Gets the midtones Density value.
  8036. * 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.
  8037. * Values less than zero provide a filter of opposite hue.
  8038. */
  8039. get midtonesDensity(): number;
  8040. /**
  8041. * Sets the midtones Density value.
  8042. * 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.
  8043. * Values less than zero provide a filter of opposite hue.
  8044. */
  8045. set midtonesDensity(value: number);
  8046. /**
  8047. * Gets the midtones Saturation value.
  8048. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8049. */
  8050. get midtonesSaturation(): number;
  8051. /**
  8052. * Sets the midtones Saturation value.
  8053. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8054. */
  8055. set midtonesSaturation(value: number);
  8056. /**
  8057. * Gets the midtones Exposure value.
  8058. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8059. */
  8060. get midtonesExposure(): number;
  8061. /**
  8062. * Sets the midtones Exposure value.
  8063. * 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.
  8064. */
  8065. set midtonesExposure(value: number);
  8066. private _shadowsHue;
  8067. private _shadowsDensity;
  8068. private _shadowsSaturation;
  8069. private _shadowsExposure;
  8070. /**
  8071. * Gets the shadows Hue value.
  8072. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8073. */
  8074. get shadowsHue(): number;
  8075. /**
  8076. * Sets the shadows Hue value.
  8077. * 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).
  8078. */
  8079. set shadowsHue(value: number);
  8080. /**
  8081. * Gets the shadows Density value.
  8082. * 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.
  8083. * Values less than zero provide a filter of opposite hue.
  8084. */
  8085. get shadowsDensity(): number;
  8086. /**
  8087. * Sets the shadows Density value.
  8088. * 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.
  8089. * Values less than zero provide a filter of opposite hue.
  8090. */
  8091. set shadowsDensity(value: number);
  8092. /**
  8093. * Gets the shadows Saturation value.
  8094. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8095. */
  8096. get shadowsSaturation(): number;
  8097. /**
  8098. * Sets the shadows Saturation value.
  8099. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8100. */
  8101. set shadowsSaturation(value: number);
  8102. /**
  8103. * Gets the shadows Exposure value.
  8104. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8105. */
  8106. get shadowsExposure(): number;
  8107. /**
  8108. * Sets the shadows Exposure value.
  8109. * 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.
  8110. */
  8111. set shadowsExposure(value: number);
  8112. /**
  8113. * Returns the class name
  8114. * @returns The class name
  8115. */
  8116. getClassName(): string;
  8117. /**
  8118. * Binds the color curves to the shader.
  8119. * @param colorCurves The color curve to bind
  8120. * @param effect The effect to bind to
  8121. * @param positiveUniform The positive uniform shader parameter
  8122. * @param neutralUniform The neutral uniform shader parameter
  8123. * @param negativeUniform The negative uniform shader parameter
  8124. */
  8125. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8126. /**
  8127. * Prepare the list of uniforms associated with the ColorCurves effects.
  8128. * @param uniformsList The list of uniforms used in the effect
  8129. */
  8130. static PrepareUniforms(uniformsList: string[]): void;
  8131. /**
  8132. * Returns color grading data based on a hue, density, saturation and exposure value.
  8133. * @param filterHue The hue of the color filter.
  8134. * @param filterDensity The density of the color filter.
  8135. * @param saturation The saturation.
  8136. * @param exposure The exposure.
  8137. * @param result The result data container.
  8138. */
  8139. private getColorGradingDataToRef;
  8140. /**
  8141. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8142. * @param value The input slider value in range [-100,100].
  8143. * @returns Adjusted value.
  8144. */
  8145. private static applyColorGradingSliderNonlinear;
  8146. /**
  8147. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8148. * @param hue The hue (H) input.
  8149. * @param saturation The saturation (S) input.
  8150. * @param brightness The brightness (B) input.
  8151. * @result An RGBA color represented as Vector4.
  8152. */
  8153. private static fromHSBToRef;
  8154. /**
  8155. * Returns a value clamped between min and max
  8156. * @param value The value to clamp
  8157. * @param min The minimum of value
  8158. * @param max The maximum of value
  8159. * @returns The clamped value.
  8160. */
  8161. private static clamp;
  8162. /**
  8163. * Clones the current color curve instance.
  8164. * @return The cloned curves
  8165. */
  8166. clone(): ColorCurves;
  8167. /**
  8168. * Serializes the current color curve instance to a json representation.
  8169. * @return a JSON representation
  8170. */
  8171. serialize(): any;
  8172. /**
  8173. * Parses the color curve from a json representation.
  8174. * @param source the JSON source to parse
  8175. * @return The parsed curves
  8176. */
  8177. static Parse(source: any): ColorCurves;
  8178. }
  8179. }
  8180. declare module BABYLON {
  8181. /**
  8182. * Interface to follow in your material defines to integrate easily the
  8183. * Image proccessing functions.
  8184. * @hidden
  8185. */
  8186. export interface IImageProcessingConfigurationDefines {
  8187. IMAGEPROCESSING: boolean;
  8188. VIGNETTE: boolean;
  8189. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8190. VIGNETTEBLENDMODEOPAQUE: boolean;
  8191. TONEMAPPING: boolean;
  8192. TONEMAPPING_ACES: boolean;
  8193. CONTRAST: boolean;
  8194. EXPOSURE: boolean;
  8195. COLORCURVES: boolean;
  8196. COLORGRADING: boolean;
  8197. COLORGRADING3D: boolean;
  8198. SAMPLER3DGREENDEPTH: boolean;
  8199. SAMPLER3DBGRMAP: boolean;
  8200. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8201. }
  8202. /**
  8203. * @hidden
  8204. */
  8205. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8206. IMAGEPROCESSING: boolean;
  8207. VIGNETTE: boolean;
  8208. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8209. VIGNETTEBLENDMODEOPAQUE: boolean;
  8210. TONEMAPPING: boolean;
  8211. TONEMAPPING_ACES: boolean;
  8212. CONTRAST: boolean;
  8213. COLORCURVES: boolean;
  8214. COLORGRADING: boolean;
  8215. COLORGRADING3D: boolean;
  8216. SAMPLER3DGREENDEPTH: boolean;
  8217. SAMPLER3DBGRMAP: boolean;
  8218. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8219. EXPOSURE: boolean;
  8220. constructor();
  8221. }
  8222. /**
  8223. * This groups together the common properties used for image processing either in direct forward pass
  8224. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8225. * or not.
  8226. */
  8227. export class ImageProcessingConfiguration {
  8228. /**
  8229. * Default tone mapping applied in BabylonJS.
  8230. */
  8231. static readonly TONEMAPPING_STANDARD: number;
  8232. /**
  8233. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8234. * to other engines rendering to increase portability.
  8235. */
  8236. static readonly TONEMAPPING_ACES: number;
  8237. /**
  8238. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8239. */
  8240. colorCurves: Nullable<ColorCurves>;
  8241. private _colorCurvesEnabled;
  8242. /**
  8243. * Gets wether the color curves effect is enabled.
  8244. */
  8245. get colorCurvesEnabled(): boolean;
  8246. /**
  8247. * Sets wether the color curves effect is enabled.
  8248. */
  8249. set colorCurvesEnabled(value: boolean);
  8250. private _colorGradingTexture;
  8251. /**
  8252. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8253. */
  8254. get colorGradingTexture(): Nullable<BaseTexture>;
  8255. /**
  8256. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8257. */
  8258. set colorGradingTexture(value: Nullable<BaseTexture>);
  8259. private _colorGradingEnabled;
  8260. /**
  8261. * Gets wether the color grading effect is enabled.
  8262. */
  8263. get colorGradingEnabled(): boolean;
  8264. /**
  8265. * Sets wether the color grading effect is enabled.
  8266. */
  8267. set colorGradingEnabled(value: boolean);
  8268. private _colorGradingWithGreenDepth;
  8269. /**
  8270. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8271. */
  8272. get colorGradingWithGreenDepth(): boolean;
  8273. /**
  8274. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8275. */
  8276. set colorGradingWithGreenDepth(value: boolean);
  8277. private _colorGradingBGR;
  8278. /**
  8279. * Gets wether the color grading texture contains BGR values.
  8280. */
  8281. get colorGradingBGR(): boolean;
  8282. /**
  8283. * Sets wether the color grading texture contains BGR values.
  8284. */
  8285. set colorGradingBGR(value: boolean);
  8286. /** @hidden */
  8287. _exposure: number;
  8288. /**
  8289. * Gets the Exposure used in the effect.
  8290. */
  8291. get exposure(): number;
  8292. /**
  8293. * Sets the Exposure used in the effect.
  8294. */
  8295. set exposure(value: number);
  8296. private _toneMappingEnabled;
  8297. /**
  8298. * Gets wether the tone mapping effect is enabled.
  8299. */
  8300. get toneMappingEnabled(): boolean;
  8301. /**
  8302. * Sets wether the tone mapping effect is enabled.
  8303. */
  8304. set toneMappingEnabled(value: boolean);
  8305. private _toneMappingType;
  8306. /**
  8307. * Gets the type of tone mapping effect.
  8308. */
  8309. get toneMappingType(): number;
  8310. /**
  8311. * Sets the type of tone mapping effect used in BabylonJS.
  8312. */
  8313. set toneMappingType(value: number);
  8314. protected _contrast: number;
  8315. /**
  8316. * Gets the contrast used in the effect.
  8317. */
  8318. get contrast(): number;
  8319. /**
  8320. * Sets the contrast used in the effect.
  8321. */
  8322. set contrast(value: number);
  8323. /**
  8324. * Vignette stretch size.
  8325. */
  8326. vignetteStretch: number;
  8327. /**
  8328. * Vignette centre X Offset.
  8329. */
  8330. vignetteCentreX: number;
  8331. /**
  8332. * Vignette centre Y Offset.
  8333. */
  8334. vignetteCentreY: number;
  8335. /**
  8336. * Vignette weight or intensity of the vignette effect.
  8337. */
  8338. vignetteWeight: number;
  8339. /**
  8340. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8341. * if vignetteEnabled is set to true.
  8342. */
  8343. vignetteColor: Color4;
  8344. /**
  8345. * Camera field of view used by the Vignette effect.
  8346. */
  8347. vignetteCameraFov: number;
  8348. private _vignetteBlendMode;
  8349. /**
  8350. * Gets the vignette blend mode allowing different kind of effect.
  8351. */
  8352. get vignetteBlendMode(): number;
  8353. /**
  8354. * Sets the vignette blend mode allowing different kind of effect.
  8355. */
  8356. set vignetteBlendMode(value: number);
  8357. private _vignetteEnabled;
  8358. /**
  8359. * Gets wether the vignette effect is enabled.
  8360. */
  8361. get vignetteEnabled(): boolean;
  8362. /**
  8363. * Sets wether the vignette effect is enabled.
  8364. */
  8365. set vignetteEnabled(value: boolean);
  8366. private _applyByPostProcess;
  8367. /**
  8368. * Gets wether the image processing is applied through a post process or not.
  8369. */
  8370. get applyByPostProcess(): boolean;
  8371. /**
  8372. * Sets wether the image processing is applied through a post process or not.
  8373. */
  8374. set applyByPostProcess(value: boolean);
  8375. private _isEnabled;
  8376. /**
  8377. * Gets wether the image processing is enabled or not.
  8378. */
  8379. get isEnabled(): boolean;
  8380. /**
  8381. * Sets wether the image processing is enabled or not.
  8382. */
  8383. set isEnabled(value: boolean);
  8384. /**
  8385. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8386. */
  8387. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8388. /**
  8389. * Method called each time the image processing information changes requires to recompile the effect.
  8390. */
  8391. protected _updateParameters(): void;
  8392. /**
  8393. * Gets the current class name.
  8394. * @return "ImageProcessingConfiguration"
  8395. */
  8396. getClassName(): string;
  8397. /**
  8398. * Prepare the list of uniforms associated with the Image Processing effects.
  8399. * @param uniforms The list of uniforms used in the effect
  8400. * @param defines the list of defines currently in use
  8401. */
  8402. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8403. /**
  8404. * Prepare the list of samplers associated with the Image Processing effects.
  8405. * @param samplersList The list of uniforms used in the effect
  8406. * @param defines the list of defines currently in use
  8407. */
  8408. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8409. /**
  8410. * Prepare the list of defines associated to the shader.
  8411. * @param defines the list of defines to complete
  8412. * @param forPostProcess Define if we are currently in post process mode or not
  8413. */
  8414. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8415. /**
  8416. * Returns true if all the image processing information are ready.
  8417. * @returns True if ready, otherwise, false
  8418. */
  8419. isReady(): boolean;
  8420. /**
  8421. * Binds the image processing to the shader.
  8422. * @param effect The effect to bind to
  8423. * @param overrideAspectRatio Override the aspect ratio of the effect
  8424. */
  8425. bind(effect: Effect, overrideAspectRatio?: number): void;
  8426. /**
  8427. * Clones the current image processing instance.
  8428. * @return The cloned image processing
  8429. */
  8430. clone(): ImageProcessingConfiguration;
  8431. /**
  8432. * Serializes the current image processing instance to a json representation.
  8433. * @return a JSON representation
  8434. */
  8435. serialize(): any;
  8436. /**
  8437. * Parses the image processing from a json representation.
  8438. * @param source the JSON source to parse
  8439. * @return The parsed image processing
  8440. */
  8441. static Parse(source: any): ImageProcessingConfiguration;
  8442. private static _VIGNETTEMODE_MULTIPLY;
  8443. private static _VIGNETTEMODE_OPAQUE;
  8444. /**
  8445. * Used to apply the vignette as a mix with the pixel color.
  8446. */
  8447. static get VIGNETTEMODE_MULTIPLY(): number;
  8448. /**
  8449. * Used to apply the vignette as a replacement of the pixel color.
  8450. */
  8451. static get VIGNETTEMODE_OPAQUE(): number;
  8452. }
  8453. }
  8454. declare module BABYLON {
  8455. /** @hidden */
  8456. export var postprocessVertexShader: {
  8457. name: string;
  8458. shader: string;
  8459. };
  8460. }
  8461. declare module BABYLON {
  8462. interface ThinEngine {
  8463. /**
  8464. * Creates a new render target texture
  8465. * @param size defines the size of the texture
  8466. * @param options defines the options used to create the texture
  8467. * @returns a new render target texture stored in an InternalTexture
  8468. */
  8469. createRenderTargetTexture(size: number | {
  8470. width: number;
  8471. height: number;
  8472. layers?: number;
  8473. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8474. /**
  8475. * Creates a depth stencil texture.
  8476. * This is only available in WebGL 2 or with the depth texture extension available.
  8477. * @param size The size of face edge in the texture.
  8478. * @param options The options defining the texture.
  8479. * @returns The texture
  8480. */
  8481. createDepthStencilTexture(size: number | {
  8482. width: number;
  8483. height: number;
  8484. layers?: number;
  8485. }, options: DepthTextureCreationOptions): InternalTexture;
  8486. /** @hidden */
  8487. _createDepthStencilTexture(size: number | {
  8488. width: number;
  8489. height: number;
  8490. layers?: number;
  8491. }, options: DepthTextureCreationOptions): InternalTexture;
  8492. }
  8493. }
  8494. declare module BABYLON {
  8495. /** Defines supported spaces */
  8496. export enum Space {
  8497. /** Local (object) space */
  8498. LOCAL = 0,
  8499. /** World space */
  8500. WORLD = 1,
  8501. /** Bone space */
  8502. BONE = 2
  8503. }
  8504. /** Defines the 3 main axes */
  8505. export class Axis {
  8506. /** X axis */
  8507. static X: Vector3;
  8508. /** Y axis */
  8509. static Y: Vector3;
  8510. /** Z axis */
  8511. static Z: Vector3;
  8512. }
  8513. }
  8514. declare module BABYLON {
  8515. /**
  8516. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8517. * This is the base of the follow, arc rotate cameras and Free camera
  8518. * @see http://doc.babylonjs.com/features/cameras
  8519. */
  8520. export class TargetCamera extends Camera {
  8521. private static _RigCamTransformMatrix;
  8522. private static _TargetTransformMatrix;
  8523. private static _TargetFocalPoint;
  8524. /**
  8525. * Define the current direction the camera is moving to
  8526. */
  8527. cameraDirection: Vector3;
  8528. /**
  8529. * Define the current rotation the camera is rotating to
  8530. */
  8531. cameraRotation: Vector2;
  8532. /**
  8533. * When set, the up vector of the camera will be updated by the rotation of the camera
  8534. */
  8535. updateUpVectorFromRotation: boolean;
  8536. private _tmpQuaternion;
  8537. /**
  8538. * Define the current rotation of the camera
  8539. */
  8540. rotation: Vector3;
  8541. /**
  8542. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8543. */
  8544. rotationQuaternion: Quaternion;
  8545. /**
  8546. * Define the current speed of the camera
  8547. */
  8548. speed: number;
  8549. /**
  8550. * Add constraint to the camera to prevent it to move freely in all directions and
  8551. * around all axis.
  8552. */
  8553. noRotationConstraint: boolean;
  8554. /**
  8555. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8556. * panning
  8557. */
  8558. invertRotation: boolean;
  8559. /**
  8560. * Speed multiplier for inverse camera panning
  8561. */
  8562. inverseRotationSpeed: number;
  8563. /**
  8564. * Define the current target of the camera as an object or a position.
  8565. */
  8566. lockedTarget: any;
  8567. /** @hidden */
  8568. _currentTarget: Vector3;
  8569. /** @hidden */
  8570. _initialFocalDistance: number;
  8571. /** @hidden */
  8572. _viewMatrix: Matrix;
  8573. /** @hidden */
  8574. _camMatrix: Matrix;
  8575. /** @hidden */
  8576. _cameraTransformMatrix: Matrix;
  8577. /** @hidden */
  8578. _cameraRotationMatrix: Matrix;
  8579. /** @hidden */
  8580. _referencePoint: Vector3;
  8581. /** @hidden */
  8582. _transformedReferencePoint: Vector3;
  8583. protected _globalCurrentTarget: Vector3;
  8584. protected _globalCurrentUpVector: Vector3;
  8585. /** @hidden */
  8586. _reset: () => void;
  8587. private _defaultUp;
  8588. /**
  8589. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8590. * This is the base of the follow, arc rotate cameras and Free camera
  8591. * @see http://doc.babylonjs.com/features/cameras
  8592. * @param name Defines the name of the camera in the scene
  8593. * @param position Defines the start position of the camera in the scene
  8594. * @param scene Defines the scene the camera belongs to
  8595. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8596. */
  8597. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8598. /**
  8599. * Gets the position in front of the camera at a given distance.
  8600. * @param distance The distance from the camera we want the position to be
  8601. * @returns the position
  8602. */
  8603. getFrontPosition(distance: number): Vector3;
  8604. /** @hidden */
  8605. _getLockedTargetPosition(): Nullable<Vector3>;
  8606. private _storedPosition;
  8607. private _storedRotation;
  8608. private _storedRotationQuaternion;
  8609. /**
  8610. * Store current camera state of the camera (fov, position, rotation, etc..)
  8611. * @returns the camera
  8612. */
  8613. storeState(): Camera;
  8614. /**
  8615. * Restored camera state. You must call storeState() first
  8616. * @returns whether it was successful or not
  8617. * @hidden
  8618. */
  8619. _restoreStateValues(): boolean;
  8620. /** @hidden */
  8621. _initCache(): void;
  8622. /** @hidden */
  8623. _updateCache(ignoreParentClass?: boolean): void;
  8624. /** @hidden */
  8625. _isSynchronizedViewMatrix(): boolean;
  8626. /** @hidden */
  8627. _computeLocalCameraSpeed(): number;
  8628. /**
  8629. * Defines the target the camera should look at.
  8630. * @param target Defines the new target as a Vector or a mesh
  8631. */
  8632. setTarget(target: Vector3): void;
  8633. /**
  8634. * Return the current target position of the camera. This value is expressed in local space.
  8635. * @returns the target position
  8636. */
  8637. getTarget(): Vector3;
  8638. /** @hidden */
  8639. _decideIfNeedsToMove(): boolean;
  8640. /** @hidden */
  8641. _updatePosition(): void;
  8642. /** @hidden */
  8643. _checkInputs(): void;
  8644. protected _updateCameraRotationMatrix(): void;
  8645. /**
  8646. * 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)
  8647. * @returns the current camera
  8648. */
  8649. private _rotateUpVectorWithCameraRotationMatrix;
  8650. private _cachedRotationZ;
  8651. private _cachedQuaternionRotationZ;
  8652. /** @hidden */
  8653. _getViewMatrix(): Matrix;
  8654. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8655. /**
  8656. * @hidden
  8657. */
  8658. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8659. /**
  8660. * @hidden
  8661. */
  8662. _updateRigCameras(): void;
  8663. private _getRigCamPositionAndTarget;
  8664. /**
  8665. * Gets the current object class name.
  8666. * @return the class name
  8667. */
  8668. getClassName(): string;
  8669. }
  8670. }
  8671. declare module BABYLON {
  8672. /**
  8673. * Gather the list of keyboard event types as constants.
  8674. */
  8675. export class KeyboardEventTypes {
  8676. /**
  8677. * The keydown event is fired when a key becomes active (pressed).
  8678. */
  8679. static readonly KEYDOWN: number;
  8680. /**
  8681. * The keyup event is fired when a key has been released.
  8682. */
  8683. static readonly KEYUP: number;
  8684. }
  8685. /**
  8686. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8687. */
  8688. export class KeyboardInfo {
  8689. /**
  8690. * Defines the type of event (KeyboardEventTypes)
  8691. */
  8692. type: number;
  8693. /**
  8694. * Defines the related dom event
  8695. */
  8696. event: KeyboardEvent;
  8697. /**
  8698. * Instantiates a new keyboard info.
  8699. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8700. * @param type Defines the type of event (KeyboardEventTypes)
  8701. * @param event Defines the related dom event
  8702. */
  8703. constructor(
  8704. /**
  8705. * Defines the type of event (KeyboardEventTypes)
  8706. */
  8707. type: number,
  8708. /**
  8709. * Defines the related dom event
  8710. */
  8711. event: KeyboardEvent);
  8712. }
  8713. /**
  8714. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8715. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8716. */
  8717. export class KeyboardInfoPre extends KeyboardInfo {
  8718. /**
  8719. * Defines the type of event (KeyboardEventTypes)
  8720. */
  8721. type: number;
  8722. /**
  8723. * Defines the related dom event
  8724. */
  8725. event: KeyboardEvent;
  8726. /**
  8727. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8728. */
  8729. skipOnPointerObservable: boolean;
  8730. /**
  8731. * Instantiates a new keyboard pre info.
  8732. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8733. * @param type Defines the type of event (KeyboardEventTypes)
  8734. * @param event Defines the related dom event
  8735. */
  8736. constructor(
  8737. /**
  8738. * Defines the type of event (KeyboardEventTypes)
  8739. */
  8740. type: number,
  8741. /**
  8742. * Defines the related dom event
  8743. */
  8744. event: KeyboardEvent);
  8745. }
  8746. }
  8747. declare module BABYLON {
  8748. /**
  8749. * Manage the keyboard inputs to control the movement of a free camera.
  8750. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8751. */
  8752. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8753. /**
  8754. * Defines the camera the input is attached to.
  8755. */
  8756. camera: FreeCamera;
  8757. /**
  8758. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8759. */
  8760. keysUp: number[];
  8761. /**
  8762. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8763. */
  8764. keysUpward: number[];
  8765. /**
  8766. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8767. */
  8768. keysDown: number[];
  8769. /**
  8770. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8771. */
  8772. keysDownward: number[];
  8773. /**
  8774. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8775. */
  8776. keysLeft: number[];
  8777. /**
  8778. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8779. */
  8780. keysRight: number[];
  8781. private _keys;
  8782. private _onCanvasBlurObserver;
  8783. private _onKeyboardObserver;
  8784. private _engine;
  8785. private _scene;
  8786. /**
  8787. * Attach the input controls to a specific dom element to get the input from.
  8788. * @param element Defines the element the controls should be listened from
  8789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8790. */
  8791. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8792. /**
  8793. * Detach the current controls from the specified dom element.
  8794. * @param element Defines the element to stop listening the inputs from
  8795. */
  8796. detachControl(element: Nullable<HTMLElement>): void;
  8797. /**
  8798. * Update the current camera state depending on the inputs that have been used this frame.
  8799. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8800. */
  8801. checkInputs(): void;
  8802. /**
  8803. * Gets the class name of the current intput.
  8804. * @returns the class name
  8805. */
  8806. getClassName(): string;
  8807. /** @hidden */
  8808. _onLostFocus(): void;
  8809. /**
  8810. * Get the friendly name associated with the input class.
  8811. * @returns the input friendly name
  8812. */
  8813. getSimpleName(): string;
  8814. }
  8815. }
  8816. declare module BABYLON {
  8817. /**
  8818. * Interface describing all the common properties and methods a shadow light needs to implement.
  8819. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8820. * as well as binding the different shadow properties to the effects.
  8821. */
  8822. export interface IShadowLight extends Light {
  8823. /**
  8824. * The light id in the scene (used in scene.findLighById for instance)
  8825. */
  8826. id: string;
  8827. /**
  8828. * The position the shdow will be casted from.
  8829. */
  8830. position: Vector3;
  8831. /**
  8832. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8833. */
  8834. direction: Vector3;
  8835. /**
  8836. * The transformed position. Position of the light in world space taking parenting in account.
  8837. */
  8838. transformedPosition: Vector3;
  8839. /**
  8840. * The transformed direction. Direction of the light in world space taking parenting in account.
  8841. */
  8842. transformedDirection: Vector3;
  8843. /**
  8844. * The friendly name of the light in the scene.
  8845. */
  8846. name: string;
  8847. /**
  8848. * Defines the shadow projection clipping minimum z value.
  8849. */
  8850. shadowMinZ: number;
  8851. /**
  8852. * Defines the shadow projection clipping maximum z value.
  8853. */
  8854. shadowMaxZ: number;
  8855. /**
  8856. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8857. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8858. */
  8859. computeTransformedInformation(): boolean;
  8860. /**
  8861. * Gets the scene the light belongs to.
  8862. * @returns The scene
  8863. */
  8864. getScene(): Scene;
  8865. /**
  8866. * Callback defining a custom Projection Matrix Builder.
  8867. * This can be used to override the default projection matrix computation.
  8868. */
  8869. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8870. /**
  8871. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8872. * @param matrix The materix to updated with the projection information
  8873. * @param viewMatrix The transform matrix of the light
  8874. * @param renderList The list of mesh to render in the map
  8875. * @returns The current light
  8876. */
  8877. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8878. /**
  8879. * Gets the current depth scale used in ESM.
  8880. * @returns The scale
  8881. */
  8882. getDepthScale(): number;
  8883. /**
  8884. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8885. * @returns true if a cube texture needs to be use
  8886. */
  8887. needCube(): boolean;
  8888. /**
  8889. * Detects if the projection matrix requires to be recomputed this frame.
  8890. * @returns true if it requires to be recomputed otherwise, false.
  8891. */
  8892. needProjectionMatrixCompute(): boolean;
  8893. /**
  8894. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8895. */
  8896. forceProjectionMatrixCompute(): void;
  8897. /**
  8898. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8899. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8900. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8901. */
  8902. getShadowDirection(faceIndex?: number): Vector3;
  8903. /**
  8904. * Gets the minZ used for shadow according to both the scene and the light.
  8905. * @param activeCamera The camera we are returning the min for
  8906. * @returns the depth min z
  8907. */
  8908. getDepthMinZ(activeCamera: Camera): number;
  8909. /**
  8910. * Gets the maxZ used for shadow according to both the scene and the light.
  8911. * @param activeCamera The camera we are returning the max for
  8912. * @returns the depth max z
  8913. */
  8914. getDepthMaxZ(activeCamera: Camera): number;
  8915. }
  8916. /**
  8917. * Base implementation IShadowLight
  8918. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8919. */
  8920. export abstract class ShadowLight extends Light implements IShadowLight {
  8921. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8922. protected _position: Vector3;
  8923. protected _setPosition(value: Vector3): void;
  8924. /**
  8925. * Sets the position the shadow will be casted from. Also use as the light position for both
  8926. * point and spot lights.
  8927. */
  8928. get position(): Vector3;
  8929. /**
  8930. * Sets the position the shadow will be casted from. Also use as the light position for both
  8931. * point and spot lights.
  8932. */
  8933. set position(value: Vector3);
  8934. protected _direction: Vector3;
  8935. protected _setDirection(value: Vector3): void;
  8936. /**
  8937. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8938. * Also use as the light direction on spot and directional lights.
  8939. */
  8940. get direction(): Vector3;
  8941. /**
  8942. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8943. * Also use as the light direction on spot and directional lights.
  8944. */
  8945. set direction(value: Vector3);
  8946. protected _shadowMinZ: number;
  8947. /**
  8948. * Gets the shadow projection clipping minimum z value.
  8949. */
  8950. get shadowMinZ(): number;
  8951. /**
  8952. * Sets the shadow projection clipping minimum z value.
  8953. */
  8954. set shadowMinZ(value: number);
  8955. protected _shadowMaxZ: number;
  8956. /**
  8957. * Sets the shadow projection clipping maximum z value.
  8958. */
  8959. get shadowMaxZ(): number;
  8960. /**
  8961. * Gets the shadow projection clipping maximum z value.
  8962. */
  8963. set shadowMaxZ(value: number);
  8964. /**
  8965. * Callback defining a custom Projection Matrix Builder.
  8966. * This can be used to override the default projection matrix computation.
  8967. */
  8968. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8969. /**
  8970. * The transformed position. Position of the light in world space taking parenting in account.
  8971. */
  8972. transformedPosition: Vector3;
  8973. /**
  8974. * The transformed direction. Direction of the light in world space taking parenting in account.
  8975. */
  8976. transformedDirection: Vector3;
  8977. private _needProjectionMatrixCompute;
  8978. /**
  8979. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8980. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8981. */
  8982. computeTransformedInformation(): boolean;
  8983. /**
  8984. * Return the depth scale used for the shadow map.
  8985. * @returns the depth scale.
  8986. */
  8987. getDepthScale(): number;
  8988. /**
  8989. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8990. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8991. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8992. */
  8993. getShadowDirection(faceIndex?: number): Vector3;
  8994. /**
  8995. * Returns the ShadowLight absolute position in the World.
  8996. * @returns the position vector in world space
  8997. */
  8998. getAbsolutePosition(): Vector3;
  8999. /**
  9000. * Sets the ShadowLight direction toward the passed target.
  9001. * @param target The point to target in local space
  9002. * @returns the updated ShadowLight direction
  9003. */
  9004. setDirectionToTarget(target: Vector3): Vector3;
  9005. /**
  9006. * Returns the light rotation in euler definition.
  9007. * @returns the x y z rotation in local space.
  9008. */
  9009. getRotation(): Vector3;
  9010. /**
  9011. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9012. * @returns true if a cube texture needs to be use
  9013. */
  9014. needCube(): boolean;
  9015. /**
  9016. * Detects if the projection matrix requires to be recomputed this frame.
  9017. * @returns true if it requires to be recomputed otherwise, false.
  9018. */
  9019. needProjectionMatrixCompute(): boolean;
  9020. /**
  9021. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9022. */
  9023. forceProjectionMatrixCompute(): void;
  9024. /** @hidden */
  9025. _initCache(): void;
  9026. /** @hidden */
  9027. _isSynchronized(): boolean;
  9028. /**
  9029. * Computes the world matrix of the node
  9030. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9031. * @returns the world matrix
  9032. */
  9033. computeWorldMatrix(force?: boolean): Matrix;
  9034. /**
  9035. * Gets the minZ used for shadow according to both the scene and the light.
  9036. * @param activeCamera The camera we are returning the min for
  9037. * @returns the depth min z
  9038. */
  9039. getDepthMinZ(activeCamera: Camera): number;
  9040. /**
  9041. * Gets the maxZ used for shadow according to both the scene and the light.
  9042. * @param activeCamera The camera we are returning the max for
  9043. * @returns the depth max z
  9044. */
  9045. getDepthMaxZ(activeCamera: Camera): number;
  9046. /**
  9047. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9048. * @param matrix The materix to updated with the projection information
  9049. * @param viewMatrix The transform matrix of the light
  9050. * @param renderList The list of mesh to render in the map
  9051. * @returns The current light
  9052. */
  9053. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9054. }
  9055. }
  9056. declare module BABYLON {
  9057. /**
  9058. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9059. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9060. */
  9061. export class EffectFallbacks implements IEffectFallbacks {
  9062. private _defines;
  9063. private _currentRank;
  9064. private _maxRank;
  9065. private _mesh;
  9066. /**
  9067. * Removes the fallback from the bound mesh.
  9068. */
  9069. unBindMesh(): void;
  9070. /**
  9071. * Adds a fallback on the specified property.
  9072. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9073. * @param define The name of the define in the shader
  9074. */
  9075. addFallback(rank: number, define: string): void;
  9076. /**
  9077. * Sets the mesh to use CPU skinning when needing to fallback.
  9078. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9079. * @param mesh The mesh to use the fallbacks.
  9080. */
  9081. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9082. /**
  9083. * Checks to see if more fallbacks are still availible.
  9084. */
  9085. get hasMoreFallbacks(): boolean;
  9086. /**
  9087. * Removes the defines that should be removed when falling back.
  9088. * @param currentDefines defines the current define statements for the shader.
  9089. * @param effect defines the current effect we try to compile
  9090. * @returns The resulting defines with defines of the current rank removed.
  9091. */
  9092. reduce(currentDefines: string, effect: Effect): string;
  9093. }
  9094. }
  9095. declare module BABYLON {
  9096. /**
  9097. * "Static Class" containing the most commonly used helper while dealing with material for
  9098. * rendering purpose.
  9099. *
  9100. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9101. *
  9102. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9103. */
  9104. export class MaterialHelper {
  9105. /**
  9106. * Bind the current view position to an effect.
  9107. * @param effect The effect to be bound
  9108. * @param scene The scene the eyes position is used from
  9109. */
  9110. static BindEyePosition(effect: Effect, scene: Scene): void;
  9111. /**
  9112. * Helps preparing the defines values about the UVs in used in the effect.
  9113. * UVs are shared as much as we can accross channels in the shaders.
  9114. * @param texture The texture we are preparing the UVs for
  9115. * @param defines The defines to update
  9116. * @param key The channel key "diffuse", "specular"... used in the shader
  9117. */
  9118. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9119. /**
  9120. * Binds a texture matrix value to its corrsponding uniform
  9121. * @param texture The texture to bind the matrix for
  9122. * @param uniformBuffer The uniform buffer receivin the data
  9123. * @param key The channel key "diffuse", "specular"... used in the shader
  9124. */
  9125. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9126. /**
  9127. * Gets the current status of the fog (should it be enabled?)
  9128. * @param mesh defines the mesh to evaluate for fog support
  9129. * @param scene defines the hosting scene
  9130. * @returns true if fog must be enabled
  9131. */
  9132. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9133. /**
  9134. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9135. * @param mesh defines the current mesh
  9136. * @param scene defines the current scene
  9137. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9138. * @param pointsCloud defines if point cloud rendering has to be turned on
  9139. * @param fogEnabled defines if fog has to be turned on
  9140. * @param alphaTest defines if alpha testing has to be turned on
  9141. * @param defines defines the current list of defines
  9142. */
  9143. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9144. /**
  9145. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9146. * @param scene defines the current scene
  9147. * @param engine defines the current engine
  9148. * @param defines specifies the list of active defines
  9149. * @param useInstances defines if instances have to be turned on
  9150. * @param useClipPlane defines if clip plane have to be turned on
  9151. */
  9152. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9153. /**
  9154. * Prepares the defines for bones
  9155. * @param mesh The mesh containing the geometry data we will draw
  9156. * @param defines The defines to update
  9157. */
  9158. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9159. /**
  9160. * Prepares the defines for morph targets
  9161. * @param mesh The mesh containing the geometry data we will draw
  9162. * @param defines The defines to update
  9163. */
  9164. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9165. /**
  9166. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9167. * @param mesh The mesh containing the geometry data we will draw
  9168. * @param defines The defines to update
  9169. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9170. * @param useBones Precise whether bones should be used or not (override mesh info)
  9171. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9172. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9173. * @returns false if defines are considered not dirty and have not been checked
  9174. */
  9175. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9176. /**
  9177. * Prepares the defines related to multiview
  9178. * @param scene The scene we are intending to draw
  9179. * @param defines The defines to update
  9180. */
  9181. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9182. /**
  9183. * Prepares the defines related to the light information passed in parameter
  9184. * @param scene The scene we are intending to draw
  9185. * @param mesh The mesh the effect is compiling for
  9186. * @param light The light the effect is compiling for
  9187. * @param lightIndex The index of the light
  9188. * @param defines The defines to update
  9189. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9190. * @param state Defines the current state regarding what is needed (normals, etc...)
  9191. */
  9192. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9193. needNormals: boolean;
  9194. needRebuild: boolean;
  9195. shadowEnabled: boolean;
  9196. specularEnabled: boolean;
  9197. lightmapMode: boolean;
  9198. }): void;
  9199. /**
  9200. * Prepares the defines related to the light information passed in parameter
  9201. * @param scene The scene we are intending to draw
  9202. * @param mesh The mesh the effect is compiling for
  9203. * @param defines The defines to update
  9204. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9205. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9206. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9207. * @returns true if normals will be required for the rest of the effect
  9208. */
  9209. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9210. /**
  9211. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9212. * @param lightIndex defines the light index
  9213. * @param uniformsList The uniform list
  9214. * @param samplersList The sampler list
  9215. * @param projectedLightTexture defines if projected texture must be used
  9216. * @param uniformBuffersList defines an optional list of uniform buffers
  9217. */
  9218. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9219. /**
  9220. * Prepares the uniforms and samplers list to be used in the effect
  9221. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9222. * @param samplersList The sampler list
  9223. * @param defines The defines helping in the list generation
  9224. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9225. */
  9226. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9227. /**
  9228. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9229. * @param defines The defines to update while falling back
  9230. * @param fallbacks The authorized effect fallbacks
  9231. * @param maxSimultaneousLights The maximum number of lights allowed
  9232. * @param rank the current rank of the Effect
  9233. * @returns The newly affected rank
  9234. */
  9235. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9236. private static _TmpMorphInfluencers;
  9237. /**
  9238. * Prepares the list of attributes required for morph targets according to the effect defines.
  9239. * @param attribs The current list of supported attribs
  9240. * @param mesh The mesh to prepare the morph targets attributes for
  9241. * @param influencers The number of influencers
  9242. */
  9243. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9244. /**
  9245. * Prepares the list of attributes required for morph targets according to the effect defines.
  9246. * @param attribs The current list of supported attribs
  9247. * @param mesh The mesh to prepare the morph targets attributes for
  9248. * @param defines The current Defines of the effect
  9249. */
  9250. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9251. /**
  9252. * Prepares the list of attributes required for bones according to the effect defines.
  9253. * @param attribs The current list of supported attribs
  9254. * @param mesh The mesh to prepare the bones attributes for
  9255. * @param defines The current Defines of the effect
  9256. * @param fallbacks The current efffect fallback strategy
  9257. */
  9258. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9259. /**
  9260. * Check and prepare the list of attributes required for instances according to the effect defines.
  9261. * @param attribs The current list of supported attribs
  9262. * @param defines The current MaterialDefines of the effect
  9263. */
  9264. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9265. /**
  9266. * Add the list of attributes required for instances to the attribs array.
  9267. * @param attribs The current list of supported attribs
  9268. */
  9269. static PushAttributesForInstances(attribs: string[]): void;
  9270. /**
  9271. * Binds the light information to the effect.
  9272. * @param light The light containing the generator
  9273. * @param effect The effect we are binding the data to
  9274. * @param lightIndex The light index in the effect used to render
  9275. */
  9276. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9277. /**
  9278. * Binds the lights information from the scene to the effect for the given mesh.
  9279. * @param light Light to bind
  9280. * @param lightIndex Light index
  9281. * @param scene The scene where the light belongs to
  9282. * @param effect The effect we are binding the data to
  9283. * @param useSpecular Defines if specular is supported
  9284. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9285. */
  9286. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9287. /**
  9288. * Binds the lights information from the scene to the effect for the given mesh.
  9289. * @param scene The scene the lights belongs to
  9290. * @param mesh The mesh we are binding the information to render
  9291. * @param effect The effect we are binding the data to
  9292. * @param defines The generated defines for the effect
  9293. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9294. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9295. */
  9296. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9297. private static _tempFogColor;
  9298. /**
  9299. * Binds the fog information from the scene to the effect for the given mesh.
  9300. * @param scene The scene the lights belongs to
  9301. * @param mesh The mesh we are binding the information to render
  9302. * @param effect The effect we are binding the data to
  9303. * @param linearSpace Defines if the fog effect is applied in linear space
  9304. */
  9305. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9306. /**
  9307. * Binds the bones information from the mesh to the effect.
  9308. * @param mesh The mesh we are binding the information to render
  9309. * @param effect The effect we are binding the data to
  9310. */
  9311. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9312. /**
  9313. * Binds the morph targets information from the mesh to the effect.
  9314. * @param abstractMesh The mesh we are binding the information to render
  9315. * @param effect The effect we are binding the data to
  9316. */
  9317. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9318. /**
  9319. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9320. * @param defines The generated defines used in the effect
  9321. * @param effect The effect we are binding the data to
  9322. * @param scene The scene we are willing to render with logarithmic scale for
  9323. */
  9324. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9325. /**
  9326. * Binds the clip plane information from the scene to the effect.
  9327. * @param scene The scene the clip plane information are extracted from
  9328. * @param effect The effect we are binding the data to
  9329. */
  9330. static BindClipPlane(effect: Effect, scene: Scene): void;
  9331. }
  9332. }
  9333. declare module BABYLON {
  9334. /** @hidden */
  9335. export var packingFunctions: {
  9336. name: string;
  9337. shader: string;
  9338. };
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var clipPlaneFragmentDeclaration: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /** @hidden */
  9349. export var clipPlaneFragment: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var shadowMapPixelShader: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var bonesDeclaration: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var morphTargetsVertexGlobalDeclaration: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var morphTargetsVertexDeclaration: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /** @hidden */
  9384. export var instancesDeclaration: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module BABYLON {
  9390. /** @hidden */
  9391. export var helperFunctions: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module BABYLON {
  9397. /** @hidden */
  9398. export var clipPlaneVertexDeclaration: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module BABYLON {
  9404. /** @hidden */
  9405. export var morphTargetsVertex: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module BABYLON {
  9411. /** @hidden */
  9412. export var instancesVertex: {
  9413. name: string;
  9414. shader: string;
  9415. };
  9416. }
  9417. declare module BABYLON {
  9418. /** @hidden */
  9419. export var bonesVertex: {
  9420. name: string;
  9421. shader: string;
  9422. };
  9423. }
  9424. declare module BABYLON {
  9425. /** @hidden */
  9426. export var clipPlaneVertex: {
  9427. name: string;
  9428. shader: string;
  9429. };
  9430. }
  9431. declare module BABYLON {
  9432. /** @hidden */
  9433. export var shadowMapVertexShader: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module BABYLON {
  9439. /** @hidden */
  9440. export var depthBoxBlurPixelShader: {
  9441. name: string;
  9442. shader: string;
  9443. };
  9444. }
  9445. declare module BABYLON {
  9446. /**
  9447. * Class representing a ray with position and direction
  9448. */
  9449. export class Ray {
  9450. /** origin point */
  9451. origin: Vector3;
  9452. /** direction */
  9453. direction: Vector3;
  9454. /** length of the ray */
  9455. length: number;
  9456. private static readonly TmpVector3;
  9457. private _tmpRay;
  9458. /**
  9459. * Creates a new ray
  9460. * @param origin origin point
  9461. * @param direction direction
  9462. * @param length length of the ray
  9463. */
  9464. constructor(
  9465. /** origin point */
  9466. origin: Vector3,
  9467. /** direction */
  9468. direction: Vector3,
  9469. /** length of the ray */
  9470. length?: number);
  9471. /**
  9472. * Checks if the ray intersects a box
  9473. * @param minimum bound of the box
  9474. * @param maximum bound of the box
  9475. * @param intersectionTreshold extra extend to be added to the box in all direction
  9476. * @returns if the box was hit
  9477. */
  9478. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9479. /**
  9480. * Checks if the ray intersects a box
  9481. * @param box the bounding box to check
  9482. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9483. * @returns if the box was hit
  9484. */
  9485. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9486. /**
  9487. * If the ray hits a sphere
  9488. * @param sphere the bounding sphere to check
  9489. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9490. * @returns true if it hits the sphere
  9491. */
  9492. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9493. /**
  9494. * If the ray hits a triange
  9495. * @param vertex0 triangle vertex
  9496. * @param vertex1 triangle vertex
  9497. * @param vertex2 triangle vertex
  9498. * @returns intersection information if hit
  9499. */
  9500. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9501. /**
  9502. * Checks if ray intersects a plane
  9503. * @param plane the plane to check
  9504. * @returns the distance away it was hit
  9505. */
  9506. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9507. /**
  9508. * Calculate the intercept of a ray on a given axis
  9509. * @param axis to check 'x' | 'y' | 'z'
  9510. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9511. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9512. */
  9513. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9514. /**
  9515. * Checks if ray intersects a mesh
  9516. * @param mesh the mesh to check
  9517. * @param fastCheck if only the bounding box should checked
  9518. * @returns picking info of the intersecton
  9519. */
  9520. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9521. /**
  9522. * Checks if ray intersects a mesh
  9523. * @param meshes the meshes to check
  9524. * @param fastCheck if only the bounding box should checked
  9525. * @param results array to store result in
  9526. * @returns Array of picking infos
  9527. */
  9528. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9529. private _comparePickingInfo;
  9530. private static smallnum;
  9531. private static rayl;
  9532. /**
  9533. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9534. * @param sega the first point of the segment to test the intersection against
  9535. * @param segb the second point of the segment to test the intersection against
  9536. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9537. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9538. */
  9539. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9540. /**
  9541. * Update the ray from viewport position
  9542. * @param x position
  9543. * @param y y position
  9544. * @param viewportWidth viewport width
  9545. * @param viewportHeight viewport height
  9546. * @param world world matrix
  9547. * @param view view matrix
  9548. * @param projection projection matrix
  9549. * @returns this ray updated
  9550. */
  9551. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9552. /**
  9553. * Creates a ray with origin and direction of 0,0,0
  9554. * @returns the new ray
  9555. */
  9556. static Zero(): Ray;
  9557. /**
  9558. * Creates a new ray from screen space and viewport
  9559. * @param x position
  9560. * @param y y position
  9561. * @param viewportWidth viewport width
  9562. * @param viewportHeight viewport height
  9563. * @param world world matrix
  9564. * @param view view matrix
  9565. * @param projection projection matrix
  9566. * @returns new ray
  9567. */
  9568. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9569. /**
  9570. * 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
  9571. * transformed to the given world matrix.
  9572. * @param origin The origin point
  9573. * @param end The end point
  9574. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9575. * @returns the new ray
  9576. */
  9577. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9578. /**
  9579. * Transforms a ray by a matrix
  9580. * @param ray ray to transform
  9581. * @param matrix matrix to apply
  9582. * @returns the resulting new ray
  9583. */
  9584. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9585. /**
  9586. * Transforms a ray by a matrix
  9587. * @param ray ray to transform
  9588. * @param matrix matrix to apply
  9589. * @param result ray to store result in
  9590. */
  9591. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9592. /**
  9593. * Unproject a ray from screen space to object space
  9594. * @param sourceX defines the screen space x coordinate to use
  9595. * @param sourceY defines the screen space y coordinate to use
  9596. * @param viewportWidth defines the current width of the viewport
  9597. * @param viewportHeight defines the current height of the viewport
  9598. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9599. * @param view defines the view matrix to use
  9600. * @param projection defines the projection matrix to use
  9601. */
  9602. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9603. }
  9604. /**
  9605. * Type used to define predicate used to select faces when a mesh intersection is detected
  9606. */
  9607. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9608. interface Scene {
  9609. /** @hidden */
  9610. _tempPickingRay: Nullable<Ray>;
  9611. /** @hidden */
  9612. _cachedRayForTransform: Ray;
  9613. /** @hidden */
  9614. _pickWithRayInverseMatrix: Matrix;
  9615. /** @hidden */
  9616. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9617. /** @hidden */
  9618. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9619. }
  9620. }
  9621. declare module BABYLON {
  9622. /**
  9623. * Groups all the scene component constants in one place to ease maintenance.
  9624. * @hidden
  9625. */
  9626. export class SceneComponentConstants {
  9627. static readonly NAME_EFFECTLAYER: string;
  9628. static readonly NAME_LAYER: string;
  9629. static readonly NAME_LENSFLARESYSTEM: string;
  9630. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9631. static readonly NAME_PARTICLESYSTEM: string;
  9632. static readonly NAME_GAMEPAD: string;
  9633. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9634. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9635. static readonly NAME_DEPTHRENDERER: string;
  9636. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9637. static readonly NAME_SPRITE: string;
  9638. static readonly NAME_OUTLINERENDERER: string;
  9639. static readonly NAME_PROCEDURALTEXTURE: string;
  9640. static readonly NAME_SHADOWGENERATOR: string;
  9641. static readonly NAME_OCTREE: string;
  9642. static readonly NAME_PHYSICSENGINE: string;
  9643. static readonly NAME_AUDIO: string;
  9644. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9645. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9646. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9647. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9648. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9649. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9650. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9651. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9652. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9653. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9654. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9655. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9656. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9657. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9658. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9659. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9660. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9661. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9662. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9663. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9664. static readonly STEP_AFTERRENDER_AUDIO: number;
  9665. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9666. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9667. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9668. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9669. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9670. static readonly STEP_POINTERMOVE_SPRITE: number;
  9671. static readonly STEP_POINTERDOWN_SPRITE: number;
  9672. static readonly STEP_POINTERUP_SPRITE: number;
  9673. }
  9674. /**
  9675. * This represents a scene component.
  9676. *
  9677. * This is used to decouple the dependency the scene is having on the different workloads like
  9678. * layers, post processes...
  9679. */
  9680. export interface ISceneComponent {
  9681. /**
  9682. * The name of the component. Each component must have a unique name.
  9683. */
  9684. name: string;
  9685. /**
  9686. * The scene the component belongs to.
  9687. */
  9688. scene: Scene;
  9689. /**
  9690. * Register the component to one instance of a scene.
  9691. */
  9692. register(): void;
  9693. /**
  9694. * Rebuilds the elements related to this component in case of
  9695. * context lost for instance.
  9696. */
  9697. rebuild(): void;
  9698. /**
  9699. * Disposes the component and the associated ressources.
  9700. */
  9701. dispose(): void;
  9702. }
  9703. /**
  9704. * This represents a SERIALIZABLE scene component.
  9705. *
  9706. * This extends Scene Component to add Serialization methods on top.
  9707. */
  9708. export interface ISceneSerializableComponent extends ISceneComponent {
  9709. /**
  9710. * Adds all the elements from the container to the scene
  9711. * @param container the container holding the elements
  9712. */
  9713. addFromContainer(container: AbstractScene): void;
  9714. /**
  9715. * Removes all the elements in the container from the scene
  9716. * @param container contains the elements to remove
  9717. * @param dispose if the removed element should be disposed (default: false)
  9718. */
  9719. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9720. /**
  9721. * Serializes the component data to the specified json object
  9722. * @param serializationObject The object to serialize to
  9723. */
  9724. serialize(serializationObject: any): void;
  9725. }
  9726. /**
  9727. * Strong typing of a Mesh related stage step action
  9728. */
  9729. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9730. /**
  9731. * Strong typing of a Evaluate Sub Mesh related stage step action
  9732. */
  9733. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9734. /**
  9735. * Strong typing of a Active Mesh related stage step action
  9736. */
  9737. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9738. /**
  9739. * Strong typing of a Camera related stage step action
  9740. */
  9741. export type CameraStageAction = (camera: Camera) => void;
  9742. /**
  9743. * Strong typing of a Camera Frame buffer related stage step action
  9744. */
  9745. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9746. /**
  9747. * Strong typing of a Render Target related stage step action
  9748. */
  9749. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9750. /**
  9751. * Strong typing of a RenderingGroup related stage step action
  9752. */
  9753. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9754. /**
  9755. * Strong typing of a Mesh Render related stage step action
  9756. */
  9757. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9758. /**
  9759. * Strong typing of a simple stage step action
  9760. */
  9761. export type SimpleStageAction = () => void;
  9762. /**
  9763. * Strong typing of a render target action.
  9764. */
  9765. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9766. /**
  9767. * Strong typing of a pointer move action.
  9768. */
  9769. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9770. /**
  9771. * Strong typing of a pointer up/down action.
  9772. */
  9773. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9774. /**
  9775. * Representation of a stage in the scene (Basically a list of ordered steps)
  9776. * @hidden
  9777. */
  9778. export class Stage<T extends Function> extends Array<{
  9779. index: number;
  9780. component: ISceneComponent;
  9781. action: T;
  9782. }> {
  9783. /**
  9784. * Hide ctor from the rest of the world.
  9785. * @param items The items to add.
  9786. */
  9787. private constructor();
  9788. /**
  9789. * Creates a new Stage.
  9790. * @returns A new instance of a Stage
  9791. */
  9792. static Create<T extends Function>(): Stage<T>;
  9793. /**
  9794. * Registers a step in an ordered way in the targeted stage.
  9795. * @param index Defines the position to register the step in
  9796. * @param component Defines the component attached to the step
  9797. * @param action Defines the action to launch during the step
  9798. */
  9799. registerStep(index: number, component: ISceneComponent, action: T): void;
  9800. /**
  9801. * Clears all the steps from the stage.
  9802. */
  9803. clear(): void;
  9804. }
  9805. }
  9806. declare module BABYLON {
  9807. interface Scene {
  9808. /** @hidden */
  9809. _pointerOverSprite: Nullable<Sprite>;
  9810. /** @hidden */
  9811. _pickedDownSprite: Nullable<Sprite>;
  9812. /** @hidden */
  9813. _tempSpritePickingRay: Nullable<Ray>;
  9814. /**
  9815. * All of the sprite managers added to this scene
  9816. * @see http://doc.babylonjs.com/babylon101/sprites
  9817. */
  9818. spriteManagers: Array<ISpriteManager>;
  9819. /**
  9820. * An event triggered when sprites rendering is about to start
  9821. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9822. */
  9823. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9824. /**
  9825. * An event triggered when sprites rendering is done
  9826. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9827. */
  9828. onAfterSpritesRenderingObservable: Observable<Scene>;
  9829. /** @hidden */
  9830. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9831. /** Launch a ray to try to pick a sprite in the scene
  9832. * @param x position on screen
  9833. * @param y position on screen
  9834. * @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
  9835. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9836. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9837. * @returns a PickingInfo
  9838. */
  9839. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9840. /** Use the given ray to pick a sprite in the scene
  9841. * @param ray The ray (in world space) to use to pick meshes
  9842. * @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
  9843. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9844. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9845. * @returns a PickingInfo
  9846. */
  9847. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9848. /** @hidden */
  9849. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9850. /** Launch a ray to try to pick sprites in the scene
  9851. * @param x position on screen
  9852. * @param y position on screen
  9853. * @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
  9854. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9855. * @returns a PickingInfo array
  9856. */
  9857. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9858. /** Use the given ray to pick sprites in the scene
  9859. * @param ray The ray (in world space) to use to pick meshes
  9860. * @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
  9861. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9862. * @returns a PickingInfo array
  9863. */
  9864. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9865. /**
  9866. * Force the sprite under the pointer
  9867. * @param sprite defines the sprite to use
  9868. */
  9869. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9870. /**
  9871. * Gets the sprite under the pointer
  9872. * @returns a Sprite or null if no sprite is under the pointer
  9873. */
  9874. getPointerOverSprite(): Nullable<Sprite>;
  9875. }
  9876. /**
  9877. * Defines the sprite scene component responsible to manage sprites
  9878. * in a given scene.
  9879. */
  9880. export class SpriteSceneComponent implements ISceneComponent {
  9881. /**
  9882. * The component name helpfull to identify the component in the list of scene components.
  9883. */
  9884. readonly name: string;
  9885. /**
  9886. * The scene the component belongs to.
  9887. */
  9888. scene: Scene;
  9889. /** @hidden */
  9890. private _spritePredicate;
  9891. /**
  9892. * Creates a new instance of the component for the given scene
  9893. * @param scene Defines the scene to register the component in
  9894. */
  9895. constructor(scene: Scene);
  9896. /**
  9897. * Registers the component in a given scene
  9898. */
  9899. register(): void;
  9900. /**
  9901. * Rebuilds the elements related to this component in case of
  9902. * context lost for instance.
  9903. */
  9904. rebuild(): void;
  9905. /**
  9906. * Disposes the component and the associated ressources.
  9907. */
  9908. dispose(): void;
  9909. private _pickSpriteButKeepRay;
  9910. private _pointerMove;
  9911. private _pointerDown;
  9912. private _pointerUp;
  9913. }
  9914. }
  9915. declare module BABYLON {
  9916. /** @hidden */
  9917. export var fogFragmentDeclaration: {
  9918. name: string;
  9919. shader: string;
  9920. };
  9921. }
  9922. declare module BABYLON {
  9923. /** @hidden */
  9924. export var fogFragment: {
  9925. name: string;
  9926. shader: string;
  9927. };
  9928. }
  9929. declare module BABYLON {
  9930. /** @hidden */
  9931. export var spritesPixelShader: {
  9932. name: string;
  9933. shader: string;
  9934. };
  9935. }
  9936. declare module BABYLON {
  9937. /** @hidden */
  9938. export var fogVertexDeclaration: {
  9939. name: string;
  9940. shader: string;
  9941. };
  9942. }
  9943. declare module BABYLON {
  9944. /** @hidden */
  9945. export var spritesVertexShader: {
  9946. name: string;
  9947. shader: string;
  9948. };
  9949. }
  9950. declare module BABYLON {
  9951. /**
  9952. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9953. */
  9954. export interface ISpriteManager extends IDisposable {
  9955. /**
  9956. * Restricts the camera to viewing objects with the same layerMask.
  9957. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9958. */
  9959. layerMask: number;
  9960. /**
  9961. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9962. */
  9963. isPickable: boolean;
  9964. /**
  9965. * Specifies the rendering group id for this mesh (0 by default)
  9966. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9967. */
  9968. renderingGroupId: number;
  9969. /**
  9970. * Defines the list of sprites managed by the manager.
  9971. */
  9972. sprites: Array<Sprite>;
  9973. /**
  9974. * Tests the intersection of a sprite with a specific ray.
  9975. * @param ray The ray we are sending to test the collision
  9976. * @param camera The camera space we are sending rays in
  9977. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9978. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9979. * @returns picking info or null.
  9980. */
  9981. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9982. /**
  9983. * Intersects the sprites with a ray
  9984. * @param ray defines the ray to intersect with
  9985. * @param camera defines the current active camera
  9986. * @param predicate defines a predicate used to select candidate sprites
  9987. * @returns null if no hit or a PickingInfo array
  9988. */
  9989. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9990. /**
  9991. * Renders the list of sprites on screen.
  9992. */
  9993. render(): void;
  9994. }
  9995. /**
  9996. * Class used to manage multiple sprites on the same spritesheet
  9997. * @see http://doc.babylonjs.com/babylon101/sprites
  9998. */
  9999. export class SpriteManager implements ISpriteManager {
  10000. /** defines the manager's name */
  10001. name: string;
  10002. /** Gets the list of sprites */
  10003. sprites: Sprite[];
  10004. /** Gets or sets the rendering group id (0 by default) */
  10005. renderingGroupId: number;
  10006. /** Gets or sets camera layer mask */
  10007. layerMask: number;
  10008. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10009. fogEnabled: boolean;
  10010. /** Gets or sets a boolean indicating if the sprites are pickable */
  10011. isPickable: boolean;
  10012. /** Defines the default width of a cell in the spritesheet */
  10013. cellWidth: number;
  10014. /** Defines the default height of a cell in the spritesheet */
  10015. cellHeight: number;
  10016. /** Associative array from JSON sprite data file */
  10017. private _cellData;
  10018. /** Array of sprite names from JSON sprite data file */
  10019. private _spriteMap;
  10020. /** True when packed cell data from JSON file is ready*/
  10021. private _packedAndReady;
  10022. /**
  10023. * An event triggered when the manager is disposed.
  10024. */
  10025. onDisposeObservable: Observable<SpriteManager>;
  10026. private _onDisposeObserver;
  10027. /**
  10028. * Callback called when the manager is disposed
  10029. */
  10030. set onDispose(callback: () => void);
  10031. private _capacity;
  10032. private _fromPacked;
  10033. private _spriteTexture;
  10034. private _epsilon;
  10035. private _scene;
  10036. private _vertexData;
  10037. private _buffer;
  10038. private _vertexBuffers;
  10039. private _indexBuffer;
  10040. private _effectBase;
  10041. private _effectFog;
  10042. /**
  10043. * Gets or sets the spritesheet texture
  10044. */
  10045. get texture(): Texture;
  10046. set texture(value: Texture);
  10047. private _blendMode;
  10048. /**
  10049. * Blend mode use to render the particle, it can be any of
  10050. * the static Constants.ALPHA_x properties provided in this class.
  10051. * Default value is Constants.ALPHA_COMBINE
  10052. */
  10053. get blendMode(): number;
  10054. set blendMode(blendMode: number);
  10055. /** Disables writing to the depth buffer when rendering the sprites.
  10056. * It can be handy to disable depth writing when using textures without alpha channel
  10057. * and setting some specific blend modes.
  10058. */
  10059. disableDepthWrite: boolean;
  10060. /**
  10061. * Creates a new sprite manager
  10062. * @param name defines the manager's name
  10063. * @param imgUrl defines the sprite sheet url
  10064. * @param capacity defines the maximum allowed number of sprites
  10065. * @param cellSize defines the size of a sprite cell
  10066. * @param scene defines the hosting scene
  10067. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10068. * @param samplingMode defines the smapling mode to use with spritesheet
  10069. * @param fromPacked set to false; do not alter
  10070. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10071. */
  10072. constructor(
  10073. /** defines the manager's name */
  10074. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10075. private _makePacked;
  10076. private _appendSpriteVertex;
  10077. /**
  10078. * Intersects the sprites with a ray
  10079. * @param ray defines the ray to intersect with
  10080. * @param camera defines the current active camera
  10081. * @param predicate defines a predicate used to select candidate sprites
  10082. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10083. * @returns null if no hit or a PickingInfo
  10084. */
  10085. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10086. /**
  10087. * Intersects the sprites with a ray
  10088. * @param ray defines the ray to intersect with
  10089. * @param camera defines the current active camera
  10090. * @param predicate defines a predicate used to select candidate sprites
  10091. * @returns null if no hit or a PickingInfo array
  10092. */
  10093. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10094. /**
  10095. * Render all child sprites
  10096. */
  10097. render(): void;
  10098. /**
  10099. * Release associated resources
  10100. */
  10101. dispose(): void;
  10102. }
  10103. }
  10104. declare module BABYLON {
  10105. /** Interface used by value gradients (color, factor, ...) */
  10106. export interface IValueGradient {
  10107. /**
  10108. * Gets or sets the gradient value (between 0 and 1)
  10109. */
  10110. gradient: number;
  10111. }
  10112. /** Class used to store color4 gradient */
  10113. export class ColorGradient implements IValueGradient {
  10114. /**
  10115. * Gets or sets the gradient value (between 0 and 1)
  10116. */
  10117. gradient: number;
  10118. /**
  10119. * Gets or sets first associated color
  10120. */
  10121. color1: Color4;
  10122. /**
  10123. * Gets or sets second associated color
  10124. */
  10125. color2?: Color4 | undefined;
  10126. /**
  10127. * Creates a new color4 gradient
  10128. * @param gradient gets or sets the gradient value (between 0 and 1)
  10129. * @param color1 gets or sets first associated color
  10130. * @param color2 gets or sets first second color
  10131. */
  10132. constructor(
  10133. /**
  10134. * Gets or sets the gradient value (between 0 and 1)
  10135. */
  10136. gradient: number,
  10137. /**
  10138. * Gets or sets first associated color
  10139. */
  10140. color1: Color4,
  10141. /**
  10142. * Gets or sets second associated color
  10143. */
  10144. color2?: Color4 | undefined);
  10145. /**
  10146. * Will get a color picked randomly between color1 and color2.
  10147. * If color2 is undefined then color1 will be used
  10148. * @param result defines the target Color4 to store the result in
  10149. */
  10150. getColorToRef(result: Color4): void;
  10151. }
  10152. /** Class used to store color 3 gradient */
  10153. export class Color3Gradient implements IValueGradient {
  10154. /**
  10155. * Gets or sets the gradient value (between 0 and 1)
  10156. */
  10157. gradient: number;
  10158. /**
  10159. * Gets or sets the associated color
  10160. */
  10161. color: Color3;
  10162. /**
  10163. * Creates a new color3 gradient
  10164. * @param gradient gets or sets the gradient value (between 0 and 1)
  10165. * @param color gets or sets associated color
  10166. */
  10167. constructor(
  10168. /**
  10169. * Gets or sets the gradient value (between 0 and 1)
  10170. */
  10171. gradient: number,
  10172. /**
  10173. * Gets or sets the associated color
  10174. */
  10175. color: Color3);
  10176. }
  10177. /** Class used to store factor gradient */
  10178. export class FactorGradient implements IValueGradient {
  10179. /**
  10180. * Gets or sets the gradient value (between 0 and 1)
  10181. */
  10182. gradient: number;
  10183. /**
  10184. * Gets or sets first associated factor
  10185. */
  10186. factor1: number;
  10187. /**
  10188. * Gets or sets second associated factor
  10189. */
  10190. factor2?: number | undefined;
  10191. /**
  10192. * Creates a new factor gradient
  10193. * @param gradient gets or sets the gradient value (between 0 and 1)
  10194. * @param factor1 gets or sets first associated factor
  10195. * @param factor2 gets or sets second associated factor
  10196. */
  10197. constructor(
  10198. /**
  10199. * Gets or sets the gradient value (between 0 and 1)
  10200. */
  10201. gradient: number,
  10202. /**
  10203. * Gets or sets first associated factor
  10204. */
  10205. factor1: number,
  10206. /**
  10207. * Gets or sets second associated factor
  10208. */
  10209. factor2?: number | undefined);
  10210. /**
  10211. * Will get a number picked randomly between factor1 and factor2.
  10212. * If factor2 is undefined then factor1 will be used
  10213. * @returns the picked number
  10214. */
  10215. getFactor(): number;
  10216. }
  10217. /**
  10218. * Helper used to simplify some generic gradient tasks
  10219. */
  10220. export class GradientHelper {
  10221. /**
  10222. * Gets the current gradient from an array of IValueGradient
  10223. * @param ratio defines the current ratio to get
  10224. * @param gradients defines the array of IValueGradient
  10225. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10226. */
  10227. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10228. }
  10229. }
  10230. declare module BABYLON {
  10231. /**
  10232. * Interface for the size containing width and height
  10233. */
  10234. export interface ISize {
  10235. /**
  10236. * Width
  10237. */
  10238. width: number;
  10239. /**
  10240. * Heighht
  10241. */
  10242. height: number;
  10243. }
  10244. /**
  10245. * Size containing widht and height
  10246. */
  10247. export class Size implements ISize {
  10248. /**
  10249. * Width
  10250. */
  10251. width: number;
  10252. /**
  10253. * Height
  10254. */
  10255. height: number;
  10256. /**
  10257. * Creates a Size object from the given width and height (floats).
  10258. * @param width width of the new size
  10259. * @param height height of the new size
  10260. */
  10261. constructor(width: number, height: number);
  10262. /**
  10263. * Returns a string with the Size width and height
  10264. * @returns a string with the Size width and height
  10265. */
  10266. toString(): string;
  10267. /**
  10268. * "Size"
  10269. * @returns the string "Size"
  10270. */
  10271. getClassName(): string;
  10272. /**
  10273. * Returns the Size hash code.
  10274. * @returns a hash code for a unique width and height
  10275. */
  10276. getHashCode(): number;
  10277. /**
  10278. * Updates the current size from the given one.
  10279. * @param src the given size
  10280. */
  10281. copyFrom(src: Size): void;
  10282. /**
  10283. * Updates in place the current Size from the given floats.
  10284. * @param width width of the new size
  10285. * @param height height of the new size
  10286. * @returns the updated Size.
  10287. */
  10288. copyFromFloats(width: number, height: number): Size;
  10289. /**
  10290. * Updates in place the current Size from the given floats.
  10291. * @param width width to set
  10292. * @param height height to set
  10293. * @returns the updated Size.
  10294. */
  10295. set(width: number, height: number): Size;
  10296. /**
  10297. * Multiplies the width and height by numbers
  10298. * @param w factor to multiple the width by
  10299. * @param h factor to multiple the height by
  10300. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10301. */
  10302. multiplyByFloats(w: number, h: number): Size;
  10303. /**
  10304. * Clones the size
  10305. * @returns a new Size copied from the given one.
  10306. */
  10307. clone(): Size;
  10308. /**
  10309. * True if the current Size and the given one width and height are strictly equal.
  10310. * @param other the other size to compare against
  10311. * @returns True if the current Size and the given one width and height are strictly equal.
  10312. */
  10313. equals(other: Size): boolean;
  10314. /**
  10315. * The surface of the Size : width * height (float).
  10316. */
  10317. get surface(): number;
  10318. /**
  10319. * Create a new size of zero
  10320. * @returns a new Size set to (0.0, 0.0)
  10321. */
  10322. static Zero(): Size;
  10323. /**
  10324. * Sums the width and height of two sizes
  10325. * @param otherSize size to add to this size
  10326. * @returns a new Size set as the addition result of the current Size and the given one.
  10327. */
  10328. add(otherSize: Size): Size;
  10329. /**
  10330. * Subtracts the width and height of two
  10331. * @param otherSize size to subtract to this size
  10332. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10333. */
  10334. subtract(otherSize: Size): Size;
  10335. /**
  10336. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10337. * @param start starting size to lerp between
  10338. * @param end end size to lerp between
  10339. * @param amount amount to lerp between the start and end values
  10340. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10341. */
  10342. static Lerp(start: Size, end: Size, amount: number): Size;
  10343. }
  10344. }
  10345. declare module BABYLON {
  10346. interface ThinEngine {
  10347. /**
  10348. * Creates a dynamic texture
  10349. * @param width defines the width of the texture
  10350. * @param height defines the height of the texture
  10351. * @param generateMipMaps defines if the engine should generate the mip levels
  10352. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10353. * @returns the dynamic texture inside an InternalTexture
  10354. */
  10355. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10356. /**
  10357. * Update the content of a dynamic texture
  10358. * @param texture defines the texture to update
  10359. * @param canvas defines the canvas containing the source
  10360. * @param invertY defines if data must be stored with Y axis inverted
  10361. * @param premulAlpha defines if alpha is stored as premultiplied
  10362. * @param format defines the format of the data
  10363. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10364. */
  10365. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10366. }
  10367. }
  10368. declare module BABYLON {
  10369. /**
  10370. * Helper class used to generate a canvas to manipulate images
  10371. */
  10372. export class CanvasGenerator {
  10373. /**
  10374. * Create a new canvas (or offscreen canvas depending on the context)
  10375. * @param width defines the expected width
  10376. * @param height defines the expected height
  10377. * @return a new canvas or offscreen canvas
  10378. */
  10379. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10380. }
  10381. }
  10382. declare module BABYLON {
  10383. /**
  10384. * A class extending Texture allowing drawing on a texture
  10385. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10386. */
  10387. export class DynamicTexture extends Texture {
  10388. private _generateMipMaps;
  10389. private _canvas;
  10390. private _context;
  10391. private _engine;
  10392. /**
  10393. * Creates a DynamicTexture
  10394. * @param name defines the name of the texture
  10395. * @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
  10396. * @param scene defines the scene where you want the texture
  10397. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10398. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10399. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10400. */
  10401. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10402. /**
  10403. * Get the current class name of the texture useful for serialization or dynamic coding.
  10404. * @returns "DynamicTexture"
  10405. */
  10406. getClassName(): string;
  10407. /**
  10408. * Gets the current state of canRescale
  10409. */
  10410. get canRescale(): boolean;
  10411. private _recreate;
  10412. /**
  10413. * Scales the texture
  10414. * @param ratio the scale factor to apply to both width and height
  10415. */
  10416. scale(ratio: number): void;
  10417. /**
  10418. * Resizes the texture
  10419. * @param width the new width
  10420. * @param height the new height
  10421. */
  10422. scaleTo(width: number, height: number): void;
  10423. /**
  10424. * Gets the context of the canvas used by the texture
  10425. * @returns the canvas context of the dynamic texture
  10426. */
  10427. getContext(): CanvasRenderingContext2D;
  10428. /**
  10429. * Clears the texture
  10430. */
  10431. clear(): void;
  10432. /**
  10433. * Updates the texture
  10434. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10435. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10436. */
  10437. update(invertY?: boolean, premulAlpha?: boolean): void;
  10438. /**
  10439. * Draws text onto the texture
  10440. * @param text defines the text to be drawn
  10441. * @param x defines the placement of the text from the left
  10442. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10443. * @param font defines the font to be used with font-style, font-size, font-name
  10444. * @param color defines the color used for the text
  10445. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10446. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10447. * @param update defines whether texture is immediately update (default is true)
  10448. */
  10449. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10450. /**
  10451. * Clones the texture
  10452. * @returns the clone of the texture.
  10453. */
  10454. clone(): DynamicTexture;
  10455. /**
  10456. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10457. * @returns a serialized dynamic texture object
  10458. */
  10459. serialize(): any;
  10460. /** @hidden */
  10461. _rebuild(): void;
  10462. }
  10463. }
  10464. declare module BABYLON {
  10465. interface Engine {
  10466. /**
  10467. * Creates a raw texture
  10468. * @param data defines the data to store in the texture
  10469. * @param width defines the width of the texture
  10470. * @param height defines the height of the texture
  10471. * @param format defines the format of the data
  10472. * @param generateMipMaps defines if the engine should generate the mip levels
  10473. * @param invertY defines if data must be stored with Y axis inverted
  10474. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10475. * @param compression defines the compression used (null by default)
  10476. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10477. * @returns the raw texture inside an InternalTexture
  10478. */
  10479. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10480. /**
  10481. * Update a raw texture
  10482. * @param texture defines the texture to update
  10483. * @param data defines the data to store in the texture
  10484. * @param format defines the format of the data
  10485. * @param invertY defines if data must be stored with Y axis inverted
  10486. */
  10487. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10488. /**
  10489. * Update a raw texture
  10490. * @param texture defines the texture to update
  10491. * @param data defines the data to store in the texture
  10492. * @param format defines the format of the data
  10493. * @param invertY defines if data must be stored with Y axis inverted
  10494. * @param compression defines the compression used (null by default)
  10495. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10496. */
  10497. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10498. /**
  10499. * Creates a new raw cube texture
  10500. * @param data defines the array of data to use to create each face
  10501. * @param size defines the size of the textures
  10502. * @param format defines the format of the data
  10503. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10504. * @param generateMipMaps defines if the engine should generate the mip levels
  10505. * @param invertY defines if data must be stored with Y axis inverted
  10506. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10507. * @param compression defines the compression used (null by default)
  10508. * @returns the cube texture as an InternalTexture
  10509. */
  10510. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10511. /**
  10512. * Update a raw cube texture
  10513. * @param texture defines the texture to udpdate
  10514. * @param data defines the data to store
  10515. * @param format defines the data format
  10516. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10517. * @param invertY defines if data must be stored with Y axis inverted
  10518. */
  10519. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10520. /**
  10521. * Update a raw cube texture
  10522. * @param texture defines the texture to udpdate
  10523. * @param data defines the data to store
  10524. * @param format defines the data format
  10525. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10526. * @param invertY defines if data must be stored with Y axis inverted
  10527. * @param compression defines the compression used (null by default)
  10528. */
  10529. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10530. /**
  10531. * Update a raw cube texture
  10532. * @param texture defines the texture to udpdate
  10533. * @param data defines the data to store
  10534. * @param format defines the data format
  10535. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10536. * @param invertY defines if data must be stored with Y axis inverted
  10537. * @param compression defines the compression used (null by default)
  10538. * @param level defines which level of the texture to update
  10539. */
  10540. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10541. /**
  10542. * Creates a new raw cube texture from a specified url
  10543. * @param url defines the url where the data is located
  10544. * @param scene defines the current scene
  10545. * @param size defines the size of the textures
  10546. * @param format defines the format of the data
  10547. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10548. * @param noMipmap defines if the engine should avoid generating the mip levels
  10549. * @param callback defines a callback used to extract texture data from loaded data
  10550. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10551. * @param onLoad defines a callback called when texture is loaded
  10552. * @param onError defines a callback called if there is an error
  10553. * @returns the cube texture as an InternalTexture
  10554. */
  10555. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10556. /**
  10557. * Creates a new raw cube texture from a specified url
  10558. * @param url defines the url where the data is located
  10559. * @param scene defines the current scene
  10560. * @param size defines the size of the textures
  10561. * @param format defines the format of the data
  10562. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10563. * @param noMipmap defines if the engine should avoid generating the mip levels
  10564. * @param callback defines a callback used to extract texture data from loaded data
  10565. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10566. * @param onLoad defines a callback called when texture is loaded
  10567. * @param onError defines a callback called if there is an error
  10568. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10569. * @param invertY defines if data must be stored with Y axis inverted
  10570. * @returns the cube texture as an InternalTexture
  10571. */
  10572. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10573. /**
  10574. * Creates a new raw 3D texture
  10575. * @param data defines the data used to create the texture
  10576. * @param width defines the width of the texture
  10577. * @param height defines the height of the texture
  10578. * @param depth defines the depth of the texture
  10579. * @param format defines the format of the texture
  10580. * @param generateMipMaps defines if the engine must generate mip levels
  10581. * @param invertY defines if data must be stored with Y axis inverted
  10582. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10583. * @param compression defines the compressed used (can be null)
  10584. * @param textureType defines the compressed used (can be null)
  10585. * @returns a new raw 3D texture (stored in an InternalTexture)
  10586. */
  10587. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10588. /**
  10589. * Update a raw 3D texture
  10590. * @param texture defines the texture to update
  10591. * @param data defines the data to store
  10592. * @param format defines the data format
  10593. * @param invertY defines if data must be stored with Y axis inverted
  10594. */
  10595. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10596. /**
  10597. * Update a raw 3D texture
  10598. * @param texture defines the texture to update
  10599. * @param data defines the data to store
  10600. * @param format defines the data format
  10601. * @param invertY defines if data must be stored with Y axis inverted
  10602. * @param compression defines the used compression (can be null)
  10603. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10604. */
  10605. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10606. /**
  10607. * Creates a new raw 2D array texture
  10608. * @param data defines the data used to create the texture
  10609. * @param width defines the width of the texture
  10610. * @param height defines the height of the texture
  10611. * @param depth defines the number of layers of the texture
  10612. * @param format defines the format of the texture
  10613. * @param generateMipMaps defines if the engine must generate mip levels
  10614. * @param invertY defines if data must be stored with Y axis inverted
  10615. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10616. * @param compression defines the compressed used (can be null)
  10617. * @param textureType defines the compressed used (can be null)
  10618. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10619. */
  10620. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10621. /**
  10622. * Update a raw 2D array texture
  10623. * @param texture defines the texture to update
  10624. * @param data defines the data to store
  10625. * @param format defines the data format
  10626. * @param invertY defines if data must be stored with Y axis inverted
  10627. */
  10628. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10629. /**
  10630. * Update a raw 2D array texture
  10631. * @param texture defines the texture to update
  10632. * @param data defines the data to store
  10633. * @param format defines the data format
  10634. * @param invertY defines if data must be stored with Y axis inverted
  10635. * @param compression defines the used compression (can be null)
  10636. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10637. */
  10638. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10639. }
  10640. }
  10641. declare module BABYLON {
  10642. /**
  10643. * Raw texture can help creating a texture directly from an array of data.
  10644. * This can be super useful if you either get the data from an uncompressed source or
  10645. * if you wish to create your texture pixel by pixel.
  10646. */
  10647. export class RawTexture extends Texture {
  10648. /**
  10649. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10650. */
  10651. format: number;
  10652. private _engine;
  10653. /**
  10654. * Instantiates a new RawTexture.
  10655. * Raw texture can help creating a texture directly from an array of data.
  10656. * This can be super useful if you either get the data from an uncompressed source or
  10657. * if you wish to create your texture pixel by pixel.
  10658. * @param data define the array of data to use to create the texture
  10659. * @param width define the width of the texture
  10660. * @param height define the height of the texture
  10661. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10662. * @param scene define the scene the texture belongs to
  10663. * @param generateMipMaps define whether mip maps should be generated or not
  10664. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10665. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10666. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10667. */
  10668. constructor(data: ArrayBufferView, width: number, height: number,
  10669. /**
  10670. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10671. */
  10672. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10673. /**
  10674. * Updates the texture underlying data.
  10675. * @param data Define the new data of the texture
  10676. */
  10677. update(data: ArrayBufferView): void;
  10678. /**
  10679. * Creates a luminance texture from some data.
  10680. * @param data Define the texture data
  10681. * @param width Define the width of the texture
  10682. * @param height Define the height of the texture
  10683. * @param scene Define the scene the texture belongs to
  10684. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10685. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10686. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10687. * @returns the luminance texture
  10688. */
  10689. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10690. /**
  10691. * Creates a luminance alpha texture from some data.
  10692. * @param data Define the texture data
  10693. * @param width Define the width of the texture
  10694. * @param height Define the height of the texture
  10695. * @param scene Define the scene the texture belongs to
  10696. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10697. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10698. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10699. * @returns the luminance alpha texture
  10700. */
  10701. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10702. /**
  10703. * Creates an alpha texture from some data.
  10704. * @param data Define the texture data
  10705. * @param width Define the width of the texture
  10706. * @param height Define the height of the texture
  10707. * @param scene Define the scene the texture belongs to
  10708. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10709. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10710. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10711. * @returns the alpha texture
  10712. */
  10713. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10714. /**
  10715. * Creates a RGB texture from some data.
  10716. * @param data Define the texture data
  10717. * @param width Define the width of the texture
  10718. * @param height Define the height of the texture
  10719. * @param scene Define the scene the texture belongs to
  10720. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10721. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10722. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10723. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10724. * @returns the RGB alpha texture
  10725. */
  10726. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10727. /**
  10728. * Creates a RGBA texture from some data.
  10729. * @param data Define the texture data
  10730. * @param width Define the width of the texture
  10731. * @param height Define the height of the texture
  10732. * @param scene Define the scene the texture belongs to
  10733. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10734. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10735. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10736. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10737. * @returns the RGBA texture
  10738. */
  10739. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10740. /**
  10741. * Creates a R texture from some data.
  10742. * @param data Define the texture data
  10743. * @param width Define the width of the texture
  10744. * @param height Define the height of the texture
  10745. * @param scene Define the scene the texture belongs to
  10746. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10747. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10748. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10749. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10750. * @returns the R texture
  10751. */
  10752. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10753. }
  10754. }
  10755. declare module BABYLON {
  10756. interface AbstractScene {
  10757. /**
  10758. * The list of procedural textures added to the scene
  10759. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10760. */
  10761. proceduralTextures: Array<ProceduralTexture>;
  10762. }
  10763. /**
  10764. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10765. * in a given scene.
  10766. */
  10767. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10768. /**
  10769. * The component name helpfull to identify the component in the list of scene components.
  10770. */
  10771. readonly name: string;
  10772. /**
  10773. * The scene the component belongs to.
  10774. */
  10775. scene: Scene;
  10776. /**
  10777. * Creates a new instance of the component for the given scene
  10778. * @param scene Defines the scene to register the component in
  10779. */
  10780. constructor(scene: Scene);
  10781. /**
  10782. * Registers the component in a given scene
  10783. */
  10784. register(): void;
  10785. /**
  10786. * Rebuilds the elements related to this component in case of
  10787. * context lost for instance.
  10788. */
  10789. rebuild(): void;
  10790. /**
  10791. * Disposes the component and the associated ressources.
  10792. */
  10793. dispose(): void;
  10794. private _beforeClear;
  10795. }
  10796. }
  10797. declare module BABYLON {
  10798. interface ThinEngine {
  10799. /**
  10800. * Creates a new render target cube texture
  10801. * @param size defines the size of the texture
  10802. * @param options defines the options used to create the texture
  10803. * @returns a new render target cube texture stored in an InternalTexture
  10804. */
  10805. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10806. }
  10807. }
  10808. declare module BABYLON {
  10809. /** @hidden */
  10810. export var proceduralVertexShader: {
  10811. name: string;
  10812. shader: string;
  10813. };
  10814. }
  10815. declare module BABYLON {
  10816. /**
  10817. * 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.
  10818. * This is the base class of any Procedural texture and contains most of the shareable code.
  10819. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10820. */
  10821. export class ProceduralTexture extends Texture {
  10822. isCube: boolean;
  10823. /**
  10824. * Define if the texture is enabled or not (disabled texture will not render)
  10825. */
  10826. isEnabled: boolean;
  10827. /**
  10828. * Define if the texture must be cleared before rendering (default is true)
  10829. */
  10830. autoClear: boolean;
  10831. /**
  10832. * Callback called when the texture is generated
  10833. */
  10834. onGenerated: () => void;
  10835. /**
  10836. * Event raised when the texture is generated
  10837. */
  10838. onGeneratedObservable: Observable<ProceduralTexture>;
  10839. /** @hidden */
  10840. _generateMipMaps: boolean;
  10841. /** @hidden **/
  10842. _effect: Effect;
  10843. /** @hidden */
  10844. _textures: {
  10845. [key: string]: Texture;
  10846. };
  10847. /** @hidden */
  10848. protected _fallbackTexture: Nullable<Texture>;
  10849. private _size;
  10850. private _currentRefreshId;
  10851. private _frameId;
  10852. private _refreshRate;
  10853. private _vertexBuffers;
  10854. private _indexBuffer;
  10855. private _uniforms;
  10856. private _samplers;
  10857. private _fragment;
  10858. private _floats;
  10859. private _ints;
  10860. private _floatsArrays;
  10861. private _colors3;
  10862. private _colors4;
  10863. private _vectors2;
  10864. private _vectors3;
  10865. private _matrices;
  10866. private _fallbackTextureUsed;
  10867. private _engine;
  10868. private _cachedDefines;
  10869. private _contentUpdateId;
  10870. private _contentData;
  10871. /**
  10872. * Instantiates a new procedural texture.
  10873. * 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.
  10874. * This is the base class of any Procedural texture and contains most of the shareable code.
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10876. * @param name Define the name of the texture
  10877. * @param size Define the size of the texture to create
  10878. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10879. * @param scene Define the scene the texture belongs to
  10880. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10881. * @param generateMipMaps Define if the texture should creates mip maps or not
  10882. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10883. */
  10884. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10885. /**
  10886. * The effect that is created when initializing the post process.
  10887. * @returns The created effect corresponding the the postprocess.
  10888. */
  10889. getEffect(): Effect;
  10890. /**
  10891. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10892. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10893. */
  10894. getContent(): Nullable<ArrayBufferView>;
  10895. private _createIndexBuffer;
  10896. /** @hidden */
  10897. _rebuild(): void;
  10898. /**
  10899. * Resets the texture in order to recreate its associated resources.
  10900. * This can be called in case of context loss
  10901. */
  10902. reset(): void;
  10903. protected _getDefines(): string;
  10904. /**
  10905. * Is the texture ready to be used ? (rendered at least once)
  10906. * @returns true if ready, otherwise, false.
  10907. */
  10908. isReady(): boolean;
  10909. /**
  10910. * Resets the refresh counter of the texture and start bak from scratch.
  10911. * Could be useful to regenerate the texture if it is setup to render only once.
  10912. */
  10913. resetRefreshCounter(): void;
  10914. /**
  10915. * Set the fragment shader to use in order to render the texture.
  10916. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10917. */
  10918. setFragment(fragment: any): void;
  10919. /**
  10920. * Define the refresh rate of the texture or the rendering frequency.
  10921. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10922. */
  10923. get refreshRate(): number;
  10924. set refreshRate(value: number);
  10925. /** @hidden */
  10926. _shouldRender(): boolean;
  10927. /**
  10928. * Get the size the texture is rendering at.
  10929. * @returns the size (texture is always squared)
  10930. */
  10931. getRenderSize(): number;
  10932. /**
  10933. * Resize the texture to new value.
  10934. * @param size Define the new size the texture should have
  10935. * @param generateMipMaps Define whether the new texture should create mip maps
  10936. */
  10937. resize(size: number, generateMipMaps: boolean): void;
  10938. private _checkUniform;
  10939. /**
  10940. * Set a texture in the shader program used to render.
  10941. * @param name Define the name of the uniform samplers as defined in the shader
  10942. * @param texture Define the texture to bind to this sampler
  10943. * @return the texture itself allowing "fluent" like uniform updates
  10944. */
  10945. setTexture(name: string, texture: Texture): ProceduralTexture;
  10946. /**
  10947. * Set a float in the shader.
  10948. * @param name Define the name of the uniform as defined in the shader
  10949. * @param value Define the value to give to the uniform
  10950. * @return the texture itself allowing "fluent" like uniform updates
  10951. */
  10952. setFloat(name: string, value: number): ProceduralTexture;
  10953. /**
  10954. * Set a int in the shader.
  10955. * @param name Define the name of the uniform as defined in the shader
  10956. * @param value Define the value to give to the uniform
  10957. * @return the texture itself allowing "fluent" like uniform updates
  10958. */
  10959. setInt(name: string, value: number): ProceduralTexture;
  10960. /**
  10961. * Set an array of floats in the shader.
  10962. * @param name Define the name of the uniform as defined in the shader
  10963. * @param value Define the value to give to the uniform
  10964. * @return the texture itself allowing "fluent" like uniform updates
  10965. */
  10966. setFloats(name: string, value: number[]): ProceduralTexture;
  10967. /**
  10968. * Set a vec3 in the shader from a Color3.
  10969. * @param name Define the name of the uniform as defined in the shader
  10970. * @param value Define the value to give to the uniform
  10971. * @return the texture itself allowing "fluent" like uniform updates
  10972. */
  10973. setColor3(name: string, value: Color3): ProceduralTexture;
  10974. /**
  10975. * Set a vec4 in the shader from a Color4.
  10976. * @param name Define the name of the uniform as defined in the shader
  10977. * @param value Define the value to give to the uniform
  10978. * @return the texture itself allowing "fluent" like uniform updates
  10979. */
  10980. setColor4(name: string, value: Color4): ProceduralTexture;
  10981. /**
  10982. * Set a vec2 in the shader from a Vector2.
  10983. * @param name Define the name of the uniform as defined in the shader
  10984. * @param value Define the value to give to the uniform
  10985. * @return the texture itself allowing "fluent" like uniform updates
  10986. */
  10987. setVector2(name: string, value: Vector2): ProceduralTexture;
  10988. /**
  10989. * Set a vec3 in the shader from a Vector3.
  10990. * @param name Define the name of the uniform as defined in the shader
  10991. * @param value Define the value to give to the uniform
  10992. * @return the texture itself allowing "fluent" like uniform updates
  10993. */
  10994. setVector3(name: string, value: Vector3): ProceduralTexture;
  10995. /**
  10996. * Set a mat4 in the shader from a MAtrix.
  10997. * @param name Define the name of the uniform as defined in the shader
  10998. * @param value Define the value to give to the uniform
  10999. * @return the texture itself allowing "fluent" like uniform updates
  11000. */
  11001. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11002. /**
  11003. * Render the texture to its associated render target.
  11004. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11005. */
  11006. render(useCameraPostProcess?: boolean): void;
  11007. /**
  11008. * Clone the texture.
  11009. * @returns the cloned texture
  11010. */
  11011. clone(): ProceduralTexture;
  11012. /**
  11013. * Dispose the texture and release its asoociated resources.
  11014. */
  11015. dispose(): void;
  11016. }
  11017. }
  11018. declare module BABYLON {
  11019. /**
  11020. * This represents the base class for particle system in Babylon.
  11021. * 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.
  11022. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11023. * @example https://doc.babylonjs.com/babylon101/particles
  11024. */
  11025. export class BaseParticleSystem {
  11026. /**
  11027. * Source color is added to the destination color without alpha affecting the result
  11028. */
  11029. static BLENDMODE_ONEONE: number;
  11030. /**
  11031. * Blend current color and particle color using particle’s alpha
  11032. */
  11033. static BLENDMODE_STANDARD: number;
  11034. /**
  11035. * Add current color and particle color multiplied by particle’s alpha
  11036. */
  11037. static BLENDMODE_ADD: number;
  11038. /**
  11039. * Multiply current color with particle color
  11040. */
  11041. static BLENDMODE_MULTIPLY: number;
  11042. /**
  11043. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11044. */
  11045. static BLENDMODE_MULTIPLYADD: number;
  11046. /**
  11047. * List of animations used by the particle system.
  11048. */
  11049. animations: Animation[];
  11050. /**
  11051. * Gets or sets the unique id of the particle system
  11052. */
  11053. uniqueId: number;
  11054. /**
  11055. * The id of the Particle system.
  11056. */
  11057. id: string;
  11058. /**
  11059. * The friendly name of the Particle system.
  11060. */
  11061. name: string;
  11062. /**
  11063. * Snippet ID if the particle system was created from the snippet server
  11064. */
  11065. snippetId: string;
  11066. /**
  11067. * The rendering group used by the Particle system to chose when to render.
  11068. */
  11069. renderingGroupId: number;
  11070. /**
  11071. * The emitter represents the Mesh or position we are attaching the particle system to.
  11072. */
  11073. emitter: Nullable<AbstractMesh | Vector3>;
  11074. /**
  11075. * The maximum number of particles to emit per frame
  11076. */
  11077. emitRate: number;
  11078. /**
  11079. * If you want to launch only a few particles at once, that can be done, as well.
  11080. */
  11081. manualEmitCount: number;
  11082. /**
  11083. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11084. */
  11085. updateSpeed: number;
  11086. /**
  11087. * The amount of time the particle system is running (depends of the overall update speed).
  11088. */
  11089. targetStopDuration: number;
  11090. /**
  11091. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11092. */
  11093. disposeOnStop: boolean;
  11094. /**
  11095. * Minimum power of emitting particles.
  11096. */
  11097. minEmitPower: number;
  11098. /**
  11099. * Maximum power of emitting particles.
  11100. */
  11101. maxEmitPower: number;
  11102. /**
  11103. * Minimum life time of emitting particles.
  11104. */
  11105. minLifeTime: number;
  11106. /**
  11107. * Maximum life time of emitting particles.
  11108. */
  11109. maxLifeTime: number;
  11110. /**
  11111. * Minimum Size of emitting particles.
  11112. */
  11113. minSize: number;
  11114. /**
  11115. * Maximum Size of emitting particles.
  11116. */
  11117. maxSize: number;
  11118. /**
  11119. * Minimum scale of emitting particles on X axis.
  11120. */
  11121. minScaleX: number;
  11122. /**
  11123. * Maximum scale of emitting particles on X axis.
  11124. */
  11125. maxScaleX: number;
  11126. /**
  11127. * Minimum scale of emitting particles on Y axis.
  11128. */
  11129. minScaleY: number;
  11130. /**
  11131. * Maximum scale of emitting particles on Y axis.
  11132. */
  11133. maxScaleY: number;
  11134. /**
  11135. * Gets or sets the minimal initial rotation in radians.
  11136. */
  11137. minInitialRotation: number;
  11138. /**
  11139. * Gets or sets the maximal initial rotation in radians.
  11140. */
  11141. maxInitialRotation: number;
  11142. /**
  11143. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11144. */
  11145. minAngularSpeed: number;
  11146. /**
  11147. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11148. */
  11149. maxAngularSpeed: number;
  11150. /**
  11151. * The texture used to render each particle. (this can be a spritesheet)
  11152. */
  11153. particleTexture: Nullable<Texture>;
  11154. /**
  11155. * The layer mask we are rendering the particles through.
  11156. */
  11157. layerMask: number;
  11158. /**
  11159. * This can help using your own shader to render the particle system.
  11160. * The according effect will be created
  11161. */
  11162. customShader: any;
  11163. /**
  11164. * By default particle system starts as soon as they are created. This prevents the
  11165. * automatic start to happen and let you decide when to start emitting particles.
  11166. */
  11167. preventAutoStart: boolean;
  11168. private _noiseTexture;
  11169. /**
  11170. * Gets or sets a texture used to add random noise to particle positions
  11171. */
  11172. get noiseTexture(): Nullable<ProceduralTexture>;
  11173. set noiseTexture(value: Nullable<ProceduralTexture>);
  11174. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11175. noiseStrength: Vector3;
  11176. /**
  11177. * Callback triggered when the particle animation is ending.
  11178. */
  11179. onAnimationEnd: Nullable<() => void>;
  11180. /**
  11181. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11182. */
  11183. blendMode: number;
  11184. /**
  11185. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11186. * to override the particles.
  11187. */
  11188. forceDepthWrite: boolean;
  11189. /** 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 */
  11190. preWarmCycles: number;
  11191. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11192. preWarmStepOffset: number;
  11193. /**
  11194. * 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)
  11195. */
  11196. spriteCellChangeSpeed: number;
  11197. /**
  11198. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11199. */
  11200. startSpriteCellID: number;
  11201. /**
  11202. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11203. */
  11204. endSpriteCellID: number;
  11205. /**
  11206. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11207. */
  11208. spriteCellWidth: number;
  11209. /**
  11210. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11211. */
  11212. spriteCellHeight: number;
  11213. /**
  11214. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11215. */
  11216. spriteRandomStartCell: boolean;
  11217. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11218. translationPivot: Vector2;
  11219. /** @hidden */
  11220. protected _isAnimationSheetEnabled: boolean;
  11221. /**
  11222. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11223. */
  11224. beginAnimationOnStart: boolean;
  11225. /**
  11226. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11227. */
  11228. beginAnimationFrom: number;
  11229. /**
  11230. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11231. */
  11232. beginAnimationTo: number;
  11233. /**
  11234. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11235. */
  11236. beginAnimationLoop: boolean;
  11237. /**
  11238. * Gets or sets a world offset applied to all particles
  11239. */
  11240. worldOffset: Vector3;
  11241. /**
  11242. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11243. */
  11244. get isAnimationSheetEnabled(): boolean;
  11245. set isAnimationSheetEnabled(value: boolean);
  11246. /**
  11247. * Get hosting scene
  11248. * @returns the scene
  11249. */
  11250. getScene(): Scene;
  11251. /**
  11252. * You can use gravity if you want to give an orientation to your particles.
  11253. */
  11254. gravity: Vector3;
  11255. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11256. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11257. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11258. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11259. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11260. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11261. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11262. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11263. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11264. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11265. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11266. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11267. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11268. /**
  11269. * Defines the delay in milliseconds before starting the system (0 by default)
  11270. */
  11271. startDelay: number;
  11272. /**
  11273. * Gets the current list of drag gradients.
  11274. * You must use addDragGradient and removeDragGradient to udpate this list
  11275. * @returns the list of drag gradients
  11276. */
  11277. getDragGradients(): Nullable<Array<FactorGradient>>;
  11278. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11279. limitVelocityDamping: number;
  11280. /**
  11281. * Gets the current list of limit velocity gradients.
  11282. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11283. * @returns the list of limit velocity gradients
  11284. */
  11285. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11286. /**
  11287. * Gets the current list of color gradients.
  11288. * You must use addColorGradient and removeColorGradient to udpate this list
  11289. * @returns the list of color gradients
  11290. */
  11291. getColorGradients(): Nullable<Array<ColorGradient>>;
  11292. /**
  11293. * Gets the current list of size gradients.
  11294. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11295. * @returns the list of size gradients
  11296. */
  11297. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11298. /**
  11299. * Gets the current list of color remap gradients.
  11300. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11301. * @returns the list of color remap gradients
  11302. */
  11303. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11304. /**
  11305. * Gets the current list of alpha remap gradients.
  11306. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11307. * @returns the list of alpha remap gradients
  11308. */
  11309. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11310. /**
  11311. * Gets the current list of life time gradients.
  11312. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11313. * @returns the list of life time gradients
  11314. */
  11315. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11316. /**
  11317. * Gets the current list of angular speed gradients.
  11318. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11319. * @returns the list of angular speed gradients
  11320. */
  11321. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11322. /**
  11323. * Gets the current list of velocity gradients.
  11324. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11325. * @returns the list of velocity gradients
  11326. */
  11327. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11328. /**
  11329. * Gets the current list of start size gradients.
  11330. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11331. * @returns the list of start size gradients
  11332. */
  11333. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11334. /**
  11335. * Gets the current list of emit rate gradients.
  11336. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11337. * @returns the list of emit rate gradients
  11338. */
  11339. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11340. /**
  11341. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11342. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11343. */
  11344. get direction1(): Vector3;
  11345. set direction1(value: Vector3);
  11346. /**
  11347. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11348. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11349. */
  11350. get direction2(): Vector3;
  11351. set direction2(value: Vector3);
  11352. /**
  11353. * 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.
  11354. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11355. */
  11356. get minEmitBox(): Vector3;
  11357. set minEmitBox(value: Vector3);
  11358. /**
  11359. * 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.
  11360. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11361. */
  11362. get maxEmitBox(): Vector3;
  11363. set maxEmitBox(value: Vector3);
  11364. /**
  11365. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11366. */
  11367. color1: Color4;
  11368. /**
  11369. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11370. */
  11371. color2: Color4;
  11372. /**
  11373. * Color the particle will have at the end of its lifetime
  11374. */
  11375. colorDead: Color4;
  11376. /**
  11377. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11378. */
  11379. textureMask: Color4;
  11380. /**
  11381. * The particle emitter type defines the emitter used by the particle system.
  11382. * It can be for example box, sphere, or cone...
  11383. */
  11384. particleEmitterType: IParticleEmitterType;
  11385. /** @hidden */
  11386. _isSubEmitter: boolean;
  11387. /**
  11388. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11389. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11390. */
  11391. billboardMode: number;
  11392. protected _isBillboardBased: boolean;
  11393. /**
  11394. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11395. */
  11396. get isBillboardBased(): boolean;
  11397. set isBillboardBased(value: boolean);
  11398. /**
  11399. * The scene the particle system belongs to.
  11400. */
  11401. protected _scene: Scene;
  11402. /**
  11403. * Local cache of defines for image processing.
  11404. */
  11405. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11406. /**
  11407. * Default configuration related to image processing available in the standard Material.
  11408. */
  11409. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11410. /**
  11411. * Gets the image processing configuration used either in this material.
  11412. */
  11413. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11414. /**
  11415. * Sets the Default image processing configuration used either in the this material.
  11416. *
  11417. * If sets to null, the scene one is in use.
  11418. */
  11419. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11420. /**
  11421. * Attaches a new image processing configuration to the Standard Material.
  11422. * @param configuration
  11423. */
  11424. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11425. /** @hidden */
  11426. protected _reset(): void;
  11427. /** @hidden */
  11428. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11429. /**
  11430. * Instantiates a particle system.
  11431. * 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.
  11432. * @param name The name of the particle system
  11433. */
  11434. constructor(name: string);
  11435. /**
  11436. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11437. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11438. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11439. * @returns the emitter
  11440. */
  11441. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11442. /**
  11443. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11444. * @param radius The radius of the hemisphere to emit from
  11445. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11446. * @returns the emitter
  11447. */
  11448. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11449. /**
  11450. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11451. * @param radius The radius of the sphere to emit from
  11452. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11453. * @returns the emitter
  11454. */
  11455. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11456. /**
  11457. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11458. * @param radius The radius of the sphere to emit from
  11459. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11460. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11461. * @returns the emitter
  11462. */
  11463. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11464. /**
  11465. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11466. * @param radius The radius of the emission cylinder
  11467. * @param height The height of the emission cylinder
  11468. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11469. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11470. * @returns the emitter
  11471. */
  11472. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11473. /**
  11474. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11475. * @param radius The radius of the cylinder to emit from
  11476. * @param height The height of the emission cylinder
  11477. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11478. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11479. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11480. * @returns the emitter
  11481. */
  11482. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11483. /**
  11484. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11485. * @param radius The radius of the cone to emit from
  11486. * @param angle The base angle of the cone
  11487. * @returns the emitter
  11488. */
  11489. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11490. /**
  11491. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11492. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11493. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11494. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11495. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11496. * @returns the emitter
  11497. */
  11498. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11499. }
  11500. }
  11501. declare module BABYLON {
  11502. /**
  11503. * Type of sub emitter
  11504. */
  11505. export enum SubEmitterType {
  11506. /**
  11507. * Attached to the particle over it's lifetime
  11508. */
  11509. ATTACHED = 0,
  11510. /**
  11511. * Created when the particle dies
  11512. */
  11513. END = 1
  11514. }
  11515. /**
  11516. * Sub emitter class used to emit particles from an existing particle
  11517. */
  11518. export class SubEmitter {
  11519. /**
  11520. * the particle system to be used by the sub emitter
  11521. */
  11522. particleSystem: ParticleSystem;
  11523. /**
  11524. * Type of the submitter (Default: END)
  11525. */
  11526. type: SubEmitterType;
  11527. /**
  11528. * 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)
  11529. * Note: This only is supported when using an emitter of type Mesh
  11530. */
  11531. inheritDirection: boolean;
  11532. /**
  11533. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11534. */
  11535. inheritedVelocityAmount: number;
  11536. /**
  11537. * Creates a sub emitter
  11538. * @param particleSystem the particle system to be used by the sub emitter
  11539. */
  11540. constructor(
  11541. /**
  11542. * the particle system to be used by the sub emitter
  11543. */
  11544. particleSystem: ParticleSystem);
  11545. /**
  11546. * Clones the sub emitter
  11547. * @returns the cloned sub emitter
  11548. */
  11549. clone(): SubEmitter;
  11550. /**
  11551. * Serialize current object to a JSON object
  11552. * @returns the serialized object
  11553. */
  11554. serialize(): any;
  11555. /** @hidden */
  11556. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11557. /**
  11558. * Creates a new SubEmitter from a serialized JSON version
  11559. * @param serializationObject defines the JSON object to read from
  11560. * @param scene defines the hosting scene
  11561. * @param rootUrl defines the rootUrl for data loading
  11562. * @returns a new SubEmitter
  11563. */
  11564. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11565. /** Release associated resources */
  11566. dispose(): void;
  11567. }
  11568. }
  11569. declare module BABYLON {
  11570. /** @hidden */
  11571. export var imageProcessingDeclaration: {
  11572. name: string;
  11573. shader: string;
  11574. };
  11575. }
  11576. declare module BABYLON {
  11577. /** @hidden */
  11578. export var imageProcessingFunctions: {
  11579. name: string;
  11580. shader: string;
  11581. };
  11582. }
  11583. declare module BABYLON {
  11584. /** @hidden */
  11585. export var particlesPixelShader: {
  11586. name: string;
  11587. shader: string;
  11588. };
  11589. }
  11590. declare module BABYLON {
  11591. /** @hidden */
  11592. export var particlesVertexShader: {
  11593. name: string;
  11594. shader: string;
  11595. };
  11596. }
  11597. declare module BABYLON {
  11598. /**
  11599. * This represents a particle system in Babylon.
  11600. * 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.
  11601. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11602. * @example https://doc.babylonjs.com/babylon101/particles
  11603. */
  11604. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11605. /**
  11606. * Billboard mode will only apply to Y axis
  11607. */
  11608. static readonly BILLBOARDMODE_Y: number;
  11609. /**
  11610. * Billboard mode will apply to all axes
  11611. */
  11612. static readonly BILLBOARDMODE_ALL: number;
  11613. /**
  11614. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11615. */
  11616. static readonly BILLBOARDMODE_STRETCHED: number;
  11617. /**
  11618. * This function can be defined to provide custom update for active particles.
  11619. * This function will be called instead of regular update (age, position, color, etc.).
  11620. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11621. */
  11622. updateFunction: (particles: Particle[]) => void;
  11623. private _emitterWorldMatrix;
  11624. /**
  11625. * This function can be defined to specify initial direction for every new particle.
  11626. * It by default use the emitterType defined function
  11627. */
  11628. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11629. /**
  11630. * This function can be defined to specify initial position for every new particle.
  11631. * It by default use the emitterType defined function
  11632. */
  11633. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11634. /**
  11635. * @hidden
  11636. */
  11637. _inheritedVelocityOffset: Vector3;
  11638. /**
  11639. * An event triggered when the system is disposed
  11640. */
  11641. onDisposeObservable: Observable<ParticleSystem>;
  11642. private _onDisposeObserver;
  11643. /**
  11644. * Sets a callback that will be triggered when the system is disposed
  11645. */
  11646. set onDispose(callback: () => void);
  11647. private _particles;
  11648. private _epsilon;
  11649. private _capacity;
  11650. private _stockParticles;
  11651. private _newPartsExcess;
  11652. private _vertexData;
  11653. private _vertexBuffer;
  11654. private _vertexBuffers;
  11655. private _spriteBuffer;
  11656. private _indexBuffer;
  11657. private _effect;
  11658. private _customEffect;
  11659. private _cachedDefines;
  11660. private _scaledColorStep;
  11661. private _colorDiff;
  11662. private _scaledDirection;
  11663. private _scaledGravity;
  11664. private _currentRenderId;
  11665. private _alive;
  11666. private _useInstancing;
  11667. private _started;
  11668. private _stopped;
  11669. private _actualFrame;
  11670. private _scaledUpdateSpeed;
  11671. private _vertexBufferSize;
  11672. /** @hidden */
  11673. _currentEmitRateGradient: Nullable<FactorGradient>;
  11674. /** @hidden */
  11675. _currentEmitRate1: number;
  11676. /** @hidden */
  11677. _currentEmitRate2: number;
  11678. /** @hidden */
  11679. _currentStartSizeGradient: Nullable<FactorGradient>;
  11680. /** @hidden */
  11681. _currentStartSize1: number;
  11682. /** @hidden */
  11683. _currentStartSize2: number;
  11684. private readonly _rawTextureWidth;
  11685. private _rampGradientsTexture;
  11686. private _useRampGradients;
  11687. /** Gets or sets a boolean indicating that ramp gradients must be used
  11688. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11689. */
  11690. get useRampGradients(): boolean;
  11691. set useRampGradients(value: boolean);
  11692. /**
  11693. * 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.
  11694. * 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: [])
  11695. */
  11696. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11697. private _subEmitters;
  11698. /**
  11699. * @hidden
  11700. * If the particle systems emitter should be disposed when the particle system is disposed
  11701. */
  11702. _disposeEmitterOnDispose: boolean;
  11703. /**
  11704. * The current active Sub-systems, this property is used by the root particle system only.
  11705. */
  11706. activeSubSystems: Array<ParticleSystem>;
  11707. /**
  11708. * Specifies if the particles are updated in emitter local space or world space
  11709. */
  11710. isLocal: boolean;
  11711. private _rootParticleSystem;
  11712. /**
  11713. * Gets the current list of active particles
  11714. */
  11715. get particles(): Particle[];
  11716. /**
  11717. * Gets the number of particles active at the same time.
  11718. * @returns The number of active particles.
  11719. */
  11720. getActiveCount(): number;
  11721. /**
  11722. * Returns the string "ParticleSystem"
  11723. * @returns a string containing the class name
  11724. */
  11725. getClassName(): string;
  11726. /**
  11727. * Gets a boolean indicating that the system is stopping
  11728. * @returns true if the system is currently stopping
  11729. */
  11730. isStopping(): boolean;
  11731. /**
  11732. * Instantiates a particle system.
  11733. * 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.
  11734. * @param name The name of the particle system
  11735. * @param capacity The max number of particles alive at the same time
  11736. * @param scene The scene the particle system belongs to
  11737. * @param customEffect a custom effect used to change the way particles are rendered by default
  11738. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11739. * @param epsilon Offset used to render the particles
  11740. */
  11741. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11742. private _addFactorGradient;
  11743. private _removeFactorGradient;
  11744. /**
  11745. * Adds a new life time gradient
  11746. * @param gradient defines the gradient to use (between 0 and 1)
  11747. * @param factor defines the life time factor to affect to the specified gradient
  11748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11749. * @returns the current particle system
  11750. */
  11751. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11752. /**
  11753. * Remove a specific life time gradient
  11754. * @param gradient defines the gradient to remove
  11755. * @returns the current particle system
  11756. */
  11757. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11758. /**
  11759. * Adds a new size gradient
  11760. * @param gradient defines the gradient to use (between 0 and 1)
  11761. * @param factor defines the size factor to affect to the specified gradient
  11762. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11763. * @returns the current particle system
  11764. */
  11765. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11766. /**
  11767. * Remove a specific size gradient
  11768. * @param gradient defines the gradient to remove
  11769. * @returns the current particle system
  11770. */
  11771. removeSizeGradient(gradient: number): IParticleSystem;
  11772. /**
  11773. * Adds a new color remap gradient
  11774. * @param gradient defines the gradient to use (between 0 and 1)
  11775. * @param min defines the color remap minimal range
  11776. * @param max defines the color remap maximal range
  11777. * @returns the current particle system
  11778. */
  11779. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11780. /**
  11781. * Remove a specific color remap gradient
  11782. * @param gradient defines the gradient to remove
  11783. * @returns the current particle system
  11784. */
  11785. removeColorRemapGradient(gradient: number): IParticleSystem;
  11786. /**
  11787. * Adds a new alpha remap gradient
  11788. * @param gradient defines the gradient to use (between 0 and 1)
  11789. * @param min defines the alpha remap minimal range
  11790. * @param max defines the alpha remap maximal range
  11791. * @returns the current particle system
  11792. */
  11793. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11794. /**
  11795. * Remove a specific alpha remap gradient
  11796. * @param gradient defines the gradient to remove
  11797. * @returns the current particle system
  11798. */
  11799. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11800. /**
  11801. * Adds a new angular speed gradient
  11802. * @param gradient defines the gradient to use (between 0 and 1)
  11803. * @param factor defines the angular speed to affect to the specified gradient
  11804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11805. * @returns the current particle system
  11806. */
  11807. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11808. /**
  11809. * Remove a specific angular speed gradient
  11810. * @param gradient defines the gradient to remove
  11811. * @returns the current particle system
  11812. */
  11813. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11814. /**
  11815. * Adds a new velocity gradient
  11816. * @param gradient defines the gradient to use (between 0 and 1)
  11817. * @param factor defines the velocity to affect to the specified gradient
  11818. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11819. * @returns the current particle system
  11820. */
  11821. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11822. /**
  11823. * Remove a specific velocity gradient
  11824. * @param gradient defines the gradient to remove
  11825. * @returns the current particle system
  11826. */
  11827. removeVelocityGradient(gradient: number): IParticleSystem;
  11828. /**
  11829. * Adds a new limit velocity gradient
  11830. * @param gradient defines the gradient to use (between 0 and 1)
  11831. * @param factor defines the limit velocity value to affect to the specified gradient
  11832. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11833. * @returns the current particle system
  11834. */
  11835. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11836. /**
  11837. * Remove a specific limit velocity gradient
  11838. * @param gradient defines the gradient to remove
  11839. * @returns the current particle system
  11840. */
  11841. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11842. /**
  11843. * Adds a new drag gradient
  11844. * @param gradient defines the gradient to use (between 0 and 1)
  11845. * @param factor defines the drag value to affect to the specified gradient
  11846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11847. * @returns the current particle system
  11848. */
  11849. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11850. /**
  11851. * Remove a specific drag gradient
  11852. * @param gradient defines the gradient to remove
  11853. * @returns the current particle system
  11854. */
  11855. removeDragGradient(gradient: number): IParticleSystem;
  11856. /**
  11857. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11858. * @param gradient defines the gradient to use (between 0 and 1)
  11859. * @param factor defines the emit rate value to affect to the specified gradient
  11860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11861. * @returns the current particle system
  11862. */
  11863. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11864. /**
  11865. * Remove a specific emit rate gradient
  11866. * @param gradient defines the gradient to remove
  11867. * @returns the current particle system
  11868. */
  11869. removeEmitRateGradient(gradient: number): IParticleSystem;
  11870. /**
  11871. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11872. * @param gradient defines the gradient to use (between 0 and 1)
  11873. * @param factor defines the start size value to affect to the specified gradient
  11874. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11875. * @returns the current particle system
  11876. */
  11877. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11878. /**
  11879. * Remove a specific start size gradient
  11880. * @param gradient defines the gradient to remove
  11881. * @returns the current particle system
  11882. */
  11883. removeStartSizeGradient(gradient: number): IParticleSystem;
  11884. private _createRampGradientTexture;
  11885. /**
  11886. * Gets the current list of ramp gradients.
  11887. * You must use addRampGradient and removeRampGradient to udpate this list
  11888. * @returns the list of ramp gradients
  11889. */
  11890. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11891. /**
  11892. * Adds a new ramp gradient used to remap particle colors
  11893. * @param gradient defines the gradient to use (between 0 and 1)
  11894. * @param color defines the color to affect to the specified gradient
  11895. * @returns the current particle system
  11896. */
  11897. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11898. /**
  11899. * Remove a specific ramp gradient
  11900. * @param gradient defines the gradient to remove
  11901. * @returns the current particle system
  11902. */
  11903. removeRampGradient(gradient: number): ParticleSystem;
  11904. /**
  11905. * Adds a new color gradient
  11906. * @param gradient defines the gradient to use (between 0 and 1)
  11907. * @param color1 defines the color to affect to the specified gradient
  11908. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11909. * @returns this particle system
  11910. */
  11911. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11912. /**
  11913. * Remove a specific color gradient
  11914. * @param gradient defines the gradient to remove
  11915. * @returns this particle system
  11916. */
  11917. removeColorGradient(gradient: number): IParticleSystem;
  11918. private _fetchR;
  11919. protected _reset(): void;
  11920. private _resetEffect;
  11921. private _createVertexBuffers;
  11922. private _createIndexBuffer;
  11923. /**
  11924. * Gets the maximum number of particles active at the same time.
  11925. * @returns The max number of active particles.
  11926. */
  11927. getCapacity(): number;
  11928. /**
  11929. * Gets whether there are still active particles in the system.
  11930. * @returns True if it is alive, otherwise false.
  11931. */
  11932. isAlive(): boolean;
  11933. /**
  11934. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11935. * @returns True if it has been started, otherwise false.
  11936. */
  11937. isStarted(): boolean;
  11938. private _prepareSubEmitterInternalArray;
  11939. /**
  11940. * Starts the particle system and begins to emit
  11941. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11942. */
  11943. start(delay?: number): void;
  11944. /**
  11945. * Stops the particle system.
  11946. * @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.
  11947. */
  11948. stop(stopSubEmitters?: boolean): void;
  11949. /**
  11950. * Remove all active particles
  11951. */
  11952. reset(): void;
  11953. /**
  11954. * @hidden (for internal use only)
  11955. */
  11956. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11957. /**
  11958. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11959. * Its lifetime will start back at 0.
  11960. */
  11961. recycleParticle: (particle: Particle) => void;
  11962. private _stopSubEmitters;
  11963. private _createParticle;
  11964. private _removeFromRoot;
  11965. private _emitFromParticle;
  11966. private _update;
  11967. /** @hidden */
  11968. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11969. /** @hidden */
  11970. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11971. /** @hidden */
  11972. private _getEffect;
  11973. /**
  11974. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11975. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11976. */
  11977. animate(preWarmOnly?: boolean): void;
  11978. private _appendParticleVertices;
  11979. /**
  11980. * Rebuilds the particle system.
  11981. */
  11982. rebuild(): void;
  11983. /**
  11984. * Is this system ready to be used/rendered
  11985. * @return true if the system is ready
  11986. */
  11987. isReady(): boolean;
  11988. private _render;
  11989. /**
  11990. * Renders the particle system in its current state.
  11991. * @returns the current number of particles
  11992. */
  11993. render(): number;
  11994. /**
  11995. * Disposes the particle system and free the associated resources
  11996. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11997. */
  11998. dispose(disposeTexture?: boolean): void;
  11999. /**
  12000. * Clones the particle system.
  12001. * @param name The name of the cloned object
  12002. * @param newEmitter The new emitter to use
  12003. * @returns the cloned particle system
  12004. */
  12005. clone(name: string, newEmitter: any): ParticleSystem;
  12006. /**
  12007. * Serializes the particle system to a JSON object.
  12008. * @returns the JSON object
  12009. */
  12010. serialize(): any;
  12011. /** @hidden */
  12012. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12013. /** @hidden */
  12014. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12015. /**
  12016. * Parses a JSON object to create a particle system.
  12017. * @param parsedParticleSystem The JSON object to parse
  12018. * @param scene The scene to create the particle system in
  12019. * @param rootUrl The root url to use to load external dependencies like texture
  12020. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12021. * @returns the Parsed particle system
  12022. */
  12023. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12024. }
  12025. }
  12026. declare module BABYLON {
  12027. /**
  12028. * A particle represents one of the element emitted by a particle system.
  12029. * This is mainly define by its coordinates, direction, velocity and age.
  12030. */
  12031. export class Particle {
  12032. /**
  12033. * The particle system the particle belongs to.
  12034. */
  12035. particleSystem: ParticleSystem;
  12036. private static _Count;
  12037. /**
  12038. * Unique ID of the particle
  12039. */
  12040. id: number;
  12041. /**
  12042. * The world position of the particle in the scene.
  12043. */
  12044. position: Vector3;
  12045. /**
  12046. * The world direction of the particle in the scene.
  12047. */
  12048. direction: Vector3;
  12049. /**
  12050. * The color of the particle.
  12051. */
  12052. color: Color4;
  12053. /**
  12054. * The color change of the particle per step.
  12055. */
  12056. colorStep: Color4;
  12057. /**
  12058. * Defines how long will the life of the particle be.
  12059. */
  12060. lifeTime: number;
  12061. /**
  12062. * The current age of the particle.
  12063. */
  12064. age: number;
  12065. /**
  12066. * The current size of the particle.
  12067. */
  12068. size: number;
  12069. /**
  12070. * The current scale of the particle.
  12071. */
  12072. scale: Vector2;
  12073. /**
  12074. * The current angle of the particle.
  12075. */
  12076. angle: number;
  12077. /**
  12078. * Defines how fast is the angle changing.
  12079. */
  12080. angularSpeed: number;
  12081. /**
  12082. * Defines the cell index used by the particle to be rendered from a sprite.
  12083. */
  12084. cellIndex: number;
  12085. /**
  12086. * The information required to support color remapping
  12087. */
  12088. remapData: Vector4;
  12089. /** @hidden */
  12090. _randomCellOffset?: number;
  12091. /** @hidden */
  12092. _initialDirection: Nullable<Vector3>;
  12093. /** @hidden */
  12094. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12095. /** @hidden */
  12096. _initialStartSpriteCellID: number;
  12097. /** @hidden */
  12098. _initialEndSpriteCellID: number;
  12099. /** @hidden */
  12100. _currentColorGradient: Nullable<ColorGradient>;
  12101. /** @hidden */
  12102. _currentColor1: Color4;
  12103. /** @hidden */
  12104. _currentColor2: Color4;
  12105. /** @hidden */
  12106. _currentSizeGradient: Nullable<FactorGradient>;
  12107. /** @hidden */
  12108. _currentSize1: number;
  12109. /** @hidden */
  12110. _currentSize2: number;
  12111. /** @hidden */
  12112. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12113. /** @hidden */
  12114. _currentAngularSpeed1: number;
  12115. /** @hidden */
  12116. _currentAngularSpeed2: number;
  12117. /** @hidden */
  12118. _currentVelocityGradient: Nullable<FactorGradient>;
  12119. /** @hidden */
  12120. _currentVelocity1: number;
  12121. /** @hidden */
  12122. _currentVelocity2: number;
  12123. /** @hidden */
  12124. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12125. /** @hidden */
  12126. _currentLimitVelocity1: number;
  12127. /** @hidden */
  12128. _currentLimitVelocity2: number;
  12129. /** @hidden */
  12130. _currentDragGradient: Nullable<FactorGradient>;
  12131. /** @hidden */
  12132. _currentDrag1: number;
  12133. /** @hidden */
  12134. _currentDrag2: number;
  12135. /** @hidden */
  12136. _randomNoiseCoordinates1: Vector3;
  12137. /** @hidden */
  12138. _randomNoiseCoordinates2: Vector3;
  12139. /** @hidden */
  12140. _localPosition?: Vector3;
  12141. /**
  12142. * Creates a new instance Particle
  12143. * @param particleSystem the particle system the particle belongs to
  12144. */
  12145. constructor(
  12146. /**
  12147. * The particle system the particle belongs to.
  12148. */
  12149. particleSystem: ParticleSystem);
  12150. private updateCellInfoFromSystem;
  12151. /**
  12152. * Defines how the sprite cell index is updated for the particle
  12153. */
  12154. updateCellIndex(): void;
  12155. /** @hidden */
  12156. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12157. /** @hidden */
  12158. _inheritParticleInfoToSubEmitters(): void;
  12159. /** @hidden */
  12160. _reset(): void;
  12161. /**
  12162. * Copy the properties of particle to another one.
  12163. * @param other the particle to copy the information to.
  12164. */
  12165. copyTo(other: Particle): void;
  12166. }
  12167. }
  12168. declare module BABYLON {
  12169. /**
  12170. * Particle emitter represents a volume emitting particles.
  12171. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12172. */
  12173. export interface IParticleEmitterType {
  12174. /**
  12175. * Called by the particle System when the direction is computed for the created particle.
  12176. * @param worldMatrix is the world matrix of the particle system
  12177. * @param directionToUpdate is the direction vector to update with the result
  12178. * @param particle is the particle we are computed the direction for
  12179. * @param isLocal defines if the direction should be set in local space
  12180. */
  12181. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12182. /**
  12183. * Called by the particle System when the position is computed for the created particle.
  12184. * @param worldMatrix is the world matrix of the particle system
  12185. * @param positionToUpdate is the position vector to update with the result
  12186. * @param particle is the particle we are computed the position for
  12187. * @param isLocal defines if the position should be set in local space
  12188. */
  12189. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12190. /**
  12191. * Clones the current emitter and returns a copy of it
  12192. * @returns the new emitter
  12193. */
  12194. clone(): IParticleEmitterType;
  12195. /**
  12196. * Called by the GPUParticleSystem to setup the update shader
  12197. * @param effect defines the update shader
  12198. */
  12199. applyToShader(effect: Effect): void;
  12200. /**
  12201. * Returns a string to use to update the GPU particles update shader
  12202. * @returns the effect defines string
  12203. */
  12204. getEffectDefines(): string;
  12205. /**
  12206. * Returns a string representing the class name
  12207. * @returns a string containing the class name
  12208. */
  12209. getClassName(): string;
  12210. /**
  12211. * Serializes the particle system to a JSON object.
  12212. * @returns the JSON object
  12213. */
  12214. serialize(): any;
  12215. /**
  12216. * Parse properties from a JSON object
  12217. * @param serializationObject defines the JSON object
  12218. * @param scene defines the hosting scene
  12219. */
  12220. parse(serializationObject: any, scene: Scene): void;
  12221. }
  12222. }
  12223. declare module BABYLON {
  12224. /**
  12225. * Particle emitter emitting particles from the inside of a box.
  12226. * It emits the particles randomly between 2 given directions.
  12227. */
  12228. export class BoxParticleEmitter implements IParticleEmitterType {
  12229. /**
  12230. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12231. */
  12232. direction1: Vector3;
  12233. /**
  12234. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12235. */
  12236. direction2: Vector3;
  12237. /**
  12238. * 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.
  12239. */
  12240. minEmitBox: Vector3;
  12241. /**
  12242. * 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.
  12243. */
  12244. maxEmitBox: Vector3;
  12245. /**
  12246. * Creates a new instance BoxParticleEmitter
  12247. */
  12248. constructor();
  12249. /**
  12250. * Called by the particle System when the direction is computed for the created particle.
  12251. * @param worldMatrix is the world matrix of the particle system
  12252. * @param directionToUpdate is the direction vector to update with the result
  12253. * @param particle is the particle we are computed the direction for
  12254. * @param isLocal defines if the direction should be set in local space
  12255. */
  12256. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12257. /**
  12258. * Called by the particle System when the position is computed for the created particle.
  12259. * @param worldMatrix is the world matrix of the particle system
  12260. * @param positionToUpdate is the position vector to update with the result
  12261. * @param particle is the particle we are computed the position for
  12262. * @param isLocal defines if the position should be set in local space
  12263. */
  12264. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12265. /**
  12266. * Clones the current emitter and returns a copy of it
  12267. * @returns the new emitter
  12268. */
  12269. clone(): BoxParticleEmitter;
  12270. /**
  12271. * Called by the GPUParticleSystem to setup the update shader
  12272. * @param effect defines the update shader
  12273. */
  12274. applyToShader(effect: Effect): void;
  12275. /**
  12276. * Returns a string to use to update the GPU particles update shader
  12277. * @returns a string containng the defines string
  12278. */
  12279. getEffectDefines(): string;
  12280. /**
  12281. * Returns the string "BoxParticleEmitter"
  12282. * @returns a string containing the class name
  12283. */
  12284. getClassName(): string;
  12285. /**
  12286. * Serializes the particle system to a JSON object.
  12287. * @returns the JSON object
  12288. */
  12289. serialize(): any;
  12290. /**
  12291. * Parse properties from a JSON object
  12292. * @param serializationObject defines the JSON object
  12293. */
  12294. parse(serializationObject: any): void;
  12295. }
  12296. }
  12297. declare module BABYLON {
  12298. /**
  12299. * Particle emitter emitting particles from the inside of a cone.
  12300. * It emits the particles alongside the cone volume from the base to the particle.
  12301. * The emission direction might be randomized.
  12302. */
  12303. export class ConeParticleEmitter implements IParticleEmitterType {
  12304. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12305. directionRandomizer: number;
  12306. private _radius;
  12307. private _angle;
  12308. private _height;
  12309. /**
  12310. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12311. */
  12312. radiusRange: number;
  12313. /**
  12314. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12315. */
  12316. heightRange: number;
  12317. /**
  12318. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12319. */
  12320. emitFromSpawnPointOnly: boolean;
  12321. /**
  12322. * Gets or sets the radius of the emission cone
  12323. */
  12324. get radius(): number;
  12325. set radius(value: number);
  12326. /**
  12327. * Gets or sets the angle of the emission cone
  12328. */
  12329. get angle(): number;
  12330. set angle(value: number);
  12331. private _buildHeight;
  12332. /**
  12333. * Creates a new instance ConeParticleEmitter
  12334. * @param radius the radius of the emission cone (1 by default)
  12335. * @param angle the cone base angle (PI by default)
  12336. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12337. */
  12338. constructor(radius?: number, angle?: number,
  12339. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12340. directionRandomizer?: number);
  12341. /**
  12342. * Called by the particle System when the direction is computed for the created particle.
  12343. * @param worldMatrix is the world matrix of the particle system
  12344. * @param directionToUpdate is the direction vector to update with the result
  12345. * @param particle is the particle we are computed the direction for
  12346. * @param isLocal defines if the direction should be set in local space
  12347. */
  12348. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12349. /**
  12350. * Called by the particle System when the position is computed for the created particle.
  12351. * @param worldMatrix is the world matrix of the particle system
  12352. * @param positionToUpdate is the position vector to update with the result
  12353. * @param particle is the particle we are computed the position for
  12354. * @param isLocal defines if the position should be set in local space
  12355. */
  12356. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12357. /**
  12358. * Clones the current emitter and returns a copy of it
  12359. * @returns the new emitter
  12360. */
  12361. clone(): ConeParticleEmitter;
  12362. /**
  12363. * Called by the GPUParticleSystem to setup the update shader
  12364. * @param effect defines the update shader
  12365. */
  12366. applyToShader(effect: Effect): void;
  12367. /**
  12368. * Returns a string to use to update the GPU particles update shader
  12369. * @returns a string containng the defines string
  12370. */
  12371. getEffectDefines(): string;
  12372. /**
  12373. * Returns the string "ConeParticleEmitter"
  12374. * @returns a string containing the class name
  12375. */
  12376. getClassName(): string;
  12377. /**
  12378. * Serializes the particle system to a JSON object.
  12379. * @returns the JSON object
  12380. */
  12381. serialize(): any;
  12382. /**
  12383. * Parse properties from a JSON object
  12384. * @param serializationObject defines the JSON object
  12385. */
  12386. parse(serializationObject: any): void;
  12387. }
  12388. }
  12389. declare module BABYLON {
  12390. /**
  12391. * Particle emitter emitting particles from the inside of a cylinder.
  12392. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12393. */
  12394. export class CylinderParticleEmitter implements IParticleEmitterType {
  12395. /**
  12396. * The radius of the emission cylinder.
  12397. */
  12398. radius: number;
  12399. /**
  12400. * The height of the emission cylinder.
  12401. */
  12402. height: number;
  12403. /**
  12404. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12405. */
  12406. radiusRange: number;
  12407. /**
  12408. * How much to randomize the particle direction [0-1].
  12409. */
  12410. directionRandomizer: number;
  12411. /**
  12412. * Creates a new instance CylinderParticleEmitter
  12413. * @param radius the radius of the emission cylinder (1 by default)
  12414. * @param height the height of the emission cylinder (1 by default)
  12415. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12416. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12417. */
  12418. constructor(
  12419. /**
  12420. * The radius of the emission cylinder.
  12421. */
  12422. radius?: number,
  12423. /**
  12424. * The height of the emission cylinder.
  12425. */
  12426. height?: number,
  12427. /**
  12428. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12429. */
  12430. radiusRange?: number,
  12431. /**
  12432. * How much to randomize the particle direction [0-1].
  12433. */
  12434. directionRandomizer?: number);
  12435. /**
  12436. * Called by the particle System when the direction is computed for the created particle.
  12437. * @param worldMatrix is the world matrix of the particle system
  12438. * @param directionToUpdate is the direction vector to update with the result
  12439. * @param particle is the particle we are computed the direction for
  12440. * @param isLocal defines if the direction should be set in local space
  12441. */
  12442. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12443. /**
  12444. * Called by the particle System when the position is computed for the created particle.
  12445. * @param worldMatrix is the world matrix of the particle system
  12446. * @param positionToUpdate is the position vector to update with the result
  12447. * @param particle is the particle we are computed the position for
  12448. * @param isLocal defines if the position should be set in local space
  12449. */
  12450. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12451. /**
  12452. * Clones the current emitter and returns a copy of it
  12453. * @returns the new emitter
  12454. */
  12455. clone(): CylinderParticleEmitter;
  12456. /**
  12457. * Called by the GPUParticleSystem to setup the update shader
  12458. * @param effect defines the update shader
  12459. */
  12460. applyToShader(effect: Effect): void;
  12461. /**
  12462. * Returns a string to use to update the GPU particles update shader
  12463. * @returns a string containng the defines string
  12464. */
  12465. getEffectDefines(): string;
  12466. /**
  12467. * Returns the string "CylinderParticleEmitter"
  12468. * @returns a string containing the class name
  12469. */
  12470. getClassName(): string;
  12471. /**
  12472. * Serializes the particle system to a JSON object.
  12473. * @returns the JSON object
  12474. */
  12475. serialize(): any;
  12476. /**
  12477. * Parse properties from a JSON object
  12478. * @param serializationObject defines the JSON object
  12479. */
  12480. parse(serializationObject: any): void;
  12481. }
  12482. /**
  12483. * Particle emitter emitting particles from the inside of a cylinder.
  12484. * It emits the particles randomly between two vectors.
  12485. */
  12486. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12487. /**
  12488. * The min limit of the emission direction.
  12489. */
  12490. direction1: Vector3;
  12491. /**
  12492. * The max limit of the emission direction.
  12493. */
  12494. direction2: Vector3;
  12495. /**
  12496. * Creates a new instance CylinderDirectedParticleEmitter
  12497. * @param radius the radius of the emission cylinder (1 by default)
  12498. * @param height the height of the emission cylinder (1 by default)
  12499. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12500. * @param direction1 the min limit of the emission direction (up vector by default)
  12501. * @param direction2 the max limit of the emission direction (up vector by default)
  12502. */
  12503. constructor(radius?: number, height?: number, radiusRange?: number,
  12504. /**
  12505. * The min limit of the emission direction.
  12506. */
  12507. direction1?: Vector3,
  12508. /**
  12509. * The max limit of the emission direction.
  12510. */
  12511. direction2?: Vector3);
  12512. /**
  12513. * Called by the particle System when the direction is computed for the created particle.
  12514. * @param worldMatrix is the world matrix of the particle system
  12515. * @param directionToUpdate is the direction vector to update with the result
  12516. * @param particle is the particle we are computed the direction for
  12517. */
  12518. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12519. /**
  12520. * Clones the current emitter and returns a copy of it
  12521. * @returns the new emitter
  12522. */
  12523. clone(): CylinderDirectedParticleEmitter;
  12524. /**
  12525. * Called by the GPUParticleSystem to setup the update shader
  12526. * @param effect defines the update shader
  12527. */
  12528. applyToShader(effect: Effect): void;
  12529. /**
  12530. * Returns a string to use to update the GPU particles update shader
  12531. * @returns a string containng the defines string
  12532. */
  12533. getEffectDefines(): string;
  12534. /**
  12535. * Returns the string "CylinderDirectedParticleEmitter"
  12536. * @returns a string containing the class name
  12537. */
  12538. getClassName(): string;
  12539. /**
  12540. * Serializes the particle system to a JSON object.
  12541. * @returns the JSON object
  12542. */
  12543. serialize(): any;
  12544. /**
  12545. * Parse properties from a JSON object
  12546. * @param serializationObject defines the JSON object
  12547. */
  12548. parse(serializationObject: any): void;
  12549. }
  12550. }
  12551. declare module BABYLON {
  12552. /**
  12553. * Particle emitter emitting particles from the inside of a hemisphere.
  12554. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12555. */
  12556. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12557. /**
  12558. * The radius of the emission hemisphere.
  12559. */
  12560. radius: number;
  12561. /**
  12562. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12563. */
  12564. radiusRange: number;
  12565. /**
  12566. * How much to randomize the particle direction [0-1].
  12567. */
  12568. directionRandomizer: number;
  12569. /**
  12570. * Creates a new instance HemisphericParticleEmitter
  12571. * @param radius the radius of the emission hemisphere (1 by default)
  12572. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12573. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12574. */
  12575. constructor(
  12576. /**
  12577. * The radius of the emission hemisphere.
  12578. */
  12579. radius?: number,
  12580. /**
  12581. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12582. */
  12583. radiusRange?: number,
  12584. /**
  12585. * How much to randomize the particle direction [0-1].
  12586. */
  12587. directionRandomizer?: number);
  12588. /**
  12589. * Called by the particle System when the direction is computed for the created particle.
  12590. * @param worldMatrix is the world matrix of the particle system
  12591. * @param directionToUpdate is the direction vector to update with the result
  12592. * @param particle is the particle we are computed the direction for
  12593. * @param isLocal defines if the direction should be set in local space
  12594. */
  12595. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12596. /**
  12597. * Called by the particle System when the position is computed for the created particle.
  12598. * @param worldMatrix is the world matrix of the particle system
  12599. * @param positionToUpdate is the position vector to update with the result
  12600. * @param particle is the particle we are computed the position for
  12601. * @param isLocal defines if the position should be set in local space
  12602. */
  12603. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12604. /**
  12605. * Clones the current emitter and returns a copy of it
  12606. * @returns the new emitter
  12607. */
  12608. clone(): HemisphericParticleEmitter;
  12609. /**
  12610. * Called by the GPUParticleSystem to setup the update shader
  12611. * @param effect defines the update shader
  12612. */
  12613. applyToShader(effect: Effect): void;
  12614. /**
  12615. * Returns a string to use to update the GPU particles update shader
  12616. * @returns a string containng the defines string
  12617. */
  12618. getEffectDefines(): string;
  12619. /**
  12620. * Returns the string "HemisphericParticleEmitter"
  12621. * @returns a string containing the class name
  12622. */
  12623. getClassName(): string;
  12624. /**
  12625. * Serializes the particle system to a JSON object.
  12626. * @returns the JSON object
  12627. */
  12628. serialize(): any;
  12629. /**
  12630. * Parse properties from a JSON object
  12631. * @param serializationObject defines the JSON object
  12632. */
  12633. parse(serializationObject: any): void;
  12634. }
  12635. }
  12636. declare module BABYLON {
  12637. /**
  12638. * Particle emitter emitting particles from a point.
  12639. * It emits the particles randomly between 2 given directions.
  12640. */
  12641. export class PointParticleEmitter implements IParticleEmitterType {
  12642. /**
  12643. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12644. */
  12645. direction1: Vector3;
  12646. /**
  12647. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12648. */
  12649. direction2: Vector3;
  12650. /**
  12651. * Creates a new instance PointParticleEmitter
  12652. */
  12653. constructor();
  12654. /**
  12655. * Called by the particle System when the direction is computed for the created particle.
  12656. * @param worldMatrix is the world matrix of the particle system
  12657. * @param directionToUpdate is the direction vector to update with the result
  12658. * @param particle is the particle we are computed the direction for
  12659. * @param isLocal defines if the direction should be set in local space
  12660. */
  12661. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12662. /**
  12663. * Called by the particle System when the position is computed for the created particle.
  12664. * @param worldMatrix is the world matrix of the particle system
  12665. * @param positionToUpdate is the position vector to update with the result
  12666. * @param particle is the particle we are computed the position for
  12667. * @param isLocal defines if the position should be set in local space
  12668. */
  12669. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12670. /**
  12671. * Clones the current emitter and returns a copy of it
  12672. * @returns the new emitter
  12673. */
  12674. clone(): PointParticleEmitter;
  12675. /**
  12676. * Called by the GPUParticleSystem to setup the update shader
  12677. * @param effect defines the update shader
  12678. */
  12679. applyToShader(effect: Effect): void;
  12680. /**
  12681. * Returns a string to use to update the GPU particles update shader
  12682. * @returns a string containng the defines string
  12683. */
  12684. getEffectDefines(): string;
  12685. /**
  12686. * Returns the string "PointParticleEmitter"
  12687. * @returns a string containing the class name
  12688. */
  12689. getClassName(): string;
  12690. /**
  12691. * Serializes the particle system to a JSON object.
  12692. * @returns the JSON object
  12693. */
  12694. serialize(): any;
  12695. /**
  12696. * Parse properties from a JSON object
  12697. * @param serializationObject defines the JSON object
  12698. */
  12699. parse(serializationObject: any): void;
  12700. }
  12701. }
  12702. declare module BABYLON {
  12703. /**
  12704. * Particle emitter emitting particles from the inside of a sphere.
  12705. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12706. */
  12707. export class SphereParticleEmitter implements IParticleEmitterType {
  12708. /**
  12709. * The radius of the emission sphere.
  12710. */
  12711. radius: number;
  12712. /**
  12713. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12714. */
  12715. radiusRange: number;
  12716. /**
  12717. * How much to randomize the particle direction [0-1].
  12718. */
  12719. directionRandomizer: number;
  12720. /**
  12721. * Creates a new instance SphereParticleEmitter
  12722. * @param radius the radius of the emission sphere (1 by default)
  12723. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12724. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12725. */
  12726. constructor(
  12727. /**
  12728. * The radius of the emission sphere.
  12729. */
  12730. radius?: number,
  12731. /**
  12732. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12733. */
  12734. radiusRange?: number,
  12735. /**
  12736. * How much to randomize the particle direction [0-1].
  12737. */
  12738. directionRandomizer?: number);
  12739. /**
  12740. * Called by the particle System when the direction is computed for the created particle.
  12741. * @param worldMatrix is the world matrix of the particle system
  12742. * @param directionToUpdate is the direction vector to update with the result
  12743. * @param particle is the particle we are computed the direction for
  12744. * @param isLocal defines if the direction should be set in local space
  12745. */
  12746. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12747. /**
  12748. * Called by the particle System when the position is computed for the created particle.
  12749. * @param worldMatrix is the world matrix of the particle system
  12750. * @param positionToUpdate is the position vector to update with the result
  12751. * @param particle is the particle we are computed the position for
  12752. * @param isLocal defines if the position should be set in local space
  12753. */
  12754. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12755. /**
  12756. * Clones the current emitter and returns a copy of it
  12757. * @returns the new emitter
  12758. */
  12759. clone(): SphereParticleEmitter;
  12760. /**
  12761. * Called by the GPUParticleSystem to setup the update shader
  12762. * @param effect defines the update shader
  12763. */
  12764. applyToShader(effect: Effect): void;
  12765. /**
  12766. * Returns a string to use to update the GPU particles update shader
  12767. * @returns a string containng the defines string
  12768. */
  12769. getEffectDefines(): string;
  12770. /**
  12771. * Returns the string "SphereParticleEmitter"
  12772. * @returns a string containing the class name
  12773. */
  12774. getClassName(): string;
  12775. /**
  12776. * Serializes the particle system to a JSON object.
  12777. * @returns the JSON object
  12778. */
  12779. serialize(): any;
  12780. /**
  12781. * Parse properties from a JSON object
  12782. * @param serializationObject defines the JSON object
  12783. */
  12784. parse(serializationObject: any): void;
  12785. }
  12786. /**
  12787. * Particle emitter emitting particles from the inside of a sphere.
  12788. * It emits the particles randomly between two vectors.
  12789. */
  12790. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12791. /**
  12792. * The min limit of the emission direction.
  12793. */
  12794. direction1: Vector3;
  12795. /**
  12796. * The max limit of the emission direction.
  12797. */
  12798. direction2: Vector3;
  12799. /**
  12800. * Creates a new instance SphereDirectedParticleEmitter
  12801. * @param radius the radius of the emission sphere (1 by default)
  12802. * @param direction1 the min limit of the emission direction (up vector by default)
  12803. * @param direction2 the max limit of the emission direction (up vector by default)
  12804. */
  12805. constructor(radius?: number,
  12806. /**
  12807. * The min limit of the emission direction.
  12808. */
  12809. direction1?: Vector3,
  12810. /**
  12811. * The max limit of the emission direction.
  12812. */
  12813. direction2?: Vector3);
  12814. /**
  12815. * Called by the particle System when the direction is computed for the created particle.
  12816. * @param worldMatrix is the world matrix of the particle system
  12817. * @param directionToUpdate is the direction vector to update with the result
  12818. * @param particle is the particle we are computed the direction for
  12819. */
  12820. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12821. /**
  12822. * Clones the current emitter and returns a copy of it
  12823. * @returns the new emitter
  12824. */
  12825. clone(): SphereDirectedParticleEmitter;
  12826. /**
  12827. * Called by the GPUParticleSystem to setup the update shader
  12828. * @param effect defines the update shader
  12829. */
  12830. applyToShader(effect: Effect): void;
  12831. /**
  12832. * Returns a string to use to update the GPU particles update shader
  12833. * @returns a string containng the defines string
  12834. */
  12835. getEffectDefines(): string;
  12836. /**
  12837. * Returns the string "SphereDirectedParticleEmitter"
  12838. * @returns a string containing the class name
  12839. */
  12840. getClassName(): string;
  12841. /**
  12842. * Serializes the particle system to a JSON object.
  12843. * @returns the JSON object
  12844. */
  12845. serialize(): any;
  12846. /**
  12847. * Parse properties from a JSON object
  12848. * @param serializationObject defines the JSON object
  12849. */
  12850. parse(serializationObject: any): void;
  12851. }
  12852. }
  12853. declare module BABYLON {
  12854. /**
  12855. * Particle emitter emitting particles from a custom list of positions.
  12856. */
  12857. export class CustomParticleEmitter implements IParticleEmitterType {
  12858. /**
  12859. * Gets or sets the position generator that will create the inital position of each particle.
  12860. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12861. */
  12862. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12863. /**
  12864. * Gets or sets the destination generator that will create the final destination of each particle.
  12865. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12866. */
  12867. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12868. /**
  12869. * Creates a new instance CustomParticleEmitter
  12870. */
  12871. constructor();
  12872. /**
  12873. * Called by the particle System when the direction is computed for the created particle.
  12874. * @param worldMatrix is the world matrix of the particle system
  12875. * @param directionToUpdate is the direction vector to update with the result
  12876. * @param particle is the particle we are computed the direction for
  12877. * @param isLocal defines if the direction should be set in local space
  12878. */
  12879. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12880. /**
  12881. * Called by the particle System when the position is computed for the created particle.
  12882. * @param worldMatrix is the world matrix of the particle system
  12883. * @param positionToUpdate is the position vector to update with the result
  12884. * @param particle is the particle we are computed the position for
  12885. * @param isLocal defines if the position should be set in local space
  12886. */
  12887. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12888. /**
  12889. * Clones the current emitter and returns a copy of it
  12890. * @returns the new emitter
  12891. */
  12892. clone(): CustomParticleEmitter;
  12893. /**
  12894. * Called by the GPUParticleSystem to setup the update shader
  12895. * @param effect defines the update shader
  12896. */
  12897. applyToShader(effect: Effect): void;
  12898. /**
  12899. * Returns a string to use to update the GPU particles update shader
  12900. * @returns a string containng the defines string
  12901. */
  12902. getEffectDefines(): string;
  12903. /**
  12904. * Returns the string "PointParticleEmitter"
  12905. * @returns a string containing the class name
  12906. */
  12907. getClassName(): string;
  12908. /**
  12909. * Serializes the particle system to a JSON object.
  12910. * @returns the JSON object
  12911. */
  12912. serialize(): any;
  12913. /**
  12914. * Parse properties from a JSON object
  12915. * @param serializationObject defines the JSON object
  12916. */
  12917. parse(serializationObject: any): void;
  12918. }
  12919. }
  12920. declare module BABYLON {
  12921. /**
  12922. * Particle emitter emitting particles from the inside of a box.
  12923. * It emits the particles randomly between 2 given directions.
  12924. */
  12925. export class MeshParticleEmitter implements IParticleEmitterType {
  12926. private _indices;
  12927. private _positions;
  12928. private _normals;
  12929. private _storedNormal;
  12930. private _mesh;
  12931. /**
  12932. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12933. */
  12934. direction1: Vector3;
  12935. /**
  12936. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12937. */
  12938. direction2: Vector3;
  12939. /**
  12940. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12941. */
  12942. useMeshNormalsForDirection: boolean;
  12943. /** Defines the mesh to use as source */
  12944. get mesh(): Nullable<AbstractMesh>;
  12945. set mesh(value: Nullable<AbstractMesh>);
  12946. /**
  12947. * Creates a new instance MeshParticleEmitter
  12948. * @param mesh defines the mesh to use as source
  12949. */
  12950. constructor(mesh?: Nullable<AbstractMesh>);
  12951. /**
  12952. * Called by the particle System when the direction is computed for the created particle.
  12953. * @param worldMatrix is the world matrix of the particle system
  12954. * @param directionToUpdate is the direction vector to update with the result
  12955. * @param particle is the particle we are computed the direction for
  12956. * @param isLocal defines if the direction should be set in local space
  12957. */
  12958. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12959. /**
  12960. * Called by the particle System when the position is computed for the created particle.
  12961. * @param worldMatrix is the world matrix of the particle system
  12962. * @param positionToUpdate is the position vector to update with the result
  12963. * @param particle is the particle we are computed the position for
  12964. * @param isLocal defines if the position should be set in local space
  12965. */
  12966. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12967. /**
  12968. * Clones the current emitter and returns a copy of it
  12969. * @returns the new emitter
  12970. */
  12971. clone(): MeshParticleEmitter;
  12972. /**
  12973. * Called by the GPUParticleSystem to setup the update shader
  12974. * @param effect defines the update shader
  12975. */
  12976. applyToShader(effect: Effect): void;
  12977. /**
  12978. * Returns a string to use to update the GPU particles update shader
  12979. * @returns a string containng the defines string
  12980. */
  12981. getEffectDefines(): string;
  12982. /**
  12983. * Returns the string "BoxParticleEmitter"
  12984. * @returns a string containing the class name
  12985. */
  12986. getClassName(): string;
  12987. /**
  12988. * Serializes the particle system to a JSON object.
  12989. * @returns the JSON object
  12990. */
  12991. serialize(): any;
  12992. /**
  12993. * Parse properties from a JSON object
  12994. * @param serializationObject defines the JSON object
  12995. * @param scene defines the hosting scene
  12996. */
  12997. parse(serializationObject: any, scene: Scene): void;
  12998. }
  12999. }
  13000. declare module BABYLON {
  13001. /**
  13002. * Interface representing a particle system in Babylon.js.
  13003. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13004. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13005. */
  13006. export interface IParticleSystem {
  13007. /**
  13008. * List of animations used by the particle system.
  13009. */
  13010. animations: Animation[];
  13011. /**
  13012. * The id of the Particle system.
  13013. */
  13014. id: string;
  13015. /**
  13016. * The name of the Particle system.
  13017. */
  13018. name: string;
  13019. /**
  13020. * The emitter represents the Mesh or position we are attaching the particle system to.
  13021. */
  13022. emitter: Nullable<AbstractMesh | Vector3>;
  13023. /**
  13024. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13025. */
  13026. isBillboardBased: boolean;
  13027. /**
  13028. * The rendering group used by the Particle system to chose when to render.
  13029. */
  13030. renderingGroupId: number;
  13031. /**
  13032. * The layer mask we are rendering the particles through.
  13033. */
  13034. layerMask: number;
  13035. /**
  13036. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13037. */
  13038. updateSpeed: number;
  13039. /**
  13040. * The amount of time the particle system is running (depends of the overall update speed).
  13041. */
  13042. targetStopDuration: number;
  13043. /**
  13044. * The texture used to render each particle. (this can be a spritesheet)
  13045. */
  13046. particleTexture: Nullable<Texture>;
  13047. /**
  13048. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13049. */
  13050. blendMode: number;
  13051. /**
  13052. * Minimum life time of emitting particles.
  13053. */
  13054. minLifeTime: number;
  13055. /**
  13056. * Maximum life time of emitting particles.
  13057. */
  13058. maxLifeTime: number;
  13059. /**
  13060. * Minimum Size of emitting particles.
  13061. */
  13062. minSize: number;
  13063. /**
  13064. * Maximum Size of emitting particles.
  13065. */
  13066. maxSize: number;
  13067. /**
  13068. * Minimum scale of emitting particles on X axis.
  13069. */
  13070. minScaleX: number;
  13071. /**
  13072. * Maximum scale of emitting particles on X axis.
  13073. */
  13074. maxScaleX: number;
  13075. /**
  13076. * Minimum scale of emitting particles on Y axis.
  13077. */
  13078. minScaleY: number;
  13079. /**
  13080. * Maximum scale of emitting particles on Y axis.
  13081. */
  13082. maxScaleY: number;
  13083. /**
  13084. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13085. */
  13086. color1: Color4;
  13087. /**
  13088. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13089. */
  13090. color2: Color4;
  13091. /**
  13092. * Color the particle will have at the end of its lifetime.
  13093. */
  13094. colorDead: Color4;
  13095. /**
  13096. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13097. */
  13098. emitRate: number;
  13099. /**
  13100. * You can use gravity if you want to give an orientation to your particles.
  13101. */
  13102. gravity: Vector3;
  13103. /**
  13104. * Minimum power of emitting particles.
  13105. */
  13106. minEmitPower: number;
  13107. /**
  13108. * Maximum power of emitting particles.
  13109. */
  13110. maxEmitPower: number;
  13111. /**
  13112. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13113. */
  13114. minAngularSpeed: number;
  13115. /**
  13116. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13117. */
  13118. maxAngularSpeed: number;
  13119. /**
  13120. * Gets or sets the minimal initial rotation in radians.
  13121. */
  13122. minInitialRotation: number;
  13123. /**
  13124. * Gets or sets the maximal initial rotation in radians.
  13125. */
  13126. maxInitialRotation: number;
  13127. /**
  13128. * The particle emitter type defines the emitter used by the particle system.
  13129. * It can be for example box, sphere, or cone...
  13130. */
  13131. particleEmitterType: Nullable<IParticleEmitterType>;
  13132. /**
  13133. * Defines the delay in milliseconds before starting the system (0 by default)
  13134. */
  13135. startDelay: number;
  13136. /**
  13137. * 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
  13138. */
  13139. preWarmCycles: number;
  13140. /**
  13141. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13142. */
  13143. preWarmStepOffset: number;
  13144. /**
  13145. * 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)
  13146. */
  13147. spriteCellChangeSpeed: number;
  13148. /**
  13149. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13150. */
  13151. startSpriteCellID: number;
  13152. /**
  13153. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13154. */
  13155. endSpriteCellID: number;
  13156. /**
  13157. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13158. */
  13159. spriteCellWidth: number;
  13160. /**
  13161. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13162. */
  13163. spriteCellHeight: number;
  13164. /**
  13165. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13166. */
  13167. spriteRandomStartCell: boolean;
  13168. /**
  13169. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13170. */
  13171. isAnimationSheetEnabled: boolean;
  13172. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13173. translationPivot: Vector2;
  13174. /**
  13175. * Gets or sets a texture used to add random noise to particle positions
  13176. */
  13177. noiseTexture: Nullable<BaseTexture>;
  13178. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13179. noiseStrength: Vector3;
  13180. /**
  13181. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13182. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13183. */
  13184. billboardMode: number;
  13185. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13186. limitVelocityDamping: number;
  13187. /**
  13188. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13189. */
  13190. beginAnimationOnStart: boolean;
  13191. /**
  13192. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13193. */
  13194. beginAnimationFrom: number;
  13195. /**
  13196. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13197. */
  13198. beginAnimationTo: number;
  13199. /**
  13200. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13201. */
  13202. beginAnimationLoop: boolean;
  13203. /**
  13204. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13205. */
  13206. disposeOnStop: boolean;
  13207. /**
  13208. * Specifies if the particles are updated in emitter local space or world space
  13209. */
  13210. isLocal: boolean;
  13211. /** Snippet ID if the particle system was created from the snippet server */
  13212. snippetId: string;
  13213. /**
  13214. * Gets the maximum number of particles active at the same time.
  13215. * @returns The max number of active particles.
  13216. */
  13217. getCapacity(): number;
  13218. /**
  13219. * Gets the number of particles active at the same time.
  13220. * @returns The number of active particles.
  13221. */
  13222. getActiveCount(): number;
  13223. /**
  13224. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13225. * @returns True if it has been started, otherwise false.
  13226. */
  13227. isStarted(): boolean;
  13228. /**
  13229. * Animates the particle system for this frame.
  13230. */
  13231. animate(): void;
  13232. /**
  13233. * Renders the particle system in its current state.
  13234. * @returns the current number of particles
  13235. */
  13236. render(): number;
  13237. /**
  13238. * Dispose the particle system and frees its associated resources.
  13239. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13240. */
  13241. dispose(disposeTexture?: boolean): void;
  13242. /**
  13243. * Clones the particle system.
  13244. * @param name The name of the cloned object
  13245. * @param newEmitter The new emitter to use
  13246. * @returns the cloned particle system
  13247. */
  13248. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13249. /**
  13250. * Serializes the particle system to a JSON object.
  13251. * @returns the JSON object
  13252. */
  13253. serialize(): any;
  13254. /**
  13255. * Rebuild the particle system
  13256. */
  13257. rebuild(): void;
  13258. /**
  13259. * Starts the particle system and begins to emit
  13260. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13261. */
  13262. start(delay?: number): void;
  13263. /**
  13264. * Stops the particle system.
  13265. */
  13266. stop(): void;
  13267. /**
  13268. * Remove all active particles
  13269. */
  13270. reset(): void;
  13271. /**
  13272. * Gets a boolean indicating that the system is stopping
  13273. * @returns true if the system is currently stopping
  13274. */
  13275. isStopping(): boolean;
  13276. /**
  13277. * Is this system ready to be used/rendered
  13278. * @return true if the system is ready
  13279. */
  13280. isReady(): boolean;
  13281. /**
  13282. * Returns the string "ParticleSystem"
  13283. * @returns a string containing the class name
  13284. */
  13285. getClassName(): string;
  13286. /**
  13287. * Adds a new color gradient
  13288. * @param gradient defines the gradient to use (between 0 and 1)
  13289. * @param color1 defines the color to affect to the specified gradient
  13290. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13291. * @returns the current particle system
  13292. */
  13293. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13294. /**
  13295. * Remove a specific color gradient
  13296. * @param gradient defines the gradient to remove
  13297. * @returns the current particle system
  13298. */
  13299. removeColorGradient(gradient: number): IParticleSystem;
  13300. /**
  13301. * Adds a new size gradient
  13302. * @param gradient defines the gradient to use (between 0 and 1)
  13303. * @param factor defines the size factor to affect to the specified gradient
  13304. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13305. * @returns the current particle system
  13306. */
  13307. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13308. /**
  13309. * Remove a specific size gradient
  13310. * @param gradient defines the gradient to remove
  13311. * @returns the current particle system
  13312. */
  13313. removeSizeGradient(gradient: number): IParticleSystem;
  13314. /**
  13315. * Gets the current list of color gradients.
  13316. * You must use addColorGradient and removeColorGradient to udpate this list
  13317. * @returns the list of color gradients
  13318. */
  13319. getColorGradients(): Nullable<Array<ColorGradient>>;
  13320. /**
  13321. * Gets the current list of size gradients.
  13322. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13323. * @returns the list of size gradients
  13324. */
  13325. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13326. /**
  13327. * Gets the current list of angular speed gradients.
  13328. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13329. * @returns the list of angular speed gradients
  13330. */
  13331. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13332. /**
  13333. * Adds a new angular speed gradient
  13334. * @param gradient defines the gradient to use (between 0 and 1)
  13335. * @param factor defines the angular speed to affect to the specified gradient
  13336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13337. * @returns the current particle system
  13338. */
  13339. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13340. /**
  13341. * Remove a specific angular speed gradient
  13342. * @param gradient defines the gradient to remove
  13343. * @returns the current particle system
  13344. */
  13345. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13346. /**
  13347. * Gets the current list of velocity gradients.
  13348. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13349. * @returns the list of velocity gradients
  13350. */
  13351. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13352. /**
  13353. * Adds a new velocity gradient
  13354. * @param gradient defines the gradient to use (between 0 and 1)
  13355. * @param factor defines the velocity to affect to the specified gradient
  13356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13357. * @returns the current particle system
  13358. */
  13359. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13360. /**
  13361. * Remove a specific velocity gradient
  13362. * @param gradient defines the gradient to remove
  13363. * @returns the current particle system
  13364. */
  13365. removeVelocityGradient(gradient: number): IParticleSystem;
  13366. /**
  13367. * Gets the current list of limit velocity gradients.
  13368. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13369. * @returns the list of limit velocity gradients
  13370. */
  13371. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13372. /**
  13373. * Adds a new limit velocity gradient
  13374. * @param gradient defines the gradient to use (between 0 and 1)
  13375. * @param factor defines the limit velocity to affect to the specified gradient
  13376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13377. * @returns the current particle system
  13378. */
  13379. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13380. /**
  13381. * Remove a specific limit velocity gradient
  13382. * @param gradient defines the gradient to remove
  13383. * @returns the current particle system
  13384. */
  13385. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13386. /**
  13387. * Adds a new drag gradient
  13388. * @param gradient defines the gradient to use (between 0 and 1)
  13389. * @param factor defines the drag to affect to the specified gradient
  13390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13391. * @returns the current particle system
  13392. */
  13393. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13394. /**
  13395. * Remove a specific drag gradient
  13396. * @param gradient defines the gradient to remove
  13397. * @returns the current particle system
  13398. */
  13399. removeDragGradient(gradient: number): IParticleSystem;
  13400. /**
  13401. * Gets the current list of drag gradients.
  13402. * You must use addDragGradient and removeDragGradient to udpate this list
  13403. * @returns the list of drag gradients
  13404. */
  13405. getDragGradients(): Nullable<Array<FactorGradient>>;
  13406. /**
  13407. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13408. * @param gradient defines the gradient to use (between 0 and 1)
  13409. * @param factor defines the emit rate to affect to the specified gradient
  13410. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13411. * @returns the current particle system
  13412. */
  13413. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13414. /**
  13415. * Remove a specific emit rate gradient
  13416. * @param gradient defines the gradient to remove
  13417. * @returns the current particle system
  13418. */
  13419. removeEmitRateGradient(gradient: number): IParticleSystem;
  13420. /**
  13421. * Gets the current list of emit rate gradients.
  13422. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13423. * @returns the list of emit rate gradients
  13424. */
  13425. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13426. /**
  13427. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13428. * @param gradient defines the gradient to use (between 0 and 1)
  13429. * @param factor defines the start size to affect to the specified gradient
  13430. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13431. * @returns the current particle system
  13432. */
  13433. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13434. /**
  13435. * Remove a specific start size gradient
  13436. * @param gradient defines the gradient to remove
  13437. * @returns the current particle system
  13438. */
  13439. removeStartSizeGradient(gradient: number): IParticleSystem;
  13440. /**
  13441. * Gets the current list of start size gradients.
  13442. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13443. * @returns the list of start size gradients
  13444. */
  13445. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13446. /**
  13447. * Adds a new life time gradient
  13448. * @param gradient defines the gradient to use (between 0 and 1)
  13449. * @param factor defines the life time factor to affect to the specified gradient
  13450. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13451. * @returns the current particle system
  13452. */
  13453. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13454. /**
  13455. * Remove a specific life time gradient
  13456. * @param gradient defines the gradient to remove
  13457. * @returns the current particle system
  13458. */
  13459. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13460. /**
  13461. * Gets the current list of life time gradients.
  13462. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13463. * @returns the list of life time gradients
  13464. */
  13465. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13466. /**
  13467. * Gets the current list of color gradients.
  13468. * You must use addColorGradient and removeColorGradient to udpate this list
  13469. * @returns the list of color gradients
  13470. */
  13471. getColorGradients(): Nullable<Array<ColorGradient>>;
  13472. /**
  13473. * Adds a new ramp gradient used to remap particle colors
  13474. * @param gradient defines the gradient to use (between 0 and 1)
  13475. * @param color defines the color to affect to the specified gradient
  13476. * @returns the current particle system
  13477. */
  13478. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13479. /**
  13480. * Gets the current list of ramp gradients.
  13481. * You must use addRampGradient and removeRampGradient to udpate this list
  13482. * @returns the list of ramp gradients
  13483. */
  13484. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13485. /** Gets or sets a boolean indicating that ramp gradients must be used
  13486. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13487. */
  13488. useRampGradients: boolean;
  13489. /**
  13490. * Adds a new color remap gradient
  13491. * @param gradient defines the gradient to use (between 0 and 1)
  13492. * @param min defines the color remap minimal range
  13493. * @param max defines the color remap maximal range
  13494. * @returns the current particle system
  13495. */
  13496. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13497. /**
  13498. * Gets the current list of color remap gradients.
  13499. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13500. * @returns the list of color remap gradients
  13501. */
  13502. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13503. /**
  13504. * Adds a new alpha remap gradient
  13505. * @param gradient defines the gradient to use (between 0 and 1)
  13506. * @param min defines the alpha remap minimal range
  13507. * @param max defines the alpha remap maximal range
  13508. * @returns the current particle system
  13509. */
  13510. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13511. /**
  13512. * Gets the current list of alpha remap gradients.
  13513. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13514. * @returns the list of alpha remap gradients
  13515. */
  13516. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13517. /**
  13518. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13519. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13520. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13521. * @returns the emitter
  13522. */
  13523. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13524. /**
  13525. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13526. * @param radius The radius of the hemisphere to emit from
  13527. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13528. * @returns the emitter
  13529. */
  13530. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13531. /**
  13532. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13533. * @param radius The radius of the sphere to emit from
  13534. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13535. * @returns the emitter
  13536. */
  13537. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13538. /**
  13539. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13540. * @param radius The radius of the sphere to emit from
  13541. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13542. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13543. * @returns the emitter
  13544. */
  13545. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13546. /**
  13547. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13548. * @param radius The radius of the emission cylinder
  13549. * @param height The height of the emission cylinder
  13550. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13551. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13552. * @returns the emitter
  13553. */
  13554. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13555. /**
  13556. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13557. * @param radius The radius of the cylinder to emit from
  13558. * @param height The height of the emission cylinder
  13559. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13560. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13561. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13562. * @returns the emitter
  13563. */
  13564. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13565. /**
  13566. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13567. * @param radius The radius of the cone to emit from
  13568. * @param angle The base angle of the cone
  13569. * @returns the emitter
  13570. */
  13571. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13572. /**
  13573. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13574. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13575. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13576. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13577. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13578. * @returns the emitter
  13579. */
  13580. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13581. /**
  13582. * Get hosting scene
  13583. * @returns the scene
  13584. */
  13585. getScene(): Scene;
  13586. }
  13587. }
  13588. declare module BABYLON {
  13589. /**
  13590. * 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.
  13591. * @see https://doc.babylonjs.com/how_to/transformnode
  13592. */
  13593. export class TransformNode extends Node {
  13594. /**
  13595. * Object will not rotate to face the camera
  13596. */
  13597. static BILLBOARDMODE_NONE: number;
  13598. /**
  13599. * Object will rotate to face the camera but only on the x axis
  13600. */
  13601. static BILLBOARDMODE_X: number;
  13602. /**
  13603. * Object will rotate to face the camera but only on the y axis
  13604. */
  13605. static BILLBOARDMODE_Y: number;
  13606. /**
  13607. * Object will rotate to face the camera but only on the z axis
  13608. */
  13609. static BILLBOARDMODE_Z: number;
  13610. /**
  13611. * Object will rotate to face the camera
  13612. */
  13613. static BILLBOARDMODE_ALL: number;
  13614. /**
  13615. * Object will rotate to face the camera's position instead of orientation
  13616. */
  13617. static BILLBOARDMODE_USE_POSITION: number;
  13618. private _forward;
  13619. private _forwardInverted;
  13620. private _up;
  13621. private _right;
  13622. private _rightInverted;
  13623. private _position;
  13624. private _rotation;
  13625. private _rotationQuaternion;
  13626. protected _scaling: Vector3;
  13627. protected _isDirty: boolean;
  13628. private _transformToBoneReferal;
  13629. private _isAbsoluteSynced;
  13630. private _billboardMode;
  13631. /**
  13632. * Gets or sets the billboard mode. Default is 0.
  13633. *
  13634. * | Value | Type | Description |
  13635. * | --- | --- | --- |
  13636. * | 0 | BILLBOARDMODE_NONE | |
  13637. * | 1 | BILLBOARDMODE_X | |
  13638. * | 2 | BILLBOARDMODE_Y | |
  13639. * | 4 | BILLBOARDMODE_Z | |
  13640. * | 7 | BILLBOARDMODE_ALL | |
  13641. *
  13642. */
  13643. get billboardMode(): number;
  13644. set billboardMode(value: number);
  13645. private _preserveParentRotationForBillboard;
  13646. /**
  13647. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13648. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13649. */
  13650. get preserveParentRotationForBillboard(): boolean;
  13651. set preserveParentRotationForBillboard(value: boolean);
  13652. /**
  13653. * 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
  13654. */
  13655. scalingDeterminant: number;
  13656. private _infiniteDistance;
  13657. /**
  13658. * Gets or sets the distance of the object to max, often used by skybox
  13659. */
  13660. get infiniteDistance(): boolean;
  13661. set infiniteDistance(value: boolean);
  13662. /**
  13663. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13664. * By default the system will update normals to compensate
  13665. */
  13666. ignoreNonUniformScaling: boolean;
  13667. /**
  13668. * 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
  13669. */
  13670. reIntegrateRotationIntoRotationQuaternion: boolean;
  13671. /** @hidden */
  13672. _poseMatrix: Nullable<Matrix>;
  13673. /** @hidden */
  13674. _localMatrix: Matrix;
  13675. private _usePivotMatrix;
  13676. private _absolutePosition;
  13677. private _absoluteScaling;
  13678. private _absoluteRotationQuaternion;
  13679. private _pivotMatrix;
  13680. private _pivotMatrixInverse;
  13681. protected _postMultiplyPivotMatrix: boolean;
  13682. protected _isWorldMatrixFrozen: boolean;
  13683. /** @hidden */
  13684. _indexInSceneTransformNodesArray: number;
  13685. /**
  13686. * An event triggered after the world matrix is updated
  13687. */
  13688. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13689. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13690. /**
  13691. * Gets a string identifying the name of the class
  13692. * @returns "TransformNode" string
  13693. */
  13694. getClassName(): string;
  13695. /**
  13696. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13697. */
  13698. get position(): Vector3;
  13699. set position(newPosition: Vector3);
  13700. /**
  13701. * 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)).
  13702. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13703. */
  13704. get rotation(): Vector3;
  13705. set rotation(newRotation: Vector3);
  13706. /**
  13707. * 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)).
  13708. */
  13709. get scaling(): Vector3;
  13710. set scaling(newScaling: Vector3);
  13711. /**
  13712. * 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).
  13713. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13714. */
  13715. get rotationQuaternion(): Nullable<Quaternion>;
  13716. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13717. /**
  13718. * The forward direction of that transform in world space.
  13719. */
  13720. get forward(): Vector3;
  13721. /**
  13722. * The up direction of that transform in world space.
  13723. */
  13724. get up(): Vector3;
  13725. /**
  13726. * The right direction of that transform in world space.
  13727. */
  13728. get right(): Vector3;
  13729. /**
  13730. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13731. * @param matrix the matrix to copy the pose from
  13732. * @returns this TransformNode.
  13733. */
  13734. updatePoseMatrix(matrix: Matrix): TransformNode;
  13735. /**
  13736. * Returns the mesh Pose matrix.
  13737. * @returns the pose matrix
  13738. */
  13739. getPoseMatrix(): Matrix;
  13740. /** @hidden */
  13741. _isSynchronized(): boolean;
  13742. /** @hidden */
  13743. _initCache(): void;
  13744. /**
  13745. * Flag the transform node as dirty (Forcing it to update everything)
  13746. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13747. * @returns this transform node
  13748. */
  13749. markAsDirty(property: string): TransformNode;
  13750. /**
  13751. * Returns the current mesh absolute position.
  13752. * Returns a Vector3.
  13753. */
  13754. get absolutePosition(): Vector3;
  13755. /**
  13756. * Returns the current mesh absolute scaling.
  13757. * Returns a Vector3.
  13758. */
  13759. get absoluteScaling(): Vector3;
  13760. /**
  13761. * Returns the current mesh absolute rotation.
  13762. * Returns a Quaternion.
  13763. */
  13764. get absoluteRotationQuaternion(): Quaternion;
  13765. /**
  13766. * Sets a new matrix to apply before all other transformation
  13767. * @param matrix defines the transform matrix
  13768. * @returns the current TransformNode
  13769. */
  13770. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13771. /**
  13772. * Sets a new pivot matrix to the current node
  13773. * @param matrix defines the new pivot matrix to use
  13774. * @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
  13775. * @returns the current TransformNode
  13776. */
  13777. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13778. /**
  13779. * Returns the mesh pivot matrix.
  13780. * Default : Identity.
  13781. * @returns the matrix
  13782. */
  13783. getPivotMatrix(): Matrix;
  13784. /**
  13785. * Instantiate (when possible) or clone that node with its hierarchy
  13786. * @param newParent defines the new parent to use for the instance (or clone)
  13787. * @param options defines options to configure how copy is done
  13788. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13789. * @returns an instance (or a clone) of the current node with its hiearchy
  13790. */
  13791. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13792. doNotInstantiate: boolean;
  13793. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13794. /**
  13795. * Prevents the World matrix to be computed any longer
  13796. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13797. * @returns the TransformNode.
  13798. */
  13799. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13800. /**
  13801. * Allows back the World matrix computation.
  13802. * @returns the TransformNode.
  13803. */
  13804. unfreezeWorldMatrix(): this;
  13805. /**
  13806. * True if the World matrix has been frozen.
  13807. */
  13808. get isWorldMatrixFrozen(): boolean;
  13809. /**
  13810. * Retuns the mesh absolute position in the World.
  13811. * @returns a Vector3.
  13812. */
  13813. getAbsolutePosition(): Vector3;
  13814. /**
  13815. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13816. * @param absolutePosition the absolute position to set
  13817. * @returns the TransformNode.
  13818. */
  13819. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13820. /**
  13821. * Sets the mesh position in its local space.
  13822. * @param vector3 the position to set in localspace
  13823. * @returns the TransformNode.
  13824. */
  13825. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13826. /**
  13827. * Returns the mesh position in the local space from the current World matrix values.
  13828. * @returns a new Vector3.
  13829. */
  13830. getPositionExpressedInLocalSpace(): Vector3;
  13831. /**
  13832. * Translates the mesh along the passed Vector3 in its local space.
  13833. * @param vector3 the distance to translate in localspace
  13834. * @returns the TransformNode.
  13835. */
  13836. locallyTranslate(vector3: Vector3): TransformNode;
  13837. private static _lookAtVectorCache;
  13838. /**
  13839. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13840. * @param targetPoint the position (must be in same space as current mesh) to look at
  13841. * @param yawCor optional yaw (y-axis) correction in radians
  13842. * @param pitchCor optional pitch (x-axis) correction in radians
  13843. * @param rollCor optional roll (z-axis) correction in radians
  13844. * @param space the choosen space of the target
  13845. * @returns the TransformNode.
  13846. */
  13847. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13848. /**
  13849. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13850. * This Vector3 is expressed in the World space.
  13851. * @param localAxis axis to rotate
  13852. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13853. */
  13854. getDirection(localAxis: Vector3): Vector3;
  13855. /**
  13856. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13857. * localAxis is expressed in the mesh local space.
  13858. * result is computed in the Wordl space from the mesh World matrix.
  13859. * @param localAxis axis to rotate
  13860. * @param result the resulting transformnode
  13861. * @returns this TransformNode.
  13862. */
  13863. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13864. /**
  13865. * Sets this transform node rotation to the given local axis.
  13866. * @param localAxis the axis in local space
  13867. * @param yawCor optional yaw (y-axis) correction in radians
  13868. * @param pitchCor optional pitch (x-axis) correction in radians
  13869. * @param rollCor optional roll (z-axis) correction in radians
  13870. * @returns this TransformNode
  13871. */
  13872. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13873. /**
  13874. * Sets a new pivot point to the current node
  13875. * @param point defines the new pivot point to use
  13876. * @param space defines if the point is in world or local space (local by default)
  13877. * @returns the current TransformNode
  13878. */
  13879. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13880. /**
  13881. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13882. * @returns the pivot point
  13883. */
  13884. getPivotPoint(): Vector3;
  13885. /**
  13886. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13887. * @param result the vector3 to store the result
  13888. * @returns this TransformNode.
  13889. */
  13890. getPivotPointToRef(result: Vector3): TransformNode;
  13891. /**
  13892. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13893. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13894. */
  13895. getAbsolutePivotPoint(): Vector3;
  13896. /**
  13897. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13898. * @param result vector3 to store the result
  13899. * @returns this TransformNode.
  13900. */
  13901. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13902. /**
  13903. * Defines the passed node as the parent of the current node.
  13904. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13905. * @see https://doc.babylonjs.com/how_to/parenting
  13906. * @param node the node ot set as the parent
  13907. * @returns this TransformNode.
  13908. */
  13909. setParent(node: Nullable<Node>): TransformNode;
  13910. private _nonUniformScaling;
  13911. /**
  13912. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13913. */
  13914. get nonUniformScaling(): boolean;
  13915. /** @hidden */
  13916. _updateNonUniformScalingState(value: boolean): boolean;
  13917. /**
  13918. * Attach the current TransformNode to another TransformNode associated with a bone
  13919. * @param bone Bone affecting the TransformNode
  13920. * @param affectedTransformNode TransformNode associated with the bone
  13921. * @returns this object
  13922. */
  13923. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13924. /**
  13925. * Detach the transform node if its associated with a bone
  13926. * @returns this object
  13927. */
  13928. detachFromBone(): TransformNode;
  13929. private static _rotationAxisCache;
  13930. /**
  13931. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13932. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13933. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13934. * The passed axis is also normalized.
  13935. * @param axis the axis to rotate around
  13936. * @param amount the amount to rotate in radians
  13937. * @param space Space to rotate in (Default: local)
  13938. * @returns the TransformNode.
  13939. */
  13940. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13941. /**
  13942. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13943. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13944. * The passed axis is also normalized. .
  13945. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13946. * @param point the point to rotate around
  13947. * @param axis the axis to rotate around
  13948. * @param amount the amount to rotate in radians
  13949. * @returns the TransformNode
  13950. */
  13951. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13952. /**
  13953. * Translates the mesh along the axis vector for the passed distance in the given space.
  13954. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13955. * @param axis the axis to translate in
  13956. * @param distance the distance to translate
  13957. * @param space Space to rotate in (Default: local)
  13958. * @returns the TransformNode.
  13959. */
  13960. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13961. /**
  13962. * Adds a rotation step to the mesh current rotation.
  13963. * x, y, z are Euler angles expressed in radians.
  13964. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13965. * This means this rotation is made in the mesh local space only.
  13966. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13967. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13968. * ```javascript
  13969. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13970. * ```
  13971. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13972. * 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.
  13973. * @param x Rotation to add
  13974. * @param y Rotation to add
  13975. * @param z Rotation to add
  13976. * @returns the TransformNode.
  13977. */
  13978. addRotation(x: number, y: number, z: number): TransformNode;
  13979. /**
  13980. * @hidden
  13981. */
  13982. protected _getEffectiveParent(): Nullable<Node>;
  13983. /**
  13984. * Computes the world matrix of the node
  13985. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13986. * @returns the world matrix
  13987. */
  13988. computeWorldMatrix(force?: boolean): Matrix;
  13989. /**
  13990. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13991. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13992. */
  13993. resetLocalMatrix(independentOfChildren?: boolean): void;
  13994. protected _afterComputeWorldMatrix(): void;
  13995. /**
  13996. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13997. * @param func callback function to add
  13998. *
  13999. * @returns the TransformNode.
  14000. */
  14001. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14002. /**
  14003. * Removes a registered callback function.
  14004. * @param func callback function to remove
  14005. * @returns the TransformNode.
  14006. */
  14007. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14008. /**
  14009. * Gets the position of the current mesh in camera space
  14010. * @param camera defines the camera to use
  14011. * @returns a position
  14012. */
  14013. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14014. /**
  14015. * Returns the distance from the mesh to the active camera
  14016. * @param camera defines the camera to use
  14017. * @returns the distance
  14018. */
  14019. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14020. /**
  14021. * Clone the current transform node
  14022. * @param name Name of the new clone
  14023. * @param newParent New parent for the clone
  14024. * @param doNotCloneChildren Do not clone children hierarchy
  14025. * @returns the new transform node
  14026. */
  14027. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14028. /**
  14029. * Serializes the objects information.
  14030. * @param currentSerializationObject defines the object to serialize in
  14031. * @returns the serialized object
  14032. */
  14033. serialize(currentSerializationObject?: any): any;
  14034. /**
  14035. * Returns a new TransformNode object parsed from the source provided.
  14036. * @param parsedTransformNode is the source.
  14037. * @param scene the scne the object belongs to
  14038. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14039. * @returns a new TransformNode object parsed from the source provided.
  14040. */
  14041. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14042. /**
  14043. * Get all child-transformNodes of this node
  14044. * @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
  14045. * @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
  14046. * @returns an array of TransformNode
  14047. */
  14048. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14049. /**
  14050. * Releases resources associated with this transform node.
  14051. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14052. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14053. */
  14054. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14055. /**
  14056. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14057. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14058. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14059. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14060. * @returns the current mesh
  14061. */
  14062. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14063. private _syncAbsoluteScalingAndRotation;
  14064. }
  14065. }
  14066. declare module BABYLON {
  14067. /**
  14068. * Class used to override all child animations of a given target
  14069. */
  14070. export class AnimationPropertiesOverride {
  14071. /**
  14072. * Gets or sets a value indicating if animation blending must be used
  14073. */
  14074. enableBlending: boolean;
  14075. /**
  14076. * Gets or sets the blending speed to use when enableBlending is true
  14077. */
  14078. blendingSpeed: number;
  14079. /**
  14080. * Gets or sets the default loop mode to use
  14081. */
  14082. loopMode: number;
  14083. }
  14084. }
  14085. declare module BABYLON {
  14086. /**
  14087. * Class used to store bone information
  14088. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14089. */
  14090. export class Bone extends Node {
  14091. /**
  14092. * defines the bone name
  14093. */
  14094. name: string;
  14095. private static _tmpVecs;
  14096. private static _tmpQuat;
  14097. private static _tmpMats;
  14098. /**
  14099. * Gets the list of child bones
  14100. */
  14101. children: Bone[];
  14102. /** Gets the animations associated with this bone */
  14103. animations: Animation[];
  14104. /**
  14105. * Gets or sets bone length
  14106. */
  14107. length: number;
  14108. /**
  14109. * @hidden Internal only
  14110. * Set this value to map this bone to a different index in the transform matrices
  14111. * Set this value to -1 to exclude the bone from the transform matrices
  14112. */
  14113. _index: Nullable<number>;
  14114. private _skeleton;
  14115. private _localMatrix;
  14116. private _restPose;
  14117. private _baseMatrix;
  14118. private _absoluteTransform;
  14119. private _invertedAbsoluteTransform;
  14120. private _parent;
  14121. private _scalingDeterminant;
  14122. private _worldTransform;
  14123. private _localScaling;
  14124. private _localRotation;
  14125. private _localPosition;
  14126. private _needToDecompose;
  14127. private _needToCompose;
  14128. /** @hidden */
  14129. _linkedTransformNode: Nullable<TransformNode>;
  14130. /** @hidden */
  14131. _waitingTransformNodeId: Nullable<string>;
  14132. /** @hidden */
  14133. get _matrix(): Matrix;
  14134. /** @hidden */
  14135. set _matrix(value: Matrix);
  14136. /**
  14137. * Create a new bone
  14138. * @param name defines the bone name
  14139. * @param skeleton defines the parent skeleton
  14140. * @param parentBone defines the parent (can be null if the bone is the root)
  14141. * @param localMatrix defines the local matrix
  14142. * @param restPose defines the rest pose matrix
  14143. * @param baseMatrix defines the base matrix
  14144. * @param index defines index of the bone in the hiearchy
  14145. */
  14146. constructor(
  14147. /**
  14148. * defines the bone name
  14149. */
  14150. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14151. /**
  14152. * Gets the current object class name.
  14153. * @return the class name
  14154. */
  14155. getClassName(): string;
  14156. /**
  14157. * Gets the parent skeleton
  14158. * @returns a skeleton
  14159. */
  14160. getSkeleton(): Skeleton;
  14161. /**
  14162. * Gets parent bone
  14163. * @returns a bone or null if the bone is the root of the bone hierarchy
  14164. */
  14165. getParent(): Nullable<Bone>;
  14166. /**
  14167. * Returns an array containing the root bones
  14168. * @returns an array containing the root bones
  14169. */
  14170. getChildren(): Array<Bone>;
  14171. /**
  14172. * Gets the node index in matrix array generated for rendering
  14173. * @returns the node index
  14174. */
  14175. getIndex(): number;
  14176. /**
  14177. * Sets the parent bone
  14178. * @param parent defines the parent (can be null if the bone is the root)
  14179. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14180. */
  14181. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14182. /**
  14183. * Gets the local matrix
  14184. * @returns a matrix
  14185. */
  14186. getLocalMatrix(): Matrix;
  14187. /**
  14188. * Gets the base matrix (initial matrix which remains unchanged)
  14189. * @returns a matrix
  14190. */
  14191. getBaseMatrix(): Matrix;
  14192. /**
  14193. * Gets the rest pose matrix
  14194. * @returns a matrix
  14195. */
  14196. getRestPose(): Matrix;
  14197. /**
  14198. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14199. */
  14200. getWorldMatrix(): Matrix;
  14201. /**
  14202. * Sets the local matrix to rest pose matrix
  14203. */
  14204. returnToRest(): void;
  14205. /**
  14206. * Gets the inverse of the absolute transform matrix.
  14207. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14208. * @returns a matrix
  14209. */
  14210. getInvertedAbsoluteTransform(): Matrix;
  14211. /**
  14212. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14213. * @returns a matrix
  14214. */
  14215. getAbsoluteTransform(): Matrix;
  14216. /**
  14217. * Links with the given transform node.
  14218. * The local matrix of this bone is copied from the transform node every frame.
  14219. * @param transformNode defines the transform node to link to
  14220. */
  14221. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14222. /**
  14223. * Gets the node used to drive the bone's transformation
  14224. * @returns a transform node or null
  14225. */
  14226. getTransformNode(): Nullable<TransformNode>;
  14227. /** Gets or sets current position (in local space) */
  14228. get position(): Vector3;
  14229. set position(newPosition: Vector3);
  14230. /** Gets or sets current rotation (in local space) */
  14231. get rotation(): Vector3;
  14232. set rotation(newRotation: Vector3);
  14233. /** Gets or sets current rotation quaternion (in local space) */
  14234. get rotationQuaternion(): Quaternion;
  14235. set rotationQuaternion(newRotation: Quaternion);
  14236. /** Gets or sets current scaling (in local space) */
  14237. get scaling(): Vector3;
  14238. set scaling(newScaling: Vector3);
  14239. /**
  14240. * Gets the animation properties override
  14241. */
  14242. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14243. private _decompose;
  14244. private _compose;
  14245. /**
  14246. * Update the base and local matrices
  14247. * @param matrix defines the new base or local matrix
  14248. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14249. * @param updateLocalMatrix defines if the local matrix should be updated
  14250. */
  14251. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14252. /** @hidden */
  14253. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14254. /**
  14255. * Flag the bone as dirty (Forcing it to update everything)
  14256. */
  14257. markAsDirty(): void;
  14258. /** @hidden */
  14259. _markAsDirtyAndCompose(): void;
  14260. private _markAsDirtyAndDecompose;
  14261. /**
  14262. * Translate the bone in local or world space
  14263. * @param vec The amount to translate the bone
  14264. * @param space The space that the translation is in
  14265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14266. */
  14267. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14268. /**
  14269. * Set the postion of the bone in local or world space
  14270. * @param position The position to set the bone
  14271. * @param space The space that the position is in
  14272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14273. */
  14274. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14275. /**
  14276. * Set the absolute position of the bone (world space)
  14277. * @param position The position to set the bone
  14278. * @param mesh The mesh that this bone is attached to
  14279. */
  14280. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14281. /**
  14282. * Scale the bone on the x, y and z axes (in local space)
  14283. * @param x The amount to scale the bone on the x axis
  14284. * @param y The amount to scale the bone on the y axis
  14285. * @param z The amount to scale the bone on the z axis
  14286. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14287. */
  14288. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14289. /**
  14290. * Set the bone scaling in local space
  14291. * @param scale defines the scaling vector
  14292. */
  14293. setScale(scale: Vector3): void;
  14294. /**
  14295. * Gets the current scaling in local space
  14296. * @returns the current scaling vector
  14297. */
  14298. getScale(): Vector3;
  14299. /**
  14300. * Gets the current scaling in local space and stores it in a target vector
  14301. * @param result defines the target vector
  14302. */
  14303. getScaleToRef(result: Vector3): void;
  14304. /**
  14305. * Set the yaw, pitch, and roll of the bone in local or world space
  14306. * @param yaw The rotation of the bone on the y axis
  14307. * @param pitch The rotation of the bone on the x axis
  14308. * @param roll The rotation of the bone on the z axis
  14309. * @param space The space that the axes of rotation are in
  14310. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14311. */
  14312. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14313. /**
  14314. * Add a rotation to the bone on an axis in local or world space
  14315. * @param axis The axis to rotate the bone on
  14316. * @param amount The amount to rotate the bone
  14317. * @param space The space that the axis is in
  14318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14319. */
  14320. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14321. /**
  14322. * Set the rotation of the bone to a particular axis angle in local or world space
  14323. * @param axis The axis to rotate the bone on
  14324. * @param angle The angle that the bone should be rotated to
  14325. * @param space The space that the axis is in
  14326. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14327. */
  14328. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14329. /**
  14330. * Set the euler rotation of the bone in local of world space
  14331. * @param rotation The euler rotation that the bone should be set to
  14332. * @param space The space that the rotation is in
  14333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14334. */
  14335. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14336. /**
  14337. * Set the quaternion rotation of the bone in local of world space
  14338. * @param quat The quaternion rotation that the bone should be set to
  14339. * @param space The space that the rotation is in
  14340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14341. */
  14342. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14343. /**
  14344. * Set the rotation matrix of the bone in local of world space
  14345. * @param rotMat The rotation matrix that the bone should be set to
  14346. * @param space The space that the rotation is in
  14347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14348. */
  14349. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14350. private _rotateWithMatrix;
  14351. private _getNegativeRotationToRef;
  14352. /**
  14353. * Get the position of the bone in local or world space
  14354. * @param space The space that the returned position is in
  14355. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14356. * @returns The position of the bone
  14357. */
  14358. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14359. /**
  14360. * Copy the position of the bone to a vector3 in local or world space
  14361. * @param space The space that the returned position is in
  14362. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14363. * @param result The vector3 to copy the position to
  14364. */
  14365. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14366. /**
  14367. * Get the absolute position of the bone (world space)
  14368. * @param mesh The mesh that this bone is attached to
  14369. * @returns The absolute position of the bone
  14370. */
  14371. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14372. /**
  14373. * Copy the absolute position of the bone (world space) to the result param
  14374. * @param mesh The mesh that this bone is attached to
  14375. * @param result The vector3 to copy the absolute position to
  14376. */
  14377. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14378. /**
  14379. * Compute the absolute transforms of this bone and its children
  14380. */
  14381. computeAbsoluteTransforms(): void;
  14382. /**
  14383. * Get the world direction from an axis that is in the local space of the bone
  14384. * @param localAxis The local direction that is used to compute the world direction
  14385. * @param mesh The mesh that this bone is attached to
  14386. * @returns The world direction
  14387. */
  14388. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14389. /**
  14390. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14391. * @param localAxis The local direction that is used to compute the world direction
  14392. * @param mesh The mesh that this bone is attached to
  14393. * @param result The vector3 that the world direction will be copied to
  14394. */
  14395. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14396. /**
  14397. * Get the euler rotation of the bone in local or world space
  14398. * @param space The space that the rotation should be in
  14399. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14400. * @returns The euler rotation
  14401. */
  14402. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14403. /**
  14404. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14405. * @param space The space that the rotation should be in
  14406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14407. * @param result The vector3 that the rotation should be copied to
  14408. */
  14409. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14410. /**
  14411. * Get the quaternion rotation of the bone in either local or world space
  14412. * @param space The space that the rotation should be in
  14413. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14414. * @returns The quaternion rotation
  14415. */
  14416. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14417. /**
  14418. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14419. * @param space The space that the rotation should be in
  14420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14421. * @param result The quaternion that the rotation should be copied to
  14422. */
  14423. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14424. /**
  14425. * Get the rotation matrix of the bone in local or world space
  14426. * @param space The space that the rotation should be in
  14427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14428. * @returns The rotation matrix
  14429. */
  14430. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14431. /**
  14432. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14433. * @param space The space that the rotation should be in
  14434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14435. * @param result The quaternion that the rotation should be copied to
  14436. */
  14437. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14438. /**
  14439. * Get the world position of a point that is in the local space of the bone
  14440. * @param position The local position
  14441. * @param mesh The mesh that this bone is attached to
  14442. * @returns The world position
  14443. */
  14444. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14445. /**
  14446. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14447. * @param position The local position
  14448. * @param mesh The mesh that this bone is attached to
  14449. * @param result The vector3 that the world position should be copied to
  14450. */
  14451. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14452. /**
  14453. * Get the local position of a point that is in world space
  14454. * @param position The world position
  14455. * @param mesh The mesh that this bone is attached to
  14456. * @returns The local position
  14457. */
  14458. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14459. /**
  14460. * Get the local position of a point that is in world space and copy it to the result param
  14461. * @param position The world position
  14462. * @param mesh The mesh that this bone is attached to
  14463. * @param result The vector3 that the local position should be copied to
  14464. */
  14465. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14466. }
  14467. }
  14468. declare module BABYLON {
  14469. /**
  14470. * Defines a runtime animation
  14471. */
  14472. export class RuntimeAnimation {
  14473. private _events;
  14474. /**
  14475. * The current frame of the runtime animation
  14476. */
  14477. private _currentFrame;
  14478. /**
  14479. * The animation used by the runtime animation
  14480. */
  14481. private _animation;
  14482. /**
  14483. * The target of the runtime animation
  14484. */
  14485. private _target;
  14486. /**
  14487. * The initiating animatable
  14488. */
  14489. private _host;
  14490. /**
  14491. * The original value of the runtime animation
  14492. */
  14493. private _originalValue;
  14494. /**
  14495. * The original blend value of the runtime animation
  14496. */
  14497. private _originalBlendValue;
  14498. /**
  14499. * The offsets cache of the runtime animation
  14500. */
  14501. private _offsetsCache;
  14502. /**
  14503. * The high limits cache of the runtime animation
  14504. */
  14505. private _highLimitsCache;
  14506. /**
  14507. * Specifies if the runtime animation has been stopped
  14508. */
  14509. private _stopped;
  14510. /**
  14511. * The blending factor of the runtime animation
  14512. */
  14513. private _blendingFactor;
  14514. /**
  14515. * The BabylonJS scene
  14516. */
  14517. private _scene;
  14518. /**
  14519. * The current value of the runtime animation
  14520. */
  14521. private _currentValue;
  14522. /** @hidden */
  14523. _animationState: _IAnimationState;
  14524. /**
  14525. * The active target of the runtime animation
  14526. */
  14527. private _activeTargets;
  14528. private _currentActiveTarget;
  14529. private _directTarget;
  14530. /**
  14531. * The target path of the runtime animation
  14532. */
  14533. private _targetPath;
  14534. /**
  14535. * The weight of the runtime animation
  14536. */
  14537. private _weight;
  14538. /**
  14539. * The ratio offset of the runtime animation
  14540. */
  14541. private _ratioOffset;
  14542. /**
  14543. * The previous delay of the runtime animation
  14544. */
  14545. private _previousDelay;
  14546. /**
  14547. * The previous ratio of the runtime animation
  14548. */
  14549. private _previousRatio;
  14550. private _enableBlending;
  14551. private _keys;
  14552. private _minFrame;
  14553. private _maxFrame;
  14554. private _minValue;
  14555. private _maxValue;
  14556. private _targetIsArray;
  14557. /**
  14558. * Gets the current frame of the runtime animation
  14559. */
  14560. get currentFrame(): number;
  14561. /**
  14562. * Gets the weight of the runtime animation
  14563. */
  14564. get weight(): number;
  14565. /**
  14566. * Gets the current value of the runtime animation
  14567. */
  14568. get currentValue(): any;
  14569. /**
  14570. * Gets the target path of the runtime animation
  14571. */
  14572. get targetPath(): string;
  14573. /**
  14574. * Gets the actual target of the runtime animation
  14575. */
  14576. get target(): any;
  14577. /**
  14578. * Gets the additive state of the runtime animation
  14579. */
  14580. get isAdditive(): boolean;
  14581. /** @hidden */
  14582. _onLoop: () => void;
  14583. /**
  14584. * Create a new RuntimeAnimation object
  14585. * @param target defines the target of the animation
  14586. * @param animation defines the source animation object
  14587. * @param scene defines the hosting scene
  14588. * @param host defines the initiating Animatable
  14589. */
  14590. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14591. private _preparePath;
  14592. /**
  14593. * Gets the animation from the runtime animation
  14594. */
  14595. get animation(): Animation;
  14596. /**
  14597. * Resets the runtime animation to the beginning
  14598. * @param restoreOriginal defines whether to restore the target property to the original value
  14599. */
  14600. reset(restoreOriginal?: boolean): void;
  14601. /**
  14602. * Specifies if the runtime animation is stopped
  14603. * @returns Boolean specifying if the runtime animation is stopped
  14604. */
  14605. isStopped(): boolean;
  14606. /**
  14607. * Disposes of the runtime animation
  14608. */
  14609. dispose(): void;
  14610. /**
  14611. * Apply the interpolated value to the target
  14612. * @param currentValue defines the value computed by the animation
  14613. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14614. */
  14615. setValue(currentValue: any, weight: number): void;
  14616. private _getOriginalValues;
  14617. private _setValue;
  14618. /**
  14619. * Gets the loop pmode of the runtime animation
  14620. * @returns Loop Mode
  14621. */
  14622. private _getCorrectLoopMode;
  14623. /**
  14624. * Move the current animation to a given frame
  14625. * @param frame defines the frame to move to
  14626. */
  14627. goToFrame(frame: number): void;
  14628. /**
  14629. * @hidden Internal use only
  14630. */
  14631. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14632. /**
  14633. * Execute the current animation
  14634. * @param delay defines the delay to add to the current frame
  14635. * @param from defines the lower bound of the animation range
  14636. * @param to defines the upper bound of the animation range
  14637. * @param loop defines if the current animation must loop
  14638. * @param speedRatio defines the current speed ratio
  14639. * @param weight defines the weight of the animation (default is -1 so no weight)
  14640. * @param onLoop optional callback called when animation loops
  14641. * @returns a boolean indicating if the animation is running
  14642. */
  14643. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14644. }
  14645. }
  14646. declare module BABYLON {
  14647. /**
  14648. * Class used to store an actual running animation
  14649. */
  14650. export class Animatable {
  14651. /** defines the target object */
  14652. target: any;
  14653. /** defines the starting frame number (default is 0) */
  14654. fromFrame: number;
  14655. /** defines the ending frame number (default is 100) */
  14656. toFrame: number;
  14657. /** defines if the animation must loop (default is false) */
  14658. loopAnimation: boolean;
  14659. /** defines a callback to call when animation ends if it is not looping */
  14660. onAnimationEnd?: (() => void) | null | undefined;
  14661. /** defines a callback to call when animation loops */
  14662. onAnimationLoop?: (() => void) | null | undefined;
  14663. /** defines whether the animation should be evaluated additively */
  14664. isAdditive: boolean;
  14665. private _localDelayOffset;
  14666. private _pausedDelay;
  14667. private _runtimeAnimations;
  14668. private _paused;
  14669. private _scene;
  14670. private _speedRatio;
  14671. private _weight;
  14672. private _syncRoot;
  14673. /**
  14674. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14675. * This will only apply for non looping animation (default is true)
  14676. */
  14677. disposeOnEnd: boolean;
  14678. /**
  14679. * Gets a boolean indicating if the animation has started
  14680. */
  14681. animationStarted: boolean;
  14682. /**
  14683. * Observer raised when the animation ends
  14684. */
  14685. onAnimationEndObservable: Observable<Animatable>;
  14686. /**
  14687. * Observer raised when the animation loops
  14688. */
  14689. onAnimationLoopObservable: Observable<Animatable>;
  14690. /**
  14691. * Gets the root Animatable used to synchronize and normalize animations
  14692. */
  14693. get syncRoot(): Nullable<Animatable>;
  14694. /**
  14695. * Gets the current frame of the first RuntimeAnimation
  14696. * Used to synchronize Animatables
  14697. */
  14698. get masterFrame(): number;
  14699. /**
  14700. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14701. */
  14702. get weight(): number;
  14703. set weight(value: number);
  14704. /**
  14705. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14706. */
  14707. get speedRatio(): number;
  14708. set speedRatio(value: number);
  14709. /**
  14710. * Creates a new Animatable
  14711. * @param scene defines the hosting scene
  14712. * @param target defines the target object
  14713. * @param fromFrame defines the starting frame number (default is 0)
  14714. * @param toFrame defines the ending frame number (default is 100)
  14715. * @param loopAnimation defines if the animation must loop (default is false)
  14716. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14717. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14718. * @param animations defines a group of animation to add to the new Animatable
  14719. * @param onAnimationLoop defines a callback to call when animation loops
  14720. * @param isAdditive defines whether the animation should be evaluated additively
  14721. */
  14722. constructor(scene: Scene,
  14723. /** defines the target object */
  14724. target: any,
  14725. /** defines the starting frame number (default is 0) */
  14726. fromFrame?: number,
  14727. /** defines the ending frame number (default is 100) */
  14728. toFrame?: number,
  14729. /** defines if the animation must loop (default is false) */
  14730. loopAnimation?: boolean, speedRatio?: number,
  14731. /** defines a callback to call when animation ends if it is not looping */
  14732. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14733. /** defines a callback to call when animation loops */
  14734. onAnimationLoop?: (() => void) | null | undefined,
  14735. /** defines whether the animation should be evaluated additively */
  14736. isAdditive?: boolean);
  14737. /**
  14738. * Synchronize and normalize current Animatable with a source Animatable
  14739. * This is useful when using animation weights and when animations are not of the same length
  14740. * @param root defines the root Animatable to synchronize with
  14741. * @returns the current Animatable
  14742. */
  14743. syncWith(root: Animatable): Animatable;
  14744. /**
  14745. * Gets the list of runtime animations
  14746. * @returns an array of RuntimeAnimation
  14747. */
  14748. getAnimations(): RuntimeAnimation[];
  14749. /**
  14750. * Adds more animations to the current animatable
  14751. * @param target defines the target of the animations
  14752. * @param animations defines the new animations to add
  14753. */
  14754. appendAnimations(target: any, animations: Animation[]): void;
  14755. /**
  14756. * Gets the source animation for a specific property
  14757. * @param property defines the propertyu to look for
  14758. * @returns null or the source animation for the given property
  14759. */
  14760. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14761. /**
  14762. * Gets the runtime animation for a specific property
  14763. * @param property defines the propertyu to look for
  14764. * @returns null or the runtime animation for the given property
  14765. */
  14766. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14767. /**
  14768. * Resets the animatable to its original state
  14769. */
  14770. reset(): void;
  14771. /**
  14772. * Allows the animatable to blend with current running animations
  14773. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14774. * @param blendingSpeed defines the blending speed to use
  14775. */
  14776. enableBlending(blendingSpeed: number): void;
  14777. /**
  14778. * Disable animation blending
  14779. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14780. */
  14781. disableBlending(): void;
  14782. /**
  14783. * Jump directly to a given frame
  14784. * @param frame defines the frame to jump to
  14785. */
  14786. goToFrame(frame: number): void;
  14787. /**
  14788. * Pause the animation
  14789. */
  14790. pause(): void;
  14791. /**
  14792. * Restart the animation
  14793. */
  14794. restart(): void;
  14795. private _raiseOnAnimationEnd;
  14796. /**
  14797. * Stop and delete the current animation
  14798. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14799. * @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)
  14800. */
  14801. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14802. /**
  14803. * Wait asynchronously for the animation to end
  14804. * @returns a promise which will be fullfilled when the animation ends
  14805. */
  14806. waitAsync(): Promise<Animatable>;
  14807. /** @hidden */
  14808. _animate(delay: number): boolean;
  14809. }
  14810. interface Scene {
  14811. /** @hidden */
  14812. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14813. /** @hidden */
  14814. _processLateAnimationBindingsForMatrices(holder: {
  14815. totalWeight: number;
  14816. totalAdditiveWeight: number;
  14817. animations: RuntimeAnimation[];
  14818. additiveAnimations: RuntimeAnimation[];
  14819. originalValue: Matrix;
  14820. }): any;
  14821. /** @hidden */
  14822. _processLateAnimationBindingsForQuaternions(holder: {
  14823. totalWeight: number;
  14824. totalAdditiveWeight: number;
  14825. animations: RuntimeAnimation[];
  14826. additiveAnimations: RuntimeAnimation[];
  14827. originalValue: Quaternion;
  14828. }, refQuaternion: Quaternion): Quaternion;
  14829. /** @hidden */
  14830. _processLateAnimationBindings(): void;
  14831. /**
  14832. * Will start the animation sequence of a given target
  14833. * @param target defines the target
  14834. * @param from defines from which frame should animation start
  14835. * @param to defines until which frame should animation run.
  14836. * @param weight defines the weight to apply to the animation (1.0 by default)
  14837. * @param loop defines if the animation loops
  14838. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14839. * @param onAnimationEnd defines the function to be executed when the animation ends
  14840. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14841. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14842. * @param onAnimationLoop defines the callback to call when an animation loops
  14843. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14844. * @returns the animatable object created for this animation
  14845. */
  14846. 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;
  14847. /**
  14848. * Will start the animation sequence of a given target
  14849. * @param target defines the target
  14850. * @param from defines from which frame should animation start
  14851. * @param to defines until which frame should animation run.
  14852. * @param loop defines if the animation loops
  14853. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14854. * @param onAnimationEnd defines the function to be executed when the animation ends
  14855. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14856. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14857. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14858. * @param onAnimationLoop defines the callback to call when an animation loops
  14859. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14860. * @returns the animatable object created for this animation
  14861. */
  14862. 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;
  14863. /**
  14864. * Will start the animation sequence of a given target and its hierarchy
  14865. * @param target defines the target
  14866. * @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.
  14867. * @param from defines from which frame should animation start
  14868. * @param to defines until which frame should animation run.
  14869. * @param loop defines if the animation loops
  14870. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14871. * @param onAnimationEnd defines the function to be executed when the animation ends
  14872. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14873. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14874. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14875. * @param onAnimationLoop defines the callback to call when an animation loops
  14876. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14877. * @returns the list of created animatables
  14878. */
  14879. 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[];
  14880. /**
  14881. * Begin a new animation on a given node
  14882. * @param target defines the target where the animation will take place
  14883. * @param animations defines the list of animations to start
  14884. * @param from defines the initial value
  14885. * @param to defines the final value
  14886. * @param loop defines if you want animation to loop (off by default)
  14887. * @param speedRatio defines the speed ratio to apply to all animations
  14888. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14889. * @param onAnimationLoop defines the callback to call when an animation loops
  14890. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14891. * @returns the list of created animatables
  14892. */
  14893. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14894. /**
  14895. * Begin a new animation on a given node and its hierarchy
  14896. * @param target defines the root node where the animation will take place
  14897. * @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.
  14898. * @param animations defines the list of animations to start
  14899. * @param from defines the initial value
  14900. * @param to defines the final value
  14901. * @param loop defines if you want animation to loop (off by default)
  14902. * @param speedRatio defines the speed ratio to apply to all animations
  14903. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14904. * @param onAnimationLoop defines the callback to call when an animation loops
  14905. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14906. * @returns the list of animatables created for all nodes
  14907. */
  14908. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14909. /**
  14910. * Gets the animatable associated with a specific target
  14911. * @param target defines the target of the animatable
  14912. * @returns the required animatable if found
  14913. */
  14914. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14915. /**
  14916. * Gets all animatables associated with a given target
  14917. * @param target defines the target to look animatables for
  14918. * @returns an array of Animatables
  14919. */
  14920. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14921. /**
  14922. * Stops and removes all animations that have been applied to the scene
  14923. */
  14924. stopAllAnimations(): void;
  14925. /**
  14926. * Gets the current delta time used by animation engine
  14927. */
  14928. deltaTime: number;
  14929. }
  14930. interface Bone {
  14931. /**
  14932. * Copy an animation range from another bone
  14933. * @param source defines the source bone
  14934. * @param rangeName defines the range name to copy
  14935. * @param frameOffset defines the frame offset
  14936. * @param rescaleAsRequired defines if rescaling must be applied if required
  14937. * @param skelDimensionsRatio defines the scaling ratio
  14938. * @returns true if operation was successful
  14939. */
  14940. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14941. }
  14942. }
  14943. declare module BABYLON {
  14944. /**
  14945. * Class used to handle skinning animations
  14946. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14947. */
  14948. export class Skeleton implements IAnimatable {
  14949. /** defines the skeleton name */
  14950. name: string;
  14951. /** defines the skeleton Id */
  14952. id: string;
  14953. /**
  14954. * Defines the list of child bones
  14955. */
  14956. bones: Bone[];
  14957. /**
  14958. * Defines an estimate of the dimension of the skeleton at rest
  14959. */
  14960. dimensionsAtRest: Vector3;
  14961. /**
  14962. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14963. */
  14964. needInitialSkinMatrix: boolean;
  14965. /**
  14966. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14967. */
  14968. overrideMesh: Nullable<AbstractMesh>;
  14969. /**
  14970. * Gets the list of animations attached to this skeleton
  14971. */
  14972. animations: Array<Animation>;
  14973. private _scene;
  14974. private _isDirty;
  14975. private _transformMatrices;
  14976. private _transformMatrixTexture;
  14977. private _meshesWithPoseMatrix;
  14978. private _animatables;
  14979. private _identity;
  14980. private _synchronizedWithMesh;
  14981. private _ranges;
  14982. private _lastAbsoluteTransformsUpdateId;
  14983. private _canUseTextureForBones;
  14984. private _uniqueId;
  14985. /** @hidden */
  14986. _numBonesWithLinkedTransformNode: number;
  14987. /** @hidden */
  14988. _hasWaitingData: Nullable<boolean>;
  14989. /**
  14990. * Specifies if the skeleton should be serialized
  14991. */
  14992. doNotSerialize: boolean;
  14993. private _useTextureToStoreBoneMatrices;
  14994. /**
  14995. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14996. * Please note that this option is not available if the hardware does not support it
  14997. */
  14998. get useTextureToStoreBoneMatrices(): boolean;
  14999. set useTextureToStoreBoneMatrices(value: boolean);
  15000. private _animationPropertiesOverride;
  15001. /**
  15002. * Gets or sets the animation properties override
  15003. */
  15004. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15005. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15006. /**
  15007. * List of inspectable custom properties (used by the Inspector)
  15008. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15009. */
  15010. inspectableCustomProperties: IInspectable[];
  15011. /**
  15012. * An observable triggered before computing the skeleton's matrices
  15013. */
  15014. onBeforeComputeObservable: Observable<Skeleton>;
  15015. /**
  15016. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15017. */
  15018. get isUsingTextureForMatrices(): boolean;
  15019. /**
  15020. * Gets the unique ID of this skeleton
  15021. */
  15022. get uniqueId(): number;
  15023. /**
  15024. * Creates a new skeleton
  15025. * @param name defines the skeleton name
  15026. * @param id defines the skeleton Id
  15027. * @param scene defines the hosting scene
  15028. */
  15029. constructor(
  15030. /** defines the skeleton name */
  15031. name: string,
  15032. /** defines the skeleton Id */
  15033. id: string, scene: Scene);
  15034. /**
  15035. * Gets the current object class name.
  15036. * @return the class name
  15037. */
  15038. getClassName(): string;
  15039. /**
  15040. * Returns an array containing the root bones
  15041. * @returns an array containing the root bones
  15042. */
  15043. getChildren(): Array<Bone>;
  15044. /**
  15045. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15046. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15047. * @returns a Float32Array containing matrices data
  15048. */
  15049. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15050. /**
  15051. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15052. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15053. * @returns a raw texture containing the data
  15054. */
  15055. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15056. /**
  15057. * Gets the current hosting scene
  15058. * @returns a scene object
  15059. */
  15060. getScene(): Scene;
  15061. /**
  15062. * Gets a string representing the current skeleton data
  15063. * @param fullDetails defines a boolean indicating if we want a verbose version
  15064. * @returns a string representing the current skeleton data
  15065. */
  15066. toString(fullDetails?: boolean): string;
  15067. /**
  15068. * Get bone's index searching by name
  15069. * @param name defines bone's name to search for
  15070. * @return the indice of the bone. Returns -1 if not found
  15071. */
  15072. getBoneIndexByName(name: string): number;
  15073. /**
  15074. * Creater a new animation range
  15075. * @param name defines the name of the range
  15076. * @param from defines the start key
  15077. * @param to defines the end key
  15078. */
  15079. createAnimationRange(name: string, from: number, to: number): void;
  15080. /**
  15081. * Delete a specific animation range
  15082. * @param name defines the name of the range
  15083. * @param deleteFrames defines if frames must be removed as well
  15084. */
  15085. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15086. /**
  15087. * Gets a specific animation range
  15088. * @param name defines the name of the range to look for
  15089. * @returns the requested animation range or null if not found
  15090. */
  15091. getAnimationRange(name: string): Nullable<AnimationRange>;
  15092. /**
  15093. * Gets the list of all animation ranges defined on this skeleton
  15094. * @returns an array
  15095. */
  15096. getAnimationRanges(): Nullable<AnimationRange>[];
  15097. /**
  15098. * Copy animation range from a source skeleton.
  15099. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15100. * @param source defines the source skeleton
  15101. * @param name defines the name of the range to copy
  15102. * @param rescaleAsRequired defines if rescaling must be applied if required
  15103. * @returns true if operation was successful
  15104. */
  15105. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15106. /**
  15107. * Forces the skeleton to go to rest pose
  15108. */
  15109. returnToRest(): void;
  15110. private _getHighestAnimationFrame;
  15111. /**
  15112. * Begin a specific animation range
  15113. * @param name defines the name of the range to start
  15114. * @param loop defines if looping must be turned on (false by default)
  15115. * @param speedRatio defines the speed ratio to apply (1 by default)
  15116. * @param onAnimationEnd defines a callback which will be called when animation will end
  15117. * @returns a new animatable
  15118. */
  15119. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15120. /**
  15121. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15122. * @param skeleton defines the Skeleton containing the animation range to convert
  15123. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15124. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15125. * @returns the original skeleton
  15126. */
  15127. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15128. /** @hidden */
  15129. _markAsDirty(): void;
  15130. /** @hidden */
  15131. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15132. /** @hidden */
  15133. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15134. private _computeTransformMatrices;
  15135. /**
  15136. * Build all resources required to render a skeleton
  15137. */
  15138. prepare(): void;
  15139. /**
  15140. * Gets the list of animatables currently running for this skeleton
  15141. * @returns an array of animatables
  15142. */
  15143. getAnimatables(): IAnimatable[];
  15144. /**
  15145. * Clone the current skeleton
  15146. * @param name defines the name of the new skeleton
  15147. * @param id defines the id of the new skeleton
  15148. * @returns the new skeleton
  15149. */
  15150. clone(name: string, id?: string): Skeleton;
  15151. /**
  15152. * Enable animation blending for this skeleton
  15153. * @param blendingSpeed defines the blending speed to apply
  15154. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15155. */
  15156. enableBlending(blendingSpeed?: number): void;
  15157. /**
  15158. * Releases all resources associated with the current skeleton
  15159. */
  15160. dispose(): void;
  15161. /**
  15162. * Serialize the skeleton in a JSON object
  15163. * @returns a JSON object
  15164. */
  15165. serialize(): any;
  15166. /**
  15167. * Creates a new skeleton from serialized data
  15168. * @param parsedSkeleton defines the serialized data
  15169. * @param scene defines the hosting scene
  15170. * @returns a new skeleton
  15171. */
  15172. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15173. /**
  15174. * Compute all node absolute transforms
  15175. * @param forceUpdate defines if computation must be done even if cache is up to date
  15176. */
  15177. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15178. /**
  15179. * Gets the root pose matrix
  15180. * @returns a matrix
  15181. */
  15182. getPoseMatrix(): Nullable<Matrix>;
  15183. /**
  15184. * Sorts bones per internal index
  15185. */
  15186. sortBones(): void;
  15187. private _sortBones;
  15188. }
  15189. }
  15190. declare module BABYLON {
  15191. /**
  15192. * Creates an instance based on a source mesh.
  15193. */
  15194. export class InstancedMesh extends AbstractMesh {
  15195. private _sourceMesh;
  15196. private _currentLOD;
  15197. /** @hidden */
  15198. _indexInSourceMeshInstanceArray: number;
  15199. constructor(name: string, source: Mesh);
  15200. /**
  15201. * Returns the string "InstancedMesh".
  15202. */
  15203. getClassName(): string;
  15204. /** Gets the list of lights affecting that mesh */
  15205. get lightSources(): Light[];
  15206. _resyncLightSources(): void;
  15207. _resyncLightSource(light: Light): void;
  15208. _removeLightSource(light: Light, dispose: boolean): void;
  15209. /**
  15210. * If the source mesh receives shadows
  15211. */
  15212. get receiveShadows(): boolean;
  15213. /**
  15214. * The material of the source mesh
  15215. */
  15216. get material(): Nullable<Material>;
  15217. /**
  15218. * Visibility of the source mesh
  15219. */
  15220. get visibility(): number;
  15221. /**
  15222. * Skeleton of the source mesh
  15223. */
  15224. get skeleton(): Nullable<Skeleton>;
  15225. /**
  15226. * Rendering ground id of the source mesh
  15227. */
  15228. get renderingGroupId(): number;
  15229. set renderingGroupId(value: number);
  15230. /**
  15231. * Returns the total number of vertices (integer).
  15232. */
  15233. getTotalVertices(): number;
  15234. /**
  15235. * Returns a positive integer : the total number of indices in this mesh geometry.
  15236. * @returns the numner of indices or zero if the mesh has no geometry.
  15237. */
  15238. getTotalIndices(): number;
  15239. /**
  15240. * The source mesh of the instance
  15241. */
  15242. get sourceMesh(): Mesh;
  15243. /**
  15244. * Is this node ready to be used/rendered
  15245. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15246. * @return {boolean} is it ready
  15247. */
  15248. isReady(completeCheck?: boolean): boolean;
  15249. /**
  15250. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15251. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15252. * @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.
  15253. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15254. */
  15255. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15256. /**
  15257. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15258. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15259. * The `data` are either a numeric array either a Float32Array.
  15260. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15261. * 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).
  15262. * Note that a new underlying VertexBuffer object is created each call.
  15263. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15264. *
  15265. * Possible `kind` values :
  15266. * - VertexBuffer.PositionKind
  15267. * - VertexBuffer.UVKind
  15268. * - VertexBuffer.UV2Kind
  15269. * - VertexBuffer.UV3Kind
  15270. * - VertexBuffer.UV4Kind
  15271. * - VertexBuffer.UV5Kind
  15272. * - VertexBuffer.UV6Kind
  15273. * - VertexBuffer.ColorKind
  15274. * - VertexBuffer.MatricesIndicesKind
  15275. * - VertexBuffer.MatricesIndicesExtraKind
  15276. * - VertexBuffer.MatricesWeightsKind
  15277. * - VertexBuffer.MatricesWeightsExtraKind
  15278. *
  15279. * Returns the Mesh.
  15280. */
  15281. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15282. /**
  15283. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15284. * If the mesh has no geometry, it is simply returned as it is.
  15285. * The `data` are either a numeric array either a Float32Array.
  15286. * No new underlying VertexBuffer object is created.
  15287. * 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.
  15288. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15289. *
  15290. * Possible `kind` values :
  15291. * - VertexBuffer.PositionKind
  15292. * - VertexBuffer.UVKind
  15293. * - VertexBuffer.UV2Kind
  15294. * - VertexBuffer.UV3Kind
  15295. * - VertexBuffer.UV4Kind
  15296. * - VertexBuffer.UV5Kind
  15297. * - VertexBuffer.UV6Kind
  15298. * - VertexBuffer.ColorKind
  15299. * - VertexBuffer.MatricesIndicesKind
  15300. * - VertexBuffer.MatricesIndicesExtraKind
  15301. * - VertexBuffer.MatricesWeightsKind
  15302. * - VertexBuffer.MatricesWeightsExtraKind
  15303. *
  15304. * Returns the Mesh.
  15305. */
  15306. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15307. /**
  15308. * Sets the mesh indices.
  15309. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15310. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15311. * This method creates a new index buffer each call.
  15312. * Returns the Mesh.
  15313. */
  15314. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15315. /**
  15316. * Boolean : True if the mesh owns the requested kind of data.
  15317. */
  15318. isVerticesDataPresent(kind: string): boolean;
  15319. /**
  15320. * Returns an array of indices (IndicesArray).
  15321. */
  15322. getIndices(): Nullable<IndicesArray>;
  15323. get _positions(): Nullable<Vector3[]>;
  15324. /**
  15325. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15326. * This means the mesh underlying bounding box and sphere are recomputed.
  15327. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15328. * @returns the current mesh
  15329. */
  15330. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15331. /** @hidden */
  15332. _preActivate(): InstancedMesh;
  15333. /** @hidden */
  15334. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15335. /** @hidden */
  15336. _postActivate(): void;
  15337. getWorldMatrix(): Matrix;
  15338. get isAnInstance(): boolean;
  15339. /**
  15340. * Returns the current associated LOD AbstractMesh.
  15341. */
  15342. getLOD(camera: Camera): AbstractMesh;
  15343. /** @hidden */
  15344. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15345. /** @hidden */
  15346. _syncSubMeshes(): InstancedMesh;
  15347. /** @hidden */
  15348. _generatePointsArray(): boolean;
  15349. /**
  15350. * Creates a new InstancedMesh from the current mesh.
  15351. * - name (string) : the cloned mesh name
  15352. * - newParent (optional Node) : the optional Node to parent the clone to.
  15353. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15354. *
  15355. * Returns the clone.
  15356. */
  15357. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15358. /**
  15359. * Disposes the InstancedMesh.
  15360. * Returns nothing.
  15361. */
  15362. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15363. }
  15364. interface Mesh {
  15365. /**
  15366. * Register a custom buffer that will be instanced
  15367. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15368. * @param kind defines the buffer kind
  15369. * @param stride defines the stride in floats
  15370. */
  15371. registerInstancedBuffer(kind: string, stride: number): void;
  15372. /** @hidden */
  15373. _userInstancedBuffersStorage: {
  15374. data: {
  15375. [key: string]: Float32Array;
  15376. };
  15377. sizes: {
  15378. [key: string]: number;
  15379. };
  15380. vertexBuffers: {
  15381. [key: string]: Nullable<VertexBuffer>;
  15382. };
  15383. strides: {
  15384. [key: string]: number;
  15385. };
  15386. };
  15387. }
  15388. interface AbstractMesh {
  15389. /**
  15390. * Object used to store instanced buffers defined by user
  15391. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15392. */
  15393. instancedBuffers: {
  15394. [key: string]: any;
  15395. };
  15396. }
  15397. }
  15398. declare module BABYLON {
  15399. /**
  15400. * Defines the options associated with the creation of a shader material.
  15401. */
  15402. export interface IShaderMaterialOptions {
  15403. /**
  15404. * Does the material work in alpha blend mode
  15405. */
  15406. needAlphaBlending: boolean;
  15407. /**
  15408. * Does the material work in alpha test mode
  15409. */
  15410. needAlphaTesting: boolean;
  15411. /**
  15412. * The list of attribute names used in the shader
  15413. */
  15414. attributes: string[];
  15415. /**
  15416. * The list of unifrom names used in the shader
  15417. */
  15418. uniforms: string[];
  15419. /**
  15420. * The list of UBO names used in the shader
  15421. */
  15422. uniformBuffers: string[];
  15423. /**
  15424. * The list of sampler names used in the shader
  15425. */
  15426. samplers: string[];
  15427. /**
  15428. * The list of defines used in the shader
  15429. */
  15430. defines: string[];
  15431. }
  15432. /**
  15433. * 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.
  15434. *
  15435. * This returned material effects how the mesh will look based on the code in the shaders.
  15436. *
  15437. * @see http://doc.babylonjs.com/how_to/shader_material
  15438. */
  15439. export class ShaderMaterial extends Material {
  15440. private _shaderPath;
  15441. private _options;
  15442. private _textures;
  15443. private _textureArrays;
  15444. private _floats;
  15445. private _ints;
  15446. private _floatsArrays;
  15447. private _colors3;
  15448. private _colors3Arrays;
  15449. private _colors4;
  15450. private _colors4Arrays;
  15451. private _vectors2;
  15452. private _vectors3;
  15453. private _vectors4;
  15454. private _matrices;
  15455. private _matrixArrays;
  15456. private _matrices3x3;
  15457. private _matrices2x2;
  15458. private _vectors2Arrays;
  15459. private _vectors3Arrays;
  15460. private _vectors4Arrays;
  15461. private _cachedWorldViewMatrix;
  15462. private _cachedWorldViewProjectionMatrix;
  15463. private _renderId;
  15464. private _multiview;
  15465. /**
  15466. * Instantiate a new shader material.
  15467. * 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.
  15468. * This returned material effects how the mesh will look based on the code in the shaders.
  15469. * @see http://doc.babylonjs.com/how_to/shader_material
  15470. * @param name Define the name of the material in the scene
  15471. * @param scene Define the scene the material belongs to
  15472. * @param shaderPath Defines the route to the shader code in one of three ways:
  15473. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15474. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15475. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15476. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15477. * @param options Define the options used to create the shader
  15478. */
  15479. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15480. /**
  15481. * Gets the shader path used to define the shader code
  15482. * It can be modified to trigger a new compilation
  15483. */
  15484. get shaderPath(): any;
  15485. /**
  15486. * Sets the shader path used to define the shader code
  15487. * It can be modified to trigger a new compilation
  15488. */
  15489. set shaderPath(shaderPath: any);
  15490. /**
  15491. * Gets the options used to compile the shader.
  15492. * They can be modified to trigger a new compilation
  15493. */
  15494. get options(): IShaderMaterialOptions;
  15495. /**
  15496. * Gets the current class name of the material e.g. "ShaderMaterial"
  15497. * Mainly use in serialization.
  15498. * @returns the class name
  15499. */
  15500. getClassName(): string;
  15501. /**
  15502. * Specifies if the material will require alpha blending
  15503. * @returns a boolean specifying if alpha blending is needed
  15504. */
  15505. needAlphaBlending(): boolean;
  15506. /**
  15507. * Specifies if this material should be rendered in alpha test mode
  15508. * @returns a boolean specifying if an alpha test is needed.
  15509. */
  15510. needAlphaTesting(): boolean;
  15511. private _checkUniform;
  15512. /**
  15513. * Set a texture in the shader.
  15514. * @param name Define the name of the uniform samplers as defined in the shader
  15515. * @param texture Define the texture to bind to this sampler
  15516. * @return the material itself allowing "fluent" like uniform updates
  15517. */
  15518. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15519. /**
  15520. * Set a texture array in the shader.
  15521. * @param name Define the name of the uniform sampler array as defined in the shader
  15522. * @param textures Define the list of textures to bind to this sampler
  15523. * @return the material itself allowing "fluent" like uniform updates
  15524. */
  15525. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15526. /**
  15527. * Set a float in the shader.
  15528. * @param name Define the name of the uniform as defined in the shader
  15529. * @param value Define the value to give to the uniform
  15530. * @return the material itself allowing "fluent" like uniform updates
  15531. */
  15532. setFloat(name: string, value: number): ShaderMaterial;
  15533. /**
  15534. * Set a int in the shader.
  15535. * @param name Define the name of the uniform as defined in the shader
  15536. * @param value Define the value to give to the uniform
  15537. * @return the material itself allowing "fluent" like uniform updates
  15538. */
  15539. setInt(name: string, value: number): ShaderMaterial;
  15540. /**
  15541. * Set an array of floats in the shader.
  15542. * @param name Define the name of the uniform as defined in the shader
  15543. * @param value Define the value to give to the uniform
  15544. * @return the material itself allowing "fluent" like uniform updates
  15545. */
  15546. setFloats(name: string, value: number[]): ShaderMaterial;
  15547. /**
  15548. * Set a vec3 in the shader from a Color3.
  15549. * @param name Define the name of the uniform as defined in the shader
  15550. * @param value Define the value to give to the uniform
  15551. * @return the material itself allowing "fluent" like uniform updates
  15552. */
  15553. setColor3(name: string, value: Color3): ShaderMaterial;
  15554. /**
  15555. * Set a vec3 array in the shader from a Color3 array.
  15556. * @param name Define the name of the uniform as defined in the shader
  15557. * @param value Define the value to give to the uniform
  15558. * @return the material itself allowing "fluent" like uniform updates
  15559. */
  15560. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15561. /**
  15562. * Set a vec4 in the shader from a Color4.
  15563. * @param name Define the name of the uniform as defined in the shader
  15564. * @param value Define the value to give to the uniform
  15565. * @return the material itself allowing "fluent" like uniform updates
  15566. */
  15567. setColor4(name: string, value: Color4): ShaderMaterial;
  15568. /**
  15569. * Set a vec4 array in the shader from a Color4 array.
  15570. * @param name Define the name of the uniform as defined in the shader
  15571. * @param value Define the value to give to the uniform
  15572. * @return the material itself allowing "fluent" like uniform updates
  15573. */
  15574. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15575. /**
  15576. * Set a vec2 in the shader from a Vector2.
  15577. * @param name Define the name of the uniform as defined in the shader
  15578. * @param value Define the value to give to the uniform
  15579. * @return the material itself allowing "fluent" like uniform updates
  15580. */
  15581. setVector2(name: string, value: Vector2): ShaderMaterial;
  15582. /**
  15583. * Set a vec3 in the shader from a Vector3.
  15584. * @param name Define the name of the uniform as defined in the shader
  15585. * @param value Define the value to give to the uniform
  15586. * @return the material itself allowing "fluent" like uniform updates
  15587. */
  15588. setVector3(name: string, value: Vector3): ShaderMaterial;
  15589. /**
  15590. * Set a vec4 in the shader from a Vector4.
  15591. * @param name Define the name of the uniform as defined in the shader
  15592. * @param value Define the value to give to the uniform
  15593. * @return the material itself allowing "fluent" like uniform updates
  15594. */
  15595. setVector4(name: string, value: Vector4): ShaderMaterial;
  15596. /**
  15597. * Set a mat4 in the shader from a Matrix.
  15598. * @param name Define the name of the uniform as defined in the shader
  15599. * @param value Define the value to give to the uniform
  15600. * @return the material itself allowing "fluent" like uniform updates
  15601. */
  15602. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15603. /**
  15604. * Set a float32Array in the shader from a matrix array.
  15605. * @param name Define the name of the uniform as defined in the shader
  15606. * @param value Define the value to give to the uniform
  15607. * @return the material itself allowing "fluent" like uniform updates
  15608. */
  15609. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15610. /**
  15611. * Set a mat3 in the shader from a Float32Array.
  15612. * @param name Define the name of the uniform as defined in the shader
  15613. * @param value Define the value to give to the uniform
  15614. * @return the material itself allowing "fluent" like uniform updates
  15615. */
  15616. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15617. /**
  15618. * Set a mat2 in the shader from a Float32Array.
  15619. * @param name Define the name of the uniform as defined in the shader
  15620. * @param value Define the value to give to the uniform
  15621. * @return the material itself allowing "fluent" like uniform updates
  15622. */
  15623. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15624. /**
  15625. * Set a vec2 array in the shader from a number array.
  15626. * @param name Define the name of the uniform as defined in the shader
  15627. * @param value Define the value to give to the uniform
  15628. * @return the material itself allowing "fluent" like uniform updates
  15629. */
  15630. setArray2(name: string, value: number[]): ShaderMaterial;
  15631. /**
  15632. * Set a vec3 array in the shader from a number array.
  15633. * @param name Define the name of the uniform as defined in the shader
  15634. * @param value Define the value to give to the uniform
  15635. * @return the material itself allowing "fluent" like uniform updates
  15636. */
  15637. setArray3(name: string, value: number[]): ShaderMaterial;
  15638. /**
  15639. * Set a vec4 array in the shader from a number array.
  15640. * @param name Define the name of the uniform as defined in the shader
  15641. * @param value Define the value to give to the uniform
  15642. * @return the material itself allowing "fluent" like uniform updates
  15643. */
  15644. setArray4(name: string, value: number[]): ShaderMaterial;
  15645. private _checkCache;
  15646. /**
  15647. * Specifies that the submesh is ready to be used
  15648. * @param mesh defines the mesh to check
  15649. * @param subMesh defines which submesh to check
  15650. * @param useInstances specifies that instances should be used
  15651. * @returns a boolean indicating that the submesh is ready or not
  15652. */
  15653. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15654. /**
  15655. * Checks if the material is ready to render the requested mesh
  15656. * @param mesh Define the mesh to render
  15657. * @param useInstances Define whether or not the material is used with instances
  15658. * @returns true if ready, otherwise false
  15659. */
  15660. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15661. /**
  15662. * Binds the world matrix to the material
  15663. * @param world defines the world transformation matrix
  15664. */
  15665. bindOnlyWorldMatrix(world: Matrix): void;
  15666. /**
  15667. * Binds the material to the mesh
  15668. * @param world defines the world transformation matrix
  15669. * @param mesh defines the mesh to bind the material to
  15670. */
  15671. bind(world: Matrix, mesh?: Mesh): void;
  15672. /**
  15673. * Gets the active textures from the material
  15674. * @returns an array of textures
  15675. */
  15676. getActiveTextures(): BaseTexture[];
  15677. /**
  15678. * Specifies if the material uses a texture
  15679. * @param texture defines the texture to check against the material
  15680. * @returns a boolean specifying if the material uses the texture
  15681. */
  15682. hasTexture(texture: BaseTexture): boolean;
  15683. /**
  15684. * Makes a duplicate of the material, and gives it a new name
  15685. * @param name defines the new name for the duplicated material
  15686. * @returns the cloned material
  15687. */
  15688. clone(name: string): ShaderMaterial;
  15689. /**
  15690. * Disposes the material
  15691. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15692. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15693. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15694. */
  15695. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15696. /**
  15697. * Serializes this material in a JSON representation
  15698. * @returns the serialized material object
  15699. */
  15700. serialize(): any;
  15701. /**
  15702. * Creates a shader material from parsed shader material data
  15703. * @param source defines the JSON represnetation of the material
  15704. * @param scene defines the hosting scene
  15705. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15706. * @returns a new material
  15707. */
  15708. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15709. }
  15710. }
  15711. declare module BABYLON {
  15712. /** @hidden */
  15713. export var colorPixelShader: {
  15714. name: string;
  15715. shader: string;
  15716. };
  15717. }
  15718. declare module BABYLON {
  15719. /** @hidden */
  15720. export var colorVertexShader: {
  15721. name: string;
  15722. shader: string;
  15723. };
  15724. }
  15725. declare module BABYLON {
  15726. /**
  15727. * Line mesh
  15728. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15729. */
  15730. export class LinesMesh extends Mesh {
  15731. /**
  15732. * If vertex color should be applied to the mesh
  15733. */
  15734. readonly useVertexColor?: boolean | undefined;
  15735. /**
  15736. * If vertex alpha should be applied to the mesh
  15737. */
  15738. readonly useVertexAlpha?: boolean | undefined;
  15739. /**
  15740. * Color of the line (Default: White)
  15741. */
  15742. color: Color3;
  15743. /**
  15744. * Alpha of the line (Default: 1)
  15745. */
  15746. alpha: number;
  15747. /**
  15748. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15749. * This margin is expressed in world space coordinates, so its value may vary.
  15750. * Default value is 0.1
  15751. */
  15752. intersectionThreshold: number;
  15753. private _colorShader;
  15754. private color4;
  15755. /**
  15756. * Creates a new LinesMesh
  15757. * @param name defines the name
  15758. * @param scene defines the hosting scene
  15759. * @param parent defines the parent mesh if any
  15760. * @param source defines the optional source LinesMesh used to clone data from
  15761. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15762. * When false, achieved by calling a clone(), also passing False.
  15763. * This will make creation of children, recursive.
  15764. * @param useVertexColor defines if this LinesMesh supports vertex color
  15765. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15766. */
  15767. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15768. /**
  15769. * If vertex color should be applied to the mesh
  15770. */
  15771. useVertexColor?: boolean | undefined,
  15772. /**
  15773. * If vertex alpha should be applied to the mesh
  15774. */
  15775. useVertexAlpha?: boolean | undefined);
  15776. private _addClipPlaneDefine;
  15777. private _removeClipPlaneDefine;
  15778. isReady(): boolean;
  15779. /**
  15780. * Returns the string "LineMesh"
  15781. */
  15782. getClassName(): string;
  15783. /**
  15784. * @hidden
  15785. */
  15786. get material(): Material;
  15787. /**
  15788. * @hidden
  15789. */
  15790. set material(value: Material);
  15791. /**
  15792. * @hidden
  15793. */
  15794. get checkCollisions(): boolean;
  15795. /** @hidden */
  15796. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15797. /** @hidden */
  15798. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15799. /**
  15800. * Disposes of the line mesh
  15801. * @param doNotRecurse If children should be disposed
  15802. */
  15803. dispose(doNotRecurse?: boolean): void;
  15804. /**
  15805. * Returns a new LineMesh object cloned from the current one.
  15806. */
  15807. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15808. /**
  15809. * Creates a new InstancedLinesMesh object from the mesh model.
  15810. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15811. * @param name defines the name of the new instance
  15812. * @returns a new InstancedLinesMesh
  15813. */
  15814. createInstance(name: string): InstancedLinesMesh;
  15815. }
  15816. /**
  15817. * Creates an instance based on a source LinesMesh
  15818. */
  15819. export class InstancedLinesMesh extends InstancedMesh {
  15820. /**
  15821. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15822. * This margin is expressed in world space coordinates, so its value may vary.
  15823. * Initilized with the intersectionThreshold value of the source LinesMesh
  15824. */
  15825. intersectionThreshold: number;
  15826. constructor(name: string, source: LinesMesh);
  15827. /**
  15828. * Returns the string "InstancedLinesMesh".
  15829. */
  15830. getClassName(): string;
  15831. }
  15832. }
  15833. declare module BABYLON {
  15834. /** @hidden */
  15835. export var linePixelShader: {
  15836. name: string;
  15837. shader: string;
  15838. };
  15839. }
  15840. declare module BABYLON {
  15841. /** @hidden */
  15842. export var lineVertexShader: {
  15843. name: string;
  15844. shader: string;
  15845. };
  15846. }
  15847. declare module BABYLON {
  15848. interface AbstractMesh {
  15849. /**
  15850. * Gets the edgesRenderer associated with the mesh
  15851. */
  15852. edgesRenderer: Nullable<EdgesRenderer>;
  15853. }
  15854. interface LinesMesh {
  15855. /**
  15856. * Enables the edge rendering mode on the mesh.
  15857. * This mode makes the mesh edges visible
  15858. * @param epsilon defines the maximal distance between two angles to detect a face
  15859. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15860. * @returns the currentAbstractMesh
  15861. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15862. */
  15863. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15864. }
  15865. interface InstancedLinesMesh {
  15866. /**
  15867. * Enables the edge rendering mode on the mesh.
  15868. * This mode makes the mesh edges visible
  15869. * @param epsilon defines the maximal distance between two angles to detect a face
  15870. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15871. * @returns the current InstancedLinesMesh
  15872. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15873. */
  15874. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15875. }
  15876. /**
  15877. * Defines the minimum contract an Edges renderer should follow.
  15878. */
  15879. export interface IEdgesRenderer extends IDisposable {
  15880. /**
  15881. * Gets or sets a boolean indicating if the edgesRenderer is active
  15882. */
  15883. isEnabled: boolean;
  15884. /**
  15885. * Renders the edges of the attached mesh,
  15886. */
  15887. render(): void;
  15888. /**
  15889. * Checks wether or not the edges renderer is ready to render.
  15890. * @return true if ready, otherwise false.
  15891. */
  15892. isReady(): boolean;
  15893. }
  15894. /**
  15895. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15896. */
  15897. export class EdgesRenderer implements IEdgesRenderer {
  15898. /**
  15899. * Define the size of the edges with an orthographic camera
  15900. */
  15901. edgesWidthScalerForOrthographic: number;
  15902. /**
  15903. * Define the size of the edges with a perspective camera
  15904. */
  15905. edgesWidthScalerForPerspective: number;
  15906. protected _source: AbstractMesh;
  15907. protected _linesPositions: number[];
  15908. protected _linesNormals: number[];
  15909. protected _linesIndices: number[];
  15910. protected _epsilon: number;
  15911. protected _indicesCount: number;
  15912. protected _lineShader: ShaderMaterial;
  15913. protected _ib: DataBuffer;
  15914. protected _buffers: {
  15915. [key: string]: Nullable<VertexBuffer>;
  15916. };
  15917. protected _checkVerticesInsteadOfIndices: boolean;
  15918. private _meshRebuildObserver;
  15919. private _meshDisposeObserver;
  15920. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15921. isEnabled: boolean;
  15922. /**
  15923. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15924. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15925. * @param source Mesh used to create edges
  15926. * @param epsilon sum of angles in adjacency to check for edge
  15927. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15928. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15929. */
  15930. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15931. protected _prepareRessources(): void;
  15932. /** @hidden */
  15933. _rebuild(): void;
  15934. /**
  15935. * Releases the required resources for the edges renderer
  15936. */
  15937. dispose(): void;
  15938. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15939. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15940. /**
  15941. * Checks if the pair of p0 and p1 is en edge
  15942. * @param faceIndex
  15943. * @param edge
  15944. * @param faceNormals
  15945. * @param p0
  15946. * @param p1
  15947. * @private
  15948. */
  15949. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15950. /**
  15951. * push line into the position, normal and index buffer
  15952. * @protected
  15953. */
  15954. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15955. /**
  15956. * Generates lines edges from adjacencjes
  15957. * @private
  15958. */
  15959. _generateEdgesLines(): void;
  15960. /**
  15961. * Checks wether or not the edges renderer is ready to render.
  15962. * @return true if ready, otherwise false.
  15963. */
  15964. isReady(): boolean;
  15965. /**
  15966. * Renders the edges of the attached mesh,
  15967. */
  15968. render(): void;
  15969. }
  15970. /**
  15971. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15972. */
  15973. export class LineEdgesRenderer extends EdgesRenderer {
  15974. /**
  15975. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15976. * @param source LineMesh used to generate edges
  15977. * @param epsilon not important (specified angle for edge detection)
  15978. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15979. */
  15980. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15981. /**
  15982. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15983. */
  15984. _generateEdgesLines(): void;
  15985. }
  15986. }
  15987. declare module BABYLON {
  15988. /**
  15989. * This represents the object necessary to create a rendering group.
  15990. * This is exclusively used and created by the rendering manager.
  15991. * To modify the behavior, you use the available helpers in your scene or meshes.
  15992. * @hidden
  15993. */
  15994. export class RenderingGroup {
  15995. index: number;
  15996. private static _zeroVector;
  15997. private _scene;
  15998. private _opaqueSubMeshes;
  15999. private _transparentSubMeshes;
  16000. private _alphaTestSubMeshes;
  16001. private _depthOnlySubMeshes;
  16002. private _particleSystems;
  16003. private _spriteManagers;
  16004. private _opaqueSortCompareFn;
  16005. private _alphaTestSortCompareFn;
  16006. private _transparentSortCompareFn;
  16007. private _renderOpaque;
  16008. private _renderAlphaTest;
  16009. private _renderTransparent;
  16010. /** @hidden */
  16011. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16012. onBeforeTransparentRendering: () => void;
  16013. /**
  16014. * Set the opaque sort comparison function.
  16015. * If null the sub meshes will be render in the order they were created
  16016. */
  16017. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16018. /**
  16019. * Set the alpha test sort comparison function.
  16020. * If null the sub meshes will be render in the order they were created
  16021. */
  16022. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16023. /**
  16024. * Set the transparent sort comparison function.
  16025. * If null the sub meshes will be render in the order they were created
  16026. */
  16027. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16028. /**
  16029. * Creates a new rendering group.
  16030. * @param index The rendering group index
  16031. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16032. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16033. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16034. */
  16035. 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>);
  16036. /**
  16037. * Render all the sub meshes contained in the group.
  16038. * @param customRenderFunction Used to override the default render behaviour of the group.
  16039. * @returns true if rendered some submeshes.
  16040. */
  16041. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16042. /**
  16043. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16044. * @param subMeshes The submeshes to render
  16045. */
  16046. private renderOpaqueSorted;
  16047. /**
  16048. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16049. * @param subMeshes The submeshes to render
  16050. */
  16051. private renderAlphaTestSorted;
  16052. /**
  16053. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16054. * @param subMeshes The submeshes to render
  16055. */
  16056. private renderTransparentSorted;
  16057. /**
  16058. * Renders the submeshes in a specified order.
  16059. * @param subMeshes The submeshes to sort before render
  16060. * @param sortCompareFn The comparison function use to sort
  16061. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16062. * @param transparent Specifies to activate blending if true
  16063. */
  16064. private static renderSorted;
  16065. /**
  16066. * Renders the submeshes in the order they were dispatched (no sort applied).
  16067. * @param subMeshes The submeshes to render
  16068. */
  16069. private static renderUnsorted;
  16070. /**
  16071. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16072. * are rendered back to front if in the same alpha index.
  16073. *
  16074. * @param a The first submesh
  16075. * @param b The second submesh
  16076. * @returns The result of the comparison
  16077. */
  16078. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16079. /**
  16080. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16081. * are rendered back to front.
  16082. *
  16083. * @param a The first submesh
  16084. * @param b The second submesh
  16085. * @returns The result of the comparison
  16086. */
  16087. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16088. /**
  16089. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16090. * are rendered front to back (prevent overdraw).
  16091. *
  16092. * @param a The first submesh
  16093. * @param b The second submesh
  16094. * @returns The result of the comparison
  16095. */
  16096. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16097. /**
  16098. * Resets the different lists of submeshes to prepare a new frame.
  16099. */
  16100. prepare(): void;
  16101. dispose(): void;
  16102. /**
  16103. * Inserts the submesh in its correct queue depending on its material.
  16104. * @param subMesh The submesh to dispatch
  16105. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16106. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16107. */
  16108. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16109. dispatchSprites(spriteManager: ISpriteManager): void;
  16110. dispatchParticles(particleSystem: IParticleSystem): void;
  16111. private _renderParticles;
  16112. private _renderSprites;
  16113. }
  16114. }
  16115. declare module BABYLON {
  16116. /**
  16117. * Interface describing the different options available in the rendering manager
  16118. * regarding Auto Clear between groups.
  16119. */
  16120. export interface IRenderingManagerAutoClearSetup {
  16121. /**
  16122. * Defines whether or not autoclear is enable.
  16123. */
  16124. autoClear: boolean;
  16125. /**
  16126. * Defines whether or not to autoclear the depth buffer.
  16127. */
  16128. depth: boolean;
  16129. /**
  16130. * Defines whether or not to autoclear the stencil buffer.
  16131. */
  16132. stencil: boolean;
  16133. }
  16134. /**
  16135. * This class is used by the onRenderingGroupObservable
  16136. */
  16137. export class RenderingGroupInfo {
  16138. /**
  16139. * The Scene that being rendered
  16140. */
  16141. scene: Scene;
  16142. /**
  16143. * The camera currently used for the rendering pass
  16144. */
  16145. camera: Nullable<Camera>;
  16146. /**
  16147. * The ID of the renderingGroup being processed
  16148. */
  16149. renderingGroupId: number;
  16150. }
  16151. /**
  16152. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16153. * It is enable to manage the different groups as well as the different necessary sort functions.
  16154. * This should not be used directly aside of the few static configurations
  16155. */
  16156. export class RenderingManager {
  16157. /**
  16158. * The max id used for rendering groups (not included)
  16159. */
  16160. static MAX_RENDERINGGROUPS: number;
  16161. /**
  16162. * The min id used for rendering groups (included)
  16163. */
  16164. static MIN_RENDERINGGROUPS: number;
  16165. /**
  16166. * Used to globally prevent autoclearing scenes.
  16167. */
  16168. static AUTOCLEAR: boolean;
  16169. /**
  16170. * @hidden
  16171. */
  16172. _useSceneAutoClearSetup: boolean;
  16173. private _scene;
  16174. private _renderingGroups;
  16175. private _depthStencilBufferAlreadyCleaned;
  16176. private _autoClearDepthStencil;
  16177. private _customOpaqueSortCompareFn;
  16178. private _customAlphaTestSortCompareFn;
  16179. private _customTransparentSortCompareFn;
  16180. private _renderingGroupInfo;
  16181. /**
  16182. * Instantiates a new rendering group for a particular scene
  16183. * @param scene Defines the scene the groups belongs to
  16184. */
  16185. constructor(scene: Scene);
  16186. private _clearDepthStencilBuffer;
  16187. /**
  16188. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16189. * @hidden
  16190. */
  16191. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16192. /**
  16193. * Resets the different information of the group to prepare a new frame
  16194. * @hidden
  16195. */
  16196. reset(): void;
  16197. /**
  16198. * Dispose and release the group and its associated resources.
  16199. * @hidden
  16200. */
  16201. dispose(): void;
  16202. /**
  16203. * Clear the info related to rendering groups preventing retention points during dispose.
  16204. */
  16205. freeRenderingGroups(): void;
  16206. private _prepareRenderingGroup;
  16207. /**
  16208. * Add a sprite manager to the rendering manager in order to render it this frame.
  16209. * @param spriteManager Define the sprite manager to render
  16210. */
  16211. dispatchSprites(spriteManager: ISpriteManager): void;
  16212. /**
  16213. * Add a particle system to the rendering manager in order to render it this frame.
  16214. * @param particleSystem Define the particle system to render
  16215. */
  16216. dispatchParticles(particleSystem: IParticleSystem): void;
  16217. /**
  16218. * Add a submesh to the manager in order to render it this frame
  16219. * @param subMesh The submesh to dispatch
  16220. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16221. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16222. */
  16223. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16224. /**
  16225. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16226. * This allowed control for front to back rendering or reversly depending of the special needs.
  16227. *
  16228. * @param renderingGroupId The rendering group id corresponding to its index
  16229. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16230. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16231. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16232. */
  16233. 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;
  16234. /**
  16235. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16236. *
  16237. * @param renderingGroupId The rendering group id corresponding to its index
  16238. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16239. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16240. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16241. */
  16242. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16243. /**
  16244. * Gets the current auto clear configuration for one rendering group of the rendering
  16245. * manager.
  16246. * @param index the rendering group index to get the information for
  16247. * @returns The auto clear setup for the requested rendering group
  16248. */
  16249. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16250. }
  16251. }
  16252. declare module BABYLON {
  16253. /**
  16254. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16255. */
  16256. export interface ICustomShaderOptions {
  16257. /**
  16258. * Gets or sets the custom shader name to use
  16259. */
  16260. shaderName: string;
  16261. /**
  16262. * The list of attribute names used in the shader
  16263. */
  16264. attributes?: string[];
  16265. /**
  16266. * The list of unifrom names used in the shader
  16267. */
  16268. uniforms?: string[];
  16269. /**
  16270. * The list of sampler names used in the shader
  16271. */
  16272. samplers?: string[];
  16273. /**
  16274. * The list of defines used in the shader
  16275. */
  16276. defines?: string[];
  16277. }
  16278. /**
  16279. * Interface to implement to create a shadow generator compatible with BJS.
  16280. */
  16281. export interface IShadowGenerator {
  16282. /**
  16283. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16284. * @returns The render target texture if present otherwise, null
  16285. */
  16286. getShadowMap(): Nullable<RenderTargetTexture>;
  16287. /**
  16288. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16289. * @param subMesh The submesh we want to render in the shadow map
  16290. * @param useInstances Defines wether will draw in the map using instances
  16291. * @returns true if ready otherwise, false
  16292. */
  16293. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16294. /**
  16295. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16296. * @param defines Defines of the material we want to update
  16297. * @param lightIndex Index of the light in the enabled light list of the material
  16298. */
  16299. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16300. /**
  16301. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16302. * defined in the generator but impacting the effect).
  16303. * It implies the unifroms available on the materials are the standard BJS ones.
  16304. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16305. * @param effect The effect we are binfing the information for
  16306. */
  16307. bindShadowLight(lightIndex: string, effect: Effect): void;
  16308. /**
  16309. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16310. * (eq to shadow prjection matrix * light transform matrix)
  16311. * @returns The transform matrix used to create the shadow map
  16312. */
  16313. getTransformMatrix(): Matrix;
  16314. /**
  16315. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16316. * Cube and 2D textures for instance.
  16317. */
  16318. recreateShadowMap(): void;
  16319. /**
  16320. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16321. * @param onCompiled Callback triggered at the and of the effects compilation
  16322. * @param options Sets of optional options forcing the compilation with different modes
  16323. */
  16324. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16325. useInstances: boolean;
  16326. }>): void;
  16327. /**
  16328. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16329. * @param options Sets of optional options forcing the compilation with different modes
  16330. * @returns A promise that resolves when the compilation completes
  16331. */
  16332. forceCompilationAsync(options?: Partial<{
  16333. useInstances: boolean;
  16334. }>): Promise<void>;
  16335. /**
  16336. * Serializes the shadow generator setup to a json object.
  16337. * @returns The serialized JSON object
  16338. */
  16339. serialize(): any;
  16340. /**
  16341. * Disposes the Shadow map and related Textures and effects.
  16342. */
  16343. dispose(): void;
  16344. }
  16345. /**
  16346. * Default implementation IShadowGenerator.
  16347. * This is the main object responsible of generating shadows in the framework.
  16348. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16349. */
  16350. export class ShadowGenerator implements IShadowGenerator {
  16351. /**
  16352. * Name of the shadow generator class
  16353. */
  16354. static CLASSNAME: string;
  16355. /**
  16356. * Shadow generator mode None: no filtering applied.
  16357. */
  16358. static readonly FILTER_NONE: number;
  16359. /**
  16360. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16361. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16362. */
  16363. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16364. /**
  16365. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16366. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16367. */
  16368. static readonly FILTER_POISSONSAMPLING: number;
  16369. /**
  16370. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16371. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16372. */
  16373. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16374. /**
  16375. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16376. * edge artifacts on steep falloff.
  16377. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16378. */
  16379. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16380. /**
  16381. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16382. * edge artifacts on steep falloff.
  16383. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16384. */
  16385. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16386. /**
  16387. * Shadow generator mode PCF: Percentage Closer Filtering
  16388. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16389. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16390. */
  16391. static readonly FILTER_PCF: number;
  16392. /**
  16393. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16394. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16395. * Contact Hardening
  16396. */
  16397. static readonly FILTER_PCSS: number;
  16398. /**
  16399. * Reserved for PCF and PCSS
  16400. * Highest Quality.
  16401. *
  16402. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16403. *
  16404. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16405. */
  16406. static readonly QUALITY_HIGH: number;
  16407. /**
  16408. * Reserved for PCF and PCSS
  16409. * Good tradeoff for quality/perf cross devices
  16410. *
  16411. * Execute PCF on a 3*3 kernel.
  16412. *
  16413. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16414. */
  16415. static readonly QUALITY_MEDIUM: number;
  16416. /**
  16417. * Reserved for PCF and PCSS
  16418. * The lowest quality but the fastest.
  16419. *
  16420. * Execute PCF on a 1*1 kernel.
  16421. *
  16422. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16423. */
  16424. static readonly QUALITY_LOW: number;
  16425. /** Gets or sets the custom shader name to use */
  16426. customShaderOptions: ICustomShaderOptions;
  16427. /**
  16428. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16429. */
  16430. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16431. /**
  16432. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16433. */
  16434. onAfterShadowMapRenderObservable: Observable<Effect>;
  16435. /**
  16436. * Observable triggered before a mesh is rendered in the shadow map.
  16437. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16438. */
  16439. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16440. /**
  16441. * Observable triggered after a mesh is rendered in the shadow map.
  16442. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16443. */
  16444. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16445. protected _bias: number;
  16446. /**
  16447. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16448. */
  16449. get bias(): number;
  16450. /**
  16451. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16452. */
  16453. set bias(bias: number);
  16454. protected _normalBias: number;
  16455. /**
  16456. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16457. */
  16458. get normalBias(): number;
  16459. /**
  16460. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16461. */
  16462. set normalBias(normalBias: number);
  16463. protected _blurBoxOffset: number;
  16464. /**
  16465. * Gets the blur box offset: offset applied during the blur pass.
  16466. * Only useful if useKernelBlur = false
  16467. */
  16468. get blurBoxOffset(): number;
  16469. /**
  16470. * Sets the blur box offset: offset applied during the blur pass.
  16471. * Only useful if useKernelBlur = false
  16472. */
  16473. set blurBoxOffset(value: number);
  16474. protected _blurScale: number;
  16475. /**
  16476. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16477. * 2 means half of the size.
  16478. */
  16479. get blurScale(): number;
  16480. /**
  16481. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16482. * 2 means half of the size.
  16483. */
  16484. set blurScale(value: number);
  16485. protected _blurKernel: number;
  16486. /**
  16487. * Gets the blur kernel: kernel size of the blur pass.
  16488. * Only useful if useKernelBlur = true
  16489. */
  16490. get blurKernel(): number;
  16491. /**
  16492. * Sets the blur kernel: kernel size of the blur pass.
  16493. * Only useful if useKernelBlur = true
  16494. */
  16495. set blurKernel(value: number);
  16496. protected _useKernelBlur: boolean;
  16497. /**
  16498. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16499. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16500. */
  16501. get useKernelBlur(): boolean;
  16502. /**
  16503. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16504. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16505. */
  16506. set useKernelBlur(value: boolean);
  16507. protected _depthScale: number;
  16508. /**
  16509. * Gets the depth scale used in ESM mode.
  16510. */
  16511. get depthScale(): number;
  16512. /**
  16513. * Sets the depth scale used in ESM mode.
  16514. * This can override the scale stored on the light.
  16515. */
  16516. set depthScale(value: number);
  16517. protected _validateFilter(filter: number): number;
  16518. protected _filter: number;
  16519. /**
  16520. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16521. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16522. */
  16523. get filter(): number;
  16524. /**
  16525. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16526. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16527. */
  16528. set filter(value: number);
  16529. /**
  16530. * Gets if the current filter is set to Poisson Sampling.
  16531. */
  16532. get usePoissonSampling(): boolean;
  16533. /**
  16534. * Sets the current filter to Poisson Sampling.
  16535. */
  16536. set usePoissonSampling(value: boolean);
  16537. /**
  16538. * Gets if the current filter is set to ESM.
  16539. */
  16540. get useExponentialShadowMap(): boolean;
  16541. /**
  16542. * Sets the current filter is to ESM.
  16543. */
  16544. set useExponentialShadowMap(value: boolean);
  16545. /**
  16546. * Gets if the current filter is set to filtered ESM.
  16547. */
  16548. get useBlurExponentialShadowMap(): boolean;
  16549. /**
  16550. * Gets if the current filter is set to filtered ESM.
  16551. */
  16552. set useBlurExponentialShadowMap(value: boolean);
  16553. /**
  16554. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16555. * exponential to prevent steep falloff artifacts).
  16556. */
  16557. get useCloseExponentialShadowMap(): boolean;
  16558. /**
  16559. * Sets the current filter to "close ESM" (using the inverse of the
  16560. * exponential to prevent steep falloff artifacts).
  16561. */
  16562. set useCloseExponentialShadowMap(value: boolean);
  16563. /**
  16564. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16565. * exponential to prevent steep falloff artifacts).
  16566. */
  16567. get useBlurCloseExponentialShadowMap(): boolean;
  16568. /**
  16569. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16570. * exponential to prevent steep falloff artifacts).
  16571. */
  16572. set useBlurCloseExponentialShadowMap(value: boolean);
  16573. /**
  16574. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16575. */
  16576. get usePercentageCloserFiltering(): boolean;
  16577. /**
  16578. * Sets the current filter to "PCF" (percentage closer filtering).
  16579. */
  16580. set usePercentageCloserFiltering(value: boolean);
  16581. protected _filteringQuality: number;
  16582. /**
  16583. * Gets the PCF or PCSS Quality.
  16584. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16585. */
  16586. get filteringQuality(): number;
  16587. /**
  16588. * Sets the PCF or PCSS Quality.
  16589. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16590. */
  16591. set filteringQuality(filteringQuality: number);
  16592. /**
  16593. * Gets if the current filter is set to "PCSS" (contact hardening).
  16594. */
  16595. get useContactHardeningShadow(): boolean;
  16596. /**
  16597. * Sets the current filter to "PCSS" (contact hardening).
  16598. */
  16599. set useContactHardeningShadow(value: boolean);
  16600. protected _contactHardeningLightSizeUVRatio: number;
  16601. /**
  16602. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16603. * Using a ratio helps keeping shape stability independently of the map size.
  16604. *
  16605. * It does not account for the light projection as it was having too much
  16606. * instability during the light setup or during light position changes.
  16607. *
  16608. * Only valid if useContactHardeningShadow is true.
  16609. */
  16610. get contactHardeningLightSizeUVRatio(): number;
  16611. /**
  16612. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16613. * Using a ratio helps keeping shape stability independently of the map size.
  16614. *
  16615. * It does not account for the light projection as it was having too much
  16616. * instability during the light setup or during light position changes.
  16617. *
  16618. * Only valid if useContactHardeningShadow is true.
  16619. */
  16620. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16621. protected _darkness: number;
  16622. /** Gets or sets the actual darkness of a shadow */
  16623. get darkness(): number;
  16624. set darkness(value: number);
  16625. /**
  16626. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16627. * 0 means strongest and 1 would means no shadow.
  16628. * @returns the darkness.
  16629. */
  16630. getDarkness(): number;
  16631. /**
  16632. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16633. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16634. * @returns the shadow generator allowing fluent coding.
  16635. */
  16636. setDarkness(darkness: number): ShadowGenerator;
  16637. protected _transparencyShadow: boolean;
  16638. /** Gets or sets the ability to have transparent shadow */
  16639. get transparencyShadow(): boolean;
  16640. set transparencyShadow(value: boolean);
  16641. /**
  16642. * Sets the ability to have transparent shadow (boolean).
  16643. * @param transparent True if transparent else False
  16644. * @returns the shadow generator allowing fluent coding
  16645. */
  16646. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16647. protected _shadowMap: Nullable<RenderTargetTexture>;
  16648. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16649. /**
  16650. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16651. * @returns The render target texture if present otherwise, null
  16652. */
  16653. getShadowMap(): Nullable<RenderTargetTexture>;
  16654. /**
  16655. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16656. * @returns The render target texture if the shadow map is present otherwise, null
  16657. */
  16658. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16659. /**
  16660. * Gets the class name of that object
  16661. * @returns "ShadowGenerator"
  16662. */
  16663. getClassName(): string;
  16664. /**
  16665. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16666. * @param mesh Mesh to add
  16667. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16668. * @returns the Shadow Generator itself
  16669. */
  16670. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16671. /**
  16672. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16673. * @param mesh Mesh to remove
  16674. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16675. * @returns the Shadow Generator itself
  16676. */
  16677. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16678. /**
  16679. * Controls the extent to which the shadows fade out at the edge of the frustum
  16680. */
  16681. frustumEdgeFalloff: number;
  16682. protected _light: IShadowLight;
  16683. /**
  16684. * Returns the associated light object.
  16685. * @returns the light generating the shadow
  16686. */
  16687. getLight(): IShadowLight;
  16688. /**
  16689. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16690. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16691. * It might on the other hand introduce peter panning.
  16692. */
  16693. forceBackFacesOnly: boolean;
  16694. protected _scene: Scene;
  16695. protected _lightDirection: Vector3;
  16696. protected _effect: Effect;
  16697. protected _viewMatrix: Matrix;
  16698. protected _projectionMatrix: Matrix;
  16699. protected _transformMatrix: Matrix;
  16700. protected _cachedPosition: Vector3;
  16701. protected _cachedDirection: Vector3;
  16702. protected _cachedDefines: string;
  16703. protected _currentRenderID: number;
  16704. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16705. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16706. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16707. protected _blurPostProcesses: PostProcess[];
  16708. protected _mapSize: number;
  16709. protected _currentFaceIndex: number;
  16710. protected _currentFaceIndexCache: number;
  16711. protected _textureType: number;
  16712. protected _defaultTextureMatrix: Matrix;
  16713. protected _storedUniqueId: Nullable<number>;
  16714. /** @hidden */
  16715. static _SceneComponentInitialization: (scene: Scene) => void;
  16716. /**
  16717. * Creates a ShadowGenerator object.
  16718. * A ShadowGenerator is the required tool to use the shadows.
  16719. * Each light casting shadows needs to use its own ShadowGenerator.
  16720. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16721. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16722. * @param light The light object generating the shadows.
  16723. * @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.
  16724. */
  16725. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16726. protected _initializeGenerator(): void;
  16727. protected _createTargetRenderTexture(): void;
  16728. protected _initializeShadowMap(): void;
  16729. protected _initializeBlurRTTAndPostProcesses(): void;
  16730. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16731. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16732. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16733. protected _applyFilterValues(): void;
  16734. /**
  16735. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16736. * @param onCompiled Callback triggered at the and of the effects compilation
  16737. * @param options Sets of optional options forcing the compilation with different modes
  16738. */
  16739. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16740. useInstances: boolean;
  16741. }>): void;
  16742. /**
  16743. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16744. * @param options Sets of optional options forcing the compilation with different modes
  16745. * @returns A promise that resolves when the compilation completes
  16746. */
  16747. forceCompilationAsync(options?: Partial<{
  16748. useInstances: boolean;
  16749. }>): Promise<void>;
  16750. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16751. /**
  16752. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16753. * @param subMesh The submesh we want to render in the shadow map
  16754. * @param useInstances Defines wether will draw in the map using instances
  16755. * @returns true if ready otherwise, false
  16756. */
  16757. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16758. /**
  16759. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16760. * @param defines Defines of the material we want to update
  16761. * @param lightIndex Index of the light in the enabled light list of the material
  16762. */
  16763. prepareDefines(defines: any, lightIndex: number): void;
  16764. /**
  16765. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16766. * defined in the generator but impacting the effect).
  16767. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16768. * @param effect The effect we are binfing the information for
  16769. */
  16770. bindShadowLight(lightIndex: string, effect: Effect): void;
  16771. /**
  16772. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16773. * (eq to shadow prjection matrix * light transform matrix)
  16774. * @returns The transform matrix used to create the shadow map
  16775. */
  16776. getTransformMatrix(): Matrix;
  16777. /**
  16778. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16779. * Cube and 2D textures for instance.
  16780. */
  16781. recreateShadowMap(): void;
  16782. protected _disposeBlurPostProcesses(): void;
  16783. protected _disposeRTTandPostProcesses(): void;
  16784. /**
  16785. * Disposes the ShadowGenerator.
  16786. * Returns nothing.
  16787. */
  16788. dispose(): void;
  16789. /**
  16790. * Serializes the shadow generator setup to a json object.
  16791. * @returns The serialized JSON object
  16792. */
  16793. serialize(): any;
  16794. /**
  16795. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16796. * @param parsedShadowGenerator The JSON object to parse
  16797. * @param scene The scene to create the shadow map for
  16798. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16799. * @returns The parsed shadow generator
  16800. */
  16801. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16802. }
  16803. }
  16804. declare module BABYLON {
  16805. /**
  16806. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16807. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16808. * 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.
  16809. */
  16810. export abstract class Light extends Node {
  16811. /**
  16812. * Falloff Default: light is falling off following the material specification:
  16813. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16814. */
  16815. static readonly FALLOFF_DEFAULT: number;
  16816. /**
  16817. * Falloff Physical: light is falling off following the inverse squared distance law.
  16818. */
  16819. static readonly FALLOFF_PHYSICAL: number;
  16820. /**
  16821. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16822. * to enhance interoperability with other engines.
  16823. */
  16824. static readonly FALLOFF_GLTF: number;
  16825. /**
  16826. * Falloff Standard: light is falling off like in the standard material
  16827. * to enhance interoperability with other materials.
  16828. */
  16829. static readonly FALLOFF_STANDARD: number;
  16830. /**
  16831. * If every light affecting the material is in this lightmapMode,
  16832. * material.lightmapTexture adds or multiplies
  16833. * (depends on material.useLightmapAsShadowmap)
  16834. * after every other light calculations.
  16835. */
  16836. static readonly LIGHTMAP_DEFAULT: number;
  16837. /**
  16838. * material.lightmapTexture as only diffuse lighting from this light
  16839. * adds only specular lighting from this light
  16840. * adds dynamic shadows
  16841. */
  16842. static readonly LIGHTMAP_SPECULAR: number;
  16843. /**
  16844. * material.lightmapTexture as only lighting
  16845. * no light calculation from this light
  16846. * only adds dynamic shadows from this light
  16847. */
  16848. static readonly LIGHTMAP_SHADOWSONLY: number;
  16849. /**
  16850. * Each light type uses the default quantity according to its type:
  16851. * point/spot lights use luminous intensity
  16852. * directional lights use illuminance
  16853. */
  16854. static readonly INTENSITYMODE_AUTOMATIC: number;
  16855. /**
  16856. * lumen (lm)
  16857. */
  16858. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16859. /**
  16860. * candela (lm/sr)
  16861. */
  16862. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16863. /**
  16864. * lux (lm/m^2)
  16865. */
  16866. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16867. /**
  16868. * nit (cd/m^2)
  16869. */
  16870. static readonly INTENSITYMODE_LUMINANCE: number;
  16871. /**
  16872. * Light type const id of the point light.
  16873. */
  16874. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16875. /**
  16876. * Light type const id of the directional light.
  16877. */
  16878. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16879. /**
  16880. * Light type const id of the spot light.
  16881. */
  16882. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16883. /**
  16884. * Light type const id of the hemispheric light.
  16885. */
  16886. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16887. /**
  16888. * Diffuse gives the basic color to an object.
  16889. */
  16890. diffuse: Color3;
  16891. /**
  16892. * Specular produces a highlight color on an object.
  16893. * Note: This is note affecting PBR materials.
  16894. */
  16895. specular: Color3;
  16896. /**
  16897. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16898. * falling off base on range or angle.
  16899. * This can be set to any values in Light.FALLOFF_x.
  16900. *
  16901. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16902. * other types of materials.
  16903. */
  16904. falloffType: number;
  16905. /**
  16906. * Strength of the light.
  16907. * Note: By default it is define in the framework own unit.
  16908. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16909. */
  16910. intensity: number;
  16911. private _range;
  16912. protected _inverseSquaredRange: number;
  16913. /**
  16914. * Defines how far from the source the light is impacting in scene units.
  16915. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16916. */
  16917. get range(): number;
  16918. /**
  16919. * Defines how far from the source the light is impacting in scene units.
  16920. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16921. */
  16922. set range(value: number);
  16923. /**
  16924. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16925. * of light.
  16926. */
  16927. private _photometricScale;
  16928. private _intensityMode;
  16929. /**
  16930. * Gets the photometric scale used to interpret the intensity.
  16931. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16932. */
  16933. get intensityMode(): number;
  16934. /**
  16935. * Sets the photometric scale used to interpret the intensity.
  16936. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16937. */
  16938. set intensityMode(value: number);
  16939. private _radius;
  16940. /**
  16941. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16942. */
  16943. get radius(): number;
  16944. /**
  16945. * sets the light radius used by PBR Materials to simulate soft area lights.
  16946. */
  16947. set radius(value: number);
  16948. private _renderPriority;
  16949. /**
  16950. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16951. * exceeding the number allowed of the materials.
  16952. */
  16953. renderPriority: number;
  16954. private _shadowEnabled;
  16955. /**
  16956. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16957. * the current shadow generator.
  16958. */
  16959. get shadowEnabled(): boolean;
  16960. /**
  16961. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16962. * the current shadow generator.
  16963. */
  16964. set shadowEnabled(value: boolean);
  16965. private _includedOnlyMeshes;
  16966. /**
  16967. * Gets the only meshes impacted by this light.
  16968. */
  16969. get includedOnlyMeshes(): AbstractMesh[];
  16970. /**
  16971. * Sets the only meshes impacted by this light.
  16972. */
  16973. set includedOnlyMeshes(value: AbstractMesh[]);
  16974. private _excludedMeshes;
  16975. /**
  16976. * Gets the meshes not impacted by this light.
  16977. */
  16978. get excludedMeshes(): AbstractMesh[];
  16979. /**
  16980. * Sets the meshes not impacted by this light.
  16981. */
  16982. set excludedMeshes(value: AbstractMesh[]);
  16983. private _excludeWithLayerMask;
  16984. /**
  16985. * Gets the layer id use to find what meshes are not impacted by the light.
  16986. * Inactive if 0
  16987. */
  16988. get excludeWithLayerMask(): number;
  16989. /**
  16990. * Sets the layer id use to find what meshes are not impacted by the light.
  16991. * Inactive if 0
  16992. */
  16993. set excludeWithLayerMask(value: number);
  16994. private _includeOnlyWithLayerMask;
  16995. /**
  16996. * Gets the layer id use to find what meshes are impacted by the light.
  16997. * Inactive if 0
  16998. */
  16999. get includeOnlyWithLayerMask(): number;
  17000. /**
  17001. * Sets the layer id use to find what meshes are impacted by the light.
  17002. * Inactive if 0
  17003. */
  17004. set includeOnlyWithLayerMask(value: number);
  17005. private _lightmapMode;
  17006. /**
  17007. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17008. */
  17009. get lightmapMode(): number;
  17010. /**
  17011. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17012. */
  17013. set lightmapMode(value: number);
  17014. /**
  17015. * Shadow generator associted to the light.
  17016. * @hidden Internal use only.
  17017. */
  17018. _shadowGenerator: Nullable<IShadowGenerator>;
  17019. /**
  17020. * @hidden Internal use only.
  17021. */
  17022. _excludedMeshesIds: string[];
  17023. /**
  17024. * @hidden Internal use only.
  17025. */
  17026. _includedOnlyMeshesIds: string[];
  17027. /**
  17028. * The current light unifom buffer.
  17029. * @hidden Internal use only.
  17030. */
  17031. _uniformBuffer: UniformBuffer;
  17032. /** @hidden */
  17033. _renderId: number;
  17034. /**
  17035. * Creates a Light object in the scene.
  17036. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17037. * @param name The firendly name of the light
  17038. * @param scene The scene the light belongs too
  17039. */
  17040. constructor(name: string, scene: Scene);
  17041. protected abstract _buildUniformLayout(): void;
  17042. /**
  17043. * Sets the passed Effect "effect" with the Light information.
  17044. * @param effect The effect to update
  17045. * @param lightIndex The index of the light in the effect to update
  17046. * @returns The light
  17047. */
  17048. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17049. /**
  17050. * Sets the passed Effect "effect" with the Light textures.
  17051. * @param effect The effect to update
  17052. * @param lightIndex The index of the light in the effect to update
  17053. * @returns The light
  17054. */
  17055. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17056. /**
  17057. * Binds the lights information from the scene to the effect for the given mesh.
  17058. * @param lightIndex Light index
  17059. * @param scene The scene where the light belongs to
  17060. * @param effect The effect we are binding the data to
  17061. * @param useSpecular Defines if specular is supported
  17062. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17063. */
  17064. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17065. /**
  17066. * Sets the passed Effect "effect" with the Light information.
  17067. * @param effect The effect to update
  17068. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17069. * @returns The light
  17070. */
  17071. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17072. /**
  17073. * Returns the string "Light".
  17074. * @returns the class name
  17075. */
  17076. getClassName(): string;
  17077. /** @hidden */
  17078. readonly _isLight: boolean;
  17079. /**
  17080. * Converts the light information to a readable string for debug purpose.
  17081. * @param fullDetails Supports for multiple levels of logging within scene loading
  17082. * @returns the human readable light info
  17083. */
  17084. toString(fullDetails?: boolean): string;
  17085. /** @hidden */
  17086. protected _syncParentEnabledState(): void;
  17087. /**
  17088. * Set the enabled state of this node.
  17089. * @param value - the new enabled state
  17090. */
  17091. setEnabled(value: boolean): void;
  17092. /**
  17093. * Returns the Light associated shadow generator if any.
  17094. * @return the associated shadow generator.
  17095. */
  17096. getShadowGenerator(): Nullable<IShadowGenerator>;
  17097. /**
  17098. * Returns a Vector3, the absolute light position in the World.
  17099. * @returns the world space position of the light
  17100. */
  17101. getAbsolutePosition(): Vector3;
  17102. /**
  17103. * Specifies if the light will affect the passed mesh.
  17104. * @param mesh The mesh to test against the light
  17105. * @return true the mesh is affected otherwise, false.
  17106. */
  17107. canAffectMesh(mesh: AbstractMesh): boolean;
  17108. /**
  17109. * Sort function to order lights for rendering.
  17110. * @param a First Light object to compare to second.
  17111. * @param b Second Light object to compare first.
  17112. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17113. */
  17114. static CompareLightsPriority(a: Light, b: Light): number;
  17115. /**
  17116. * Releases resources associated with this node.
  17117. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17118. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17119. */
  17120. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17121. /**
  17122. * Returns the light type ID (integer).
  17123. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17124. */
  17125. getTypeID(): number;
  17126. /**
  17127. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17128. * @returns the scaled intensity in intensity mode unit
  17129. */
  17130. getScaledIntensity(): number;
  17131. /**
  17132. * Returns a new Light object, named "name", from the current one.
  17133. * @param name The name of the cloned light
  17134. * @returns the new created light
  17135. */
  17136. clone(name: string): Nullable<Light>;
  17137. /**
  17138. * Serializes the current light into a Serialization object.
  17139. * @returns the serialized object.
  17140. */
  17141. serialize(): any;
  17142. /**
  17143. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17144. * This new light is named "name" and added to the passed scene.
  17145. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17146. * @param name The friendly name of the light
  17147. * @param scene The scene the new light will belong to
  17148. * @returns the constructor function
  17149. */
  17150. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17151. /**
  17152. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17153. * @param parsedLight The JSON representation of the light
  17154. * @param scene The scene to create the parsed light in
  17155. * @returns the created light after parsing
  17156. */
  17157. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17158. private _hookArrayForExcluded;
  17159. private _hookArrayForIncludedOnly;
  17160. private _resyncMeshes;
  17161. /**
  17162. * Forces the meshes to update their light related information in their rendering used effects
  17163. * @hidden Internal Use Only
  17164. */
  17165. _markMeshesAsLightDirty(): void;
  17166. /**
  17167. * Recomputes the cached photometric scale if needed.
  17168. */
  17169. private _computePhotometricScale;
  17170. /**
  17171. * Returns the Photometric Scale according to the light type and intensity mode.
  17172. */
  17173. private _getPhotometricScale;
  17174. /**
  17175. * Reorder the light in the scene according to their defined priority.
  17176. * @hidden Internal Use Only
  17177. */
  17178. _reorderLightsInScene(): void;
  17179. /**
  17180. * Prepares the list of defines specific to the light type.
  17181. * @param defines the list of defines
  17182. * @param lightIndex defines the index of the light for the effect
  17183. */
  17184. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17185. }
  17186. }
  17187. declare module BABYLON {
  17188. /**
  17189. * Interface used to define Action
  17190. */
  17191. export interface IAction {
  17192. /**
  17193. * Trigger for the action
  17194. */
  17195. trigger: number;
  17196. /** Options of the trigger */
  17197. triggerOptions: any;
  17198. /**
  17199. * Gets the trigger parameters
  17200. * @returns the trigger parameters
  17201. */
  17202. getTriggerParameter(): any;
  17203. /**
  17204. * Internal only - executes current action event
  17205. * @hidden
  17206. */
  17207. _executeCurrent(evt?: ActionEvent): void;
  17208. /**
  17209. * Serialize placeholder for child classes
  17210. * @param parent of child
  17211. * @returns the serialized object
  17212. */
  17213. serialize(parent: any): any;
  17214. /**
  17215. * Internal only
  17216. * @hidden
  17217. */
  17218. _prepare(): void;
  17219. /**
  17220. * Internal only - manager for action
  17221. * @hidden
  17222. */
  17223. _actionManager: AbstractActionManager;
  17224. /**
  17225. * Adds action to chain of actions, may be a DoNothingAction
  17226. * @param action defines the next action to execute
  17227. * @returns The action passed in
  17228. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17229. */
  17230. then(action: IAction): IAction;
  17231. }
  17232. /**
  17233. * The action to be carried out following a trigger
  17234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17235. */
  17236. export class Action implements IAction {
  17237. /** the trigger, with or without parameters, for the action */
  17238. triggerOptions: any;
  17239. /**
  17240. * Trigger for the action
  17241. */
  17242. trigger: number;
  17243. /**
  17244. * Internal only - manager for action
  17245. * @hidden
  17246. */
  17247. _actionManager: ActionManager;
  17248. private _nextActiveAction;
  17249. private _child;
  17250. private _condition?;
  17251. private _triggerParameter;
  17252. /**
  17253. * An event triggered prior to action being executed.
  17254. */
  17255. onBeforeExecuteObservable: Observable<Action>;
  17256. /**
  17257. * Creates a new Action
  17258. * @param triggerOptions the trigger, with or without parameters, for the action
  17259. * @param condition an optional determinant of action
  17260. */
  17261. constructor(
  17262. /** the trigger, with or without parameters, for the action */
  17263. triggerOptions: any, condition?: Condition);
  17264. /**
  17265. * Internal only
  17266. * @hidden
  17267. */
  17268. _prepare(): void;
  17269. /**
  17270. * Gets the trigger parameters
  17271. * @returns the trigger parameters
  17272. */
  17273. getTriggerParameter(): any;
  17274. /**
  17275. * Internal only - executes current action event
  17276. * @hidden
  17277. */
  17278. _executeCurrent(evt?: ActionEvent): void;
  17279. /**
  17280. * Execute placeholder for child classes
  17281. * @param evt optional action event
  17282. */
  17283. execute(evt?: ActionEvent): void;
  17284. /**
  17285. * Skips to next active action
  17286. */
  17287. skipToNextActiveAction(): void;
  17288. /**
  17289. * Adds action to chain of actions, may be a DoNothingAction
  17290. * @param action defines the next action to execute
  17291. * @returns The action passed in
  17292. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17293. */
  17294. then(action: Action): Action;
  17295. /**
  17296. * Internal only
  17297. * @hidden
  17298. */
  17299. _getProperty(propertyPath: string): string;
  17300. /**
  17301. * Internal only
  17302. * @hidden
  17303. */
  17304. _getEffectiveTarget(target: any, propertyPath: string): any;
  17305. /**
  17306. * Serialize placeholder for child classes
  17307. * @param parent of child
  17308. * @returns the serialized object
  17309. */
  17310. serialize(parent: any): any;
  17311. /**
  17312. * Internal only called by serialize
  17313. * @hidden
  17314. */
  17315. protected _serialize(serializedAction: any, parent?: any): any;
  17316. /**
  17317. * Internal only
  17318. * @hidden
  17319. */
  17320. static _SerializeValueAsString: (value: any) => string;
  17321. /**
  17322. * Internal only
  17323. * @hidden
  17324. */
  17325. static _GetTargetProperty: (target: Node | Scene) => {
  17326. name: string;
  17327. targetType: string;
  17328. value: string;
  17329. };
  17330. }
  17331. }
  17332. declare module BABYLON {
  17333. /**
  17334. * A Condition applied to an Action
  17335. */
  17336. export class Condition {
  17337. /**
  17338. * Internal only - manager for action
  17339. * @hidden
  17340. */
  17341. _actionManager: ActionManager;
  17342. /**
  17343. * Internal only
  17344. * @hidden
  17345. */
  17346. _evaluationId: number;
  17347. /**
  17348. * Internal only
  17349. * @hidden
  17350. */
  17351. _currentResult: boolean;
  17352. /**
  17353. * Creates a new Condition
  17354. * @param actionManager the manager of the action the condition is applied to
  17355. */
  17356. constructor(actionManager: ActionManager);
  17357. /**
  17358. * Check if the current condition is valid
  17359. * @returns a boolean
  17360. */
  17361. isValid(): boolean;
  17362. /**
  17363. * Internal only
  17364. * @hidden
  17365. */
  17366. _getProperty(propertyPath: string): string;
  17367. /**
  17368. * Internal only
  17369. * @hidden
  17370. */
  17371. _getEffectiveTarget(target: any, propertyPath: string): any;
  17372. /**
  17373. * Serialize placeholder for child classes
  17374. * @returns the serialized object
  17375. */
  17376. serialize(): any;
  17377. /**
  17378. * Internal only
  17379. * @hidden
  17380. */
  17381. protected _serialize(serializedCondition: any): any;
  17382. }
  17383. /**
  17384. * Defines specific conditional operators as extensions of Condition
  17385. */
  17386. export class ValueCondition extends Condition {
  17387. /** path to specify the property of the target the conditional operator uses */
  17388. propertyPath: string;
  17389. /** the value compared by the conditional operator against the current value of the property */
  17390. value: any;
  17391. /** the conditional operator, default ValueCondition.IsEqual */
  17392. operator: number;
  17393. /**
  17394. * Internal only
  17395. * @hidden
  17396. */
  17397. private static _IsEqual;
  17398. /**
  17399. * Internal only
  17400. * @hidden
  17401. */
  17402. private static _IsDifferent;
  17403. /**
  17404. * Internal only
  17405. * @hidden
  17406. */
  17407. private static _IsGreater;
  17408. /**
  17409. * Internal only
  17410. * @hidden
  17411. */
  17412. private static _IsLesser;
  17413. /**
  17414. * returns the number for IsEqual
  17415. */
  17416. static get IsEqual(): number;
  17417. /**
  17418. * Returns the number for IsDifferent
  17419. */
  17420. static get IsDifferent(): number;
  17421. /**
  17422. * Returns the number for IsGreater
  17423. */
  17424. static get IsGreater(): number;
  17425. /**
  17426. * Returns the number for IsLesser
  17427. */
  17428. static get IsLesser(): number;
  17429. /**
  17430. * Internal only The action manager for the condition
  17431. * @hidden
  17432. */
  17433. _actionManager: ActionManager;
  17434. /**
  17435. * Internal only
  17436. * @hidden
  17437. */
  17438. private _target;
  17439. /**
  17440. * Internal only
  17441. * @hidden
  17442. */
  17443. private _effectiveTarget;
  17444. /**
  17445. * Internal only
  17446. * @hidden
  17447. */
  17448. private _property;
  17449. /**
  17450. * Creates a new ValueCondition
  17451. * @param actionManager manager for the action the condition applies to
  17452. * @param target for the action
  17453. * @param propertyPath path to specify the property of the target the conditional operator uses
  17454. * @param value the value compared by the conditional operator against the current value of the property
  17455. * @param operator the conditional operator, default ValueCondition.IsEqual
  17456. */
  17457. constructor(actionManager: ActionManager, target: any,
  17458. /** path to specify the property of the target the conditional operator uses */
  17459. propertyPath: string,
  17460. /** the value compared by the conditional operator against the current value of the property */
  17461. value: any,
  17462. /** the conditional operator, default ValueCondition.IsEqual */
  17463. operator?: number);
  17464. /**
  17465. * Compares the given value with the property value for the specified conditional operator
  17466. * @returns the result of the comparison
  17467. */
  17468. isValid(): boolean;
  17469. /**
  17470. * Serialize the ValueCondition into a JSON compatible object
  17471. * @returns serialization object
  17472. */
  17473. serialize(): any;
  17474. /**
  17475. * Gets the name of the conditional operator for the ValueCondition
  17476. * @param operator the conditional operator
  17477. * @returns the name
  17478. */
  17479. static GetOperatorName(operator: number): string;
  17480. }
  17481. /**
  17482. * Defines a predicate condition as an extension of Condition
  17483. */
  17484. export class PredicateCondition extends Condition {
  17485. /** defines the predicate function used to validate the condition */
  17486. predicate: () => boolean;
  17487. /**
  17488. * Internal only - manager for action
  17489. * @hidden
  17490. */
  17491. _actionManager: ActionManager;
  17492. /**
  17493. * Creates a new PredicateCondition
  17494. * @param actionManager manager for the action the condition applies to
  17495. * @param predicate defines the predicate function used to validate the condition
  17496. */
  17497. constructor(actionManager: ActionManager,
  17498. /** defines the predicate function used to validate the condition */
  17499. predicate: () => boolean);
  17500. /**
  17501. * @returns the validity of the predicate condition
  17502. */
  17503. isValid(): boolean;
  17504. }
  17505. /**
  17506. * Defines a state condition as an extension of Condition
  17507. */
  17508. export class StateCondition extends Condition {
  17509. /** Value to compare with target state */
  17510. value: string;
  17511. /**
  17512. * Internal only - manager for action
  17513. * @hidden
  17514. */
  17515. _actionManager: ActionManager;
  17516. /**
  17517. * Internal only
  17518. * @hidden
  17519. */
  17520. private _target;
  17521. /**
  17522. * Creates a new StateCondition
  17523. * @param actionManager manager for the action the condition applies to
  17524. * @param target of the condition
  17525. * @param value to compare with target state
  17526. */
  17527. constructor(actionManager: ActionManager, target: any,
  17528. /** Value to compare with target state */
  17529. value: string);
  17530. /**
  17531. * Gets a boolean indicating if the current condition is met
  17532. * @returns the validity of the state
  17533. */
  17534. isValid(): boolean;
  17535. /**
  17536. * Serialize the StateCondition into a JSON compatible object
  17537. * @returns serialization object
  17538. */
  17539. serialize(): any;
  17540. }
  17541. }
  17542. declare module BABYLON {
  17543. /**
  17544. * This defines an action responsible to toggle a boolean once triggered.
  17545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17546. */
  17547. export class SwitchBooleanAction extends Action {
  17548. /**
  17549. * The path to the boolean property in the target object
  17550. */
  17551. propertyPath: string;
  17552. private _target;
  17553. private _effectiveTarget;
  17554. private _property;
  17555. /**
  17556. * Instantiate the action
  17557. * @param triggerOptions defines the trigger options
  17558. * @param target defines the object containing the boolean
  17559. * @param propertyPath defines the path to the boolean property in the target object
  17560. * @param condition defines the trigger related conditions
  17561. */
  17562. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17563. /** @hidden */
  17564. _prepare(): void;
  17565. /**
  17566. * Execute the action toggle the boolean value.
  17567. */
  17568. execute(): void;
  17569. /**
  17570. * Serializes the actions and its related information.
  17571. * @param parent defines the object to serialize in
  17572. * @returns the serialized object
  17573. */
  17574. serialize(parent: any): any;
  17575. }
  17576. /**
  17577. * This defines an action responsible to set a the state field of the target
  17578. * to a desired value once triggered.
  17579. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17580. */
  17581. export class SetStateAction extends Action {
  17582. /**
  17583. * The value to store in the state field.
  17584. */
  17585. value: string;
  17586. private _target;
  17587. /**
  17588. * Instantiate the action
  17589. * @param triggerOptions defines the trigger options
  17590. * @param target defines the object containing the state property
  17591. * @param value defines the value to store in the state field
  17592. * @param condition defines the trigger related conditions
  17593. */
  17594. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17595. /**
  17596. * Execute the action and store the value on the target state property.
  17597. */
  17598. execute(): void;
  17599. /**
  17600. * Serializes the actions and its related information.
  17601. * @param parent defines the object to serialize in
  17602. * @returns the serialized object
  17603. */
  17604. serialize(parent: any): any;
  17605. }
  17606. /**
  17607. * This defines an action responsible to set a property of the target
  17608. * to a desired value once triggered.
  17609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17610. */
  17611. export class SetValueAction extends Action {
  17612. /**
  17613. * The path of the property to set in the target.
  17614. */
  17615. propertyPath: string;
  17616. /**
  17617. * The value to set in the property
  17618. */
  17619. value: any;
  17620. private _target;
  17621. private _effectiveTarget;
  17622. private _property;
  17623. /**
  17624. * Instantiate the action
  17625. * @param triggerOptions defines the trigger options
  17626. * @param target defines the object containing the property
  17627. * @param propertyPath defines the path of the property to set in the target
  17628. * @param value defines the value to set in the property
  17629. * @param condition defines the trigger related conditions
  17630. */
  17631. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17632. /** @hidden */
  17633. _prepare(): void;
  17634. /**
  17635. * Execute the action and set the targetted property to the desired value.
  17636. */
  17637. execute(): void;
  17638. /**
  17639. * Serializes the actions and its related information.
  17640. * @param parent defines the object to serialize in
  17641. * @returns the serialized object
  17642. */
  17643. serialize(parent: any): any;
  17644. }
  17645. /**
  17646. * This defines an action responsible to increment the target value
  17647. * to a desired value once triggered.
  17648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17649. */
  17650. export class IncrementValueAction extends Action {
  17651. /**
  17652. * The path of the property to increment in the target.
  17653. */
  17654. propertyPath: string;
  17655. /**
  17656. * The value we should increment the property by.
  17657. */
  17658. value: any;
  17659. private _target;
  17660. private _effectiveTarget;
  17661. private _property;
  17662. /**
  17663. * Instantiate the action
  17664. * @param triggerOptions defines the trigger options
  17665. * @param target defines the object containing the property
  17666. * @param propertyPath defines the path of the property to increment in the target
  17667. * @param value defines the value value we should increment the property by
  17668. * @param condition defines the trigger related conditions
  17669. */
  17670. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17671. /** @hidden */
  17672. _prepare(): void;
  17673. /**
  17674. * Execute the action and increment the target of the value amount.
  17675. */
  17676. execute(): void;
  17677. /**
  17678. * Serializes the actions and its related information.
  17679. * @param parent defines the object to serialize in
  17680. * @returns the serialized object
  17681. */
  17682. serialize(parent: any): any;
  17683. }
  17684. /**
  17685. * This defines an action responsible to start an animation once triggered.
  17686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17687. */
  17688. export class PlayAnimationAction extends Action {
  17689. /**
  17690. * Where the animation should start (animation frame)
  17691. */
  17692. from: number;
  17693. /**
  17694. * Where the animation should stop (animation frame)
  17695. */
  17696. to: number;
  17697. /**
  17698. * Define if the animation should loop or stop after the first play.
  17699. */
  17700. loop?: boolean;
  17701. private _target;
  17702. /**
  17703. * Instantiate the action
  17704. * @param triggerOptions defines the trigger options
  17705. * @param target defines the target animation or animation name
  17706. * @param from defines from where the animation should start (animation frame)
  17707. * @param end defines where the animation should stop (animation frame)
  17708. * @param loop defines if the animation should loop or stop after the first play
  17709. * @param condition defines the trigger related conditions
  17710. */
  17711. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17712. /** @hidden */
  17713. _prepare(): void;
  17714. /**
  17715. * Execute the action and play the animation.
  17716. */
  17717. execute(): void;
  17718. /**
  17719. * Serializes the actions and its related information.
  17720. * @param parent defines the object to serialize in
  17721. * @returns the serialized object
  17722. */
  17723. serialize(parent: any): any;
  17724. }
  17725. /**
  17726. * This defines an action responsible to stop an animation once triggered.
  17727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17728. */
  17729. export class StopAnimationAction extends Action {
  17730. private _target;
  17731. /**
  17732. * Instantiate the action
  17733. * @param triggerOptions defines the trigger options
  17734. * @param target defines the target animation or animation name
  17735. * @param condition defines the trigger related conditions
  17736. */
  17737. constructor(triggerOptions: any, target: any, condition?: Condition);
  17738. /** @hidden */
  17739. _prepare(): void;
  17740. /**
  17741. * Execute the action and stop the animation.
  17742. */
  17743. execute(): void;
  17744. /**
  17745. * Serializes the actions and its related information.
  17746. * @param parent defines the object to serialize in
  17747. * @returns the serialized object
  17748. */
  17749. serialize(parent: any): any;
  17750. }
  17751. /**
  17752. * This defines an action responsible that does nothing once triggered.
  17753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17754. */
  17755. export class DoNothingAction extends Action {
  17756. /**
  17757. * Instantiate the action
  17758. * @param triggerOptions defines the trigger options
  17759. * @param condition defines the trigger related conditions
  17760. */
  17761. constructor(triggerOptions?: any, condition?: Condition);
  17762. /**
  17763. * Execute the action and do nothing.
  17764. */
  17765. execute(): void;
  17766. /**
  17767. * Serializes the actions and its related information.
  17768. * @param parent defines the object to serialize in
  17769. * @returns the serialized object
  17770. */
  17771. serialize(parent: any): any;
  17772. }
  17773. /**
  17774. * This defines an action responsible to trigger several actions once triggered.
  17775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17776. */
  17777. export class CombineAction extends Action {
  17778. /**
  17779. * The list of aggregated animations to run.
  17780. */
  17781. children: Action[];
  17782. /**
  17783. * Instantiate the action
  17784. * @param triggerOptions defines the trigger options
  17785. * @param children defines the list of aggregated animations to run
  17786. * @param condition defines the trigger related conditions
  17787. */
  17788. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17789. /** @hidden */
  17790. _prepare(): void;
  17791. /**
  17792. * Execute the action and executes all the aggregated actions.
  17793. */
  17794. execute(evt: ActionEvent): void;
  17795. /**
  17796. * Serializes the actions and its related information.
  17797. * @param parent defines the object to serialize in
  17798. * @returns the serialized object
  17799. */
  17800. serialize(parent: any): any;
  17801. }
  17802. /**
  17803. * This defines an action responsible to run code (external event) once triggered.
  17804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17805. */
  17806. export class ExecuteCodeAction extends Action {
  17807. /**
  17808. * The callback function to run.
  17809. */
  17810. func: (evt: ActionEvent) => void;
  17811. /**
  17812. * Instantiate the action
  17813. * @param triggerOptions defines the trigger options
  17814. * @param func defines the callback function to run
  17815. * @param condition defines the trigger related conditions
  17816. */
  17817. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17818. /**
  17819. * Execute the action and run the attached code.
  17820. */
  17821. execute(evt: ActionEvent): void;
  17822. }
  17823. /**
  17824. * This defines an action responsible to set the parent property of the target once triggered.
  17825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17826. */
  17827. export class SetParentAction extends Action {
  17828. private _parent;
  17829. private _target;
  17830. /**
  17831. * Instantiate the action
  17832. * @param triggerOptions defines the trigger options
  17833. * @param target defines the target containing the parent property
  17834. * @param parent defines from where the animation should start (animation frame)
  17835. * @param condition defines the trigger related conditions
  17836. */
  17837. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17838. /** @hidden */
  17839. _prepare(): void;
  17840. /**
  17841. * Execute the action and set the parent property.
  17842. */
  17843. execute(): void;
  17844. /**
  17845. * Serializes the actions and its related information.
  17846. * @param parent defines the object to serialize in
  17847. * @returns the serialized object
  17848. */
  17849. serialize(parent: any): any;
  17850. }
  17851. }
  17852. declare module BABYLON {
  17853. /**
  17854. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17855. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17857. */
  17858. export class ActionManager extends AbstractActionManager {
  17859. /**
  17860. * Nothing
  17861. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17862. */
  17863. static readonly NothingTrigger: number;
  17864. /**
  17865. * On pick
  17866. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17867. */
  17868. static readonly OnPickTrigger: number;
  17869. /**
  17870. * On left pick
  17871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17872. */
  17873. static readonly OnLeftPickTrigger: number;
  17874. /**
  17875. * On right pick
  17876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17877. */
  17878. static readonly OnRightPickTrigger: number;
  17879. /**
  17880. * On center pick
  17881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17882. */
  17883. static readonly OnCenterPickTrigger: number;
  17884. /**
  17885. * On pick down
  17886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17887. */
  17888. static readonly OnPickDownTrigger: number;
  17889. /**
  17890. * On double pick
  17891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17892. */
  17893. static readonly OnDoublePickTrigger: number;
  17894. /**
  17895. * On pick up
  17896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17897. */
  17898. static readonly OnPickUpTrigger: number;
  17899. /**
  17900. * On pick out.
  17901. * This trigger will only be raised if you also declared a OnPickDown
  17902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17903. */
  17904. static readonly OnPickOutTrigger: number;
  17905. /**
  17906. * On long press
  17907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17908. */
  17909. static readonly OnLongPressTrigger: number;
  17910. /**
  17911. * On pointer over
  17912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17913. */
  17914. static readonly OnPointerOverTrigger: number;
  17915. /**
  17916. * On pointer out
  17917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17918. */
  17919. static readonly OnPointerOutTrigger: number;
  17920. /**
  17921. * On every frame
  17922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17923. */
  17924. static readonly OnEveryFrameTrigger: number;
  17925. /**
  17926. * On intersection enter
  17927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17928. */
  17929. static readonly OnIntersectionEnterTrigger: number;
  17930. /**
  17931. * On intersection exit
  17932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17933. */
  17934. static readonly OnIntersectionExitTrigger: number;
  17935. /**
  17936. * On key down
  17937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17938. */
  17939. static readonly OnKeyDownTrigger: number;
  17940. /**
  17941. * On key up
  17942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17943. */
  17944. static readonly OnKeyUpTrigger: number;
  17945. private _scene;
  17946. /**
  17947. * Creates a new action manager
  17948. * @param scene defines the hosting scene
  17949. */
  17950. constructor(scene: Scene);
  17951. /**
  17952. * Releases all associated resources
  17953. */
  17954. dispose(): void;
  17955. /**
  17956. * Gets hosting scene
  17957. * @returns the hosting scene
  17958. */
  17959. getScene(): Scene;
  17960. /**
  17961. * Does this action manager handles actions of any of the given triggers
  17962. * @param triggers defines the triggers to be tested
  17963. * @return a boolean indicating whether one (or more) of the triggers is handled
  17964. */
  17965. hasSpecificTriggers(triggers: number[]): boolean;
  17966. /**
  17967. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17968. * speed.
  17969. * @param triggerA defines the trigger to be tested
  17970. * @param triggerB defines the trigger to be tested
  17971. * @return a boolean indicating whether one (or more) of the triggers is handled
  17972. */
  17973. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17974. /**
  17975. * Does this action manager handles actions of a given trigger
  17976. * @param trigger defines the trigger to be tested
  17977. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17978. * @return whether the trigger is handled
  17979. */
  17980. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17981. /**
  17982. * Does this action manager has pointer triggers
  17983. */
  17984. get hasPointerTriggers(): boolean;
  17985. /**
  17986. * Does this action manager has pick triggers
  17987. */
  17988. get hasPickTriggers(): boolean;
  17989. /**
  17990. * Registers an action to this action manager
  17991. * @param action defines the action to be registered
  17992. * @return the action amended (prepared) after registration
  17993. */
  17994. registerAction(action: IAction): Nullable<IAction>;
  17995. /**
  17996. * Unregisters an action to this action manager
  17997. * @param action defines the action to be unregistered
  17998. * @return a boolean indicating whether the action has been unregistered
  17999. */
  18000. unregisterAction(action: IAction): Boolean;
  18001. /**
  18002. * Process a specific trigger
  18003. * @param trigger defines the trigger to process
  18004. * @param evt defines the event details to be processed
  18005. */
  18006. processTrigger(trigger: number, evt?: IActionEvent): void;
  18007. /** @hidden */
  18008. _getEffectiveTarget(target: any, propertyPath: string): any;
  18009. /** @hidden */
  18010. _getProperty(propertyPath: string): string;
  18011. /**
  18012. * Serialize this manager to a JSON object
  18013. * @param name defines the property name to store this manager
  18014. * @returns a JSON representation of this manager
  18015. */
  18016. serialize(name: string): any;
  18017. /**
  18018. * Creates a new ActionManager from a JSON data
  18019. * @param parsedActions defines the JSON data to read from
  18020. * @param object defines the hosting mesh
  18021. * @param scene defines the hosting scene
  18022. */
  18023. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18024. /**
  18025. * Get a trigger name by index
  18026. * @param trigger defines the trigger index
  18027. * @returns a trigger name
  18028. */
  18029. static GetTriggerName(trigger: number): string;
  18030. }
  18031. }
  18032. declare module BABYLON {
  18033. /**
  18034. * Class used to represent a sprite
  18035. * @see http://doc.babylonjs.com/babylon101/sprites
  18036. */
  18037. export class Sprite {
  18038. /** defines the name */
  18039. name: string;
  18040. /** Gets or sets the current world position */
  18041. position: Vector3;
  18042. /** Gets or sets the main color */
  18043. color: Color4;
  18044. /** Gets or sets the width */
  18045. width: number;
  18046. /** Gets or sets the height */
  18047. height: number;
  18048. /** Gets or sets rotation angle */
  18049. angle: number;
  18050. /** Gets or sets the cell index in the sprite sheet */
  18051. cellIndex: number;
  18052. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18053. cellRef: string;
  18054. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18055. invertU: number;
  18056. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18057. invertV: number;
  18058. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18059. disposeWhenFinishedAnimating: boolean;
  18060. /** Gets the list of attached animations */
  18061. animations: Animation[];
  18062. /** Gets or sets a boolean indicating if the sprite can be picked */
  18063. isPickable: boolean;
  18064. /**
  18065. * Gets or sets the associated action manager
  18066. */
  18067. actionManager: Nullable<ActionManager>;
  18068. private _animationStarted;
  18069. private _loopAnimation;
  18070. private _fromIndex;
  18071. private _toIndex;
  18072. private _delay;
  18073. private _direction;
  18074. private _manager;
  18075. private _time;
  18076. private _onAnimationEnd;
  18077. /**
  18078. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18079. */
  18080. isVisible: boolean;
  18081. /**
  18082. * Gets or sets the sprite size
  18083. */
  18084. get size(): number;
  18085. set size(value: number);
  18086. /**
  18087. * Creates a new Sprite
  18088. * @param name defines the name
  18089. * @param manager defines the manager
  18090. */
  18091. constructor(
  18092. /** defines the name */
  18093. name: string, manager: ISpriteManager);
  18094. /**
  18095. * Starts an animation
  18096. * @param from defines the initial key
  18097. * @param to defines the end key
  18098. * @param loop defines if the animation must loop
  18099. * @param delay defines the start delay (in ms)
  18100. * @param onAnimationEnd defines a callback to call when animation ends
  18101. */
  18102. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18103. /** Stops current animation (if any) */
  18104. stopAnimation(): void;
  18105. /** @hidden */
  18106. _animate(deltaTime: number): void;
  18107. /** Release associated resources */
  18108. dispose(): void;
  18109. }
  18110. }
  18111. declare module BABYLON {
  18112. /**
  18113. * Information about the result of picking within a scene
  18114. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18115. */
  18116. export class PickingInfo {
  18117. /** @hidden */
  18118. _pickingUnavailable: boolean;
  18119. /**
  18120. * If the pick collided with an object
  18121. */
  18122. hit: boolean;
  18123. /**
  18124. * Distance away where the pick collided
  18125. */
  18126. distance: number;
  18127. /**
  18128. * The location of pick collision
  18129. */
  18130. pickedPoint: Nullable<Vector3>;
  18131. /**
  18132. * The mesh corresponding the the pick collision
  18133. */
  18134. pickedMesh: Nullable<AbstractMesh>;
  18135. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18136. bu: number;
  18137. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18138. bv: number;
  18139. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18140. faceId: number;
  18141. /** Id of the the submesh that was picked */
  18142. subMeshId: number;
  18143. /** If a sprite was picked, this will be the sprite the pick collided with */
  18144. pickedSprite: Nullable<Sprite>;
  18145. /**
  18146. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18147. */
  18148. originMesh: Nullable<AbstractMesh>;
  18149. /**
  18150. * The ray that was used to perform the picking.
  18151. */
  18152. ray: Nullable<Ray>;
  18153. /**
  18154. * Gets the normal correspodning to the face the pick collided with
  18155. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18156. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18157. * @returns The normal correspodning to the face the pick collided with
  18158. */
  18159. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18160. /**
  18161. * Gets the texture coordinates of where the pick occured
  18162. * @returns the vector containing the coordnates of the texture
  18163. */
  18164. getTextureCoordinates(): Nullable<Vector2>;
  18165. }
  18166. }
  18167. declare module BABYLON {
  18168. /**
  18169. * Gather the list of pointer event types as constants.
  18170. */
  18171. export class PointerEventTypes {
  18172. /**
  18173. * 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.
  18174. */
  18175. static readonly POINTERDOWN: number;
  18176. /**
  18177. * The pointerup event is fired when a pointer is no longer active.
  18178. */
  18179. static readonly POINTERUP: number;
  18180. /**
  18181. * The pointermove event is fired when a pointer changes coordinates.
  18182. */
  18183. static readonly POINTERMOVE: number;
  18184. /**
  18185. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18186. */
  18187. static readonly POINTERWHEEL: number;
  18188. /**
  18189. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18190. */
  18191. static readonly POINTERPICK: number;
  18192. /**
  18193. * The pointertap event is fired when a the object has been touched and released without drag.
  18194. */
  18195. static readonly POINTERTAP: number;
  18196. /**
  18197. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18198. */
  18199. static readonly POINTERDOUBLETAP: number;
  18200. }
  18201. /**
  18202. * Base class of pointer info types.
  18203. */
  18204. export class PointerInfoBase {
  18205. /**
  18206. * Defines the type of event (PointerEventTypes)
  18207. */
  18208. type: number;
  18209. /**
  18210. * Defines the related dom event
  18211. */
  18212. event: PointerEvent | MouseWheelEvent;
  18213. /**
  18214. * Instantiates the base class of pointers info.
  18215. * @param type Defines the type of event (PointerEventTypes)
  18216. * @param event Defines the related dom event
  18217. */
  18218. constructor(
  18219. /**
  18220. * Defines the type of event (PointerEventTypes)
  18221. */
  18222. type: number,
  18223. /**
  18224. * Defines the related dom event
  18225. */
  18226. event: PointerEvent | MouseWheelEvent);
  18227. }
  18228. /**
  18229. * This class is used to store pointer related info for the onPrePointerObservable event.
  18230. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18231. */
  18232. export class PointerInfoPre extends PointerInfoBase {
  18233. /**
  18234. * Ray from a pointer if availible (eg. 6dof controller)
  18235. */
  18236. ray: Nullable<Ray>;
  18237. /**
  18238. * Defines the local position of the pointer on the canvas.
  18239. */
  18240. localPosition: Vector2;
  18241. /**
  18242. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18243. */
  18244. skipOnPointerObservable: boolean;
  18245. /**
  18246. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18247. * @param type Defines the type of event (PointerEventTypes)
  18248. * @param event Defines the related dom event
  18249. * @param localX Defines the local x coordinates of the pointer when the event occured
  18250. * @param localY Defines the local y coordinates of the pointer when the event occured
  18251. */
  18252. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18253. }
  18254. /**
  18255. * This type contains all the data related to a pointer event in Babylon.js.
  18256. * 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.
  18257. */
  18258. export class PointerInfo extends PointerInfoBase {
  18259. /**
  18260. * Defines the picking info associated to the info (if any)\
  18261. */
  18262. pickInfo: Nullable<PickingInfo>;
  18263. /**
  18264. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18265. * @param type Defines the type of event (PointerEventTypes)
  18266. * @param event Defines the related dom event
  18267. * @param pickInfo Defines the picking info associated to the info (if any)\
  18268. */
  18269. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18270. /**
  18271. * Defines the picking info associated to the info (if any)\
  18272. */
  18273. pickInfo: Nullable<PickingInfo>);
  18274. }
  18275. /**
  18276. * Data relating to a touch event on the screen.
  18277. */
  18278. export interface PointerTouch {
  18279. /**
  18280. * X coordinate of touch.
  18281. */
  18282. x: number;
  18283. /**
  18284. * Y coordinate of touch.
  18285. */
  18286. y: number;
  18287. /**
  18288. * Id of touch. Unique for each finger.
  18289. */
  18290. pointerId: number;
  18291. /**
  18292. * Event type passed from DOM.
  18293. */
  18294. type: any;
  18295. }
  18296. }
  18297. declare module BABYLON {
  18298. /**
  18299. * Manage the mouse inputs to control the movement of a free camera.
  18300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18301. */
  18302. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18303. /**
  18304. * Define if touch is enabled in the mouse input
  18305. */
  18306. touchEnabled: boolean;
  18307. /**
  18308. * Defines the camera the input is attached to.
  18309. */
  18310. camera: FreeCamera;
  18311. /**
  18312. * Defines the buttons associated with the input to handle camera move.
  18313. */
  18314. buttons: number[];
  18315. /**
  18316. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18317. */
  18318. angularSensibility: number;
  18319. private _pointerInput;
  18320. private _onMouseMove;
  18321. private _observer;
  18322. private previousPosition;
  18323. /**
  18324. * Observable for when a pointer move event occurs containing the move offset
  18325. */
  18326. onPointerMovedObservable: Observable<{
  18327. offsetX: number;
  18328. offsetY: number;
  18329. }>;
  18330. /**
  18331. * @hidden
  18332. * If the camera should be rotated automatically based on pointer movement
  18333. */
  18334. _allowCameraRotation: boolean;
  18335. /**
  18336. * Manage the mouse inputs to control the movement of a free camera.
  18337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18338. * @param touchEnabled Defines if touch is enabled or not
  18339. */
  18340. constructor(
  18341. /**
  18342. * Define if touch is enabled in the mouse input
  18343. */
  18344. touchEnabled?: boolean);
  18345. /**
  18346. * Attach the input controls to a specific dom element to get the input from.
  18347. * @param element Defines the element the controls should be listened from
  18348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18349. */
  18350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18351. /**
  18352. * Called on JS contextmenu event.
  18353. * Override this method to provide functionality.
  18354. */
  18355. protected onContextMenu(evt: PointerEvent): void;
  18356. /**
  18357. * Detach the current controls from the specified dom element.
  18358. * @param element Defines the element to stop listening the inputs from
  18359. */
  18360. detachControl(element: Nullable<HTMLElement>): void;
  18361. /**
  18362. * Gets the class name of the current intput.
  18363. * @returns the class name
  18364. */
  18365. getClassName(): string;
  18366. /**
  18367. * Get the friendly name associated with the input class.
  18368. * @returns the input friendly name
  18369. */
  18370. getSimpleName(): string;
  18371. }
  18372. }
  18373. declare module BABYLON {
  18374. /**
  18375. * Manage the touch inputs to control the movement of a free camera.
  18376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18377. */
  18378. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18379. /**
  18380. * Defines the camera the input is attached to.
  18381. */
  18382. camera: FreeCamera;
  18383. /**
  18384. * Defines the touch sensibility for rotation.
  18385. * The higher the faster.
  18386. */
  18387. touchAngularSensibility: number;
  18388. /**
  18389. * Defines the touch sensibility for move.
  18390. * The higher the faster.
  18391. */
  18392. touchMoveSensibility: number;
  18393. private _offsetX;
  18394. private _offsetY;
  18395. private _pointerPressed;
  18396. private _pointerInput;
  18397. private _observer;
  18398. private _onLostFocus;
  18399. /**
  18400. * Attach the input controls to a specific dom element to get the input from.
  18401. * @param element Defines the element the controls should be listened from
  18402. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18403. */
  18404. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18405. /**
  18406. * Detach the current controls from the specified dom element.
  18407. * @param element Defines the element to stop listening the inputs from
  18408. */
  18409. detachControl(element: Nullable<HTMLElement>): void;
  18410. /**
  18411. * Update the current camera state depending on the inputs that have been used this frame.
  18412. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18413. */
  18414. checkInputs(): void;
  18415. /**
  18416. * Gets the class name of the current intput.
  18417. * @returns the class name
  18418. */
  18419. getClassName(): string;
  18420. /**
  18421. * Get the friendly name associated with the input class.
  18422. * @returns the input friendly name
  18423. */
  18424. getSimpleName(): string;
  18425. }
  18426. }
  18427. declare module BABYLON {
  18428. /**
  18429. * Default Inputs manager for the FreeCamera.
  18430. * It groups all the default supported inputs for ease of use.
  18431. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18432. */
  18433. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18434. /**
  18435. * @hidden
  18436. */
  18437. _mouseInput: Nullable<FreeCameraMouseInput>;
  18438. /**
  18439. * Instantiates a new FreeCameraInputsManager.
  18440. * @param camera Defines the camera the inputs belong to
  18441. */
  18442. constructor(camera: FreeCamera);
  18443. /**
  18444. * Add keyboard input support to the input manager.
  18445. * @returns the current input manager
  18446. */
  18447. addKeyboard(): FreeCameraInputsManager;
  18448. /**
  18449. * Add mouse input support to the input manager.
  18450. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18451. * @returns the current input manager
  18452. */
  18453. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18454. /**
  18455. * Removes the mouse input support from the manager
  18456. * @returns the current input manager
  18457. */
  18458. removeMouse(): FreeCameraInputsManager;
  18459. /**
  18460. * Add touch input support to the input manager.
  18461. * @returns the current input manager
  18462. */
  18463. addTouch(): FreeCameraInputsManager;
  18464. /**
  18465. * Remove all attached input methods from a camera
  18466. */
  18467. clear(): void;
  18468. }
  18469. }
  18470. declare module BABYLON {
  18471. /**
  18472. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18473. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18474. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18475. */
  18476. export class FreeCamera extends TargetCamera {
  18477. /**
  18478. * Define the collision ellipsoid of the camera.
  18479. * This is helpful to simulate a camera body like the player body around the camera
  18480. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18481. */
  18482. ellipsoid: Vector3;
  18483. /**
  18484. * Define an offset for the position of the ellipsoid around the camera.
  18485. * This can be helpful to determine the center of the body near the gravity center of the body
  18486. * instead of its head.
  18487. */
  18488. ellipsoidOffset: Vector3;
  18489. /**
  18490. * Enable or disable collisions of the camera with the rest of the scene objects.
  18491. */
  18492. checkCollisions: boolean;
  18493. /**
  18494. * Enable or disable gravity on the camera.
  18495. */
  18496. applyGravity: boolean;
  18497. /**
  18498. * Define the input manager associated to the camera.
  18499. */
  18500. inputs: FreeCameraInputsManager;
  18501. /**
  18502. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18503. * Higher values reduce sensitivity.
  18504. */
  18505. get angularSensibility(): number;
  18506. /**
  18507. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18508. * Higher values reduce sensitivity.
  18509. */
  18510. set angularSensibility(value: number);
  18511. /**
  18512. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18513. */
  18514. get keysUp(): number[];
  18515. set keysUp(value: number[]);
  18516. /**
  18517. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18518. */
  18519. get keysUpward(): number[];
  18520. set keysUpward(value: number[]);
  18521. /**
  18522. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18523. */
  18524. get keysDown(): number[];
  18525. set keysDown(value: number[]);
  18526. /**
  18527. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18528. */
  18529. get keysDownward(): number[];
  18530. set keysDownward(value: number[]);
  18531. /**
  18532. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18533. */
  18534. get keysLeft(): number[];
  18535. set keysLeft(value: number[]);
  18536. /**
  18537. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18538. */
  18539. get keysRight(): number[];
  18540. set keysRight(value: number[]);
  18541. /**
  18542. * Event raised when the camera collide with a mesh in the scene.
  18543. */
  18544. onCollide: (collidedMesh: AbstractMesh) => void;
  18545. private _collider;
  18546. private _needMoveForGravity;
  18547. private _oldPosition;
  18548. private _diffPosition;
  18549. private _newPosition;
  18550. /** @hidden */
  18551. _localDirection: Vector3;
  18552. /** @hidden */
  18553. _transformedDirection: Vector3;
  18554. /**
  18555. * Instantiates a Free Camera.
  18556. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18557. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18558. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18559. * @param name Define the name of the camera in the scene
  18560. * @param position Define the start position of the camera in the scene
  18561. * @param scene Define the scene the camera belongs to
  18562. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18563. */
  18564. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18565. /**
  18566. * Attached controls to the current camera.
  18567. * @param element Defines the element the controls should be listened from
  18568. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18569. */
  18570. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18571. /**
  18572. * Detach the current controls from the camera.
  18573. * The camera will stop reacting to inputs.
  18574. * @param element Defines the element to stop listening the inputs from
  18575. */
  18576. detachControl(element: HTMLElement): void;
  18577. private _collisionMask;
  18578. /**
  18579. * Define a collision mask to limit the list of object the camera can collide with
  18580. */
  18581. get collisionMask(): number;
  18582. set collisionMask(mask: number);
  18583. /** @hidden */
  18584. _collideWithWorld(displacement: Vector3): void;
  18585. private _onCollisionPositionChange;
  18586. /** @hidden */
  18587. _checkInputs(): void;
  18588. /** @hidden */
  18589. _decideIfNeedsToMove(): boolean;
  18590. /** @hidden */
  18591. _updatePosition(): void;
  18592. /**
  18593. * Destroy the camera and release the current resources hold by it.
  18594. */
  18595. dispose(): void;
  18596. /**
  18597. * Gets the current object class name.
  18598. * @return the class name
  18599. */
  18600. getClassName(): string;
  18601. }
  18602. }
  18603. declare module BABYLON {
  18604. /**
  18605. * Represents a gamepad control stick position
  18606. */
  18607. export class StickValues {
  18608. /**
  18609. * The x component of the control stick
  18610. */
  18611. x: number;
  18612. /**
  18613. * The y component of the control stick
  18614. */
  18615. y: number;
  18616. /**
  18617. * Initializes the gamepad x and y control stick values
  18618. * @param x The x component of the gamepad control stick value
  18619. * @param y The y component of the gamepad control stick value
  18620. */
  18621. constructor(
  18622. /**
  18623. * The x component of the control stick
  18624. */
  18625. x: number,
  18626. /**
  18627. * The y component of the control stick
  18628. */
  18629. y: number);
  18630. }
  18631. /**
  18632. * An interface which manages callbacks for gamepad button changes
  18633. */
  18634. export interface GamepadButtonChanges {
  18635. /**
  18636. * Called when a gamepad has been changed
  18637. */
  18638. changed: boolean;
  18639. /**
  18640. * Called when a gamepad press event has been triggered
  18641. */
  18642. pressChanged: boolean;
  18643. /**
  18644. * Called when a touch event has been triggered
  18645. */
  18646. touchChanged: boolean;
  18647. /**
  18648. * Called when a value has changed
  18649. */
  18650. valueChanged: boolean;
  18651. }
  18652. /**
  18653. * Represents a gamepad
  18654. */
  18655. export class Gamepad {
  18656. /**
  18657. * The id of the gamepad
  18658. */
  18659. id: string;
  18660. /**
  18661. * The index of the gamepad
  18662. */
  18663. index: number;
  18664. /**
  18665. * The browser gamepad
  18666. */
  18667. browserGamepad: any;
  18668. /**
  18669. * Specifies what type of gamepad this represents
  18670. */
  18671. type: number;
  18672. private _leftStick;
  18673. private _rightStick;
  18674. /** @hidden */
  18675. _isConnected: boolean;
  18676. private _leftStickAxisX;
  18677. private _leftStickAxisY;
  18678. private _rightStickAxisX;
  18679. private _rightStickAxisY;
  18680. /**
  18681. * Triggered when the left control stick has been changed
  18682. */
  18683. private _onleftstickchanged;
  18684. /**
  18685. * Triggered when the right control stick has been changed
  18686. */
  18687. private _onrightstickchanged;
  18688. /**
  18689. * Represents a gamepad controller
  18690. */
  18691. static GAMEPAD: number;
  18692. /**
  18693. * Represents a generic controller
  18694. */
  18695. static GENERIC: number;
  18696. /**
  18697. * Represents an XBox controller
  18698. */
  18699. static XBOX: number;
  18700. /**
  18701. * Represents a pose-enabled controller
  18702. */
  18703. static POSE_ENABLED: number;
  18704. /**
  18705. * Represents an Dual Shock controller
  18706. */
  18707. static DUALSHOCK: number;
  18708. /**
  18709. * Specifies whether the left control stick should be Y-inverted
  18710. */
  18711. protected _invertLeftStickY: boolean;
  18712. /**
  18713. * Specifies if the gamepad has been connected
  18714. */
  18715. get isConnected(): boolean;
  18716. /**
  18717. * Initializes the gamepad
  18718. * @param id The id of the gamepad
  18719. * @param index The index of the gamepad
  18720. * @param browserGamepad The browser gamepad
  18721. * @param leftStickX The x component of the left joystick
  18722. * @param leftStickY The y component of the left joystick
  18723. * @param rightStickX The x component of the right joystick
  18724. * @param rightStickY The y component of the right joystick
  18725. */
  18726. constructor(
  18727. /**
  18728. * The id of the gamepad
  18729. */
  18730. id: string,
  18731. /**
  18732. * The index of the gamepad
  18733. */
  18734. index: number,
  18735. /**
  18736. * The browser gamepad
  18737. */
  18738. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18739. /**
  18740. * Callback triggered when the left joystick has changed
  18741. * @param callback
  18742. */
  18743. onleftstickchanged(callback: (values: StickValues) => void): void;
  18744. /**
  18745. * Callback triggered when the right joystick has changed
  18746. * @param callback
  18747. */
  18748. onrightstickchanged(callback: (values: StickValues) => void): void;
  18749. /**
  18750. * Gets the left joystick
  18751. */
  18752. get leftStick(): StickValues;
  18753. /**
  18754. * Sets the left joystick values
  18755. */
  18756. set leftStick(newValues: StickValues);
  18757. /**
  18758. * Gets the right joystick
  18759. */
  18760. get rightStick(): StickValues;
  18761. /**
  18762. * Sets the right joystick value
  18763. */
  18764. set rightStick(newValues: StickValues);
  18765. /**
  18766. * Updates the gamepad joystick positions
  18767. */
  18768. update(): void;
  18769. /**
  18770. * Disposes the gamepad
  18771. */
  18772. dispose(): void;
  18773. }
  18774. /**
  18775. * Represents a generic gamepad
  18776. */
  18777. export class GenericPad extends Gamepad {
  18778. private _buttons;
  18779. private _onbuttondown;
  18780. private _onbuttonup;
  18781. /**
  18782. * Observable triggered when a button has been pressed
  18783. */
  18784. onButtonDownObservable: Observable<number>;
  18785. /**
  18786. * Observable triggered when a button has been released
  18787. */
  18788. onButtonUpObservable: Observable<number>;
  18789. /**
  18790. * Callback triggered when a button has been pressed
  18791. * @param callback Called when a button has been pressed
  18792. */
  18793. onbuttondown(callback: (buttonPressed: number) => void): void;
  18794. /**
  18795. * Callback triggered when a button has been released
  18796. * @param callback Called when a button has been released
  18797. */
  18798. onbuttonup(callback: (buttonReleased: number) => void): void;
  18799. /**
  18800. * Initializes the generic gamepad
  18801. * @param id The id of the generic gamepad
  18802. * @param index The index of the generic gamepad
  18803. * @param browserGamepad The browser gamepad
  18804. */
  18805. constructor(id: string, index: number, browserGamepad: any);
  18806. private _setButtonValue;
  18807. /**
  18808. * Updates the generic gamepad
  18809. */
  18810. update(): void;
  18811. /**
  18812. * Disposes the generic gamepad
  18813. */
  18814. dispose(): void;
  18815. }
  18816. }
  18817. declare module BABYLON {
  18818. /**
  18819. * Defines the types of pose enabled controllers that are supported
  18820. */
  18821. export enum PoseEnabledControllerType {
  18822. /**
  18823. * HTC Vive
  18824. */
  18825. VIVE = 0,
  18826. /**
  18827. * Oculus Rift
  18828. */
  18829. OCULUS = 1,
  18830. /**
  18831. * Windows mixed reality
  18832. */
  18833. WINDOWS = 2,
  18834. /**
  18835. * Samsung gear VR
  18836. */
  18837. GEAR_VR = 3,
  18838. /**
  18839. * Google Daydream
  18840. */
  18841. DAYDREAM = 4,
  18842. /**
  18843. * Generic
  18844. */
  18845. GENERIC = 5
  18846. }
  18847. /**
  18848. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18849. */
  18850. export interface MutableGamepadButton {
  18851. /**
  18852. * Value of the button/trigger
  18853. */
  18854. value: number;
  18855. /**
  18856. * If the button/trigger is currently touched
  18857. */
  18858. touched: boolean;
  18859. /**
  18860. * If the button/trigger is currently pressed
  18861. */
  18862. pressed: boolean;
  18863. }
  18864. /**
  18865. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18866. * @hidden
  18867. */
  18868. export interface ExtendedGamepadButton extends GamepadButton {
  18869. /**
  18870. * If the button/trigger is currently pressed
  18871. */
  18872. readonly pressed: boolean;
  18873. /**
  18874. * If the button/trigger is currently touched
  18875. */
  18876. readonly touched: boolean;
  18877. /**
  18878. * Value of the button/trigger
  18879. */
  18880. readonly value: number;
  18881. }
  18882. /** @hidden */
  18883. export interface _GamePadFactory {
  18884. /**
  18885. * Returns whether or not the current gamepad can be created for this type of controller.
  18886. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18887. * @returns true if it can be created, otherwise false
  18888. */
  18889. canCreate(gamepadInfo: any): boolean;
  18890. /**
  18891. * Creates a new instance of the Gamepad.
  18892. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18893. * @returns the new gamepad instance
  18894. */
  18895. create(gamepadInfo: any): Gamepad;
  18896. }
  18897. /**
  18898. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18899. */
  18900. export class PoseEnabledControllerHelper {
  18901. /** @hidden */
  18902. static _ControllerFactories: _GamePadFactory[];
  18903. /** @hidden */
  18904. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18905. /**
  18906. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18907. * @param vrGamepad the gamepad to initialized
  18908. * @returns a vr controller of the type the gamepad identified as
  18909. */
  18910. static InitiateController(vrGamepad: any): Gamepad;
  18911. }
  18912. /**
  18913. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18914. */
  18915. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18916. /**
  18917. * If the controller is used in a webXR session
  18918. */
  18919. isXR: boolean;
  18920. private _deviceRoomPosition;
  18921. private _deviceRoomRotationQuaternion;
  18922. /**
  18923. * The device position in babylon space
  18924. */
  18925. devicePosition: Vector3;
  18926. /**
  18927. * The device rotation in babylon space
  18928. */
  18929. deviceRotationQuaternion: Quaternion;
  18930. /**
  18931. * The scale factor of the device in babylon space
  18932. */
  18933. deviceScaleFactor: number;
  18934. /**
  18935. * (Likely devicePosition should be used instead) The device position in its room space
  18936. */
  18937. position: Vector3;
  18938. /**
  18939. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18940. */
  18941. rotationQuaternion: Quaternion;
  18942. /**
  18943. * The type of controller (Eg. Windows mixed reality)
  18944. */
  18945. controllerType: PoseEnabledControllerType;
  18946. protected _calculatedPosition: Vector3;
  18947. private _calculatedRotation;
  18948. /**
  18949. * The raw pose from the device
  18950. */
  18951. rawPose: DevicePose;
  18952. private _trackPosition;
  18953. private _maxRotationDistFromHeadset;
  18954. private _draggedRoomRotation;
  18955. /**
  18956. * @hidden
  18957. */
  18958. _disableTrackPosition(fixedPosition: Vector3): void;
  18959. /**
  18960. * Internal, the mesh attached to the controller
  18961. * @hidden
  18962. */
  18963. _mesh: Nullable<AbstractMesh>;
  18964. private _poseControlledCamera;
  18965. private _leftHandSystemQuaternion;
  18966. /**
  18967. * Internal, matrix used to convert room space to babylon space
  18968. * @hidden
  18969. */
  18970. _deviceToWorld: Matrix;
  18971. /**
  18972. * Node to be used when casting a ray from the controller
  18973. * @hidden
  18974. */
  18975. _pointingPoseNode: Nullable<TransformNode>;
  18976. /**
  18977. * Name of the child mesh that can be used to cast a ray from the controller
  18978. */
  18979. static readonly POINTING_POSE: string;
  18980. /**
  18981. * Creates a new PoseEnabledController from a gamepad
  18982. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18983. */
  18984. constructor(browserGamepad: any);
  18985. private _workingMatrix;
  18986. /**
  18987. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18988. */
  18989. update(): void;
  18990. /**
  18991. * Updates only the pose device and mesh without doing any button event checking
  18992. */
  18993. protected _updatePoseAndMesh(): void;
  18994. /**
  18995. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18996. * @param poseData raw pose fromthe device
  18997. */
  18998. updateFromDevice(poseData: DevicePose): void;
  18999. /**
  19000. * @hidden
  19001. */
  19002. _meshAttachedObservable: Observable<AbstractMesh>;
  19003. /**
  19004. * Attaches a mesh to the controller
  19005. * @param mesh the mesh to be attached
  19006. */
  19007. attachToMesh(mesh: AbstractMesh): void;
  19008. /**
  19009. * Attaches the controllers mesh to a camera
  19010. * @param camera the camera the mesh should be attached to
  19011. */
  19012. attachToPoseControlledCamera(camera: TargetCamera): void;
  19013. /**
  19014. * Disposes of the controller
  19015. */
  19016. dispose(): void;
  19017. /**
  19018. * The mesh that is attached to the controller
  19019. */
  19020. get mesh(): Nullable<AbstractMesh>;
  19021. /**
  19022. * Gets the ray of the controller in the direction the controller is pointing
  19023. * @param length the length the resulting ray should be
  19024. * @returns a ray in the direction the controller is pointing
  19025. */
  19026. getForwardRay(length?: number): Ray;
  19027. }
  19028. }
  19029. declare module BABYLON {
  19030. /**
  19031. * Defines the WebVRController object that represents controllers tracked in 3D space
  19032. */
  19033. export abstract class WebVRController extends PoseEnabledController {
  19034. /**
  19035. * Internal, the default controller model for the controller
  19036. */
  19037. protected _defaultModel: Nullable<AbstractMesh>;
  19038. /**
  19039. * Fired when the trigger state has changed
  19040. */
  19041. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19042. /**
  19043. * Fired when the main button state has changed
  19044. */
  19045. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19046. /**
  19047. * Fired when the secondary button state has changed
  19048. */
  19049. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19050. /**
  19051. * Fired when the pad state has changed
  19052. */
  19053. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19054. /**
  19055. * Fired when controllers stick values have changed
  19056. */
  19057. onPadValuesChangedObservable: Observable<StickValues>;
  19058. /**
  19059. * Array of button availible on the controller
  19060. */
  19061. protected _buttons: Array<MutableGamepadButton>;
  19062. private _onButtonStateChange;
  19063. /**
  19064. * Fired when a controller button's state has changed
  19065. * @param callback the callback containing the button that was modified
  19066. */
  19067. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19068. /**
  19069. * X and Y axis corresponding to the controllers joystick
  19070. */
  19071. pad: StickValues;
  19072. /**
  19073. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19074. */
  19075. hand: string;
  19076. /**
  19077. * The default controller model for the controller
  19078. */
  19079. get defaultModel(): Nullable<AbstractMesh>;
  19080. /**
  19081. * Creates a new WebVRController from a gamepad
  19082. * @param vrGamepad the gamepad that the WebVRController should be created from
  19083. */
  19084. constructor(vrGamepad: any);
  19085. /**
  19086. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19087. */
  19088. update(): void;
  19089. /**
  19090. * Function to be called when a button is modified
  19091. */
  19092. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19093. /**
  19094. * Loads a mesh and attaches it to the controller
  19095. * @param scene the scene the mesh should be added to
  19096. * @param meshLoaded callback for when the mesh has been loaded
  19097. */
  19098. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19099. private _setButtonValue;
  19100. private _changes;
  19101. private _checkChanges;
  19102. /**
  19103. * Disposes of th webVRCOntroller
  19104. */
  19105. dispose(): void;
  19106. }
  19107. }
  19108. declare module BABYLON {
  19109. /**
  19110. * The HemisphericLight simulates the ambient environment light,
  19111. * so the passed direction is the light reflection direction, not the incoming direction.
  19112. */
  19113. export class HemisphericLight extends Light {
  19114. /**
  19115. * The groundColor is the light in the opposite direction to the one specified during creation.
  19116. * 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.
  19117. */
  19118. groundColor: Color3;
  19119. /**
  19120. * The light reflection direction, not the incoming direction.
  19121. */
  19122. direction: Vector3;
  19123. /**
  19124. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19125. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19126. * The HemisphericLight can't cast shadows.
  19127. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19128. * @param name The friendly name of the light
  19129. * @param direction The direction of the light reflection
  19130. * @param scene The scene the light belongs to
  19131. */
  19132. constructor(name: string, direction: Vector3, scene: Scene);
  19133. protected _buildUniformLayout(): void;
  19134. /**
  19135. * Returns the string "HemisphericLight".
  19136. * @return The class name
  19137. */
  19138. getClassName(): string;
  19139. /**
  19140. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19141. * Returns the updated direction.
  19142. * @param target The target the direction should point to
  19143. * @return The computed direction
  19144. */
  19145. setDirectionToTarget(target: Vector3): Vector3;
  19146. /**
  19147. * Returns the shadow generator associated to the light.
  19148. * @returns Always null for hemispheric lights because it does not support shadows.
  19149. */
  19150. getShadowGenerator(): Nullable<IShadowGenerator>;
  19151. /**
  19152. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19153. * @param effect The effect to update
  19154. * @param lightIndex The index of the light in the effect to update
  19155. * @returns The hemispheric light
  19156. */
  19157. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19158. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19159. /**
  19160. * Computes the world matrix of the node
  19161. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19162. * @param useWasUpdatedFlag defines a reserved property
  19163. * @returns the world matrix
  19164. */
  19165. computeWorldMatrix(): Matrix;
  19166. /**
  19167. * Returns the integer 3.
  19168. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19169. */
  19170. getTypeID(): number;
  19171. /**
  19172. * Prepares the list of defines specific to the light type.
  19173. * @param defines the list of defines
  19174. * @param lightIndex defines the index of the light for the effect
  19175. */
  19176. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19177. }
  19178. }
  19179. declare module BABYLON {
  19180. /** @hidden */
  19181. export var vrMultiviewToSingleviewPixelShader: {
  19182. name: string;
  19183. shader: string;
  19184. };
  19185. }
  19186. declare module BABYLON {
  19187. /**
  19188. * Renders to multiple views with a single draw call
  19189. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19190. */
  19191. export class MultiviewRenderTarget extends RenderTargetTexture {
  19192. /**
  19193. * Creates a multiview render target
  19194. * @param scene scene used with the render target
  19195. * @param size the size of the render target (used for each view)
  19196. */
  19197. constructor(scene: Scene, size?: number | {
  19198. width: number;
  19199. height: number;
  19200. } | {
  19201. ratio: number;
  19202. });
  19203. /**
  19204. * @hidden
  19205. * @param faceIndex the face index, if its a cube texture
  19206. */
  19207. _bindFrameBuffer(faceIndex?: number): void;
  19208. /**
  19209. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19210. * @returns the view count
  19211. */
  19212. getViewCount(): number;
  19213. }
  19214. }
  19215. declare module BABYLON {
  19216. /**
  19217. * Represents a camera frustum
  19218. */
  19219. export class Frustum {
  19220. /**
  19221. * Gets the planes representing the frustum
  19222. * @param transform matrix to be applied to the returned planes
  19223. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19224. */
  19225. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19226. /**
  19227. * Gets the near frustum plane transformed by the transform matrix
  19228. * @param transform transformation matrix to be applied to the resulting frustum plane
  19229. * @param frustumPlane the resuling frustum plane
  19230. */
  19231. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19232. /**
  19233. * Gets the far frustum plane transformed by the transform matrix
  19234. * @param transform transformation matrix to be applied to the resulting frustum plane
  19235. * @param frustumPlane the resuling frustum plane
  19236. */
  19237. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19238. /**
  19239. * Gets the left frustum plane transformed by the transform matrix
  19240. * @param transform transformation matrix to be applied to the resulting frustum plane
  19241. * @param frustumPlane the resuling frustum plane
  19242. */
  19243. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19244. /**
  19245. * Gets the right frustum plane transformed by the transform matrix
  19246. * @param transform transformation matrix to be applied to the resulting frustum plane
  19247. * @param frustumPlane the resuling frustum plane
  19248. */
  19249. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19250. /**
  19251. * Gets the top frustum plane transformed by the transform matrix
  19252. * @param transform transformation matrix to be applied to the resulting frustum plane
  19253. * @param frustumPlane the resuling frustum plane
  19254. */
  19255. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19256. /**
  19257. * Gets the bottom frustum plane transformed by the transform matrix
  19258. * @param transform transformation matrix to be applied to the resulting frustum plane
  19259. * @param frustumPlane the resuling frustum plane
  19260. */
  19261. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19262. /**
  19263. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19264. * @param transform transformation matrix to be applied to the resulting frustum planes
  19265. * @param frustumPlanes the resuling frustum planes
  19266. */
  19267. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19268. }
  19269. }
  19270. declare module BABYLON {
  19271. interface Engine {
  19272. /**
  19273. * Creates a new multiview render target
  19274. * @param width defines the width of the texture
  19275. * @param height defines the height of the texture
  19276. * @returns the created multiview texture
  19277. */
  19278. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19279. /**
  19280. * Binds a multiview framebuffer to be drawn to
  19281. * @param multiviewTexture texture to bind
  19282. */
  19283. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19284. }
  19285. interface Camera {
  19286. /**
  19287. * @hidden
  19288. * 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)
  19289. */
  19290. _useMultiviewToSingleView: boolean;
  19291. /**
  19292. * @hidden
  19293. * 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)
  19294. */
  19295. _multiviewTexture: Nullable<RenderTargetTexture>;
  19296. /**
  19297. * @hidden
  19298. * ensures the multiview texture of the camera exists and has the specified width/height
  19299. * @param width height to set on the multiview texture
  19300. * @param height width to set on the multiview texture
  19301. */
  19302. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19303. }
  19304. interface Scene {
  19305. /** @hidden */
  19306. _transformMatrixR: Matrix;
  19307. /** @hidden */
  19308. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19309. /** @hidden */
  19310. _createMultiviewUbo(): void;
  19311. /** @hidden */
  19312. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19313. /** @hidden */
  19314. _renderMultiviewToSingleView(camera: Camera): void;
  19315. }
  19316. }
  19317. declare module BABYLON {
  19318. /**
  19319. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19320. * This will not be used for webXR as it supports displaying texture arrays directly
  19321. */
  19322. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19323. /**
  19324. * Initializes a VRMultiviewToSingleview
  19325. * @param name name of the post process
  19326. * @param camera camera to be applied to
  19327. * @param scaleFactor scaling factor to the size of the output texture
  19328. */
  19329. constructor(name: string, camera: Camera, scaleFactor: number);
  19330. }
  19331. }
  19332. declare module BABYLON {
  19333. /**
  19334. * Interface used to define additional presentation attributes
  19335. */
  19336. export interface IVRPresentationAttributes {
  19337. /**
  19338. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19339. */
  19340. highRefreshRate: boolean;
  19341. /**
  19342. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19343. */
  19344. foveationLevel: number;
  19345. }
  19346. interface Engine {
  19347. /** @hidden */
  19348. _vrDisplay: any;
  19349. /** @hidden */
  19350. _vrSupported: boolean;
  19351. /** @hidden */
  19352. _oldSize: Size;
  19353. /** @hidden */
  19354. _oldHardwareScaleFactor: number;
  19355. /** @hidden */
  19356. _vrExclusivePointerMode: boolean;
  19357. /** @hidden */
  19358. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19359. /** @hidden */
  19360. _onVRDisplayPointerRestricted: () => void;
  19361. /** @hidden */
  19362. _onVRDisplayPointerUnrestricted: () => void;
  19363. /** @hidden */
  19364. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19365. /** @hidden */
  19366. _onVrDisplayDisconnect: Nullable<() => void>;
  19367. /** @hidden */
  19368. _onVrDisplayPresentChange: Nullable<() => void>;
  19369. /**
  19370. * Observable signaled when VR display mode changes
  19371. */
  19372. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19373. /**
  19374. * Observable signaled when VR request present is complete
  19375. */
  19376. onVRRequestPresentComplete: Observable<boolean>;
  19377. /**
  19378. * Observable signaled when VR request present starts
  19379. */
  19380. onVRRequestPresentStart: Observable<Engine>;
  19381. /**
  19382. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19383. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19384. */
  19385. isInVRExclusivePointerMode: boolean;
  19386. /**
  19387. * Gets a boolean indicating if a webVR device was detected
  19388. * @returns true if a webVR device was detected
  19389. */
  19390. isVRDevicePresent(): boolean;
  19391. /**
  19392. * Gets the current webVR device
  19393. * @returns the current webVR device (or null)
  19394. */
  19395. getVRDevice(): any;
  19396. /**
  19397. * Initializes a webVR display and starts listening to display change events
  19398. * The onVRDisplayChangedObservable will be notified upon these changes
  19399. * @returns A promise containing a VRDisplay and if vr is supported
  19400. */
  19401. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19402. /** @hidden */
  19403. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19404. /**
  19405. * Gets or sets the presentation attributes used to configure VR rendering
  19406. */
  19407. vrPresentationAttributes?: IVRPresentationAttributes;
  19408. /**
  19409. * Call this function to switch to webVR mode
  19410. * Will do nothing if webVR is not supported or if there is no webVR device
  19411. * @param options the webvr options provided to the camera. mainly used for multiview
  19412. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19413. */
  19414. enableVR(options: WebVROptions): void;
  19415. /** @hidden */
  19416. _onVRFullScreenTriggered(): void;
  19417. }
  19418. }
  19419. declare module BABYLON {
  19420. /**
  19421. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19422. * IMPORTANT!! The data is right-hand data.
  19423. * @export
  19424. * @interface DevicePose
  19425. */
  19426. export interface DevicePose {
  19427. /**
  19428. * The position of the device, values in array are [x,y,z].
  19429. */
  19430. readonly position: Nullable<Float32Array>;
  19431. /**
  19432. * The linearVelocity of the device, values in array are [x,y,z].
  19433. */
  19434. readonly linearVelocity: Nullable<Float32Array>;
  19435. /**
  19436. * The linearAcceleration of the device, values in array are [x,y,z].
  19437. */
  19438. readonly linearAcceleration: Nullable<Float32Array>;
  19439. /**
  19440. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19441. */
  19442. readonly orientation: Nullable<Float32Array>;
  19443. /**
  19444. * The angularVelocity of the device, values in array are [x,y,z].
  19445. */
  19446. readonly angularVelocity: Nullable<Float32Array>;
  19447. /**
  19448. * The angularAcceleration of the device, values in array are [x,y,z].
  19449. */
  19450. readonly angularAcceleration: Nullable<Float32Array>;
  19451. }
  19452. /**
  19453. * Interface representing a pose controlled object in Babylon.
  19454. * A pose controlled object has both regular pose values as well as pose values
  19455. * from an external device such as a VR head mounted display
  19456. */
  19457. export interface PoseControlled {
  19458. /**
  19459. * The position of the object in babylon space.
  19460. */
  19461. position: Vector3;
  19462. /**
  19463. * The rotation quaternion of the object in babylon space.
  19464. */
  19465. rotationQuaternion: Quaternion;
  19466. /**
  19467. * The position of the device in babylon space.
  19468. */
  19469. devicePosition?: Vector3;
  19470. /**
  19471. * The rotation quaternion of the device in babylon space.
  19472. */
  19473. deviceRotationQuaternion: Quaternion;
  19474. /**
  19475. * The raw pose coming from the device.
  19476. */
  19477. rawPose: Nullable<DevicePose>;
  19478. /**
  19479. * The scale of the device to be used when translating from device space to babylon space.
  19480. */
  19481. deviceScaleFactor: number;
  19482. /**
  19483. * Updates the poseControlled values based on the input device pose.
  19484. * @param poseData the pose data to update the object with
  19485. */
  19486. updateFromDevice(poseData: DevicePose): void;
  19487. }
  19488. /**
  19489. * Set of options to customize the webVRCamera
  19490. */
  19491. export interface WebVROptions {
  19492. /**
  19493. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19494. */
  19495. trackPosition?: boolean;
  19496. /**
  19497. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19498. */
  19499. positionScale?: number;
  19500. /**
  19501. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19502. */
  19503. displayName?: string;
  19504. /**
  19505. * Should the native controller meshes be initialized. (default: true)
  19506. */
  19507. controllerMeshes?: boolean;
  19508. /**
  19509. * Creating a default HemiLight only on controllers. (default: true)
  19510. */
  19511. defaultLightingOnControllers?: boolean;
  19512. /**
  19513. * If you don't want to use the default VR button of the helper. (default: false)
  19514. */
  19515. useCustomVRButton?: boolean;
  19516. /**
  19517. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19518. */
  19519. customVRButton?: HTMLButtonElement;
  19520. /**
  19521. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19522. */
  19523. rayLength?: number;
  19524. /**
  19525. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19526. */
  19527. defaultHeight?: number;
  19528. /**
  19529. * If multiview should be used if availible (default: false)
  19530. */
  19531. useMultiview?: boolean;
  19532. }
  19533. /**
  19534. * This represents a WebVR camera.
  19535. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19536. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19537. */
  19538. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19539. private webVROptions;
  19540. /**
  19541. * @hidden
  19542. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19543. */
  19544. _vrDevice: any;
  19545. /**
  19546. * The rawPose of the vrDevice.
  19547. */
  19548. rawPose: Nullable<DevicePose>;
  19549. private _onVREnabled;
  19550. private _specsVersion;
  19551. private _attached;
  19552. private _frameData;
  19553. protected _descendants: Array<Node>;
  19554. private _deviceRoomPosition;
  19555. /** @hidden */
  19556. _deviceRoomRotationQuaternion: Quaternion;
  19557. private _standingMatrix;
  19558. /**
  19559. * Represents device position in babylon space.
  19560. */
  19561. devicePosition: Vector3;
  19562. /**
  19563. * Represents device rotation in babylon space.
  19564. */
  19565. deviceRotationQuaternion: Quaternion;
  19566. /**
  19567. * The scale of the device to be used when translating from device space to babylon space.
  19568. */
  19569. deviceScaleFactor: number;
  19570. private _deviceToWorld;
  19571. private _worldToDevice;
  19572. /**
  19573. * References to the webVR controllers for the vrDevice.
  19574. */
  19575. controllers: Array<WebVRController>;
  19576. /**
  19577. * Emits an event when a controller is attached.
  19578. */
  19579. onControllersAttachedObservable: Observable<WebVRController[]>;
  19580. /**
  19581. * Emits an event when a controller's mesh has been loaded;
  19582. */
  19583. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19584. /**
  19585. * Emits an event when the HMD's pose has been updated.
  19586. */
  19587. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19588. private _poseSet;
  19589. /**
  19590. * If the rig cameras be used as parent instead of this camera.
  19591. */
  19592. rigParenting: boolean;
  19593. private _lightOnControllers;
  19594. private _defaultHeight?;
  19595. /**
  19596. * Instantiates a WebVRFreeCamera.
  19597. * @param name The name of the WebVRFreeCamera
  19598. * @param position The starting anchor position for the camera
  19599. * @param scene The scene the camera belongs to
  19600. * @param webVROptions a set of customizable options for the webVRCamera
  19601. */
  19602. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19603. /**
  19604. * Gets the device distance from the ground in meters.
  19605. * @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.
  19606. */
  19607. deviceDistanceToRoomGround(): number;
  19608. /**
  19609. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19610. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19611. */
  19612. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19613. /**
  19614. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19615. * @returns A promise with a boolean set to if the standing matrix is supported.
  19616. */
  19617. useStandingMatrixAsync(): Promise<boolean>;
  19618. /**
  19619. * Disposes the camera
  19620. */
  19621. dispose(): void;
  19622. /**
  19623. * Gets a vrController by name.
  19624. * @param name The name of the controller to retreive
  19625. * @returns the controller matching the name specified or null if not found
  19626. */
  19627. getControllerByName(name: string): Nullable<WebVRController>;
  19628. private _leftController;
  19629. /**
  19630. * The controller corresponding to the users left hand.
  19631. */
  19632. get leftController(): Nullable<WebVRController>;
  19633. private _rightController;
  19634. /**
  19635. * The controller corresponding to the users right hand.
  19636. */
  19637. get rightController(): Nullable<WebVRController>;
  19638. /**
  19639. * Casts a ray forward from the vrCamera's gaze.
  19640. * @param length Length of the ray (default: 100)
  19641. * @returns the ray corresponding to the gaze
  19642. */
  19643. getForwardRay(length?: number): Ray;
  19644. /**
  19645. * @hidden
  19646. * Updates the camera based on device's frame data
  19647. */
  19648. _checkInputs(): void;
  19649. /**
  19650. * Updates the poseControlled values based on the input device pose.
  19651. * @param poseData Pose coming from the device
  19652. */
  19653. updateFromDevice(poseData: DevicePose): void;
  19654. private _htmlElementAttached;
  19655. private _detachIfAttached;
  19656. /**
  19657. * WebVR's attach control will start broadcasting frames to the device.
  19658. * Note that in certain browsers (chrome for example) this function must be called
  19659. * within a user-interaction callback. Example:
  19660. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19661. *
  19662. * @param element html element to attach the vrDevice to
  19663. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19664. */
  19665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19666. /**
  19667. * Detaches the camera from the html element and disables VR
  19668. *
  19669. * @param element html element to detach from
  19670. */
  19671. detachControl(element: HTMLElement): void;
  19672. /**
  19673. * @returns the name of this class
  19674. */
  19675. getClassName(): string;
  19676. /**
  19677. * Calls resetPose on the vrDisplay
  19678. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19679. */
  19680. resetToCurrentRotation(): void;
  19681. /**
  19682. * @hidden
  19683. * Updates the rig cameras (left and right eye)
  19684. */
  19685. _updateRigCameras(): void;
  19686. private _workingVector;
  19687. private _oneVector;
  19688. private _workingMatrix;
  19689. private updateCacheCalled;
  19690. private _correctPositionIfNotTrackPosition;
  19691. /**
  19692. * @hidden
  19693. * Updates the cached values of the camera
  19694. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19695. */
  19696. _updateCache(ignoreParentClass?: boolean): void;
  19697. /**
  19698. * @hidden
  19699. * Get current device position in babylon world
  19700. */
  19701. _computeDevicePosition(): void;
  19702. /**
  19703. * Updates the current device position and rotation in the babylon world
  19704. */
  19705. update(): void;
  19706. /**
  19707. * @hidden
  19708. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19709. * @returns an identity matrix
  19710. */
  19711. _getViewMatrix(): Matrix;
  19712. private _tmpMatrix;
  19713. /**
  19714. * This function is called by the two RIG cameras.
  19715. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19716. * @hidden
  19717. */
  19718. _getWebVRViewMatrix(): Matrix;
  19719. /** @hidden */
  19720. _getWebVRProjectionMatrix(): Matrix;
  19721. private _onGamepadConnectedObserver;
  19722. private _onGamepadDisconnectedObserver;
  19723. private _updateCacheWhenTrackingDisabledObserver;
  19724. /**
  19725. * Initializes the controllers and their meshes
  19726. */
  19727. initControllers(): void;
  19728. }
  19729. }
  19730. declare module BABYLON {
  19731. /**
  19732. * Size options for a post process
  19733. */
  19734. export type PostProcessOptions = {
  19735. width: number;
  19736. height: number;
  19737. };
  19738. /**
  19739. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19740. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19741. */
  19742. export class PostProcess {
  19743. /** Name of the PostProcess. */
  19744. name: string;
  19745. /**
  19746. * Gets or sets the unique id of the post process
  19747. */
  19748. uniqueId: number;
  19749. /**
  19750. * Width of the texture to apply the post process on
  19751. */
  19752. width: number;
  19753. /**
  19754. * Height of the texture to apply the post process on
  19755. */
  19756. height: number;
  19757. /**
  19758. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19759. * @hidden
  19760. */
  19761. _outputTexture: Nullable<InternalTexture>;
  19762. /**
  19763. * Sampling mode used by the shader
  19764. * See https://doc.babylonjs.com/classes/3.1/texture
  19765. */
  19766. renderTargetSamplingMode: number;
  19767. /**
  19768. * Clear color to use when screen clearing
  19769. */
  19770. clearColor: Color4;
  19771. /**
  19772. * If the buffer needs to be cleared before applying the post process. (default: true)
  19773. * Should be set to false if shader will overwrite all previous pixels.
  19774. */
  19775. autoClear: boolean;
  19776. /**
  19777. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19778. */
  19779. alphaMode: number;
  19780. /**
  19781. * Sets the setAlphaBlendConstants of the babylon engine
  19782. */
  19783. alphaConstants: Color4;
  19784. /**
  19785. * Animations to be used for the post processing
  19786. */
  19787. animations: Animation[];
  19788. /**
  19789. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19790. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19791. */
  19792. enablePixelPerfectMode: boolean;
  19793. /**
  19794. * Force the postprocess to be applied without taking in account viewport
  19795. */
  19796. forceFullscreenViewport: boolean;
  19797. /**
  19798. * List of inspectable custom properties (used by the Inspector)
  19799. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19800. */
  19801. inspectableCustomProperties: IInspectable[];
  19802. /**
  19803. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19804. *
  19805. * | Value | Type | Description |
  19806. * | ----- | ----------------------------------- | ----------- |
  19807. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19808. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19809. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19810. *
  19811. */
  19812. scaleMode: number;
  19813. /**
  19814. * Force textures to be a power of two (default: false)
  19815. */
  19816. alwaysForcePOT: boolean;
  19817. private _samples;
  19818. /**
  19819. * Number of sample textures (default: 1)
  19820. */
  19821. get samples(): number;
  19822. set samples(n: number);
  19823. /**
  19824. * Modify the scale of the post process to be the same as the viewport (default: false)
  19825. */
  19826. adaptScaleToCurrentViewport: boolean;
  19827. private _camera;
  19828. private _scene;
  19829. private _engine;
  19830. private _options;
  19831. private _reusable;
  19832. private _textureType;
  19833. private _textureFormat;
  19834. /**
  19835. * Smart array of input and output textures for the post process.
  19836. * @hidden
  19837. */
  19838. _textures: SmartArray<InternalTexture>;
  19839. /**
  19840. * The index in _textures that corresponds to the output texture.
  19841. * @hidden
  19842. */
  19843. _currentRenderTextureInd: number;
  19844. private _effect;
  19845. private _samplers;
  19846. private _fragmentUrl;
  19847. private _vertexUrl;
  19848. private _parameters;
  19849. private _scaleRatio;
  19850. protected _indexParameters: any;
  19851. private _shareOutputWithPostProcess;
  19852. private _texelSize;
  19853. private _forcedOutputTexture;
  19854. /**
  19855. * Returns the fragment url or shader name used in the post process.
  19856. * @returns the fragment url or name in the shader store.
  19857. */
  19858. getEffectName(): string;
  19859. /**
  19860. * An event triggered when the postprocess is activated.
  19861. */
  19862. onActivateObservable: Observable<Camera>;
  19863. private _onActivateObserver;
  19864. /**
  19865. * A function that is added to the onActivateObservable
  19866. */
  19867. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19868. /**
  19869. * An event triggered when the postprocess changes its size.
  19870. */
  19871. onSizeChangedObservable: Observable<PostProcess>;
  19872. private _onSizeChangedObserver;
  19873. /**
  19874. * A function that is added to the onSizeChangedObservable
  19875. */
  19876. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19877. /**
  19878. * An event triggered when the postprocess applies its effect.
  19879. */
  19880. onApplyObservable: Observable<Effect>;
  19881. private _onApplyObserver;
  19882. /**
  19883. * A function that is added to the onApplyObservable
  19884. */
  19885. set onApply(callback: (effect: Effect) => void);
  19886. /**
  19887. * An event triggered before rendering the postprocess
  19888. */
  19889. onBeforeRenderObservable: Observable<Effect>;
  19890. private _onBeforeRenderObserver;
  19891. /**
  19892. * A function that is added to the onBeforeRenderObservable
  19893. */
  19894. set onBeforeRender(callback: (effect: Effect) => void);
  19895. /**
  19896. * An event triggered after rendering the postprocess
  19897. */
  19898. onAfterRenderObservable: Observable<Effect>;
  19899. private _onAfterRenderObserver;
  19900. /**
  19901. * A function that is added to the onAfterRenderObservable
  19902. */
  19903. set onAfterRender(callback: (efect: Effect) => void);
  19904. /**
  19905. * 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
  19906. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19907. */
  19908. get inputTexture(): InternalTexture;
  19909. set inputTexture(value: InternalTexture);
  19910. /**
  19911. * Gets the camera which post process is applied to.
  19912. * @returns The camera the post process is applied to.
  19913. */
  19914. getCamera(): Camera;
  19915. /**
  19916. * Gets the texel size of the postprocess.
  19917. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19918. */
  19919. get texelSize(): Vector2;
  19920. /**
  19921. * Creates a new instance PostProcess
  19922. * @param name The name of the PostProcess.
  19923. * @param fragmentUrl The url of the fragment shader to be used.
  19924. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19925. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19926. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19927. * @param camera The camera to apply the render pass to.
  19928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19929. * @param engine The engine which the post process will be applied. (default: current engine)
  19930. * @param reusable If the post process can be reused on the same frame. (default: false)
  19931. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19932. * @param textureType Type of textures used when performing the post process. (default: 0)
  19933. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19934. * @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
  19935. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19936. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19937. */
  19938. constructor(
  19939. /** Name of the PostProcess. */
  19940. 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);
  19941. /**
  19942. * Gets a string idenfifying the name of the class
  19943. * @returns "PostProcess" string
  19944. */
  19945. getClassName(): string;
  19946. /**
  19947. * Gets the engine which this post process belongs to.
  19948. * @returns The engine the post process was enabled with.
  19949. */
  19950. getEngine(): Engine;
  19951. /**
  19952. * The effect that is created when initializing the post process.
  19953. * @returns The created effect corresponding the the postprocess.
  19954. */
  19955. getEffect(): Effect;
  19956. /**
  19957. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19958. * @param postProcess The post process to share the output with.
  19959. * @returns This post process.
  19960. */
  19961. shareOutputWith(postProcess: PostProcess): PostProcess;
  19962. /**
  19963. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19964. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19965. */
  19966. useOwnOutput(): void;
  19967. /**
  19968. * Updates the effect with the current post process compile time values and recompiles the shader.
  19969. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19970. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19971. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19972. * @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
  19973. * @param onCompiled Called when the shader has been compiled.
  19974. * @param onError Called if there is an error when compiling a shader.
  19975. */
  19976. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19977. /**
  19978. * The post process is reusable if it can be used multiple times within one frame.
  19979. * @returns If the post process is reusable
  19980. */
  19981. isReusable(): boolean;
  19982. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19983. markTextureDirty(): void;
  19984. /**
  19985. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19986. * 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.
  19987. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19988. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19989. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19990. * @returns The target texture that was bound to be written to.
  19991. */
  19992. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19993. /**
  19994. * If the post process is supported.
  19995. */
  19996. get isSupported(): boolean;
  19997. /**
  19998. * The aspect ratio of the output texture.
  19999. */
  20000. get aspectRatio(): number;
  20001. /**
  20002. * Get a value indicating if the post-process is ready to be used
  20003. * @returns true if the post-process is ready (shader is compiled)
  20004. */
  20005. isReady(): boolean;
  20006. /**
  20007. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20008. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20009. */
  20010. apply(): Nullable<Effect>;
  20011. private _disposeTextures;
  20012. /**
  20013. * Disposes the post process.
  20014. * @param camera The camera to dispose the post process on.
  20015. */
  20016. dispose(camera?: Camera): void;
  20017. }
  20018. }
  20019. declare module BABYLON {
  20020. /** @hidden */
  20021. export var kernelBlurVaryingDeclaration: {
  20022. name: string;
  20023. shader: string;
  20024. };
  20025. }
  20026. declare module BABYLON {
  20027. /** @hidden */
  20028. export var kernelBlurFragment: {
  20029. name: string;
  20030. shader: string;
  20031. };
  20032. }
  20033. declare module BABYLON {
  20034. /** @hidden */
  20035. export var kernelBlurFragment2: {
  20036. name: string;
  20037. shader: string;
  20038. };
  20039. }
  20040. declare module BABYLON {
  20041. /** @hidden */
  20042. export var kernelBlurPixelShader: {
  20043. name: string;
  20044. shader: string;
  20045. };
  20046. }
  20047. declare module BABYLON {
  20048. /** @hidden */
  20049. export var kernelBlurVertex: {
  20050. name: string;
  20051. shader: string;
  20052. };
  20053. }
  20054. declare module BABYLON {
  20055. /** @hidden */
  20056. export var kernelBlurVertexShader: {
  20057. name: string;
  20058. shader: string;
  20059. };
  20060. }
  20061. declare module BABYLON {
  20062. /**
  20063. * The Blur Post Process which blurs an image based on a kernel and direction.
  20064. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20065. */
  20066. export class BlurPostProcess extends PostProcess {
  20067. /** The direction in which to blur the image. */
  20068. direction: Vector2;
  20069. private blockCompilation;
  20070. protected _kernel: number;
  20071. protected _idealKernel: number;
  20072. protected _packedFloat: boolean;
  20073. private _staticDefines;
  20074. /**
  20075. * Sets the length in pixels of the blur sample region
  20076. */
  20077. set kernel(v: number);
  20078. /**
  20079. * Gets the length in pixels of the blur sample region
  20080. */
  20081. get kernel(): number;
  20082. /**
  20083. * Sets wether or not the blur needs to unpack/repack floats
  20084. */
  20085. set packedFloat(v: boolean);
  20086. /**
  20087. * Gets wether or not the blur is unpacking/repacking floats
  20088. */
  20089. get packedFloat(): boolean;
  20090. /**
  20091. * Creates a new instance BlurPostProcess
  20092. * @param name The name of the effect.
  20093. * @param direction The direction in which to blur the image.
  20094. * @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.
  20095. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20096. * @param camera The camera to apply the render pass to.
  20097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20098. * @param engine The engine which the post process will be applied. (default: current engine)
  20099. * @param reusable If the post process can be reused on the same frame. (default: false)
  20100. * @param textureType Type of textures used when performing the post process. (default: 0)
  20101. * @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)
  20102. */
  20103. constructor(name: string,
  20104. /** The direction in which to blur the image. */
  20105. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20106. /**
  20107. * Updates the effect with the current post process compile time values and recompiles the shader.
  20108. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20109. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20110. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20111. * @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
  20112. * @param onCompiled Called when the shader has been compiled.
  20113. * @param onError Called if there is an error when compiling a shader.
  20114. */
  20115. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20116. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20117. /**
  20118. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20119. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20120. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20121. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20122. * The gaps between physical kernels are compensated for in the weighting of the samples
  20123. * @param idealKernel Ideal blur kernel.
  20124. * @return Nearest best kernel.
  20125. */
  20126. protected _nearestBestKernel(idealKernel: number): number;
  20127. /**
  20128. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20129. * @param x The point on the Gaussian distribution to sample.
  20130. * @return the value of the Gaussian function at x.
  20131. */
  20132. protected _gaussianWeight(x: number): number;
  20133. /**
  20134. * Generates a string that can be used as a floating point number in GLSL.
  20135. * @param x Value to print.
  20136. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20137. * @return GLSL float string.
  20138. */
  20139. protected _glslFloat(x: number, decimalFigures?: number): string;
  20140. }
  20141. }
  20142. declare module BABYLON {
  20143. /**
  20144. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20145. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20146. * You can then easily use it as a reflectionTexture on a flat surface.
  20147. * In case the surface is not a plane, please consider relying on reflection probes.
  20148. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20149. */
  20150. export class MirrorTexture extends RenderTargetTexture {
  20151. private scene;
  20152. /**
  20153. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20154. * 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.
  20155. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20156. */
  20157. mirrorPlane: Plane;
  20158. /**
  20159. * Define the blur ratio used to blur the reflection if needed.
  20160. */
  20161. set blurRatio(value: number);
  20162. get blurRatio(): number;
  20163. /**
  20164. * Define the adaptive blur kernel used to blur the reflection if needed.
  20165. * This will autocompute the closest best match for the `blurKernel`
  20166. */
  20167. set adaptiveBlurKernel(value: number);
  20168. /**
  20169. * Define the blur kernel used to blur the reflection if needed.
  20170. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20171. */
  20172. set blurKernel(value: number);
  20173. /**
  20174. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20175. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20176. */
  20177. set blurKernelX(value: number);
  20178. get blurKernelX(): number;
  20179. /**
  20180. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20181. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20182. */
  20183. set blurKernelY(value: number);
  20184. get blurKernelY(): number;
  20185. private _autoComputeBlurKernel;
  20186. protected _onRatioRescale(): void;
  20187. private _updateGammaSpace;
  20188. private _imageProcessingConfigChangeObserver;
  20189. private _transformMatrix;
  20190. private _mirrorMatrix;
  20191. private _savedViewMatrix;
  20192. private _blurX;
  20193. private _blurY;
  20194. private _adaptiveBlurKernel;
  20195. private _blurKernelX;
  20196. private _blurKernelY;
  20197. private _blurRatio;
  20198. /**
  20199. * Instantiates a Mirror Texture.
  20200. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20201. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20202. * You can then easily use it as a reflectionTexture on a flat surface.
  20203. * In case the surface is not a plane, please consider relying on reflection probes.
  20204. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20205. * @param name
  20206. * @param size
  20207. * @param scene
  20208. * @param generateMipMaps
  20209. * @param type
  20210. * @param samplingMode
  20211. * @param generateDepthBuffer
  20212. */
  20213. constructor(name: string, size: number | {
  20214. width: number;
  20215. height: number;
  20216. } | {
  20217. ratio: number;
  20218. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20219. private _preparePostProcesses;
  20220. /**
  20221. * Clone the mirror texture.
  20222. * @returns the cloned texture
  20223. */
  20224. clone(): MirrorTexture;
  20225. /**
  20226. * Serialize the texture to a JSON representation you could use in Parse later on
  20227. * @returns the serialized JSON representation
  20228. */
  20229. serialize(): any;
  20230. /**
  20231. * Dispose the texture and release its associated resources.
  20232. */
  20233. dispose(): void;
  20234. }
  20235. }
  20236. declare module BABYLON {
  20237. /**
  20238. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20239. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20240. */
  20241. export class Texture extends BaseTexture {
  20242. /**
  20243. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20244. */
  20245. static SerializeBuffers: boolean;
  20246. /** @hidden */
  20247. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20248. /** @hidden */
  20249. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20250. /** @hidden */
  20251. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20252. /** nearest is mag = nearest and min = nearest and mip = linear */
  20253. static readonly NEAREST_SAMPLINGMODE: number;
  20254. /** nearest is mag = nearest and min = nearest and mip = linear */
  20255. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20256. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20257. static readonly BILINEAR_SAMPLINGMODE: number;
  20258. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20259. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20260. /** Trilinear is mag = linear and min = linear and mip = linear */
  20261. static readonly TRILINEAR_SAMPLINGMODE: number;
  20262. /** Trilinear is mag = linear and min = linear and mip = linear */
  20263. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20264. /** mag = nearest and min = nearest and mip = nearest */
  20265. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20266. /** mag = nearest and min = linear and mip = nearest */
  20267. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20268. /** mag = nearest and min = linear and mip = linear */
  20269. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20270. /** mag = nearest and min = linear and mip = none */
  20271. static readonly NEAREST_LINEAR: number;
  20272. /** mag = nearest and min = nearest and mip = none */
  20273. static readonly NEAREST_NEAREST: number;
  20274. /** mag = linear and min = nearest and mip = nearest */
  20275. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20276. /** mag = linear and min = nearest and mip = linear */
  20277. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20278. /** mag = linear and min = linear and mip = none */
  20279. static readonly LINEAR_LINEAR: number;
  20280. /** mag = linear and min = nearest and mip = none */
  20281. static readonly LINEAR_NEAREST: number;
  20282. /** Explicit coordinates mode */
  20283. static readonly EXPLICIT_MODE: number;
  20284. /** Spherical coordinates mode */
  20285. static readonly SPHERICAL_MODE: number;
  20286. /** Planar coordinates mode */
  20287. static readonly PLANAR_MODE: number;
  20288. /** Cubic coordinates mode */
  20289. static readonly CUBIC_MODE: number;
  20290. /** Projection coordinates mode */
  20291. static readonly PROJECTION_MODE: number;
  20292. /** Inverse Cubic coordinates mode */
  20293. static readonly SKYBOX_MODE: number;
  20294. /** Inverse Cubic coordinates mode */
  20295. static readonly INVCUBIC_MODE: number;
  20296. /** Equirectangular coordinates mode */
  20297. static readonly EQUIRECTANGULAR_MODE: number;
  20298. /** Equirectangular Fixed coordinates mode */
  20299. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20300. /** Equirectangular Fixed Mirrored coordinates mode */
  20301. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20302. /** Texture is not repeating outside of 0..1 UVs */
  20303. static readonly CLAMP_ADDRESSMODE: number;
  20304. /** Texture is repeating outside of 0..1 UVs */
  20305. static readonly WRAP_ADDRESSMODE: number;
  20306. /** Texture is repeating and mirrored */
  20307. static readonly MIRROR_ADDRESSMODE: number;
  20308. /**
  20309. * 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
  20310. */
  20311. static UseSerializedUrlIfAny: boolean;
  20312. /**
  20313. * Define the url of the texture.
  20314. */
  20315. url: Nullable<string>;
  20316. /**
  20317. * Define an offset on the texture to offset the u coordinates of the UVs
  20318. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20319. */
  20320. uOffset: number;
  20321. /**
  20322. * Define an offset on the texture to offset the v coordinates of the UVs
  20323. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20324. */
  20325. vOffset: number;
  20326. /**
  20327. * Define an offset on the texture to scale the u coordinates of the UVs
  20328. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20329. */
  20330. uScale: number;
  20331. /**
  20332. * Define an offset on the texture to scale the v coordinates of the UVs
  20333. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20334. */
  20335. vScale: number;
  20336. /**
  20337. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20338. * @see http://doc.babylonjs.com/how_to/more_materials
  20339. */
  20340. uAng: number;
  20341. /**
  20342. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20343. * @see http://doc.babylonjs.com/how_to/more_materials
  20344. */
  20345. vAng: number;
  20346. /**
  20347. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20348. * @see http://doc.babylonjs.com/how_to/more_materials
  20349. */
  20350. wAng: number;
  20351. /**
  20352. * Defines the center of rotation (U)
  20353. */
  20354. uRotationCenter: number;
  20355. /**
  20356. * Defines the center of rotation (V)
  20357. */
  20358. vRotationCenter: number;
  20359. /**
  20360. * Defines the center of rotation (W)
  20361. */
  20362. wRotationCenter: number;
  20363. /**
  20364. * Are mip maps generated for this texture or not.
  20365. */
  20366. get noMipmap(): boolean;
  20367. /**
  20368. * List of inspectable custom properties (used by the Inspector)
  20369. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20370. */
  20371. inspectableCustomProperties: Nullable<IInspectable[]>;
  20372. private _noMipmap;
  20373. /** @hidden */
  20374. _invertY: boolean;
  20375. private _rowGenerationMatrix;
  20376. private _cachedTextureMatrix;
  20377. private _projectionModeMatrix;
  20378. private _t0;
  20379. private _t1;
  20380. private _t2;
  20381. private _cachedUOffset;
  20382. private _cachedVOffset;
  20383. private _cachedUScale;
  20384. private _cachedVScale;
  20385. private _cachedUAng;
  20386. private _cachedVAng;
  20387. private _cachedWAng;
  20388. private _cachedProjectionMatrixId;
  20389. private _cachedCoordinatesMode;
  20390. /** @hidden */
  20391. protected _initialSamplingMode: number;
  20392. /** @hidden */
  20393. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20394. private _deleteBuffer;
  20395. protected _format: Nullable<number>;
  20396. private _delayedOnLoad;
  20397. private _delayedOnError;
  20398. private _mimeType?;
  20399. /**
  20400. * Observable triggered once the texture has been loaded.
  20401. */
  20402. onLoadObservable: Observable<Texture>;
  20403. protected _isBlocking: boolean;
  20404. /**
  20405. * Is the texture preventing material to render while loading.
  20406. * If false, a default texture will be used instead of the loading one during the preparation step.
  20407. */
  20408. set isBlocking(value: boolean);
  20409. get isBlocking(): boolean;
  20410. /**
  20411. * Get the current sampling mode associated with the texture.
  20412. */
  20413. get samplingMode(): number;
  20414. /**
  20415. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20416. */
  20417. get invertY(): boolean;
  20418. /**
  20419. * Instantiates a new texture.
  20420. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20421. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20422. * @param url defines the url of the picture to load as a texture
  20423. * @param scene defines the scene or engine the texture will belong to
  20424. * @param noMipmap defines if the texture will require mip maps or not
  20425. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20426. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20427. * @param onLoad defines a callback triggered when the texture has been loaded
  20428. * @param onError defines a callback triggered when an error occurred during the loading session
  20429. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20430. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20431. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20432. * @param mimeType defines an optional mime type information
  20433. */
  20434. 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);
  20435. /**
  20436. * Update the url (and optional buffer) of this texture if url was null during construction.
  20437. * @param url the url of the texture
  20438. * @param buffer the buffer of the texture (defaults to null)
  20439. * @param onLoad callback called when the texture is loaded (defaults to null)
  20440. */
  20441. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20442. /**
  20443. * Finish the loading sequence of a texture flagged as delayed load.
  20444. * @hidden
  20445. */
  20446. delayLoad(): void;
  20447. private _prepareRowForTextureGeneration;
  20448. /**
  20449. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20450. * @returns the transform matrix of the texture.
  20451. */
  20452. getTextureMatrix(uBase?: number): Matrix;
  20453. /**
  20454. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20455. * @returns The reflection texture transform
  20456. */
  20457. getReflectionTextureMatrix(): Matrix;
  20458. /**
  20459. * Clones the texture.
  20460. * @returns the cloned texture
  20461. */
  20462. clone(): Texture;
  20463. /**
  20464. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20465. * @returns The JSON representation of the texture
  20466. */
  20467. serialize(): any;
  20468. /**
  20469. * Get the current class name of the texture useful for serialization or dynamic coding.
  20470. * @returns "Texture"
  20471. */
  20472. getClassName(): string;
  20473. /**
  20474. * Dispose the texture and release its associated resources.
  20475. */
  20476. dispose(): void;
  20477. /**
  20478. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20479. * @param parsedTexture Define the JSON representation of the texture
  20480. * @param scene Define the scene the parsed texture should be instantiated in
  20481. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20482. * @returns The parsed texture if successful
  20483. */
  20484. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20485. /**
  20486. * Creates a texture from its base 64 representation.
  20487. * @param data Define the base64 payload without the data: prefix
  20488. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20489. * @param scene Define the scene the texture should belong to
  20490. * @param noMipmap Forces the texture to not create mip map information if true
  20491. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20492. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20493. * @param onLoad define a callback triggered when the texture has been loaded
  20494. * @param onError define a callback triggered when an error occurred during the loading session
  20495. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20496. * @returns the created texture
  20497. */
  20498. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20499. /**
  20500. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20501. * @param data Define the base64 payload without the data: prefix
  20502. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20503. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20504. * @param scene Define the scene the texture should belong to
  20505. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20506. * @param noMipmap Forces the texture to not create mip map information if true
  20507. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20508. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20509. * @param onLoad define a callback triggered when the texture has been loaded
  20510. * @param onError define a callback triggered when an error occurred during the loading session
  20511. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20512. * @returns the created texture
  20513. */
  20514. 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;
  20515. }
  20516. }
  20517. declare module BABYLON {
  20518. /**
  20519. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20520. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20521. */
  20522. export class PostProcessManager {
  20523. private _scene;
  20524. private _indexBuffer;
  20525. private _vertexBuffers;
  20526. /**
  20527. * Creates a new instance PostProcess
  20528. * @param scene The scene that the post process is associated with.
  20529. */
  20530. constructor(scene: Scene);
  20531. private _prepareBuffers;
  20532. private _buildIndexBuffer;
  20533. /**
  20534. * Rebuilds the vertex buffers of the manager.
  20535. * @hidden
  20536. */
  20537. _rebuild(): void;
  20538. /**
  20539. * Prepares a frame to be run through a post process.
  20540. * @param sourceTexture The input texture to the post procesess. (default: null)
  20541. * @param postProcesses An array of post processes to be run. (default: null)
  20542. * @returns True if the post processes were able to be run.
  20543. * @hidden
  20544. */
  20545. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20546. /**
  20547. * Manually render a set of post processes to a texture.
  20548. * @param postProcesses An array of post processes to be run.
  20549. * @param targetTexture The target texture to render to.
  20550. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20551. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20552. * @param lodLevel defines which lod of the texture to render to
  20553. */
  20554. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20555. /**
  20556. * Finalize the result of the output of the postprocesses.
  20557. * @param doNotPresent If true the result will not be displayed to the screen.
  20558. * @param targetTexture The target texture to render to.
  20559. * @param faceIndex The index of the face to bind the target texture to.
  20560. * @param postProcesses The array of post processes to render.
  20561. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20562. * @hidden
  20563. */
  20564. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20565. /**
  20566. * Disposes of the post process manager.
  20567. */
  20568. dispose(): void;
  20569. }
  20570. }
  20571. declare module BABYLON {
  20572. /**
  20573. * This Helps creating a texture that will be created from a camera in your scene.
  20574. * It is basically a dynamic texture that could be used to create special effects for instance.
  20575. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20576. */
  20577. export class RenderTargetTexture extends Texture {
  20578. isCube: boolean;
  20579. /**
  20580. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20581. */
  20582. static readonly REFRESHRATE_RENDER_ONCE: number;
  20583. /**
  20584. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20585. */
  20586. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20587. /**
  20588. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20589. * the central point of your effect and can save a lot of performances.
  20590. */
  20591. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20592. /**
  20593. * Use this predicate to dynamically define the list of mesh you want to render.
  20594. * If set, the renderList property will be overwritten.
  20595. */
  20596. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20597. private _renderList;
  20598. /**
  20599. * Use this list to define the list of mesh you want to render.
  20600. */
  20601. get renderList(): Nullable<Array<AbstractMesh>>;
  20602. set renderList(value: Nullable<Array<AbstractMesh>>);
  20603. /**
  20604. * Use this function to overload the renderList array at rendering time.
  20605. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20606. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20607. * the cube (if the RTT is a cube, else layerOrFace=0).
  20608. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20609. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20610. * hold dummy elements!
  20611. */
  20612. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20613. private _hookArray;
  20614. /**
  20615. * Define if particles should be rendered in your texture.
  20616. */
  20617. renderParticles: boolean;
  20618. /**
  20619. * Define if sprites should be rendered in your texture.
  20620. */
  20621. renderSprites: boolean;
  20622. /**
  20623. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20624. */
  20625. coordinatesMode: number;
  20626. /**
  20627. * Define the camera used to render the texture.
  20628. */
  20629. activeCamera: Nullable<Camera>;
  20630. /**
  20631. * Override the mesh isReady function with your own one.
  20632. */
  20633. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20634. /**
  20635. * Override the render function of the texture with your own one.
  20636. */
  20637. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20638. /**
  20639. * Define if camera post processes should be use while rendering the texture.
  20640. */
  20641. useCameraPostProcesses: boolean;
  20642. /**
  20643. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20644. */
  20645. ignoreCameraViewport: boolean;
  20646. private _postProcessManager;
  20647. private _postProcesses;
  20648. private _resizeObserver;
  20649. /**
  20650. * An event triggered when the texture is unbind.
  20651. */
  20652. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20653. /**
  20654. * An event triggered when the texture is unbind.
  20655. */
  20656. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20657. private _onAfterUnbindObserver;
  20658. /**
  20659. * Set a after unbind callback in the texture.
  20660. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20661. */
  20662. set onAfterUnbind(callback: () => void);
  20663. /**
  20664. * An event triggered before rendering the texture
  20665. */
  20666. onBeforeRenderObservable: Observable<number>;
  20667. private _onBeforeRenderObserver;
  20668. /**
  20669. * Set a before render callback in the texture.
  20670. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20671. */
  20672. set onBeforeRender(callback: (faceIndex: number) => void);
  20673. /**
  20674. * An event triggered after rendering the texture
  20675. */
  20676. onAfterRenderObservable: Observable<number>;
  20677. private _onAfterRenderObserver;
  20678. /**
  20679. * Set a after render callback in the texture.
  20680. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20681. */
  20682. set onAfterRender(callback: (faceIndex: number) => void);
  20683. /**
  20684. * An event triggered after the texture clear
  20685. */
  20686. onClearObservable: Observable<Engine>;
  20687. private _onClearObserver;
  20688. /**
  20689. * Set a clear callback in the texture.
  20690. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20691. */
  20692. set onClear(callback: (Engine: Engine) => void);
  20693. /**
  20694. * An event triggered when the texture is resized.
  20695. */
  20696. onResizeObservable: Observable<RenderTargetTexture>;
  20697. /**
  20698. * Define the clear color of the Render Target if it should be different from the scene.
  20699. */
  20700. clearColor: Color4;
  20701. protected _size: number | {
  20702. width: number;
  20703. height: number;
  20704. layers?: number;
  20705. };
  20706. protected _initialSizeParameter: number | {
  20707. width: number;
  20708. height: number;
  20709. } | {
  20710. ratio: number;
  20711. };
  20712. protected _sizeRatio: Nullable<number>;
  20713. /** @hidden */
  20714. _generateMipMaps: boolean;
  20715. protected _renderingManager: RenderingManager;
  20716. /** @hidden */
  20717. _waitingRenderList: string[];
  20718. protected _doNotChangeAspectRatio: boolean;
  20719. protected _currentRefreshId: number;
  20720. protected _refreshRate: number;
  20721. protected _textureMatrix: Matrix;
  20722. protected _samples: number;
  20723. protected _renderTargetOptions: RenderTargetCreationOptions;
  20724. /**
  20725. * Gets render target creation options that were used.
  20726. */
  20727. get renderTargetOptions(): RenderTargetCreationOptions;
  20728. protected _engine: Engine;
  20729. protected _onRatioRescale(): void;
  20730. /**
  20731. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20732. * It must define where the camera used to render the texture is set
  20733. */
  20734. boundingBoxPosition: Vector3;
  20735. private _boundingBoxSize;
  20736. /**
  20737. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20738. * When defined, the cubemap will switch to local mode
  20739. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20740. * @example https://www.babylonjs-playground.com/#RNASML
  20741. */
  20742. set boundingBoxSize(value: Vector3);
  20743. get boundingBoxSize(): Vector3;
  20744. /**
  20745. * In case the RTT has been created with a depth texture, get the associated
  20746. * depth texture.
  20747. * Otherwise, return null.
  20748. */
  20749. get depthStencilTexture(): Nullable<InternalTexture>;
  20750. /**
  20751. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20752. * or used a shadow, depth texture...
  20753. * @param name The friendly name of the texture
  20754. * @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)
  20755. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20756. * @param generateMipMaps True if mip maps need to be generated after render.
  20757. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20758. * @param type The type of the buffer in the RTT (int, half float, float...)
  20759. * @param isCube True if a cube texture needs to be created
  20760. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20761. * @param generateDepthBuffer True to generate a depth buffer
  20762. * @param generateStencilBuffer True to generate a stencil buffer
  20763. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20764. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20765. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20766. */
  20767. constructor(name: string, size: number | {
  20768. width: number;
  20769. height: number;
  20770. layers?: number;
  20771. } | {
  20772. ratio: number;
  20773. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20774. /**
  20775. * Creates a depth stencil texture.
  20776. * This is only available in WebGL 2 or with the depth texture extension available.
  20777. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20778. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20779. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20780. */
  20781. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20782. private _processSizeParameter;
  20783. /**
  20784. * Define the number of samples to use in case of MSAA.
  20785. * It defaults to one meaning no MSAA has been enabled.
  20786. */
  20787. get samples(): number;
  20788. set samples(value: number);
  20789. /**
  20790. * Resets the refresh counter of the texture and start bak from scratch.
  20791. * Could be useful to regenerate the texture if it is setup to render only once.
  20792. */
  20793. resetRefreshCounter(): void;
  20794. /**
  20795. * Define the refresh rate of the texture or the rendering frequency.
  20796. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20797. */
  20798. get refreshRate(): number;
  20799. set refreshRate(value: number);
  20800. /**
  20801. * Adds a post process to the render target rendering passes.
  20802. * @param postProcess define the post process to add
  20803. */
  20804. addPostProcess(postProcess: PostProcess): void;
  20805. /**
  20806. * Clear all the post processes attached to the render target
  20807. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20808. */
  20809. clearPostProcesses(dispose?: boolean): void;
  20810. /**
  20811. * Remove one of the post process from the list of attached post processes to the texture
  20812. * @param postProcess define the post process to remove from the list
  20813. */
  20814. removePostProcess(postProcess: PostProcess): void;
  20815. /** @hidden */
  20816. _shouldRender(): boolean;
  20817. /**
  20818. * Gets the actual render size of the texture.
  20819. * @returns the width of the render size
  20820. */
  20821. getRenderSize(): number;
  20822. /**
  20823. * Gets the actual render width of the texture.
  20824. * @returns the width of the render size
  20825. */
  20826. getRenderWidth(): number;
  20827. /**
  20828. * Gets the actual render height of the texture.
  20829. * @returns the height of the render size
  20830. */
  20831. getRenderHeight(): number;
  20832. /**
  20833. * Gets the actual number of layers of the texture.
  20834. * @returns the number of layers
  20835. */
  20836. getRenderLayers(): number;
  20837. /**
  20838. * Get if the texture can be rescaled or not.
  20839. */
  20840. get canRescale(): boolean;
  20841. /**
  20842. * Resize the texture using a ratio.
  20843. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20844. */
  20845. scale(ratio: number): void;
  20846. /**
  20847. * Get the texture reflection matrix used to rotate/transform the reflection.
  20848. * @returns the reflection matrix
  20849. */
  20850. getReflectionTextureMatrix(): Matrix;
  20851. /**
  20852. * Resize the texture to a new desired size.
  20853. * Be carrefull as it will recreate all the data in the new texture.
  20854. * @param size Define the new size. It can be:
  20855. * - a number for squared texture,
  20856. * - an object containing { width: number, height: number }
  20857. * - or an object containing a ratio { ratio: number }
  20858. */
  20859. resize(size: number | {
  20860. width: number;
  20861. height: number;
  20862. } | {
  20863. ratio: number;
  20864. }): void;
  20865. private _defaultRenderListPrepared;
  20866. /**
  20867. * Renders all the objects from the render list into the texture.
  20868. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20869. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20870. */
  20871. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20872. private _bestReflectionRenderTargetDimension;
  20873. private _prepareRenderingManager;
  20874. /**
  20875. * @hidden
  20876. * @param faceIndex face index to bind to if this is a cubetexture
  20877. * @param layer defines the index of the texture to bind in the array
  20878. */
  20879. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20880. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20881. private renderToTarget;
  20882. /**
  20883. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20884. * This allowed control for front to back rendering or reversly depending of the special needs.
  20885. *
  20886. * @param renderingGroupId The rendering group id corresponding to its index
  20887. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20888. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20889. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20890. */
  20891. 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;
  20892. /**
  20893. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20894. *
  20895. * @param renderingGroupId The rendering group id corresponding to its index
  20896. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20897. */
  20898. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20899. /**
  20900. * Clones the texture.
  20901. * @returns the cloned texture
  20902. */
  20903. clone(): RenderTargetTexture;
  20904. /**
  20905. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20906. * @returns The JSON representation of the texture
  20907. */
  20908. serialize(): any;
  20909. /**
  20910. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20911. */
  20912. disposeFramebufferObjects(): void;
  20913. /**
  20914. * Dispose the texture and release its associated resources.
  20915. */
  20916. dispose(): void;
  20917. /** @hidden */
  20918. _rebuild(): void;
  20919. /**
  20920. * Clear the info related to rendering groups preventing retention point in material dispose.
  20921. */
  20922. freeRenderingGroups(): void;
  20923. /**
  20924. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20925. * @returns the view count
  20926. */
  20927. getViewCount(): number;
  20928. }
  20929. }
  20930. declare module BABYLON {
  20931. /**
  20932. * Options for compiling materials.
  20933. */
  20934. export interface IMaterialCompilationOptions {
  20935. /**
  20936. * Defines whether clip planes are enabled.
  20937. */
  20938. clipPlane: boolean;
  20939. /**
  20940. * Defines whether instances are enabled.
  20941. */
  20942. useInstances: boolean;
  20943. }
  20944. /**
  20945. * Base class for the main features of a material in Babylon.js
  20946. */
  20947. export class Material implements IAnimatable {
  20948. /**
  20949. * Returns the triangle fill mode
  20950. */
  20951. static readonly TriangleFillMode: number;
  20952. /**
  20953. * Returns the wireframe mode
  20954. */
  20955. static readonly WireFrameFillMode: number;
  20956. /**
  20957. * Returns the point fill mode
  20958. */
  20959. static readonly PointFillMode: number;
  20960. /**
  20961. * Returns the point list draw mode
  20962. */
  20963. static readonly PointListDrawMode: number;
  20964. /**
  20965. * Returns the line list draw mode
  20966. */
  20967. static readonly LineListDrawMode: number;
  20968. /**
  20969. * Returns the line loop draw mode
  20970. */
  20971. static readonly LineLoopDrawMode: number;
  20972. /**
  20973. * Returns the line strip draw mode
  20974. */
  20975. static readonly LineStripDrawMode: number;
  20976. /**
  20977. * Returns the triangle strip draw mode
  20978. */
  20979. static readonly TriangleStripDrawMode: number;
  20980. /**
  20981. * Returns the triangle fan draw mode
  20982. */
  20983. static readonly TriangleFanDrawMode: number;
  20984. /**
  20985. * Stores the clock-wise side orientation
  20986. */
  20987. static readonly ClockWiseSideOrientation: number;
  20988. /**
  20989. * Stores the counter clock-wise side orientation
  20990. */
  20991. static readonly CounterClockWiseSideOrientation: number;
  20992. /**
  20993. * The dirty texture flag value
  20994. */
  20995. static readonly TextureDirtyFlag: number;
  20996. /**
  20997. * The dirty light flag value
  20998. */
  20999. static readonly LightDirtyFlag: number;
  21000. /**
  21001. * The dirty fresnel flag value
  21002. */
  21003. static readonly FresnelDirtyFlag: number;
  21004. /**
  21005. * The dirty attribute flag value
  21006. */
  21007. static readonly AttributesDirtyFlag: number;
  21008. /**
  21009. * The dirty misc flag value
  21010. */
  21011. static readonly MiscDirtyFlag: number;
  21012. /**
  21013. * The all dirty flag value
  21014. */
  21015. static readonly AllDirtyFlag: number;
  21016. /**
  21017. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21018. */
  21019. static readonly MATERIAL_OPAQUE: number;
  21020. /**
  21021. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21022. */
  21023. static readonly MATERIAL_ALPHATEST: number;
  21024. /**
  21025. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21026. */
  21027. static readonly MATERIAL_ALPHABLEND: number;
  21028. /**
  21029. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21030. * They are also discarded below the alpha cutoff threshold to improve performances.
  21031. */
  21032. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21033. /**
  21034. * The ID of the material
  21035. */
  21036. id: string;
  21037. /**
  21038. * Gets or sets the unique id of the material
  21039. */
  21040. uniqueId: number;
  21041. /**
  21042. * The name of the material
  21043. */
  21044. name: string;
  21045. /**
  21046. * Gets or sets user defined metadata
  21047. */
  21048. metadata: any;
  21049. /**
  21050. * For internal use only. Please do not use.
  21051. */
  21052. reservedDataStore: any;
  21053. /**
  21054. * Specifies if the ready state should be checked on each call
  21055. */
  21056. checkReadyOnEveryCall: boolean;
  21057. /**
  21058. * Specifies if the ready state should be checked once
  21059. */
  21060. checkReadyOnlyOnce: boolean;
  21061. /**
  21062. * The state of the material
  21063. */
  21064. state: string;
  21065. /**
  21066. * The alpha value of the material
  21067. */
  21068. protected _alpha: number;
  21069. /**
  21070. * List of inspectable custom properties (used by the Inspector)
  21071. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21072. */
  21073. inspectableCustomProperties: IInspectable[];
  21074. /**
  21075. * Sets the alpha value of the material
  21076. */
  21077. set alpha(value: number);
  21078. /**
  21079. * Gets the alpha value of the material
  21080. */
  21081. get alpha(): number;
  21082. /**
  21083. * Specifies if back face culling is enabled
  21084. */
  21085. protected _backFaceCulling: boolean;
  21086. /**
  21087. * Sets the back-face culling state
  21088. */
  21089. set backFaceCulling(value: boolean);
  21090. /**
  21091. * Gets the back-face culling state
  21092. */
  21093. get backFaceCulling(): boolean;
  21094. /**
  21095. * Stores the value for side orientation
  21096. */
  21097. sideOrientation: number;
  21098. /**
  21099. * Callback triggered when the material is compiled
  21100. */
  21101. onCompiled: Nullable<(effect: Effect) => void>;
  21102. /**
  21103. * Callback triggered when an error occurs
  21104. */
  21105. onError: Nullable<(effect: Effect, errors: string) => void>;
  21106. /**
  21107. * Callback triggered to get the render target textures
  21108. */
  21109. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21110. /**
  21111. * Gets a boolean indicating that current material needs to register RTT
  21112. */
  21113. get hasRenderTargetTextures(): boolean;
  21114. /**
  21115. * Specifies if the material should be serialized
  21116. */
  21117. doNotSerialize: boolean;
  21118. /**
  21119. * @hidden
  21120. */
  21121. _storeEffectOnSubMeshes: boolean;
  21122. /**
  21123. * Stores the animations for the material
  21124. */
  21125. animations: Nullable<Array<Animation>>;
  21126. /**
  21127. * An event triggered when the material is disposed
  21128. */
  21129. onDisposeObservable: Observable<Material>;
  21130. /**
  21131. * An observer which watches for dispose events
  21132. */
  21133. private _onDisposeObserver;
  21134. private _onUnBindObservable;
  21135. /**
  21136. * Called during a dispose event
  21137. */
  21138. set onDispose(callback: () => void);
  21139. private _onBindObservable;
  21140. /**
  21141. * An event triggered when the material is bound
  21142. */
  21143. get onBindObservable(): Observable<AbstractMesh>;
  21144. /**
  21145. * An observer which watches for bind events
  21146. */
  21147. private _onBindObserver;
  21148. /**
  21149. * Called during a bind event
  21150. */
  21151. set onBind(callback: (Mesh: AbstractMesh) => void);
  21152. /**
  21153. * An event triggered when the material is unbound
  21154. */
  21155. get onUnBindObservable(): Observable<Material>;
  21156. /**
  21157. * Stores the value of the alpha mode
  21158. */
  21159. private _alphaMode;
  21160. /**
  21161. * Sets the value of the alpha mode.
  21162. *
  21163. * | Value | Type | Description |
  21164. * | --- | --- | --- |
  21165. * | 0 | ALPHA_DISABLE | |
  21166. * | 1 | ALPHA_ADD | |
  21167. * | 2 | ALPHA_COMBINE | |
  21168. * | 3 | ALPHA_SUBTRACT | |
  21169. * | 4 | ALPHA_MULTIPLY | |
  21170. * | 5 | ALPHA_MAXIMIZED | |
  21171. * | 6 | ALPHA_ONEONE | |
  21172. * | 7 | ALPHA_PREMULTIPLIED | |
  21173. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21174. * | 9 | ALPHA_INTERPOLATE | |
  21175. * | 10 | ALPHA_SCREENMODE | |
  21176. *
  21177. */
  21178. set alphaMode(value: number);
  21179. /**
  21180. * Gets the value of the alpha mode
  21181. */
  21182. get alphaMode(): number;
  21183. /**
  21184. * Stores the state of the need depth pre-pass value
  21185. */
  21186. private _needDepthPrePass;
  21187. /**
  21188. * Sets the need depth pre-pass value
  21189. */
  21190. set needDepthPrePass(value: boolean);
  21191. /**
  21192. * Gets the depth pre-pass value
  21193. */
  21194. get needDepthPrePass(): boolean;
  21195. /**
  21196. * Specifies if depth writing should be disabled
  21197. */
  21198. disableDepthWrite: boolean;
  21199. /**
  21200. * Specifies if depth writing should be forced
  21201. */
  21202. forceDepthWrite: boolean;
  21203. /**
  21204. * Specifies the depth function that should be used. 0 means the default engine function
  21205. */
  21206. depthFunction: number;
  21207. /**
  21208. * Specifies if there should be a separate pass for culling
  21209. */
  21210. separateCullingPass: boolean;
  21211. /**
  21212. * Stores the state specifing if fog should be enabled
  21213. */
  21214. private _fogEnabled;
  21215. /**
  21216. * Sets the state for enabling fog
  21217. */
  21218. set fogEnabled(value: boolean);
  21219. /**
  21220. * Gets the value of the fog enabled state
  21221. */
  21222. get fogEnabled(): boolean;
  21223. /**
  21224. * Stores the size of points
  21225. */
  21226. pointSize: number;
  21227. /**
  21228. * Stores the z offset value
  21229. */
  21230. zOffset: number;
  21231. /**
  21232. * Gets a value specifying if wireframe mode is enabled
  21233. */
  21234. get wireframe(): boolean;
  21235. /**
  21236. * Sets the state of wireframe mode
  21237. */
  21238. set wireframe(value: boolean);
  21239. /**
  21240. * Gets the value specifying if point clouds are enabled
  21241. */
  21242. get pointsCloud(): boolean;
  21243. /**
  21244. * Sets the state of point cloud mode
  21245. */
  21246. set pointsCloud(value: boolean);
  21247. /**
  21248. * Gets the material fill mode
  21249. */
  21250. get fillMode(): number;
  21251. /**
  21252. * Sets the material fill mode
  21253. */
  21254. set fillMode(value: number);
  21255. /**
  21256. * @hidden
  21257. * Stores the effects for the material
  21258. */
  21259. _effect: Nullable<Effect>;
  21260. /**
  21261. * Specifies if uniform buffers should be used
  21262. */
  21263. private _useUBO;
  21264. /**
  21265. * Stores a reference to the scene
  21266. */
  21267. private _scene;
  21268. /**
  21269. * Stores the fill mode state
  21270. */
  21271. private _fillMode;
  21272. /**
  21273. * Specifies if the depth write state should be cached
  21274. */
  21275. private _cachedDepthWriteState;
  21276. /**
  21277. * Specifies if the depth function state should be cached
  21278. */
  21279. private _cachedDepthFunctionState;
  21280. /**
  21281. * Stores the uniform buffer
  21282. */
  21283. protected _uniformBuffer: UniformBuffer;
  21284. /** @hidden */
  21285. _indexInSceneMaterialArray: number;
  21286. /** @hidden */
  21287. meshMap: Nullable<{
  21288. [id: string]: AbstractMesh | undefined;
  21289. }>;
  21290. /**
  21291. * Creates a material instance
  21292. * @param name defines the name of the material
  21293. * @param scene defines the scene to reference
  21294. * @param doNotAdd specifies if the material should be added to the scene
  21295. */
  21296. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21297. /**
  21298. * Returns a string representation of the current material
  21299. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21300. * @returns a string with material information
  21301. */
  21302. toString(fullDetails?: boolean): string;
  21303. /**
  21304. * Gets the class name of the material
  21305. * @returns a string with the class name of the material
  21306. */
  21307. getClassName(): string;
  21308. /**
  21309. * Specifies if updates for the material been locked
  21310. */
  21311. get isFrozen(): boolean;
  21312. /**
  21313. * Locks updates for the material
  21314. */
  21315. freeze(): void;
  21316. /**
  21317. * Unlocks updates for the material
  21318. */
  21319. unfreeze(): void;
  21320. /**
  21321. * Specifies if the material is ready to be used
  21322. * @param mesh defines the mesh to check
  21323. * @param useInstances specifies if instances should be used
  21324. * @returns a boolean indicating if the material is ready to be used
  21325. */
  21326. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21327. /**
  21328. * Specifies that the submesh is ready to be used
  21329. * @param mesh defines the mesh to check
  21330. * @param subMesh defines which submesh to check
  21331. * @param useInstances specifies that instances should be used
  21332. * @returns a boolean indicating that the submesh is ready or not
  21333. */
  21334. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21335. /**
  21336. * Returns the material effect
  21337. * @returns the effect associated with the material
  21338. */
  21339. getEffect(): Nullable<Effect>;
  21340. /**
  21341. * Returns the current scene
  21342. * @returns a Scene
  21343. */
  21344. getScene(): Scene;
  21345. /**
  21346. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21347. */
  21348. protected _forceAlphaTest: boolean;
  21349. /**
  21350. * The transparency mode of the material.
  21351. */
  21352. protected _transparencyMode: Nullable<number>;
  21353. /**
  21354. * Gets the current transparency mode.
  21355. */
  21356. get transparencyMode(): Nullable<number>;
  21357. /**
  21358. * Sets the transparency mode of the material.
  21359. *
  21360. * | Value | Type | Description |
  21361. * | ----- | ----------------------------------- | ----------- |
  21362. * | 0 | OPAQUE | |
  21363. * | 1 | ALPHATEST | |
  21364. * | 2 | ALPHABLEND | |
  21365. * | 3 | ALPHATESTANDBLEND | |
  21366. *
  21367. */
  21368. set transparencyMode(value: Nullable<number>);
  21369. /**
  21370. * Returns true if alpha blending should be disabled.
  21371. */
  21372. protected get _disableAlphaBlending(): boolean;
  21373. /**
  21374. * Specifies whether or not this material should be rendered in alpha blend mode.
  21375. * @returns a boolean specifying if alpha blending is needed
  21376. */
  21377. needAlphaBlending(): boolean;
  21378. /**
  21379. * Specifies if the mesh will require alpha blending
  21380. * @param mesh defines the mesh to check
  21381. * @returns a boolean specifying if alpha blending is needed for the mesh
  21382. */
  21383. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21384. /**
  21385. * Specifies whether or not this material should be rendered in alpha test mode.
  21386. * @returns a boolean specifying if an alpha test is needed.
  21387. */
  21388. needAlphaTesting(): boolean;
  21389. /**
  21390. * Specifies if material alpha testing should be turned on for the mesh
  21391. * @param mesh defines the mesh to check
  21392. */
  21393. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21394. /**
  21395. * Gets the texture used for the alpha test
  21396. * @returns the texture to use for alpha testing
  21397. */
  21398. getAlphaTestTexture(): Nullable<BaseTexture>;
  21399. /**
  21400. * Marks the material to indicate that it needs to be re-calculated
  21401. */
  21402. markDirty(): void;
  21403. /** @hidden */
  21404. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21405. /**
  21406. * Binds the material to the mesh
  21407. * @param world defines the world transformation matrix
  21408. * @param mesh defines the mesh to bind the material to
  21409. */
  21410. bind(world: Matrix, mesh?: Mesh): void;
  21411. /**
  21412. * Binds the submesh to the material
  21413. * @param world defines the world transformation matrix
  21414. * @param mesh defines the mesh containing the submesh
  21415. * @param subMesh defines the submesh to bind the material to
  21416. */
  21417. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21418. /**
  21419. * Binds the world matrix to the material
  21420. * @param world defines the world transformation matrix
  21421. */
  21422. bindOnlyWorldMatrix(world: Matrix): void;
  21423. /**
  21424. * Binds the scene's uniform buffer to the effect.
  21425. * @param effect defines the effect to bind to the scene uniform buffer
  21426. * @param sceneUbo defines the uniform buffer storing scene data
  21427. */
  21428. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21429. /**
  21430. * Binds the view matrix to the effect
  21431. * @param effect defines the effect to bind the view matrix to
  21432. */
  21433. bindView(effect: Effect): void;
  21434. /**
  21435. * Binds the view projection matrix to the effect
  21436. * @param effect defines the effect to bind the view projection matrix to
  21437. */
  21438. bindViewProjection(effect: Effect): void;
  21439. /**
  21440. * Processes to execute after binding the material to a mesh
  21441. * @param mesh defines the rendered mesh
  21442. */
  21443. protected _afterBind(mesh?: Mesh): void;
  21444. /**
  21445. * Unbinds the material from the mesh
  21446. */
  21447. unbind(): void;
  21448. /**
  21449. * Gets the active textures from the material
  21450. * @returns an array of textures
  21451. */
  21452. getActiveTextures(): BaseTexture[];
  21453. /**
  21454. * Specifies if the material uses a texture
  21455. * @param texture defines the texture to check against the material
  21456. * @returns a boolean specifying if the material uses the texture
  21457. */
  21458. hasTexture(texture: BaseTexture): boolean;
  21459. /**
  21460. * Makes a duplicate of the material, and gives it a new name
  21461. * @param name defines the new name for the duplicated material
  21462. * @returns the cloned material
  21463. */
  21464. clone(name: string): Nullable<Material>;
  21465. /**
  21466. * Gets the meshes bound to the material
  21467. * @returns an array of meshes bound to the material
  21468. */
  21469. getBindedMeshes(): AbstractMesh[];
  21470. /**
  21471. * Force shader compilation
  21472. * @param mesh defines the mesh associated with this material
  21473. * @param onCompiled defines a function to execute once the material is compiled
  21474. * @param options defines the options to configure the compilation
  21475. * @param onError defines a function to execute if the material fails compiling
  21476. */
  21477. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21478. /**
  21479. * Force shader compilation
  21480. * @param mesh defines the mesh that will use this material
  21481. * @param options defines additional options for compiling the shaders
  21482. * @returns a promise that resolves when the compilation completes
  21483. */
  21484. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21485. private static readonly _AllDirtyCallBack;
  21486. private static readonly _ImageProcessingDirtyCallBack;
  21487. private static readonly _TextureDirtyCallBack;
  21488. private static readonly _FresnelDirtyCallBack;
  21489. private static readonly _MiscDirtyCallBack;
  21490. private static readonly _LightsDirtyCallBack;
  21491. private static readonly _AttributeDirtyCallBack;
  21492. private static _FresnelAndMiscDirtyCallBack;
  21493. private static _TextureAndMiscDirtyCallBack;
  21494. private static readonly _DirtyCallbackArray;
  21495. private static readonly _RunDirtyCallBacks;
  21496. /**
  21497. * Marks a define in the material to indicate that it needs to be re-computed
  21498. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21499. */
  21500. markAsDirty(flag: number): void;
  21501. /**
  21502. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21503. * @param func defines a function which checks material defines against the submeshes
  21504. */
  21505. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21506. /**
  21507. * Indicates that we need to re-calculated for all submeshes
  21508. */
  21509. protected _markAllSubMeshesAsAllDirty(): void;
  21510. /**
  21511. * Indicates that image processing needs to be re-calculated for all submeshes
  21512. */
  21513. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21514. /**
  21515. * Indicates that textures need to be re-calculated for all submeshes
  21516. */
  21517. protected _markAllSubMeshesAsTexturesDirty(): void;
  21518. /**
  21519. * Indicates that fresnel needs to be re-calculated for all submeshes
  21520. */
  21521. protected _markAllSubMeshesAsFresnelDirty(): void;
  21522. /**
  21523. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21524. */
  21525. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21526. /**
  21527. * Indicates that lights need to be re-calculated for all submeshes
  21528. */
  21529. protected _markAllSubMeshesAsLightsDirty(): void;
  21530. /**
  21531. * Indicates that attributes need to be re-calculated for all submeshes
  21532. */
  21533. protected _markAllSubMeshesAsAttributesDirty(): void;
  21534. /**
  21535. * Indicates that misc needs to be re-calculated for all submeshes
  21536. */
  21537. protected _markAllSubMeshesAsMiscDirty(): void;
  21538. /**
  21539. * Indicates that textures and misc need to be re-calculated for all submeshes
  21540. */
  21541. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21542. /**
  21543. * Disposes the material
  21544. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21545. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21546. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21547. */
  21548. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21549. /** @hidden */
  21550. private releaseVertexArrayObject;
  21551. /**
  21552. * Serializes this material
  21553. * @returns the serialized material object
  21554. */
  21555. serialize(): any;
  21556. /**
  21557. * Creates a material from parsed material data
  21558. * @param parsedMaterial defines parsed material data
  21559. * @param scene defines the hosting scene
  21560. * @param rootUrl defines the root URL to use to load textures
  21561. * @returns a new material
  21562. */
  21563. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21564. }
  21565. }
  21566. declare module BABYLON {
  21567. /**
  21568. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21569. * separate meshes. This can be use to improve performances.
  21570. * @see http://doc.babylonjs.com/how_to/multi_materials
  21571. */
  21572. export class MultiMaterial extends Material {
  21573. private _subMaterials;
  21574. /**
  21575. * Gets or Sets the list of Materials used within the multi material.
  21576. * They need to be ordered according to the submeshes order in the associated mesh
  21577. */
  21578. get subMaterials(): Nullable<Material>[];
  21579. set subMaterials(value: Nullable<Material>[]);
  21580. /**
  21581. * Function used to align with Node.getChildren()
  21582. * @returns the list of Materials used within the multi material
  21583. */
  21584. getChildren(): Nullable<Material>[];
  21585. /**
  21586. * Instantiates a new Multi Material
  21587. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21588. * separate meshes. This can be use to improve performances.
  21589. * @see http://doc.babylonjs.com/how_to/multi_materials
  21590. * @param name Define the name in the scene
  21591. * @param scene Define the scene the material belongs to
  21592. */
  21593. constructor(name: string, scene: Scene);
  21594. private _hookArray;
  21595. /**
  21596. * Get one of the submaterial by its index in the submaterials array
  21597. * @param index The index to look the sub material at
  21598. * @returns The Material if the index has been defined
  21599. */
  21600. getSubMaterial(index: number): Nullable<Material>;
  21601. /**
  21602. * Get the list of active textures for the whole sub materials list.
  21603. * @returns All the textures that will be used during the rendering
  21604. */
  21605. getActiveTextures(): BaseTexture[];
  21606. /**
  21607. * Gets the current class name of the material e.g. "MultiMaterial"
  21608. * Mainly use in serialization.
  21609. * @returns the class name
  21610. */
  21611. getClassName(): string;
  21612. /**
  21613. * Checks if the material is ready to render the requested sub mesh
  21614. * @param mesh Define the mesh the submesh belongs to
  21615. * @param subMesh Define the sub mesh to look readyness for
  21616. * @param useInstances Define whether or not the material is used with instances
  21617. * @returns true if ready, otherwise false
  21618. */
  21619. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21620. /**
  21621. * Clones the current material and its related sub materials
  21622. * @param name Define the name of the newly cloned material
  21623. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21624. * @returns the cloned material
  21625. */
  21626. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21627. /**
  21628. * Serializes the materials into a JSON representation.
  21629. * @returns the JSON representation
  21630. */
  21631. serialize(): any;
  21632. /**
  21633. * Dispose the material and release its associated resources
  21634. * @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)
  21635. * @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)
  21636. * @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)
  21637. */
  21638. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21639. /**
  21640. * Creates a MultiMaterial from parsed MultiMaterial data.
  21641. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21642. * @param scene defines the hosting scene
  21643. * @returns a new MultiMaterial
  21644. */
  21645. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21646. }
  21647. }
  21648. declare module BABYLON {
  21649. /**
  21650. * Base class for submeshes
  21651. */
  21652. export class BaseSubMesh {
  21653. /** @hidden */
  21654. _materialDefines: Nullable<MaterialDefines>;
  21655. /** @hidden */
  21656. _materialEffect: Nullable<Effect>;
  21657. /**
  21658. * Gets material defines used by the effect associated to the sub mesh
  21659. */
  21660. get materialDefines(): Nullable<MaterialDefines>;
  21661. /**
  21662. * Sets material defines used by the effect associated to the sub mesh
  21663. */
  21664. set materialDefines(defines: Nullable<MaterialDefines>);
  21665. /**
  21666. * Gets associated effect
  21667. */
  21668. get effect(): Nullable<Effect>;
  21669. /**
  21670. * Sets associated effect (effect used to render this submesh)
  21671. * @param effect defines the effect to associate with
  21672. * @param defines defines the set of defines used to compile this effect
  21673. */
  21674. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21675. }
  21676. /**
  21677. * Defines a subdivision inside a mesh
  21678. */
  21679. export class SubMesh extends BaseSubMesh implements ICullable {
  21680. /** the material index to use */
  21681. materialIndex: number;
  21682. /** vertex index start */
  21683. verticesStart: number;
  21684. /** vertices count */
  21685. verticesCount: number;
  21686. /** index start */
  21687. indexStart: number;
  21688. /** indices count */
  21689. indexCount: number;
  21690. /** @hidden */
  21691. _linesIndexCount: number;
  21692. private _mesh;
  21693. private _renderingMesh;
  21694. private _boundingInfo;
  21695. private _linesIndexBuffer;
  21696. /** @hidden */
  21697. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21698. /** @hidden */
  21699. _trianglePlanes: Plane[];
  21700. /** @hidden */
  21701. _lastColliderTransformMatrix: Nullable<Matrix>;
  21702. /** @hidden */
  21703. _renderId: number;
  21704. /** @hidden */
  21705. _alphaIndex: number;
  21706. /** @hidden */
  21707. _distanceToCamera: number;
  21708. /** @hidden */
  21709. _id: number;
  21710. private _currentMaterial;
  21711. /**
  21712. * Add a new submesh to a mesh
  21713. * @param materialIndex defines the material index to use
  21714. * @param verticesStart defines vertex index start
  21715. * @param verticesCount defines vertices count
  21716. * @param indexStart defines index start
  21717. * @param indexCount defines indices count
  21718. * @param mesh defines the parent mesh
  21719. * @param renderingMesh defines an optional rendering mesh
  21720. * @param createBoundingBox defines if bounding box should be created for this submesh
  21721. * @returns the new submesh
  21722. */
  21723. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21724. /**
  21725. * Creates a new submesh
  21726. * @param materialIndex defines the material index to use
  21727. * @param verticesStart defines vertex index start
  21728. * @param verticesCount defines vertices count
  21729. * @param indexStart defines index start
  21730. * @param indexCount defines indices count
  21731. * @param mesh defines the parent mesh
  21732. * @param renderingMesh defines an optional rendering mesh
  21733. * @param createBoundingBox defines if bounding box should be created for this submesh
  21734. */
  21735. constructor(
  21736. /** the material index to use */
  21737. materialIndex: number,
  21738. /** vertex index start */
  21739. verticesStart: number,
  21740. /** vertices count */
  21741. verticesCount: number,
  21742. /** index start */
  21743. indexStart: number,
  21744. /** indices count */
  21745. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21746. /**
  21747. * Returns true if this submesh covers the entire parent mesh
  21748. * @ignorenaming
  21749. */
  21750. get IsGlobal(): boolean;
  21751. /**
  21752. * Returns the submesh BoudingInfo object
  21753. * @returns current bounding info (or mesh's one if the submesh is global)
  21754. */
  21755. getBoundingInfo(): BoundingInfo;
  21756. /**
  21757. * Sets the submesh BoundingInfo
  21758. * @param boundingInfo defines the new bounding info to use
  21759. * @returns the SubMesh
  21760. */
  21761. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21762. /**
  21763. * Returns the mesh of the current submesh
  21764. * @return the parent mesh
  21765. */
  21766. getMesh(): AbstractMesh;
  21767. /**
  21768. * Returns the rendering mesh of the submesh
  21769. * @returns the rendering mesh (could be different from parent mesh)
  21770. */
  21771. getRenderingMesh(): Mesh;
  21772. /**
  21773. * Returns the submesh material
  21774. * @returns null or the current material
  21775. */
  21776. getMaterial(): Nullable<Material>;
  21777. /**
  21778. * Sets a new updated BoundingInfo object to the submesh
  21779. * @param data defines an optional position array to use to determine the bounding info
  21780. * @returns the SubMesh
  21781. */
  21782. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21783. /** @hidden */
  21784. _checkCollision(collider: Collider): boolean;
  21785. /**
  21786. * Updates the submesh BoundingInfo
  21787. * @param world defines the world matrix to use to update the bounding info
  21788. * @returns the submesh
  21789. */
  21790. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21791. /**
  21792. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21793. * @param frustumPlanes defines the frustum planes
  21794. * @returns true if the submesh is intersecting with the frustum
  21795. */
  21796. isInFrustum(frustumPlanes: Plane[]): boolean;
  21797. /**
  21798. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21799. * @param frustumPlanes defines the frustum planes
  21800. * @returns true if the submesh is inside the frustum
  21801. */
  21802. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21803. /**
  21804. * Renders the submesh
  21805. * @param enableAlphaMode defines if alpha needs to be used
  21806. * @returns the submesh
  21807. */
  21808. render(enableAlphaMode: boolean): SubMesh;
  21809. /**
  21810. * @hidden
  21811. */
  21812. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21813. /**
  21814. * Checks if the submesh intersects with a ray
  21815. * @param ray defines the ray to test
  21816. * @returns true is the passed ray intersects the submesh bounding box
  21817. */
  21818. canIntersects(ray: Ray): boolean;
  21819. /**
  21820. * Intersects current submesh with a ray
  21821. * @param ray defines the ray to test
  21822. * @param positions defines mesh's positions array
  21823. * @param indices defines mesh's indices array
  21824. * @param fastCheck defines if only bounding info should be used
  21825. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21826. * @returns intersection info or null if no intersection
  21827. */
  21828. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21829. /** @hidden */
  21830. private _intersectLines;
  21831. /** @hidden */
  21832. private _intersectUnIndexedLines;
  21833. /** @hidden */
  21834. private _intersectTriangles;
  21835. /** @hidden */
  21836. private _intersectUnIndexedTriangles;
  21837. /** @hidden */
  21838. _rebuild(): void;
  21839. /**
  21840. * Creates a new submesh from the passed mesh
  21841. * @param newMesh defines the new hosting mesh
  21842. * @param newRenderingMesh defines an optional rendering mesh
  21843. * @returns the new submesh
  21844. */
  21845. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21846. /**
  21847. * Release associated resources
  21848. */
  21849. dispose(): void;
  21850. /**
  21851. * Gets the class name
  21852. * @returns the string "SubMesh".
  21853. */
  21854. getClassName(): string;
  21855. /**
  21856. * Creates a new submesh from indices data
  21857. * @param materialIndex the index of the main mesh material
  21858. * @param startIndex the index where to start the copy in the mesh indices array
  21859. * @param indexCount the number of indices to copy then from the startIndex
  21860. * @param mesh the main mesh to create the submesh from
  21861. * @param renderingMesh the optional rendering mesh
  21862. * @returns a new submesh
  21863. */
  21864. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21865. }
  21866. }
  21867. declare module BABYLON {
  21868. /**
  21869. * Class used to represent data loading progression
  21870. */
  21871. export class SceneLoaderFlags {
  21872. private static _ForceFullSceneLoadingForIncremental;
  21873. private static _ShowLoadingScreen;
  21874. private static _CleanBoneMatrixWeights;
  21875. private static _loggingLevel;
  21876. /**
  21877. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21878. */
  21879. static get ForceFullSceneLoadingForIncremental(): boolean;
  21880. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21881. /**
  21882. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21883. */
  21884. static get ShowLoadingScreen(): boolean;
  21885. static set ShowLoadingScreen(value: boolean);
  21886. /**
  21887. * Defines the current logging level (while loading the scene)
  21888. * @ignorenaming
  21889. */
  21890. static get loggingLevel(): number;
  21891. static set loggingLevel(value: number);
  21892. /**
  21893. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21894. */
  21895. static get CleanBoneMatrixWeights(): boolean;
  21896. static set CleanBoneMatrixWeights(value: boolean);
  21897. }
  21898. }
  21899. declare module BABYLON {
  21900. /**
  21901. * Class used to store geometry data (vertex buffers + index buffer)
  21902. */
  21903. export class Geometry implements IGetSetVerticesData {
  21904. /**
  21905. * Gets or sets the ID of the geometry
  21906. */
  21907. id: string;
  21908. /**
  21909. * Gets or sets the unique ID of the geometry
  21910. */
  21911. uniqueId: number;
  21912. /**
  21913. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21914. */
  21915. delayLoadState: number;
  21916. /**
  21917. * Gets the file containing the data to load when running in delay load state
  21918. */
  21919. delayLoadingFile: Nullable<string>;
  21920. /**
  21921. * Callback called when the geometry is updated
  21922. */
  21923. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21924. private _scene;
  21925. private _engine;
  21926. private _meshes;
  21927. private _totalVertices;
  21928. /** @hidden */
  21929. _indices: IndicesArray;
  21930. /** @hidden */
  21931. _vertexBuffers: {
  21932. [key: string]: VertexBuffer;
  21933. };
  21934. private _isDisposed;
  21935. private _extend;
  21936. private _boundingBias;
  21937. /** @hidden */
  21938. _delayInfo: Array<string>;
  21939. private _indexBuffer;
  21940. private _indexBufferIsUpdatable;
  21941. /** @hidden */
  21942. _boundingInfo: Nullable<BoundingInfo>;
  21943. /** @hidden */
  21944. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21945. /** @hidden */
  21946. _softwareSkinningFrameId: number;
  21947. private _vertexArrayObjects;
  21948. private _updatable;
  21949. /** @hidden */
  21950. _positions: Nullable<Vector3[]>;
  21951. /**
  21952. * 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
  21953. */
  21954. get boundingBias(): Vector2;
  21955. /**
  21956. * 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
  21957. */
  21958. set boundingBias(value: Vector2);
  21959. /**
  21960. * Static function used to attach a new empty geometry to a mesh
  21961. * @param mesh defines the mesh to attach the geometry to
  21962. * @returns the new Geometry
  21963. */
  21964. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21965. /**
  21966. * Creates a new geometry
  21967. * @param id defines the unique ID
  21968. * @param scene defines the hosting scene
  21969. * @param vertexData defines the VertexData used to get geometry data
  21970. * @param updatable defines if geometry must be updatable (false by default)
  21971. * @param mesh defines the mesh that will be associated with the geometry
  21972. */
  21973. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21974. /**
  21975. * Gets the current extend of the geometry
  21976. */
  21977. get extend(): {
  21978. minimum: Vector3;
  21979. maximum: Vector3;
  21980. };
  21981. /**
  21982. * Gets the hosting scene
  21983. * @returns the hosting Scene
  21984. */
  21985. getScene(): Scene;
  21986. /**
  21987. * Gets the hosting engine
  21988. * @returns the hosting Engine
  21989. */
  21990. getEngine(): Engine;
  21991. /**
  21992. * Defines if the geometry is ready to use
  21993. * @returns true if the geometry is ready to be used
  21994. */
  21995. isReady(): boolean;
  21996. /**
  21997. * Gets a value indicating that the geometry should not be serialized
  21998. */
  21999. get doNotSerialize(): boolean;
  22000. /** @hidden */
  22001. _rebuild(): void;
  22002. /**
  22003. * Affects all geometry data in one call
  22004. * @param vertexData defines the geometry data
  22005. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22006. */
  22007. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22008. /**
  22009. * Set specific vertex data
  22010. * @param kind defines the data kind (Position, normal, etc...)
  22011. * @param data defines the vertex data to use
  22012. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22013. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22014. */
  22015. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22016. /**
  22017. * Removes a specific vertex data
  22018. * @param kind defines the data kind (Position, normal, etc...)
  22019. */
  22020. removeVerticesData(kind: string): void;
  22021. /**
  22022. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22023. * @param buffer defines the vertex buffer to use
  22024. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22025. */
  22026. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22027. /**
  22028. * Update a specific vertex buffer
  22029. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22030. * It will do nothing if the buffer is not updatable
  22031. * @param kind defines the data kind (Position, normal, etc...)
  22032. * @param data defines the data to use
  22033. * @param offset defines the offset in the target buffer where to store the data
  22034. * @param useBytes set to true if the offset is in bytes
  22035. */
  22036. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22037. /**
  22038. * Update a specific vertex buffer
  22039. * This function will create a new buffer if the current one is not updatable
  22040. * @param kind defines the data kind (Position, normal, etc...)
  22041. * @param data defines the data to use
  22042. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22043. */
  22044. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22045. private _updateBoundingInfo;
  22046. /** @hidden */
  22047. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22048. /**
  22049. * Gets total number of vertices
  22050. * @returns the total number of vertices
  22051. */
  22052. getTotalVertices(): number;
  22053. /**
  22054. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22055. * @param kind defines the data kind (Position, normal, etc...)
  22056. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22057. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22058. * @returns a float array containing vertex data
  22059. */
  22060. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22061. /**
  22062. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22063. * @param kind defines the data kind (Position, normal, etc...)
  22064. * @returns true if the vertex buffer with the specified kind is updatable
  22065. */
  22066. isVertexBufferUpdatable(kind: string): boolean;
  22067. /**
  22068. * Gets a specific vertex buffer
  22069. * @param kind defines the data kind (Position, normal, etc...)
  22070. * @returns a VertexBuffer
  22071. */
  22072. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22073. /**
  22074. * Returns all vertex buffers
  22075. * @return an object holding all vertex buffers indexed by kind
  22076. */
  22077. getVertexBuffers(): Nullable<{
  22078. [key: string]: VertexBuffer;
  22079. }>;
  22080. /**
  22081. * Gets a boolean indicating if specific vertex buffer is present
  22082. * @param kind defines the data kind (Position, normal, etc...)
  22083. * @returns true if data is present
  22084. */
  22085. isVerticesDataPresent(kind: string): boolean;
  22086. /**
  22087. * Gets a list of all attached data kinds (Position, normal, etc...)
  22088. * @returns a list of string containing all kinds
  22089. */
  22090. getVerticesDataKinds(): string[];
  22091. /**
  22092. * Update index buffer
  22093. * @param indices defines the indices to store in the index buffer
  22094. * @param offset defines the offset in the target buffer where to store the data
  22095. * @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)
  22096. */
  22097. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22098. /**
  22099. * Creates a new index buffer
  22100. * @param indices defines the indices to store in the index buffer
  22101. * @param totalVertices defines the total number of vertices (could be null)
  22102. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22103. */
  22104. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22105. /**
  22106. * Return the total number of indices
  22107. * @returns the total number of indices
  22108. */
  22109. getTotalIndices(): number;
  22110. /**
  22111. * Gets the index buffer array
  22112. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22113. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22114. * @returns the index buffer array
  22115. */
  22116. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22117. /**
  22118. * Gets the index buffer
  22119. * @return the index buffer
  22120. */
  22121. getIndexBuffer(): Nullable<DataBuffer>;
  22122. /** @hidden */
  22123. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22124. /**
  22125. * Release the associated resources for a specific mesh
  22126. * @param mesh defines the source mesh
  22127. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22128. */
  22129. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22130. /**
  22131. * Apply current geometry to a given mesh
  22132. * @param mesh defines the mesh to apply geometry to
  22133. */
  22134. applyToMesh(mesh: Mesh): void;
  22135. private _updateExtend;
  22136. private _applyToMesh;
  22137. private notifyUpdate;
  22138. /**
  22139. * Load the geometry if it was flagged as delay loaded
  22140. * @param scene defines the hosting scene
  22141. * @param onLoaded defines a callback called when the geometry is loaded
  22142. */
  22143. load(scene: Scene, onLoaded?: () => void): void;
  22144. private _queueLoad;
  22145. /**
  22146. * Invert the geometry to move from a right handed system to a left handed one.
  22147. */
  22148. toLeftHanded(): void;
  22149. /** @hidden */
  22150. _resetPointsArrayCache(): void;
  22151. /** @hidden */
  22152. _generatePointsArray(): boolean;
  22153. /**
  22154. * Gets a value indicating if the geometry is disposed
  22155. * @returns true if the geometry was disposed
  22156. */
  22157. isDisposed(): boolean;
  22158. private _disposeVertexArrayObjects;
  22159. /**
  22160. * Free all associated resources
  22161. */
  22162. dispose(): void;
  22163. /**
  22164. * Clone the current geometry into a new geometry
  22165. * @param id defines the unique ID of the new geometry
  22166. * @returns a new geometry object
  22167. */
  22168. copy(id: string): Geometry;
  22169. /**
  22170. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22171. * @return a JSON representation of the current geometry data (without the vertices data)
  22172. */
  22173. serialize(): any;
  22174. private toNumberArray;
  22175. /**
  22176. * Serialize all vertices data into a JSON oject
  22177. * @returns a JSON representation of the current geometry data
  22178. */
  22179. serializeVerticeData(): any;
  22180. /**
  22181. * Extracts a clone of a mesh geometry
  22182. * @param mesh defines the source mesh
  22183. * @param id defines the unique ID of the new geometry object
  22184. * @returns the new geometry object
  22185. */
  22186. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22187. /**
  22188. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22189. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22190. * Be aware Math.random() could cause collisions, but:
  22191. * "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"
  22192. * @returns a string containing a new GUID
  22193. */
  22194. static RandomId(): string;
  22195. /** @hidden */
  22196. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22197. private static _CleanMatricesWeights;
  22198. /**
  22199. * Create a new geometry from persisted data (Using .babylon file format)
  22200. * @param parsedVertexData defines the persisted data
  22201. * @param scene defines the hosting scene
  22202. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22203. * @returns the new geometry object
  22204. */
  22205. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22206. }
  22207. }
  22208. declare module BABYLON {
  22209. /**
  22210. * Define an interface for all classes that will get and set the data on vertices
  22211. */
  22212. export interface IGetSetVerticesData {
  22213. /**
  22214. * Gets a boolean indicating if specific vertex data is present
  22215. * @param kind defines the vertex data kind to use
  22216. * @returns true is data kind is present
  22217. */
  22218. isVerticesDataPresent(kind: string): boolean;
  22219. /**
  22220. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22221. * @param kind defines the data kind (Position, normal, etc...)
  22222. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22223. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22224. * @returns a float array containing vertex data
  22225. */
  22226. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22227. /**
  22228. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22229. * @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.
  22230. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22231. * @returns the indices array or an empty array if the mesh has no geometry
  22232. */
  22233. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22234. /**
  22235. * Set specific vertex data
  22236. * @param kind defines the data kind (Position, normal, etc...)
  22237. * @param data defines the vertex data to use
  22238. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22239. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22240. */
  22241. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22242. /**
  22243. * Update a specific associated vertex buffer
  22244. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22245. * - VertexBuffer.PositionKind
  22246. * - VertexBuffer.UVKind
  22247. * - VertexBuffer.UV2Kind
  22248. * - VertexBuffer.UV3Kind
  22249. * - VertexBuffer.UV4Kind
  22250. * - VertexBuffer.UV5Kind
  22251. * - VertexBuffer.UV6Kind
  22252. * - VertexBuffer.ColorKind
  22253. * - VertexBuffer.MatricesIndicesKind
  22254. * - VertexBuffer.MatricesIndicesExtraKind
  22255. * - VertexBuffer.MatricesWeightsKind
  22256. * - VertexBuffer.MatricesWeightsExtraKind
  22257. * @param data defines the data source
  22258. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22259. * @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)
  22260. */
  22261. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22262. /**
  22263. * Creates a new index buffer
  22264. * @param indices defines the indices to store in the index buffer
  22265. * @param totalVertices defines the total number of vertices (could be null)
  22266. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22267. */
  22268. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22269. }
  22270. /**
  22271. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22272. */
  22273. export class VertexData {
  22274. /**
  22275. * Mesh side orientation : usually the external or front surface
  22276. */
  22277. static readonly FRONTSIDE: number;
  22278. /**
  22279. * Mesh side orientation : usually the internal or back surface
  22280. */
  22281. static readonly BACKSIDE: number;
  22282. /**
  22283. * Mesh side orientation : both internal and external or front and back surfaces
  22284. */
  22285. static readonly DOUBLESIDE: number;
  22286. /**
  22287. * Mesh side orientation : by default, `FRONTSIDE`
  22288. */
  22289. static readonly DEFAULTSIDE: number;
  22290. /**
  22291. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22292. */
  22293. positions: Nullable<FloatArray>;
  22294. /**
  22295. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22296. */
  22297. normals: Nullable<FloatArray>;
  22298. /**
  22299. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22300. */
  22301. tangents: Nullable<FloatArray>;
  22302. /**
  22303. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22304. */
  22305. uvs: Nullable<FloatArray>;
  22306. /**
  22307. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22308. */
  22309. uvs2: Nullable<FloatArray>;
  22310. /**
  22311. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22312. */
  22313. uvs3: Nullable<FloatArray>;
  22314. /**
  22315. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22316. */
  22317. uvs4: Nullable<FloatArray>;
  22318. /**
  22319. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22320. */
  22321. uvs5: Nullable<FloatArray>;
  22322. /**
  22323. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22324. */
  22325. uvs6: Nullable<FloatArray>;
  22326. /**
  22327. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22328. */
  22329. colors: Nullable<FloatArray>;
  22330. /**
  22331. * 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).
  22332. */
  22333. matricesIndices: Nullable<FloatArray>;
  22334. /**
  22335. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22336. */
  22337. matricesWeights: Nullable<FloatArray>;
  22338. /**
  22339. * An array extending the number of possible indices
  22340. */
  22341. matricesIndicesExtra: Nullable<FloatArray>;
  22342. /**
  22343. * An array extending the number of possible weights when the number of indices is extended
  22344. */
  22345. matricesWeightsExtra: Nullable<FloatArray>;
  22346. /**
  22347. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22348. */
  22349. indices: Nullable<IndicesArray>;
  22350. /**
  22351. * Uses the passed data array to set the set the values for the specified kind of data
  22352. * @param data a linear array of floating numbers
  22353. * @param kind the type of data that is being set, eg positions, colors etc
  22354. */
  22355. set(data: FloatArray, kind: string): void;
  22356. /**
  22357. * Associates the vertexData to the passed Mesh.
  22358. * Sets it as updatable or not (default `false`)
  22359. * @param mesh the mesh the vertexData is applied to
  22360. * @param updatable when used and having the value true allows new data to update the vertexData
  22361. * @returns the VertexData
  22362. */
  22363. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22364. /**
  22365. * Associates the vertexData to the passed Geometry.
  22366. * Sets it as updatable or not (default `false`)
  22367. * @param geometry the geometry the vertexData is applied to
  22368. * @param updatable when used and having the value true allows new data to update the vertexData
  22369. * @returns VertexData
  22370. */
  22371. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22372. /**
  22373. * Updates the associated mesh
  22374. * @param mesh the mesh to be updated
  22375. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22376. * @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
  22377. * @returns VertexData
  22378. */
  22379. updateMesh(mesh: Mesh): VertexData;
  22380. /**
  22381. * Updates the associated geometry
  22382. * @param geometry the geometry to be updated
  22383. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22384. * @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
  22385. * @returns VertexData.
  22386. */
  22387. updateGeometry(geometry: Geometry): VertexData;
  22388. private _applyTo;
  22389. private _update;
  22390. /**
  22391. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22392. * @param matrix the transforming matrix
  22393. * @returns the VertexData
  22394. */
  22395. transform(matrix: Matrix): VertexData;
  22396. /**
  22397. * Merges the passed VertexData into the current one
  22398. * @param other the VertexData to be merged into the current one
  22399. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22400. * @returns the modified VertexData
  22401. */
  22402. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22403. private _mergeElement;
  22404. private _validate;
  22405. /**
  22406. * Serializes the VertexData
  22407. * @returns a serialized object
  22408. */
  22409. serialize(): any;
  22410. /**
  22411. * Extracts the vertexData from a mesh
  22412. * @param mesh the mesh from which to extract the VertexData
  22413. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22414. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22415. * @returns the object VertexData associated to the passed mesh
  22416. */
  22417. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22418. /**
  22419. * Extracts the vertexData from the geometry
  22420. * @param geometry the geometry from which to extract the VertexData
  22421. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22422. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22423. * @returns the object VertexData associated to the passed mesh
  22424. */
  22425. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22426. private static _ExtractFrom;
  22427. /**
  22428. * Creates the VertexData for a Ribbon
  22429. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22430. * * pathArray array of paths, each of which an array of successive Vector3
  22431. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22432. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22433. * * 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
  22434. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22435. * * 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)
  22436. * * 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)
  22437. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22438. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22439. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22440. * @returns the VertexData of the ribbon
  22441. */
  22442. static CreateRibbon(options: {
  22443. pathArray: Vector3[][];
  22444. closeArray?: boolean;
  22445. closePath?: boolean;
  22446. offset?: number;
  22447. sideOrientation?: number;
  22448. frontUVs?: Vector4;
  22449. backUVs?: Vector4;
  22450. invertUV?: boolean;
  22451. uvs?: Vector2[];
  22452. colors?: Color4[];
  22453. }): VertexData;
  22454. /**
  22455. * Creates the VertexData for a box
  22456. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22457. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22458. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22459. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22460. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22461. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22462. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22463. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22464. * * 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)
  22465. * * 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)
  22466. * @returns the VertexData of the box
  22467. */
  22468. static CreateBox(options: {
  22469. size?: number;
  22470. width?: number;
  22471. height?: number;
  22472. depth?: number;
  22473. faceUV?: Vector4[];
  22474. faceColors?: Color4[];
  22475. sideOrientation?: number;
  22476. frontUVs?: Vector4;
  22477. backUVs?: Vector4;
  22478. }): VertexData;
  22479. /**
  22480. * Creates the VertexData for a tiled box
  22481. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22482. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22483. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22484. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22486. * @returns the VertexData of the box
  22487. */
  22488. static CreateTiledBox(options: {
  22489. pattern?: number;
  22490. width?: number;
  22491. height?: number;
  22492. depth?: number;
  22493. tileSize?: number;
  22494. tileWidth?: number;
  22495. tileHeight?: number;
  22496. alignHorizontal?: number;
  22497. alignVertical?: number;
  22498. faceUV?: Vector4[];
  22499. faceColors?: Color4[];
  22500. sideOrientation?: number;
  22501. }): VertexData;
  22502. /**
  22503. * Creates the VertexData for a tiled plane
  22504. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22505. * * pattern a limited pattern arrangement depending on the number
  22506. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22507. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22508. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22509. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22510. * * 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)
  22511. * * 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)
  22512. * @returns the VertexData of the tiled plane
  22513. */
  22514. static CreateTiledPlane(options: {
  22515. pattern?: number;
  22516. tileSize?: number;
  22517. tileWidth?: number;
  22518. tileHeight?: number;
  22519. size?: number;
  22520. width?: number;
  22521. height?: number;
  22522. alignHorizontal?: number;
  22523. alignVertical?: number;
  22524. sideOrientation?: number;
  22525. frontUVs?: Vector4;
  22526. backUVs?: Vector4;
  22527. }): VertexData;
  22528. /**
  22529. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22530. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22531. * * segments sets the number of horizontal strips optional, default 32
  22532. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22533. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22534. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22535. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22536. * * 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
  22537. * * 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
  22538. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22539. * * 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)
  22540. * * 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)
  22541. * @returns the VertexData of the ellipsoid
  22542. */
  22543. static CreateSphere(options: {
  22544. segments?: number;
  22545. diameter?: number;
  22546. diameterX?: number;
  22547. diameterY?: number;
  22548. diameterZ?: number;
  22549. arc?: number;
  22550. slice?: number;
  22551. sideOrientation?: number;
  22552. frontUVs?: Vector4;
  22553. backUVs?: Vector4;
  22554. }): VertexData;
  22555. /**
  22556. * Creates the VertexData for a cylinder, cone or prism
  22557. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22558. * * height sets the height (y direction) of the cylinder, optional, default 2
  22559. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22560. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22561. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22562. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22563. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22564. * * 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
  22565. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22566. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22567. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22568. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22569. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22570. * * 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)
  22571. * * 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)
  22572. * @returns the VertexData of the cylinder, cone or prism
  22573. */
  22574. static CreateCylinder(options: {
  22575. height?: number;
  22576. diameterTop?: number;
  22577. diameterBottom?: number;
  22578. diameter?: number;
  22579. tessellation?: number;
  22580. subdivisions?: number;
  22581. arc?: number;
  22582. faceColors?: Color4[];
  22583. faceUV?: Vector4[];
  22584. hasRings?: boolean;
  22585. enclose?: boolean;
  22586. sideOrientation?: number;
  22587. frontUVs?: Vector4;
  22588. backUVs?: Vector4;
  22589. }): VertexData;
  22590. /**
  22591. * Creates the VertexData for a torus
  22592. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22593. * * diameter the diameter of the torus, optional default 1
  22594. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22595. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22596. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22597. * * 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)
  22598. * * 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)
  22599. * @returns the VertexData of the torus
  22600. */
  22601. static CreateTorus(options: {
  22602. diameter?: number;
  22603. thickness?: number;
  22604. tessellation?: number;
  22605. sideOrientation?: number;
  22606. frontUVs?: Vector4;
  22607. backUVs?: Vector4;
  22608. }): VertexData;
  22609. /**
  22610. * Creates the VertexData of the LineSystem
  22611. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22612. * - lines an array of lines, each line being an array of successive Vector3
  22613. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22614. * @returns the VertexData of the LineSystem
  22615. */
  22616. static CreateLineSystem(options: {
  22617. lines: Vector3[][];
  22618. colors?: Nullable<Color4[][]>;
  22619. }): VertexData;
  22620. /**
  22621. * Create the VertexData for a DashedLines
  22622. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22623. * - points an array successive Vector3
  22624. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22625. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22626. * - dashNb the intended total number of dashes, optional, default 200
  22627. * @returns the VertexData for the DashedLines
  22628. */
  22629. static CreateDashedLines(options: {
  22630. points: Vector3[];
  22631. dashSize?: number;
  22632. gapSize?: number;
  22633. dashNb?: number;
  22634. }): VertexData;
  22635. /**
  22636. * Creates the VertexData for a Ground
  22637. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22638. * - width the width (x direction) of the ground, optional, default 1
  22639. * - height the height (z direction) of the ground, optional, default 1
  22640. * - subdivisions the number of subdivisions per side, optional, default 1
  22641. * @returns the VertexData of the Ground
  22642. */
  22643. static CreateGround(options: {
  22644. width?: number;
  22645. height?: number;
  22646. subdivisions?: number;
  22647. subdivisionsX?: number;
  22648. subdivisionsY?: number;
  22649. }): VertexData;
  22650. /**
  22651. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22652. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22653. * * xmin the ground minimum X coordinate, optional, default -1
  22654. * * zmin the ground minimum Z coordinate, optional, default -1
  22655. * * xmax the ground maximum X coordinate, optional, default 1
  22656. * * zmax the ground maximum Z coordinate, optional, default 1
  22657. * * 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}
  22658. * * 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}
  22659. * @returns the VertexData of the TiledGround
  22660. */
  22661. static CreateTiledGround(options: {
  22662. xmin: number;
  22663. zmin: number;
  22664. xmax: number;
  22665. zmax: number;
  22666. subdivisions?: {
  22667. w: number;
  22668. h: number;
  22669. };
  22670. precision?: {
  22671. w: number;
  22672. h: number;
  22673. };
  22674. }): VertexData;
  22675. /**
  22676. * Creates the VertexData of the Ground designed from a heightmap
  22677. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22678. * * width the width (x direction) of the ground
  22679. * * height the height (z direction) of the ground
  22680. * * subdivisions the number of subdivisions per side
  22681. * * minHeight the minimum altitude on the ground, optional, default 0
  22682. * * maxHeight the maximum altitude on the ground, optional default 1
  22683. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22684. * * buffer the array holding the image color data
  22685. * * bufferWidth the width of image
  22686. * * bufferHeight the height of image
  22687. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22688. * @returns the VertexData of the Ground designed from a heightmap
  22689. */
  22690. static CreateGroundFromHeightMap(options: {
  22691. width: number;
  22692. height: number;
  22693. subdivisions: number;
  22694. minHeight: number;
  22695. maxHeight: number;
  22696. colorFilter: Color3;
  22697. buffer: Uint8Array;
  22698. bufferWidth: number;
  22699. bufferHeight: number;
  22700. alphaFilter: number;
  22701. }): VertexData;
  22702. /**
  22703. * Creates the VertexData for a Plane
  22704. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22705. * * size sets the width and height of the plane to the value of size, optional default 1
  22706. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22707. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22709. * * 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)
  22710. * * 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)
  22711. * @returns the VertexData of the box
  22712. */
  22713. static CreatePlane(options: {
  22714. size?: number;
  22715. width?: number;
  22716. height?: number;
  22717. sideOrientation?: number;
  22718. frontUVs?: Vector4;
  22719. backUVs?: Vector4;
  22720. }): VertexData;
  22721. /**
  22722. * Creates the VertexData of the Disc or regular Polygon
  22723. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22724. * * radius the radius of the disc, optional default 0.5
  22725. * * tessellation the number of polygon sides, optional, default 64
  22726. * * 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
  22727. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22728. * * 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)
  22729. * * 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)
  22730. * @returns the VertexData of the box
  22731. */
  22732. static CreateDisc(options: {
  22733. radius?: number;
  22734. tessellation?: number;
  22735. arc?: number;
  22736. sideOrientation?: number;
  22737. frontUVs?: Vector4;
  22738. backUVs?: Vector4;
  22739. }): VertexData;
  22740. /**
  22741. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22742. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22743. * @param polygon a mesh built from polygonTriangulation.build()
  22744. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22745. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22746. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22747. * @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)
  22748. * @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)
  22749. * @returns the VertexData of the Polygon
  22750. */
  22751. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22752. /**
  22753. * Creates the VertexData of the IcoSphere
  22754. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22755. * * radius the radius of the IcoSphere, optional default 1
  22756. * * radiusX allows stretching in the x direction, optional, default radius
  22757. * * radiusY allows stretching in the y direction, optional, default radius
  22758. * * radiusZ allows stretching in the z direction, optional, default radius
  22759. * * flat when true creates a flat shaded mesh, optional, default true
  22760. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22761. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22762. * * 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)
  22763. * * 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)
  22764. * @returns the VertexData of the IcoSphere
  22765. */
  22766. static CreateIcoSphere(options: {
  22767. radius?: number;
  22768. radiusX?: number;
  22769. radiusY?: number;
  22770. radiusZ?: number;
  22771. flat?: boolean;
  22772. subdivisions?: number;
  22773. sideOrientation?: number;
  22774. frontUVs?: Vector4;
  22775. backUVs?: Vector4;
  22776. }): VertexData;
  22777. /**
  22778. * Creates the VertexData for a Polyhedron
  22779. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22780. * * type provided types are:
  22781. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22782. * * 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)
  22783. * * size the size of the IcoSphere, optional default 1
  22784. * * sizeX allows stretching in the x direction, optional, default size
  22785. * * sizeY allows stretching in the y direction, optional, default size
  22786. * * sizeZ allows stretching in the z direction, optional, default size
  22787. * * 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
  22788. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22789. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22790. * * flat when true creates a flat shaded mesh, optional, default true
  22791. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22792. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22793. * * 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)
  22794. * * 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)
  22795. * @returns the VertexData of the Polyhedron
  22796. */
  22797. static CreatePolyhedron(options: {
  22798. type?: number;
  22799. size?: number;
  22800. sizeX?: number;
  22801. sizeY?: number;
  22802. sizeZ?: number;
  22803. custom?: any;
  22804. faceUV?: Vector4[];
  22805. faceColors?: Color4[];
  22806. flat?: boolean;
  22807. sideOrientation?: number;
  22808. frontUVs?: Vector4;
  22809. backUVs?: Vector4;
  22810. }): VertexData;
  22811. /**
  22812. * Creates the VertexData for a TorusKnot
  22813. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22814. * * radius the radius of the torus knot, optional, default 2
  22815. * * tube the thickness of the tube, optional, default 0.5
  22816. * * radialSegments the number of sides on each tube segments, optional, default 32
  22817. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22818. * * p the number of windings around the z axis, optional, default 2
  22819. * * q the number of windings around the x axis, optional, default 3
  22820. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22821. * * 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)
  22822. * * 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)
  22823. * @returns the VertexData of the Torus Knot
  22824. */
  22825. static CreateTorusKnot(options: {
  22826. radius?: number;
  22827. tube?: number;
  22828. radialSegments?: number;
  22829. tubularSegments?: number;
  22830. p?: number;
  22831. q?: number;
  22832. sideOrientation?: number;
  22833. frontUVs?: Vector4;
  22834. backUVs?: Vector4;
  22835. }): VertexData;
  22836. /**
  22837. * Compute normals for given positions and indices
  22838. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22839. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22840. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22841. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22842. * * facetNormals : optional array of facet normals (vector3)
  22843. * * facetPositions : optional array of facet positions (vector3)
  22844. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22845. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22846. * * bInfo : optional bounding info, required for facetPartitioning computation
  22847. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22848. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22849. * * useRightHandedSystem: optional boolean to for right handed system computation
  22850. * * depthSort : optional boolean to enable the facet depth sort computation
  22851. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22852. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22853. */
  22854. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22855. facetNormals?: any;
  22856. facetPositions?: any;
  22857. facetPartitioning?: any;
  22858. ratio?: number;
  22859. bInfo?: any;
  22860. bbSize?: Vector3;
  22861. subDiv?: any;
  22862. useRightHandedSystem?: boolean;
  22863. depthSort?: boolean;
  22864. distanceTo?: Vector3;
  22865. depthSortedFacets?: any;
  22866. }): void;
  22867. /** @hidden */
  22868. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22869. /**
  22870. * Applies VertexData created from the imported parameters to the geometry
  22871. * @param parsedVertexData the parsed data from an imported file
  22872. * @param geometry the geometry to apply the VertexData to
  22873. */
  22874. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22875. }
  22876. }
  22877. declare module BABYLON {
  22878. /**
  22879. * Defines a target to use with MorphTargetManager
  22880. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22881. */
  22882. export class MorphTarget implements IAnimatable {
  22883. /** defines the name of the target */
  22884. name: string;
  22885. /**
  22886. * Gets or sets the list of animations
  22887. */
  22888. animations: Animation[];
  22889. private _scene;
  22890. private _positions;
  22891. private _normals;
  22892. private _tangents;
  22893. private _uvs;
  22894. private _influence;
  22895. private _uniqueId;
  22896. /**
  22897. * Observable raised when the influence changes
  22898. */
  22899. onInfluenceChanged: Observable<boolean>;
  22900. /** @hidden */
  22901. _onDataLayoutChanged: Observable<void>;
  22902. /**
  22903. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22904. */
  22905. get influence(): number;
  22906. set influence(influence: number);
  22907. /**
  22908. * Gets or sets the id of the morph Target
  22909. */
  22910. id: string;
  22911. private _animationPropertiesOverride;
  22912. /**
  22913. * Gets or sets the animation properties override
  22914. */
  22915. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22916. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22917. /**
  22918. * Creates a new MorphTarget
  22919. * @param name defines the name of the target
  22920. * @param influence defines the influence to use
  22921. * @param scene defines the scene the morphtarget belongs to
  22922. */
  22923. constructor(
  22924. /** defines the name of the target */
  22925. name: string, influence?: number, scene?: Nullable<Scene>);
  22926. /**
  22927. * Gets the unique ID of this manager
  22928. */
  22929. get uniqueId(): number;
  22930. /**
  22931. * Gets a boolean defining if the target contains position data
  22932. */
  22933. get hasPositions(): boolean;
  22934. /**
  22935. * Gets a boolean defining if the target contains normal data
  22936. */
  22937. get hasNormals(): boolean;
  22938. /**
  22939. * Gets a boolean defining if the target contains tangent data
  22940. */
  22941. get hasTangents(): boolean;
  22942. /**
  22943. * Gets a boolean defining if the target contains texture coordinates data
  22944. */
  22945. get hasUVs(): boolean;
  22946. /**
  22947. * Affects position data to this target
  22948. * @param data defines the position data to use
  22949. */
  22950. setPositions(data: Nullable<FloatArray>): void;
  22951. /**
  22952. * Gets the position data stored in this target
  22953. * @returns a FloatArray containing the position data (or null if not present)
  22954. */
  22955. getPositions(): Nullable<FloatArray>;
  22956. /**
  22957. * Affects normal data to this target
  22958. * @param data defines the normal data to use
  22959. */
  22960. setNormals(data: Nullable<FloatArray>): void;
  22961. /**
  22962. * Gets the normal data stored in this target
  22963. * @returns a FloatArray containing the normal data (or null if not present)
  22964. */
  22965. getNormals(): Nullable<FloatArray>;
  22966. /**
  22967. * Affects tangent data to this target
  22968. * @param data defines the tangent data to use
  22969. */
  22970. setTangents(data: Nullable<FloatArray>): void;
  22971. /**
  22972. * Gets the tangent data stored in this target
  22973. * @returns a FloatArray containing the tangent data (or null if not present)
  22974. */
  22975. getTangents(): Nullable<FloatArray>;
  22976. /**
  22977. * Affects texture coordinates data to this target
  22978. * @param data defines the texture coordinates data to use
  22979. */
  22980. setUVs(data: Nullable<FloatArray>): void;
  22981. /**
  22982. * Gets the texture coordinates data stored in this target
  22983. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22984. */
  22985. getUVs(): Nullable<FloatArray>;
  22986. /**
  22987. * Clone the current target
  22988. * @returns a new MorphTarget
  22989. */
  22990. clone(): MorphTarget;
  22991. /**
  22992. * Serializes the current target into a Serialization object
  22993. * @returns the serialized object
  22994. */
  22995. serialize(): any;
  22996. /**
  22997. * Returns the string "MorphTarget"
  22998. * @returns "MorphTarget"
  22999. */
  23000. getClassName(): string;
  23001. /**
  23002. * Creates a new target from serialized data
  23003. * @param serializationObject defines the serialized data to use
  23004. * @returns a new MorphTarget
  23005. */
  23006. static Parse(serializationObject: any): MorphTarget;
  23007. /**
  23008. * Creates a MorphTarget from mesh data
  23009. * @param mesh defines the source mesh
  23010. * @param name defines the name to use for the new target
  23011. * @param influence defines the influence to attach to the target
  23012. * @returns a new MorphTarget
  23013. */
  23014. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23015. }
  23016. }
  23017. declare module BABYLON {
  23018. /**
  23019. * This class is used to deform meshes using morphing between different targets
  23020. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23021. */
  23022. export class MorphTargetManager {
  23023. private _targets;
  23024. private _targetInfluenceChangedObservers;
  23025. private _targetDataLayoutChangedObservers;
  23026. private _activeTargets;
  23027. private _scene;
  23028. private _influences;
  23029. private _supportsNormals;
  23030. private _supportsTangents;
  23031. private _supportsUVs;
  23032. private _vertexCount;
  23033. private _uniqueId;
  23034. private _tempInfluences;
  23035. /**
  23036. * Gets or sets a boolean indicating if normals must be morphed
  23037. */
  23038. enableNormalMorphing: boolean;
  23039. /**
  23040. * Gets or sets a boolean indicating if tangents must be morphed
  23041. */
  23042. enableTangentMorphing: boolean;
  23043. /**
  23044. * Gets or sets a boolean indicating if UV must be morphed
  23045. */
  23046. enableUVMorphing: boolean;
  23047. /**
  23048. * Creates a new MorphTargetManager
  23049. * @param scene defines the current scene
  23050. */
  23051. constructor(scene?: Nullable<Scene>);
  23052. /**
  23053. * Gets the unique ID of this manager
  23054. */
  23055. get uniqueId(): number;
  23056. /**
  23057. * Gets the number of vertices handled by this manager
  23058. */
  23059. get vertexCount(): number;
  23060. /**
  23061. * Gets a boolean indicating if this manager supports morphing of normals
  23062. */
  23063. get supportsNormals(): boolean;
  23064. /**
  23065. * Gets a boolean indicating if this manager supports morphing of tangents
  23066. */
  23067. get supportsTangents(): boolean;
  23068. /**
  23069. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23070. */
  23071. get supportsUVs(): boolean;
  23072. /**
  23073. * Gets the number of targets stored in this manager
  23074. */
  23075. get numTargets(): number;
  23076. /**
  23077. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23078. */
  23079. get numInfluencers(): number;
  23080. /**
  23081. * Gets the list of influences (one per target)
  23082. */
  23083. get influences(): Float32Array;
  23084. /**
  23085. * Gets the active target at specified index. An active target is a target with an influence > 0
  23086. * @param index defines the index to check
  23087. * @returns the requested target
  23088. */
  23089. getActiveTarget(index: number): MorphTarget;
  23090. /**
  23091. * Gets the target at specified index
  23092. * @param index defines the index to check
  23093. * @returns the requested target
  23094. */
  23095. getTarget(index: number): MorphTarget;
  23096. /**
  23097. * Add a new target to this manager
  23098. * @param target defines the target to add
  23099. */
  23100. addTarget(target: MorphTarget): void;
  23101. /**
  23102. * Removes a target from the manager
  23103. * @param target defines the target to remove
  23104. */
  23105. removeTarget(target: MorphTarget): void;
  23106. /**
  23107. * Clone the current manager
  23108. * @returns a new MorphTargetManager
  23109. */
  23110. clone(): MorphTargetManager;
  23111. /**
  23112. * Serializes the current manager into a Serialization object
  23113. * @returns the serialized object
  23114. */
  23115. serialize(): any;
  23116. private _syncActiveTargets;
  23117. /**
  23118. * Syncrhonize the targets with all the meshes using this morph target manager
  23119. */
  23120. synchronize(): void;
  23121. /**
  23122. * Creates a new MorphTargetManager from serialized data
  23123. * @param serializationObject defines the serialized data
  23124. * @param scene defines the hosting scene
  23125. * @returns the new MorphTargetManager
  23126. */
  23127. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23128. }
  23129. }
  23130. declare module BABYLON {
  23131. /**
  23132. * Class used to represent a specific level of detail of a mesh
  23133. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23134. */
  23135. export class MeshLODLevel {
  23136. /** Defines the distance where this level should start being displayed */
  23137. distance: number;
  23138. /** Defines the mesh to use to render this level */
  23139. mesh: Nullable<Mesh>;
  23140. /**
  23141. * Creates a new LOD level
  23142. * @param distance defines the distance where this level should star being displayed
  23143. * @param mesh defines the mesh to use to render this level
  23144. */
  23145. constructor(
  23146. /** Defines the distance where this level should start being displayed */
  23147. distance: number,
  23148. /** Defines the mesh to use to render this level */
  23149. mesh: Nullable<Mesh>);
  23150. }
  23151. }
  23152. declare module BABYLON {
  23153. /**
  23154. * Mesh representing the gorund
  23155. */
  23156. export class GroundMesh extends Mesh {
  23157. /** If octree should be generated */
  23158. generateOctree: boolean;
  23159. private _heightQuads;
  23160. /** @hidden */
  23161. _subdivisionsX: number;
  23162. /** @hidden */
  23163. _subdivisionsY: number;
  23164. /** @hidden */
  23165. _width: number;
  23166. /** @hidden */
  23167. _height: number;
  23168. /** @hidden */
  23169. _minX: number;
  23170. /** @hidden */
  23171. _maxX: number;
  23172. /** @hidden */
  23173. _minZ: number;
  23174. /** @hidden */
  23175. _maxZ: number;
  23176. constructor(name: string, scene: Scene);
  23177. /**
  23178. * "GroundMesh"
  23179. * @returns "GroundMesh"
  23180. */
  23181. getClassName(): string;
  23182. /**
  23183. * The minimum of x and y subdivisions
  23184. */
  23185. get subdivisions(): number;
  23186. /**
  23187. * X subdivisions
  23188. */
  23189. get subdivisionsX(): number;
  23190. /**
  23191. * Y subdivisions
  23192. */
  23193. get subdivisionsY(): number;
  23194. /**
  23195. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23196. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23197. * @param chunksCount the number of subdivisions for x and y
  23198. * @param octreeBlocksSize (Default: 32)
  23199. */
  23200. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23201. /**
  23202. * Returns a height (y) value in the Worl system :
  23203. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23204. * @param x x coordinate
  23205. * @param z z coordinate
  23206. * @returns the ground y position if (x, z) are outside the ground surface.
  23207. */
  23208. getHeightAtCoordinates(x: number, z: number): number;
  23209. /**
  23210. * Returns a normalized vector (Vector3) orthogonal to the ground
  23211. * at the ground coordinates (x, z) expressed in the World system.
  23212. * @param x x coordinate
  23213. * @param z z coordinate
  23214. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23215. */
  23216. getNormalAtCoordinates(x: number, z: number): Vector3;
  23217. /**
  23218. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23219. * at the ground coordinates (x, z) expressed in the World system.
  23220. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23221. * @param x x coordinate
  23222. * @param z z coordinate
  23223. * @param ref vector to store the result
  23224. * @returns the GroundMesh.
  23225. */
  23226. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23227. /**
  23228. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23229. * if the ground has been updated.
  23230. * This can be used in the render loop.
  23231. * @returns the GroundMesh.
  23232. */
  23233. updateCoordinateHeights(): GroundMesh;
  23234. private _getFacetAt;
  23235. private _initHeightQuads;
  23236. private _computeHeightQuads;
  23237. /**
  23238. * Serializes this ground mesh
  23239. * @param serializationObject object to write serialization to
  23240. */
  23241. serialize(serializationObject: any): void;
  23242. /**
  23243. * Parses a serialized ground mesh
  23244. * @param parsedMesh the serialized mesh
  23245. * @param scene the scene to create the ground mesh in
  23246. * @returns the created ground mesh
  23247. */
  23248. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23249. }
  23250. }
  23251. declare module BABYLON {
  23252. /**
  23253. * Interface for Physics-Joint data
  23254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23255. */
  23256. export interface PhysicsJointData {
  23257. /**
  23258. * The main pivot of the joint
  23259. */
  23260. mainPivot?: Vector3;
  23261. /**
  23262. * The connected pivot of the joint
  23263. */
  23264. connectedPivot?: Vector3;
  23265. /**
  23266. * The main axis of the joint
  23267. */
  23268. mainAxis?: Vector3;
  23269. /**
  23270. * The connected axis of the joint
  23271. */
  23272. connectedAxis?: Vector3;
  23273. /**
  23274. * The collision of the joint
  23275. */
  23276. collision?: boolean;
  23277. /**
  23278. * Native Oimo/Cannon/Energy data
  23279. */
  23280. nativeParams?: any;
  23281. }
  23282. /**
  23283. * This is a holder class for the physics joint created by the physics plugin
  23284. * It holds a set of functions to control the underlying joint
  23285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23286. */
  23287. export class PhysicsJoint {
  23288. /**
  23289. * The type of the physics joint
  23290. */
  23291. type: number;
  23292. /**
  23293. * The data for the physics joint
  23294. */
  23295. jointData: PhysicsJointData;
  23296. private _physicsJoint;
  23297. protected _physicsPlugin: IPhysicsEnginePlugin;
  23298. /**
  23299. * Initializes the physics joint
  23300. * @param type The type of the physics joint
  23301. * @param jointData The data for the physics joint
  23302. */
  23303. constructor(
  23304. /**
  23305. * The type of the physics joint
  23306. */
  23307. type: number,
  23308. /**
  23309. * The data for the physics joint
  23310. */
  23311. jointData: PhysicsJointData);
  23312. /**
  23313. * Gets the physics joint
  23314. */
  23315. get physicsJoint(): any;
  23316. /**
  23317. * Sets the physics joint
  23318. */
  23319. set physicsJoint(newJoint: any);
  23320. /**
  23321. * Sets the physics plugin
  23322. */
  23323. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23324. /**
  23325. * Execute a function that is physics-plugin specific.
  23326. * @param {Function} func the function that will be executed.
  23327. * It accepts two parameters: the physics world and the physics joint
  23328. */
  23329. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23330. /**
  23331. * Distance-Joint type
  23332. */
  23333. static DistanceJoint: number;
  23334. /**
  23335. * Hinge-Joint type
  23336. */
  23337. static HingeJoint: number;
  23338. /**
  23339. * Ball-and-Socket joint type
  23340. */
  23341. static BallAndSocketJoint: number;
  23342. /**
  23343. * Wheel-Joint type
  23344. */
  23345. static WheelJoint: number;
  23346. /**
  23347. * Slider-Joint type
  23348. */
  23349. static SliderJoint: number;
  23350. /**
  23351. * Prismatic-Joint type
  23352. */
  23353. static PrismaticJoint: number;
  23354. /**
  23355. * Universal-Joint type
  23356. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23357. */
  23358. static UniversalJoint: number;
  23359. /**
  23360. * Hinge-Joint 2 type
  23361. */
  23362. static Hinge2Joint: number;
  23363. /**
  23364. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23365. */
  23366. static PointToPointJoint: number;
  23367. /**
  23368. * Spring-Joint type
  23369. */
  23370. static SpringJoint: number;
  23371. /**
  23372. * Lock-Joint type
  23373. */
  23374. static LockJoint: number;
  23375. }
  23376. /**
  23377. * A class representing a physics distance joint
  23378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23379. */
  23380. export class DistanceJoint extends PhysicsJoint {
  23381. /**
  23382. *
  23383. * @param jointData The data for the Distance-Joint
  23384. */
  23385. constructor(jointData: DistanceJointData);
  23386. /**
  23387. * Update the predefined distance.
  23388. * @param maxDistance The maximum preferred distance
  23389. * @param minDistance The minimum preferred distance
  23390. */
  23391. updateDistance(maxDistance: number, minDistance?: number): void;
  23392. }
  23393. /**
  23394. * Represents a Motor-Enabled Joint
  23395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23396. */
  23397. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23398. /**
  23399. * Initializes the Motor-Enabled Joint
  23400. * @param type The type of the joint
  23401. * @param jointData The physica joint data for the joint
  23402. */
  23403. constructor(type: number, jointData: PhysicsJointData);
  23404. /**
  23405. * Set the motor values.
  23406. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23407. * @param force the force to apply
  23408. * @param maxForce max force for this motor.
  23409. */
  23410. setMotor(force?: number, maxForce?: number): void;
  23411. /**
  23412. * Set the motor's limits.
  23413. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23414. * @param upperLimit The upper limit of the motor
  23415. * @param lowerLimit The lower limit of the motor
  23416. */
  23417. setLimit(upperLimit: number, lowerLimit?: number): void;
  23418. }
  23419. /**
  23420. * This class represents a single physics Hinge-Joint
  23421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23422. */
  23423. export class HingeJoint extends MotorEnabledJoint {
  23424. /**
  23425. * Initializes the Hinge-Joint
  23426. * @param jointData The joint data for the Hinge-Joint
  23427. */
  23428. constructor(jointData: PhysicsJointData);
  23429. /**
  23430. * Set the motor values.
  23431. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23432. * @param {number} force the force to apply
  23433. * @param {number} maxForce max force for this motor.
  23434. */
  23435. setMotor(force?: number, maxForce?: number): void;
  23436. /**
  23437. * Set the motor's limits.
  23438. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23439. * @param upperLimit The upper limit of the motor
  23440. * @param lowerLimit The lower limit of the motor
  23441. */
  23442. setLimit(upperLimit: number, lowerLimit?: number): void;
  23443. }
  23444. /**
  23445. * This class represents a dual hinge physics joint (same as wheel joint)
  23446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23447. */
  23448. export class Hinge2Joint extends MotorEnabledJoint {
  23449. /**
  23450. * Initializes the Hinge2-Joint
  23451. * @param jointData The joint data for the Hinge2-Joint
  23452. */
  23453. constructor(jointData: PhysicsJointData);
  23454. /**
  23455. * Set the motor values.
  23456. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23457. * @param {number} targetSpeed the speed the motor is to reach
  23458. * @param {number} maxForce max force for this motor.
  23459. * @param {motorIndex} the motor's index, 0 or 1.
  23460. */
  23461. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23462. /**
  23463. * Set the motor limits.
  23464. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23465. * @param {number} upperLimit the upper limit
  23466. * @param {number} lowerLimit lower limit
  23467. * @param {motorIndex} the motor's index, 0 or 1.
  23468. */
  23469. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23470. }
  23471. /**
  23472. * Interface for a motor enabled joint
  23473. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23474. */
  23475. export interface IMotorEnabledJoint {
  23476. /**
  23477. * Physics joint
  23478. */
  23479. physicsJoint: any;
  23480. /**
  23481. * Sets the motor of the motor-enabled joint
  23482. * @param force The force of the motor
  23483. * @param maxForce The maximum force of the motor
  23484. * @param motorIndex The index of the motor
  23485. */
  23486. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23487. /**
  23488. * Sets the limit of the motor
  23489. * @param upperLimit The upper limit of the motor
  23490. * @param lowerLimit The lower limit of the motor
  23491. * @param motorIndex The index of the motor
  23492. */
  23493. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23494. }
  23495. /**
  23496. * Joint data for a Distance-Joint
  23497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23498. */
  23499. export interface DistanceJointData extends PhysicsJointData {
  23500. /**
  23501. * Max distance the 2 joint objects can be apart
  23502. */
  23503. maxDistance: number;
  23504. }
  23505. /**
  23506. * Joint data from a spring joint
  23507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23508. */
  23509. export interface SpringJointData extends PhysicsJointData {
  23510. /**
  23511. * Length of the spring
  23512. */
  23513. length: number;
  23514. /**
  23515. * Stiffness of the spring
  23516. */
  23517. stiffness: number;
  23518. /**
  23519. * Damping of the spring
  23520. */
  23521. damping: number;
  23522. /** this callback will be called when applying the force to the impostors. */
  23523. forceApplicationCallback: () => void;
  23524. }
  23525. }
  23526. declare module BABYLON {
  23527. /**
  23528. * Holds the data for the raycast result
  23529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23530. */
  23531. export class PhysicsRaycastResult {
  23532. private _hasHit;
  23533. private _hitDistance;
  23534. private _hitNormalWorld;
  23535. private _hitPointWorld;
  23536. private _rayFromWorld;
  23537. private _rayToWorld;
  23538. /**
  23539. * Gets if there was a hit
  23540. */
  23541. get hasHit(): boolean;
  23542. /**
  23543. * Gets the distance from the hit
  23544. */
  23545. get hitDistance(): number;
  23546. /**
  23547. * Gets the hit normal/direction in the world
  23548. */
  23549. get hitNormalWorld(): Vector3;
  23550. /**
  23551. * Gets the hit point in the world
  23552. */
  23553. get hitPointWorld(): Vector3;
  23554. /**
  23555. * Gets the ray "start point" of the ray in the world
  23556. */
  23557. get rayFromWorld(): Vector3;
  23558. /**
  23559. * Gets the ray "end point" of the ray in the world
  23560. */
  23561. get rayToWorld(): Vector3;
  23562. /**
  23563. * Sets the hit data (normal & point in world space)
  23564. * @param hitNormalWorld defines the normal in world space
  23565. * @param hitPointWorld defines the point in world space
  23566. */
  23567. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23568. /**
  23569. * Sets the distance from the start point to the hit point
  23570. * @param distance
  23571. */
  23572. setHitDistance(distance: number): void;
  23573. /**
  23574. * Calculates the distance manually
  23575. */
  23576. calculateHitDistance(): void;
  23577. /**
  23578. * Resets all the values to default
  23579. * @param from The from point on world space
  23580. * @param to The to point on world space
  23581. */
  23582. reset(from?: Vector3, to?: Vector3): void;
  23583. }
  23584. /**
  23585. * Interface for the size containing width and height
  23586. */
  23587. interface IXYZ {
  23588. /**
  23589. * X
  23590. */
  23591. x: number;
  23592. /**
  23593. * Y
  23594. */
  23595. y: number;
  23596. /**
  23597. * Z
  23598. */
  23599. z: number;
  23600. }
  23601. }
  23602. declare module BABYLON {
  23603. /**
  23604. * Interface used to describe a physics joint
  23605. */
  23606. export interface PhysicsImpostorJoint {
  23607. /** Defines the main impostor to which the joint is linked */
  23608. mainImpostor: PhysicsImpostor;
  23609. /** Defines the impostor that is connected to the main impostor using this joint */
  23610. connectedImpostor: PhysicsImpostor;
  23611. /** Defines the joint itself */
  23612. joint: PhysicsJoint;
  23613. }
  23614. /** @hidden */
  23615. export interface IPhysicsEnginePlugin {
  23616. world: any;
  23617. name: string;
  23618. setGravity(gravity: Vector3): void;
  23619. setTimeStep(timeStep: number): void;
  23620. getTimeStep(): number;
  23621. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23622. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23623. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23624. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23625. removePhysicsBody(impostor: PhysicsImpostor): void;
  23626. generateJoint(joint: PhysicsImpostorJoint): void;
  23627. removeJoint(joint: PhysicsImpostorJoint): void;
  23628. isSupported(): boolean;
  23629. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23630. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23631. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23632. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23633. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23634. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23635. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23636. getBodyMass(impostor: PhysicsImpostor): number;
  23637. getBodyFriction(impostor: PhysicsImpostor): number;
  23638. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23639. getBodyRestitution(impostor: PhysicsImpostor): number;
  23640. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23641. getBodyPressure?(impostor: PhysicsImpostor): number;
  23642. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23643. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23644. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23645. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23646. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23647. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23648. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23649. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23650. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23651. sleepBody(impostor: PhysicsImpostor): void;
  23652. wakeUpBody(impostor: PhysicsImpostor): void;
  23653. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23654. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23655. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23656. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23657. getRadius(impostor: PhysicsImpostor): number;
  23658. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23659. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23660. dispose(): void;
  23661. }
  23662. /**
  23663. * Interface used to define a physics engine
  23664. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23665. */
  23666. export interface IPhysicsEngine {
  23667. /**
  23668. * Gets the gravity vector used by the simulation
  23669. */
  23670. gravity: Vector3;
  23671. /**
  23672. * Sets the gravity vector used by the simulation
  23673. * @param gravity defines the gravity vector to use
  23674. */
  23675. setGravity(gravity: Vector3): void;
  23676. /**
  23677. * Set the time step of the physics engine.
  23678. * Default is 1/60.
  23679. * To slow it down, enter 1/600 for example.
  23680. * To speed it up, 1/30
  23681. * @param newTimeStep the new timestep to apply to this world.
  23682. */
  23683. setTimeStep(newTimeStep: number): void;
  23684. /**
  23685. * Get the time step of the physics engine.
  23686. * @returns the current time step
  23687. */
  23688. getTimeStep(): number;
  23689. /**
  23690. * Set the sub time step of the physics engine.
  23691. * Default is 0 meaning there is no sub steps
  23692. * To increase physics resolution precision, set a small value (like 1 ms)
  23693. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23694. */
  23695. setSubTimeStep(subTimeStep: number): void;
  23696. /**
  23697. * Get the sub time step of the physics engine.
  23698. * @returns the current sub time step
  23699. */
  23700. getSubTimeStep(): number;
  23701. /**
  23702. * Release all resources
  23703. */
  23704. dispose(): void;
  23705. /**
  23706. * Gets the name of the current physics plugin
  23707. * @returns the name of the plugin
  23708. */
  23709. getPhysicsPluginName(): string;
  23710. /**
  23711. * Adding a new impostor for the impostor tracking.
  23712. * This will be done by the impostor itself.
  23713. * @param impostor the impostor to add
  23714. */
  23715. addImpostor(impostor: PhysicsImpostor): void;
  23716. /**
  23717. * Remove an impostor from the engine.
  23718. * This impostor and its mesh will not longer be updated by the physics engine.
  23719. * @param impostor the impostor to remove
  23720. */
  23721. removeImpostor(impostor: PhysicsImpostor): void;
  23722. /**
  23723. * Add a joint to the physics engine
  23724. * @param mainImpostor defines the main impostor to which the joint is added.
  23725. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23726. * @param joint defines the joint that will connect both impostors.
  23727. */
  23728. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23729. /**
  23730. * Removes a joint from the simulation
  23731. * @param mainImpostor defines the impostor used with the joint
  23732. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23733. * @param joint defines the joint to remove
  23734. */
  23735. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23736. /**
  23737. * Gets the current plugin used to run the simulation
  23738. * @returns current plugin
  23739. */
  23740. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23741. /**
  23742. * Gets the list of physic impostors
  23743. * @returns an array of PhysicsImpostor
  23744. */
  23745. getImpostors(): Array<PhysicsImpostor>;
  23746. /**
  23747. * Gets the impostor for a physics enabled object
  23748. * @param object defines the object impersonated by the impostor
  23749. * @returns the PhysicsImpostor or null if not found
  23750. */
  23751. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23752. /**
  23753. * Gets the impostor for a physics body object
  23754. * @param body defines physics body used by the impostor
  23755. * @returns the PhysicsImpostor or null if not found
  23756. */
  23757. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23758. /**
  23759. * Does a raycast in the physics world
  23760. * @param from when should the ray start?
  23761. * @param to when should the ray end?
  23762. * @returns PhysicsRaycastResult
  23763. */
  23764. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23765. /**
  23766. * Called by the scene. No need to call it.
  23767. * @param delta defines the timespam between frames
  23768. */
  23769. _step(delta: number): void;
  23770. }
  23771. }
  23772. declare module BABYLON {
  23773. /**
  23774. * The interface for the physics imposter parameters
  23775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23776. */
  23777. export interface PhysicsImpostorParameters {
  23778. /**
  23779. * The mass of the physics imposter
  23780. */
  23781. mass: number;
  23782. /**
  23783. * The friction of the physics imposter
  23784. */
  23785. friction?: number;
  23786. /**
  23787. * The coefficient of restitution of the physics imposter
  23788. */
  23789. restitution?: number;
  23790. /**
  23791. * The native options of the physics imposter
  23792. */
  23793. nativeOptions?: any;
  23794. /**
  23795. * Specifies if the parent should be ignored
  23796. */
  23797. ignoreParent?: boolean;
  23798. /**
  23799. * Specifies if bi-directional transformations should be disabled
  23800. */
  23801. disableBidirectionalTransformation?: boolean;
  23802. /**
  23803. * The pressure inside the physics imposter, soft object only
  23804. */
  23805. pressure?: number;
  23806. /**
  23807. * The stiffness the physics imposter, soft object only
  23808. */
  23809. stiffness?: number;
  23810. /**
  23811. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23812. */
  23813. velocityIterations?: number;
  23814. /**
  23815. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23816. */
  23817. positionIterations?: number;
  23818. /**
  23819. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23820. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23821. * Add to fix multiple points
  23822. */
  23823. fixedPoints?: number;
  23824. /**
  23825. * The collision margin around a soft object
  23826. */
  23827. margin?: number;
  23828. /**
  23829. * The collision margin around a soft object
  23830. */
  23831. damping?: number;
  23832. /**
  23833. * The path for a rope based on an extrusion
  23834. */
  23835. path?: any;
  23836. /**
  23837. * The shape of an extrusion used for a rope based on an extrusion
  23838. */
  23839. shape?: any;
  23840. }
  23841. /**
  23842. * Interface for a physics-enabled object
  23843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23844. */
  23845. export interface IPhysicsEnabledObject {
  23846. /**
  23847. * The position of the physics-enabled object
  23848. */
  23849. position: Vector3;
  23850. /**
  23851. * The rotation of the physics-enabled object
  23852. */
  23853. rotationQuaternion: Nullable<Quaternion>;
  23854. /**
  23855. * The scale of the physics-enabled object
  23856. */
  23857. scaling: Vector3;
  23858. /**
  23859. * The rotation of the physics-enabled object
  23860. */
  23861. rotation?: Vector3;
  23862. /**
  23863. * The parent of the physics-enabled object
  23864. */
  23865. parent?: any;
  23866. /**
  23867. * The bounding info of the physics-enabled object
  23868. * @returns The bounding info of the physics-enabled object
  23869. */
  23870. getBoundingInfo(): BoundingInfo;
  23871. /**
  23872. * Computes the world matrix
  23873. * @param force Specifies if the world matrix should be computed by force
  23874. * @returns A world matrix
  23875. */
  23876. computeWorldMatrix(force: boolean): Matrix;
  23877. /**
  23878. * Gets the world matrix
  23879. * @returns A world matrix
  23880. */
  23881. getWorldMatrix?(): Matrix;
  23882. /**
  23883. * Gets the child meshes
  23884. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23885. * @returns An array of abstract meshes
  23886. */
  23887. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23888. /**
  23889. * Gets the vertex data
  23890. * @param kind The type of vertex data
  23891. * @returns A nullable array of numbers, or a float32 array
  23892. */
  23893. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23894. /**
  23895. * Gets the indices from the mesh
  23896. * @returns A nullable array of index arrays
  23897. */
  23898. getIndices?(): Nullable<IndicesArray>;
  23899. /**
  23900. * Gets the scene from the mesh
  23901. * @returns the indices array or null
  23902. */
  23903. getScene?(): Scene;
  23904. /**
  23905. * Gets the absolute position from the mesh
  23906. * @returns the absolute position
  23907. */
  23908. getAbsolutePosition(): Vector3;
  23909. /**
  23910. * Gets the absolute pivot point from the mesh
  23911. * @returns the absolute pivot point
  23912. */
  23913. getAbsolutePivotPoint(): Vector3;
  23914. /**
  23915. * Rotates the mesh
  23916. * @param axis The axis of rotation
  23917. * @param amount The amount of rotation
  23918. * @param space The space of the rotation
  23919. * @returns The rotation transform node
  23920. */
  23921. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23922. /**
  23923. * Translates the mesh
  23924. * @param axis The axis of translation
  23925. * @param distance The distance of translation
  23926. * @param space The space of the translation
  23927. * @returns The transform node
  23928. */
  23929. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23930. /**
  23931. * Sets the absolute position of the mesh
  23932. * @param absolutePosition The absolute position of the mesh
  23933. * @returns The transform node
  23934. */
  23935. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23936. /**
  23937. * Gets the class name of the mesh
  23938. * @returns The class name
  23939. */
  23940. getClassName(): string;
  23941. }
  23942. /**
  23943. * Represents a physics imposter
  23944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23945. */
  23946. export class PhysicsImpostor {
  23947. /**
  23948. * The physics-enabled object used as the physics imposter
  23949. */
  23950. object: IPhysicsEnabledObject;
  23951. /**
  23952. * The type of the physics imposter
  23953. */
  23954. type: number;
  23955. private _options;
  23956. private _scene?;
  23957. /**
  23958. * The default object size of the imposter
  23959. */
  23960. static DEFAULT_OBJECT_SIZE: Vector3;
  23961. /**
  23962. * The identity quaternion of the imposter
  23963. */
  23964. static IDENTITY_QUATERNION: Quaternion;
  23965. /** @hidden */
  23966. _pluginData: any;
  23967. private _physicsEngine;
  23968. private _physicsBody;
  23969. private _bodyUpdateRequired;
  23970. private _onBeforePhysicsStepCallbacks;
  23971. private _onAfterPhysicsStepCallbacks;
  23972. /** @hidden */
  23973. _onPhysicsCollideCallbacks: Array<{
  23974. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23975. otherImpostors: Array<PhysicsImpostor>;
  23976. }>;
  23977. private _deltaPosition;
  23978. private _deltaRotation;
  23979. private _deltaRotationConjugated;
  23980. /** @hidden */
  23981. _isFromLine: boolean;
  23982. private _parent;
  23983. private _isDisposed;
  23984. private static _tmpVecs;
  23985. private static _tmpQuat;
  23986. /**
  23987. * Specifies if the physics imposter is disposed
  23988. */
  23989. get isDisposed(): boolean;
  23990. /**
  23991. * Gets the mass of the physics imposter
  23992. */
  23993. get mass(): number;
  23994. set mass(value: number);
  23995. /**
  23996. * Gets the coefficient of friction
  23997. */
  23998. get friction(): number;
  23999. /**
  24000. * Sets the coefficient of friction
  24001. */
  24002. set friction(value: number);
  24003. /**
  24004. * Gets the coefficient of restitution
  24005. */
  24006. get restitution(): number;
  24007. /**
  24008. * Sets the coefficient of restitution
  24009. */
  24010. set restitution(value: number);
  24011. /**
  24012. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24013. */
  24014. get pressure(): number;
  24015. /**
  24016. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24017. */
  24018. set pressure(value: number);
  24019. /**
  24020. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24021. */
  24022. get stiffness(): number;
  24023. /**
  24024. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24025. */
  24026. set stiffness(value: number);
  24027. /**
  24028. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24029. */
  24030. get velocityIterations(): number;
  24031. /**
  24032. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24033. */
  24034. set velocityIterations(value: number);
  24035. /**
  24036. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24037. */
  24038. get positionIterations(): number;
  24039. /**
  24040. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24041. */
  24042. set positionIterations(value: number);
  24043. /**
  24044. * The unique id of the physics imposter
  24045. * set by the physics engine when adding this impostor to the array
  24046. */
  24047. uniqueId: number;
  24048. /**
  24049. * @hidden
  24050. */
  24051. soft: boolean;
  24052. /**
  24053. * @hidden
  24054. */
  24055. segments: number;
  24056. private _joints;
  24057. /**
  24058. * Initializes the physics imposter
  24059. * @param object The physics-enabled object used as the physics imposter
  24060. * @param type The type of the physics imposter
  24061. * @param _options The options for the physics imposter
  24062. * @param _scene The Babylon scene
  24063. */
  24064. constructor(
  24065. /**
  24066. * The physics-enabled object used as the physics imposter
  24067. */
  24068. object: IPhysicsEnabledObject,
  24069. /**
  24070. * The type of the physics imposter
  24071. */
  24072. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24073. /**
  24074. * This function will completly initialize this impostor.
  24075. * It will create a new body - but only if this mesh has no parent.
  24076. * If it has, this impostor will not be used other than to define the impostor
  24077. * of the child mesh.
  24078. * @hidden
  24079. */
  24080. _init(): void;
  24081. private _getPhysicsParent;
  24082. /**
  24083. * Should a new body be generated.
  24084. * @returns boolean specifying if body initialization is required
  24085. */
  24086. isBodyInitRequired(): boolean;
  24087. /**
  24088. * Sets the updated scaling
  24089. * @param updated Specifies if the scaling is updated
  24090. */
  24091. setScalingUpdated(): void;
  24092. /**
  24093. * Force a regeneration of this or the parent's impostor's body.
  24094. * Use under cautious - This will remove all joints already implemented.
  24095. */
  24096. forceUpdate(): void;
  24097. /**
  24098. * Gets the body that holds this impostor. Either its own, or its parent.
  24099. */
  24100. get physicsBody(): any;
  24101. /**
  24102. * Get the parent of the physics imposter
  24103. * @returns Physics imposter or null
  24104. */
  24105. get parent(): Nullable<PhysicsImpostor>;
  24106. /**
  24107. * Sets the parent of the physics imposter
  24108. */
  24109. set parent(value: Nullable<PhysicsImpostor>);
  24110. /**
  24111. * Set the physics body. Used mainly by the physics engine/plugin
  24112. */
  24113. set physicsBody(physicsBody: any);
  24114. /**
  24115. * Resets the update flags
  24116. */
  24117. resetUpdateFlags(): void;
  24118. /**
  24119. * Gets the object extend size
  24120. * @returns the object extend size
  24121. */
  24122. getObjectExtendSize(): Vector3;
  24123. /**
  24124. * Gets the object center
  24125. * @returns The object center
  24126. */
  24127. getObjectCenter(): Vector3;
  24128. /**
  24129. * Get a specific parameter from the options parameters
  24130. * @param paramName The object parameter name
  24131. * @returns The object parameter
  24132. */
  24133. getParam(paramName: string): any;
  24134. /**
  24135. * Sets a specific parameter in the options given to the physics plugin
  24136. * @param paramName The parameter name
  24137. * @param value The value of the parameter
  24138. */
  24139. setParam(paramName: string, value: number): void;
  24140. /**
  24141. * Specifically change the body's mass option. Won't recreate the physics body object
  24142. * @param mass The mass of the physics imposter
  24143. */
  24144. setMass(mass: number): void;
  24145. /**
  24146. * Gets the linear velocity
  24147. * @returns linear velocity or null
  24148. */
  24149. getLinearVelocity(): Nullable<Vector3>;
  24150. /**
  24151. * Sets the linear velocity
  24152. * @param velocity linear velocity or null
  24153. */
  24154. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24155. /**
  24156. * Gets the angular velocity
  24157. * @returns angular velocity or null
  24158. */
  24159. getAngularVelocity(): Nullable<Vector3>;
  24160. /**
  24161. * Sets the angular velocity
  24162. * @param velocity The velocity or null
  24163. */
  24164. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24165. /**
  24166. * Execute a function with the physics plugin native code
  24167. * Provide a function the will have two variables - the world object and the physics body object
  24168. * @param func The function to execute with the physics plugin native code
  24169. */
  24170. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24171. /**
  24172. * Register a function that will be executed before the physics world is stepping forward
  24173. * @param func The function to execute before the physics world is stepped forward
  24174. */
  24175. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24176. /**
  24177. * Unregister a function that will be executed before the physics world is stepping forward
  24178. * @param func The function to execute before the physics world is stepped forward
  24179. */
  24180. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24181. /**
  24182. * Register a function that will be executed after the physics step
  24183. * @param func The function to execute after physics step
  24184. */
  24185. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24186. /**
  24187. * Unregisters a function that will be executed after the physics step
  24188. * @param func The function to execute after physics step
  24189. */
  24190. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24191. /**
  24192. * register a function that will be executed when this impostor collides against a different body
  24193. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24194. * @param func Callback that is executed on collision
  24195. */
  24196. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24197. /**
  24198. * Unregisters the physics imposter on contact
  24199. * @param collideAgainst The physics object to collide against
  24200. * @param func Callback to execute on collision
  24201. */
  24202. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24203. private _tmpQuat;
  24204. private _tmpQuat2;
  24205. /**
  24206. * Get the parent rotation
  24207. * @returns The parent rotation
  24208. */
  24209. getParentsRotation(): Quaternion;
  24210. /**
  24211. * this function is executed by the physics engine.
  24212. */
  24213. beforeStep: () => void;
  24214. /**
  24215. * this function is executed by the physics engine
  24216. */
  24217. afterStep: () => void;
  24218. /**
  24219. * Legacy collision detection event support
  24220. */
  24221. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24222. /**
  24223. * event and body object due to cannon's event-based architecture.
  24224. */
  24225. onCollide: (e: {
  24226. body: any;
  24227. }) => void;
  24228. /**
  24229. * Apply a force
  24230. * @param force The force to apply
  24231. * @param contactPoint The contact point for the force
  24232. * @returns The physics imposter
  24233. */
  24234. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24235. /**
  24236. * Apply an impulse
  24237. * @param force The impulse force
  24238. * @param contactPoint The contact point for the impulse force
  24239. * @returns The physics imposter
  24240. */
  24241. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24242. /**
  24243. * A help function to create a joint
  24244. * @param otherImpostor A physics imposter used to create a joint
  24245. * @param jointType The type of joint
  24246. * @param jointData The data for the joint
  24247. * @returns The physics imposter
  24248. */
  24249. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24250. /**
  24251. * Add a joint to this impostor with a different impostor
  24252. * @param otherImpostor A physics imposter used to add a joint
  24253. * @param joint The joint to add
  24254. * @returns The physics imposter
  24255. */
  24256. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24257. /**
  24258. * Add an anchor to a cloth impostor
  24259. * @param otherImpostor rigid impostor to anchor to
  24260. * @param width ratio across width from 0 to 1
  24261. * @param height ratio up height from 0 to 1
  24262. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24263. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24264. * @returns impostor the soft imposter
  24265. */
  24266. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24267. /**
  24268. * Add a hook to a rope impostor
  24269. * @param otherImpostor rigid impostor to anchor to
  24270. * @param length ratio across rope from 0 to 1
  24271. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24272. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24273. * @returns impostor the rope imposter
  24274. */
  24275. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24276. /**
  24277. * Will keep this body still, in a sleep mode.
  24278. * @returns the physics imposter
  24279. */
  24280. sleep(): PhysicsImpostor;
  24281. /**
  24282. * Wake the body up.
  24283. * @returns The physics imposter
  24284. */
  24285. wakeUp(): PhysicsImpostor;
  24286. /**
  24287. * Clones the physics imposter
  24288. * @param newObject The physics imposter clones to this physics-enabled object
  24289. * @returns A nullable physics imposter
  24290. */
  24291. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24292. /**
  24293. * Disposes the physics imposter
  24294. */
  24295. dispose(): void;
  24296. /**
  24297. * Sets the delta position
  24298. * @param position The delta position amount
  24299. */
  24300. setDeltaPosition(position: Vector3): void;
  24301. /**
  24302. * Sets the delta rotation
  24303. * @param rotation The delta rotation amount
  24304. */
  24305. setDeltaRotation(rotation: Quaternion): void;
  24306. /**
  24307. * Gets the box size of the physics imposter and stores the result in the input parameter
  24308. * @param result Stores the box size
  24309. * @returns The physics imposter
  24310. */
  24311. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24312. /**
  24313. * Gets the radius of the physics imposter
  24314. * @returns Radius of the physics imposter
  24315. */
  24316. getRadius(): number;
  24317. /**
  24318. * Sync a bone with this impostor
  24319. * @param bone The bone to sync to the impostor.
  24320. * @param boneMesh The mesh that the bone is influencing.
  24321. * @param jointPivot The pivot of the joint / bone in local space.
  24322. * @param distToJoint Optional distance from the impostor to the joint.
  24323. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24324. */
  24325. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24326. /**
  24327. * Sync impostor to a bone
  24328. * @param bone The bone that the impostor will be synced to.
  24329. * @param boneMesh The mesh that the bone is influencing.
  24330. * @param jointPivot The pivot of the joint / bone in local space.
  24331. * @param distToJoint Optional distance from the impostor to the joint.
  24332. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24333. * @param boneAxis Optional vector3 axis the bone is aligned with
  24334. */
  24335. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24336. /**
  24337. * No-Imposter type
  24338. */
  24339. static NoImpostor: number;
  24340. /**
  24341. * Sphere-Imposter type
  24342. */
  24343. static SphereImpostor: number;
  24344. /**
  24345. * Box-Imposter type
  24346. */
  24347. static BoxImpostor: number;
  24348. /**
  24349. * Plane-Imposter type
  24350. */
  24351. static PlaneImpostor: number;
  24352. /**
  24353. * Mesh-imposter type
  24354. */
  24355. static MeshImpostor: number;
  24356. /**
  24357. * Capsule-Impostor type (Ammo.js plugin only)
  24358. */
  24359. static CapsuleImpostor: number;
  24360. /**
  24361. * Cylinder-Imposter type
  24362. */
  24363. static CylinderImpostor: number;
  24364. /**
  24365. * Particle-Imposter type
  24366. */
  24367. static ParticleImpostor: number;
  24368. /**
  24369. * Heightmap-Imposter type
  24370. */
  24371. static HeightmapImpostor: number;
  24372. /**
  24373. * ConvexHull-Impostor type (Ammo.js plugin only)
  24374. */
  24375. static ConvexHullImpostor: number;
  24376. /**
  24377. * Custom-Imposter type (Ammo.js plugin only)
  24378. */
  24379. static CustomImpostor: number;
  24380. /**
  24381. * Rope-Imposter type
  24382. */
  24383. static RopeImpostor: number;
  24384. /**
  24385. * Cloth-Imposter type
  24386. */
  24387. static ClothImpostor: number;
  24388. /**
  24389. * Softbody-Imposter type
  24390. */
  24391. static SoftbodyImpostor: number;
  24392. }
  24393. }
  24394. declare module BABYLON {
  24395. /**
  24396. * @hidden
  24397. **/
  24398. export class _CreationDataStorage {
  24399. closePath?: boolean;
  24400. closeArray?: boolean;
  24401. idx: number[];
  24402. dashSize: number;
  24403. gapSize: number;
  24404. path3D: Path3D;
  24405. pathArray: Vector3[][];
  24406. arc: number;
  24407. radius: number;
  24408. cap: number;
  24409. tessellation: number;
  24410. }
  24411. /**
  24412. * @hidden
  24413. **/
  24414. class _InstanceDataStorage {
  24415. visibleInstances: any;
  24416. batchCache: _InstancesBatch;
  24417. instancesBufferSize: number;
  24418. instancesBuffer: Nullable<Buffer>;
  24419. instancesData: Float32Array;
  24420. overridenInstanceCount: number;
  24421. isFrozen: boolean;
  24422. previousBatch: Nullable<_InstancesBatch>;
  24423. hardwareInstancedRendering: boolean;
  24424. sideOrientation: number;
  24425. manualUpdate: boolean;
  24426. }
  24427. /**
  24428. * @hidden
  24429. **/
  24430. export class _InstancesBatch {
  24431. mustReturn: boolean;
  24432. visibleInstances: Nullable<InstancedMesh[]>[];
  24433. renderSelf: boolean[];
  24434. hardwareInstancedRendering: boolean[];
  24435. }
  24436. /**
  24437. * Class used to represent renderable models
  24438. */
  24439. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24440. /**
  24441. * Mesh side orientation : usually the external or front surface
  24442. */
  24443. static readonly FRONTSIDE: number;
  24444. /**
  24445. * Mesh side orientation : usually the internal or back surface
  24446. */
  24447. static readonly BACKSIDE: number;
  24448. /**
  24449. * Mesh side orientation : both internal and external or front and back surfaces
  24450. */
  24451. static readonly DOUBLESIDE: number;
  24452. /**
  24453. * Mesh side orientation : by default, `FRONTSIDE`
  24454. */
  24455. static readonly DEFAULTSIDE: number;
  24456. /**
  24457. * Mesh cap setting : no cap
  24458. */
  24459. static readonly NO_CAP: number;
  24460. /**
  24461. * Mesh cap setting : one cap at the beginning of the mesh
  24462. */
  24463. static readonly CAP_START: number;
  24464. /**
  24465. * Mesh cap setting : one cap at the end of the mesh
  24466. */
  24467. static readonly CAP_END: number;
  24468. /**
  24469. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24470. */
  24471. static readonly CAP_ALL: number;
  24472. /**
  24473. * Mesh pattern setting : no flip or rotate
  24474. */
  24475. static readonly NO_FLIP: number;
  24476. /**
  24477. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24478. */
  24479. static readonly FLIP_TILE: number;
  24480. /**
  24481. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24482. */
  24483. static readonly ROTATE_TILE: number;
  24484. /**
  24485. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24486. */
  24487. static readonly FLIP_ROW: number;
  24488. /**
  24489. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24490. */
  24491. static readonly ROTATE_ROW: number;
  24492. /**
  24493. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24494. */
  24495. static readonly FLIP_N_ROTATE_TILE: number;
  24496. /**
  24497. * Mesh pattern setting : rotate pattern and rotate
  24498. */
  24499. static readonly FLIP_N_ROTATE_ROW: number;
  24500. /**
  24501. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24502. */
  24503. static readonly CENTER: number;
  24504. /**
  24505. * Mesh tile positioning : part tiles on left
  24506. */
  24507. static readonly LEFT: number;
  24508. /**
  24509. * Mesh tile positioning : part tiles on right
  24510. */
  24511. static readonly RIGHT: number;
  24512. /**
  24513. * Mesh tile positioning : part tiles on top
  24514. */
  24515. static readonly TOP: number;
  24516. /**
  24517. * Mesh tile positioning : part tiles on bottom
  24518. */
  24519. static readonly BOTTOM: number;
  24520. /**
  24521. * Gets the default side orientation.
  24522. * @param orientation the orientation to value to attempt to get
  24523. * @returns the default orientation
  24524. * @hidden
  24525. */
  24526. static _GetDefaultSideOrientation(orientation?: number): number;
  24527. private _internalMeshDataInfo;
  24528. /**
  24529. * An event triggered before rendering the mesh
  24530. */
  24531. get onBeforeRenderObservable(): Observable<Mesh>;
  24532. /**
  24533. * An event triggered before binding the mesh
  24534. */
  24535. get onBeforeBindObservable(): Observable<Mesh>;
  24536. /**
  24537. * An event triggered after rendering the mesh
  24538. */
  24539. get onAfterRenderObservable(): Observable<Mesh>;
  24540. /**
  24541. * An event triggered before drawing the mesh
  24542. */
  24543. get onBeforeDrawObservable(): Observable<Mesh>;
  24544. private _onBeforeDrawObserver;
  24545. /**
  24546. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24547. */
  24548. set onBeforeDraw(callback: () => void);
  24549. get hasInstances(): boolean;
  24550. /**
  24551. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24552. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24553. */
  24554. delayLoadState: number;
  24555. /**
  24556. * Gets the list of instances created from this mesh
  24557. * it is not supposed to be modified manually.
  24558. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24559. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24560. */
  24561. instances: InstancedMesh[];
  24562. /**
  24563. * Gets the file containing delay loading data for this mesh
  24564. */
  24565. delayLoadingFile: string;
  24566. /** @hidden */
  24567. _binaryInfo: any;
  24568. /**
  24569. * User defined function used to change how LOD level selection is done
  24570. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24571. */
  24572. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24573. /**
  24574. * Gets or sets the morph target manager
  24575. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24576. */
  24577. get morphTargetManager(): Nullable<MorphTargetManager>;
  24578. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24579. /** @hidden */
  24580. _creationDataStorage: Nullable<_CreationDataStorage>;
  24581. /** @hidden */
  24582. _geometry: Nullable<Geometry>;
  24583. /** @hidden */
  24584. _delayInfo: Array<string>;
  24585. /** @hidden */
  24586. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24587. /** @hidden */
  24588. _instanceDataStorage: _InstanceDataStorage;
  24589. private _effectiveMaterial;
  24590. /** @hidden */
  24591. _shouldGenerateFlatShading: boolean;
  24592. /** @hidden */
  24593. _originalBuilderSideOrientation: number;
  24594. /**
  24595. * Use this property to change the original side orientation defined at construction time
  24596. */
  24597. overrideMaterialSideOrientation: Nullable<number>;
  24598. /**
  24599. * Gets the source mesh (the one used to clone this one from)
  24600. */
  24601. get source(): Nullable<Mesh>;
  24602. /**
  24603. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24604. */
  24605. get isUnIndexed(): boolean;
  24606. set isUnIndexed(value: boolean);
  24607. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24608. get worldMatrixInstancedBuffer(): Float32Array;
  24609. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24610. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24611. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24612. /**
  24613. * @constructor
  24614. * @param name The value used by scene.getMeshByName() to do a lookup.
  24615. * @param scene The scene to add this mesh to.
  24616. * @param parent The parent of this mesh, if it has one
  24617. * @param source An optional Mesh from which geometry is shared, cloned.
  24618. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24619. * When false, achieved by calling a clone(), also passing False.
  24620. * This will make creation of children, recursive.
  24621. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24622. */
  24623. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24624. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24625. doNotInstantiate: boolean;
  24626. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24627. /**
  24628. * Gets the class name
  24629. * @returns the string "Mesh".
  24630. */
  24631. getClassName(): string;
  24632. /** @hidden */
  24633. get _isMesh(): boolean;
  24634. /**
  24635. * Returns a description of this mesh
  24636. * @param fullDetails define if full details about this mesh must be used
  24637. * @returns a descriptive string representing this mesh
  24638. */
  24639. toString(fullDetails?: boolean): string;
  24640. /** @hidden */
  24641. _unBindEffect(): void;
  24642. /**
  24643. * Gets a boolean indicating if this mesh has LOD
  24644. */
  24645. get hasLODLevels(): boolean;
  24646. /**
  24647. * Gets the list of MeshLODLevel associated with the current mesh
  24648. * @returns an array of MeshLODLevel
  24649. */
  24650. getLODLevels(): MeshLODLevel[];
  24651. private _sortLODLevels;
  24652. /**
  24653. * Add a mesh as LOD level triggered at the given distance.
  24654. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24655. * @param distance The distance from the center of the object to show this level
  24656. * @param mesh The mesh to be added as LOD level (can be null)
  24657. * @return This mesh (for chaining)
  24658. */
  24659. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24660. /**
  24661. * Returns the LOD level mesh at the passed distance or null if not found.
  24662. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24663. * @param distance The distance from the center of the object to show this level
  24664. * @returns a Mesh or `null`
  24665. */
  24666. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24667. /**
  24668. * Remove a mesh from the LOD array
  24669. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24670. * @param mesh defines the mesh to be removed
  24671. * @return This mesh (for chaining)
  24672. */
  24673. removeLODLevel(mesh: Mesh): Mesh;
  24674. /**
  24675. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24676. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24677. * @param camera defines the camera to use to compute distance
  24678. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24679. * @return This mesh (for chaining)
  24680. */
  24681. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24682. /**
  24683. * Gets the mesh internal Geometry object
  24684. */
  24685. get geometry(): Nullable<Geometry>;
  24686. /**
  24687. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24688. * @returns the total number of vertices
  24689. */
  24690. getTotalVertices(): number;
  24691. /**
  24692. * Returns the content of an associated vertex buffer
  24693. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24694. * - VertexBuffer.PositionKind
  24695. * - VertexBuffer.UVKind
  24696. * - VertexBuffer.UV2Kind
  24697. * - VertexBuffer.UV3Kind
  24698. * - VertexBuffer.UV4Kind
  24699. * - VertexBuffer.UV5Kind
  24700. * - VertexBuffer.UV6Kind
  24701. * - VertexBuffer.ColorKind
  24702. * - VertexBuffer.MatricesIndicesKind
  24703. * - VertexBuffer.MatricesIndicesExtraKind
  24704. * - VertexBuffer.MatricesWeightsKind
  24705. * - VertexBuffer.MatricesWeightsExtraKind
  24706. * @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
  24707. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24708. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24709. */
  24710. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24711. /**
  24712. * Returns the mesh VertexBuffer object from the requested `kind`
  24713. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24714. * - VertexBuffer.PositionKind
  24715. * - VertexBuffer.NormalKind
  24716. * - VertexBuffer.UVKind
  24717. * - VertexBuffer.UV2Kind
  24718. * - VertexBuffer.UV3Kind
  24719. * - VertexBuffer.UV4Kind
  24720. * - VertexBuffer.UV5Kind
  24721. * - VertexBuffer.UV6Kind
  24722. * - VertexBuffer.ColorKind
  24723. * - VertexBuffer.MatricesIndicesKind
  24724. * - VertexBuffer.MatricesIndicesExtraKind
  24725. * - VertexBuffer.MatricesWeightsKind
  24726. * - VertexBuffer.MatricesWeightsExtraKind
  24727. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24728. */
  24729. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24730. /**
  24731. * Tests if a specific vertex buffer is associated with this mesh
  24732. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24733. * - VertexBuffer.PositionKind
  24734. * - VertexBuffer.NormalKind
  24735. * - VertexBuffer.UVKind
  24736. * - VertexBuffer.UV2Kind
  24737. * - VertexBuffer.UV3Kind
  24738. * - VertexBuffer.UV4Kind
  24739. * - VertexBuffer.UV5Kind
  24740. * - VertexBuffer.UV6Kind
  24741. * - VertexBuffer.ColorKind
  24742. * - VertexBuffer.MatricesIndicesKind
  24743. * - VertexBuffer.MatricesIndicesExtraKind
  24744. * - VertexBuffer.MatricesWeightsKind
  24745. * - VertexBuffer.MatricesWeightsExtraKind
  24746. * @returns a boolean
  24747. */
  24748. isVerticesDataPresent(kind: string): boolean;
  24749. /**
  24750. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24751. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24752. * - VertexBuffer.PositionKind
  24753. * - VertexBuffer.UVKind
  24754. * - VertexBuffer.UV2Kind
  24755. * - VertexBuffer.UV3Kind
  24756. * - VertexBuffer.UV4Kind
  24757. * - VertexBuffer.UV5Kind
  24758. * - VertexBuffer.UV6Kind
  24759. * - VertexBuffer.ColorKind
  24760. * - VertexBuffer.MatricesIndicesKind
  24761. * - VertexBuffer.MatricesIndicesExtraKind
  24762. * - VertexBuffer.MatricesWeightsKind
  24763. * - VertexBuffer.MatricesWeightsExtraKind
  24764. * @returns a boolean
  24765. */
  24766. isVertexBufferUpdatable(kind: string): boolean;
  24767. /**
  24768. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24769. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24770. * - VertexBuffer.PositionKind
  24771. * - VertexBuffer.NormalKind
  24772. * - VertexBuffer.UVKind
  24773. * - VertexBuffer.UV2Kind
  24774. * - VertexBuffer.UV3Kind
  24775. * - VertexBuffer.UV4Kind
  24776. * - VertexBuffer.UV5Kind
  24777. * - VertexBuffer.UV6Kind
  24778. * - VertexBuffer.ColorKind
  24779. * - VertexBuffer.MatricesIndicesKind
  24780. * - VertexBuffer.MatricesIndicesExtraKind
  24781. * - VertexBuffer.MatricesWeightsKind
  24782. * - VertexBuffer.MatricesWeightsExtraKind
  24783. * @returns an array of strings
  24784. */
  24785. getVerticesDataKinds(): string[];
  24786. /**
  24787. * Returns a positive integer : the total number of indices in this mesh geometry.
  24788. * @returns the numner of indices or zero if the mesh has no geometry.
  24789. */
  24790. getTotalIndices(): number;
  24791. /**
  24792. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24793. * @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.
  24794. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24795. * @returns the indices array or an empty array if the mesh has no geometry
  24796. */
  24797. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24798. get isBlocked(): boolean;
  24799. /**
  24800. * Determine if the current mesh is ready to be rendered
  24801. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24802. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24803. * @returns true if all associated assets are ready (material, textures, shaders)
  24804. */
  24805. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24806. /**
  24807. * 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.
  24808. */
  24809. get areNormalsFrozen(): boolean;
  24810. /**
  24811. * 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.
  24812. * @returns the current mesh
  24813. */
  24814. freezeNormals(): Mesh;
  24815. /**
  24816. * 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
  24817. * @returns the current mesh
  24818. */
  24819. unfreezeNormals(): Mesh;
  24820. /**
  24821. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24822. */
  24823. set overridenInstanceCount(count: number);
  24824. /** @hidden */
  24825. _preActivate(): Mesh;
  24826. /** @hidden */
  24827. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24828. /** @hidden */
  24829. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24830. /**
  24831. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24832. * This means the mesh underlying bounding box and sphere are recomputed.
  24833. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24834. * @returns the current mesh
  24835. */
  24836. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24837. /** @hidden */
  24838. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24839. /**
  24840. * This function will subdivide the mesh into multiple submeshes
  24841. * @param count defines the expected number of submeshes
  24842. */
  24843. subdivide(count: number): void;
  24844. /**
  24845. * Copy a FloatArray into a specific associated vertex buffer
  24846. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24847. * - VertexBuffer.PositionKind
  24848. * - VertexBuffer.UVKind
  24849. * - VertexBuffer.UV2Kind
  24850. * - VertexBuffer.UV3Kind
  24851. * - VertexBuffer.UV4Kind
  24852. * - VertexBuffer.UV5Kind
  24853. * - VertexBuffer.UV6Kind
  24854. * - VertexBuffer.ColorKind
  24855. * - VertexBuffer.MatricesIndicesKind
  24856. * - VertexBuffer.MatricesIndicesExtraKind
  24857. * - VertexBuffer.MatricesWeightsKind
  24858. * - VertexBuffer.MatricesWeightsExtraKind
  24859. * @param data defines the data source
  24860. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24861. * @param stride defines the data stride size (can be null)
  24862. * @returns the current mesh
  24863. */
  24864. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24865. /**
  24866. * Delete a vertex buffer associated with this mesh
  24867. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24868. * - VertexBuffer.PositionKind
  24869. * - VertexBuffer.UVKind
  24870. * - VertexBuffer.UV2Kind
  24871. * - VertexBuffer.UV3Kind
  24872. * - VertexBuffer.UV4Kind
  24873. * - VertexBuffer.UV5Kind
  24874. * - VertexBuffer.UV6Kind
  24875. * - VertexBuffer.ColorKind
  24876. * - VertexBuffer.MatricesIndicesKind
  24877. * - VertexBuffer.MatricesIndicesExtraKind
  24878. * - VertexBuffer.MatricesWeightsKind
  24879. * - VertexBuffer.MatricesWeightsExtraKind
  24880. */
  24881. removeVerticesData(kind: string): void;
  24882. /**
  24883. * Flags an associated vertex buffer as updatable
  24884. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24885. * - VertexBuffer.PositionKind
  24886. * - VertexBuffer.UVKind
  24887. * - VertexBuffer.UV2Kind
  24888. * - VertexBuffer.UV3Kind
  24889. * - VertexBuffer.UV4Kind
  24890. * - VertexBuffer.UV5Kind
  24891. * - VertexBuffer.UV6Kind
  24892. * - VertexBuffer.ColorKind
  24893. * - VertexBuffer.MatricesIndicesKind
  24894. * - VertexBuffer.MatricesIndicesExtraKind
  24895. * - VertexBuffer.MatricesWeightsKind
  24896. * - VertexBuffer.MatricesWeightsExtraKind
  24897. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24898. */
  24899. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24900. /**
  24901. * Sets the mesh global Vertex Buffer
  24902. * @param buffer defines the buffer to use
  24903. * @returns the current mesh
  24904. */
  24905. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24906. /**
  24907. * Update a specific associated vertex buffer
  24908. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24909. * - VertexBuffer.PositionKind
  24910. * - VertexBuffer.UVKind
  24911. * - VertexBuffer.UV2Kind
  24912. * - VertexBuffer.UV3Kind
  24913. * - VertexBuffer.UV4Kind
  24914. * - VertexBuffer.UV5Kind
  24915. * - VertexBuffer.UV6Kind
  24916. * - VertexBuffer.ColorKind
  24917. * - VertexBuffer.MatricesIndicesKind
  24918. * - VertexBuffer.MatricesIndicesExtraKind
  24919. * - VertexBuffer.MatricesWeightsKind
  24920. * - VertexBuffer.MatricesWeightsExtraKind
  24921. * @param data defines the data source
  24922. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24923. * @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)
  24924. * @returns the current mesh
  24925. */
  24926. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24927. /**
  24928. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24929. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24930. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24931. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24932. * @returns the current mesh
  24933. */
  24934. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24935. /**
  24936. * Creates a un-shared specific occurence of the geometry for the mesh.
  24937. * @returns the current mesh
  24938. */
  24939. makeGeometryUnique(): Mesh;
  24940. /**
  24941. * Set the index buffer of this mesh
  24942. * @param indices defines the source data
  24943. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24944. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24945. * @returns the current mesh
  24946. */
  24947. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24948. /**
  24949. * Update the current index buffer
  24950. * @param indices defines the source data
  24951. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24952. * @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)
  24953. * @returns the current mesh
  24954. */
  24955. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24956. /**
  24957. * Invert the geometry to move from a right handed system to a left handed one.
  24958. * @returns the current mesh
  24959. */
  24960. toLeftHanded(): Mesh;
  24961. /** @hidden */
  24962. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24963. /** @hidden */
  24964. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24965. /**
  24966. * Registers for this mesh a javascript function called just before the rendering process
  24967. * @param func defines the function to call before rendering this mesh
  24968. * @returns the current mesh
  24969. */
  24970. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24971. /**
  24972. * Disposes a previously registered javascript function called before the rendering
  24973. * @param func defines the function to remove
  24974. * @returns the current mesh
  24975. */
  24976. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24977. /**
  24978. * Registers for this mesh a javascript function called just after the rendering is complete
  24979. * @param func defines the function to call after rendering this mesh
  24980. * @returns the current mesh
  24981. */
  24982. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24983. /**
  24984. * Disposes a previously registered javascript function called after the rendering.
  24985. * @param func defines the function to remove
  24986. * @returns the current mesh
  24987. */
  24988. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24989. /** @hidden */
  24990. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24991. /** @hidden */
  24992. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24993. /** @hidden */
  24994. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24995. /** @hidden */
  24996. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24997. /** @hidden */
  24998. _rebuild(): void;
  24999. /** @hidden */
  25000. _freeze(): void;
  25001. /** @hidden */
  25002. _unFreeze(): void;
  25003. /**
  25004. * 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
  25005. * @param subMesh defines the subMesh to render
  25006. * @param enableAlphaMode defines if alpha mode can be changed
  25007. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25008. * @returns the current mesh
  25009. */
  25010. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25011. private _onBeforeDraw;
  25012. /**
  25013. * Renormalize the mesh and patch it up if there are no weights
  25014. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25015. * However in the case of zero weights then we set just a single influence to 1.
  25016. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25017. */
  25018. cleanMatrixWeights(): void;
  25019. private normalizeSkinFourWeights;
  25020. private normalizeSkinWeightsAndExtra;
  25021. /**
  25022. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25023. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25024. * the user know there was an issue with importing the mesh
  25025. * @returns a validation object with skinned, valid and report string
  25026. */
  25027. validateSkinning(): {
  25028. skinned: boolean;
  25029. valid: boolean;
  25030. report: string;
  25031. };
  25032. /** @hidden */
  25033. _checkDelayState(): Mesh;
  25034. private _queueLoad;
  25035. /**
  25036. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25037. * A mesh is in the frustum if its bounding box intersects the frustum
  25038. * @param frustumPlanes defines the frustum to test
  25039. * @returns true if the mesh is in the frustum planes
  25040. */
  25041. isInFrustum(frustumPlanes: Plane[]): boolean;
  25042. /**
  25043. * Sets the mesh material by the material or multiMaterial `id` property
  25044. * @param id is a string identifying the material or the multiMaterial
  25045. * @returns the current mesh
  25046. */
  25047. setMaterialByID(id: string): Mesh;
  25048. /**
  25049. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25050. * @returns an array of IAnimatable
  25051. */
  25052. getAnimatables(): IAnimatable[];
  25053. /**
  25054. * Modifies the mesh geometry according to the passed transformation matrix.
  25055. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25056. * The mesh normals are modified using the same transformation.
  25057. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25058. * @param transform defines the transform matrix to use
  25059. * @see http://doc.babylonjs.com/resources/baking_transformations
  25060. * @returns the current mesh
  25061. */
  25062. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25063. /**
  25064. * Modifies the mesh geometry according to its own current World Matrix.
  25065. * The mesh World Matrix is then reset.
  25066. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25067. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25068. * @see http://doc.babylonjs.com/resources/baking_transformations
  25069. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25070. * @returns the current mesh
  25071. */
  25072. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25073. /** @hidden */
  25074. get _positions(): Nullable<Vector3[]>;
  25075. /** @hidden */
  25076. _resetPointsArrayCache(): Mesh;
  25077. /** @hidden */
  25078. _generatePointsArray(): boolean;
  25079. /**
  25080. * Returns a new Mesh object generated from the current mesh properties.
  25081. * This method must not get confused with createInstance()
  25082. * @param name is a string, the name given to the new mesh
  25083. * @param newParent can be any Node object (default `null`)
  25084. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25085. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25086. * @returns a new mesh
  25087. */
  25088. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25089. /**
  25090. * Releases resources associated with this mesh.
  25091. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25092. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25093. */
  25094. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25095. /** @hidden */
  25096. _disposeInstanceSpecificData(): void;
  25097. /**
  25098. * Modifies the mesh geometry according to a displacement map.
  25099. * 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.
  25100. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25101. * @param url is a string, the URL from the image file is to be downloaded.
  25102. * @param minHeight is the lower limit of the displacement.
  25103. * @param maxHeight is the upper limit of the displacement.
  25104. * @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.
  25105. * @param uvOffset is an optional vector2 used to offset UV.
  25106. * @param uvScale is an optional vector2 used to scale UV.
  25107. * @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.
  25108. * @returns the Mesh.
  25109. */
  25110. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25111. /**
  25112. * Modifies the mesh geometry according to a displacementMap buffer.
  25113. * 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.
  25114. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25115. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25116. * @param heightMapWidth is the width of the buffer image.
  25117. * @param heightMapHeight is the height of the buffer image.
  25118. * @param minHeight is the lower limit of the displacement.
  25119. * @param maxHeight is the upper limit of the displacement.
  25120. * @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.
  25121. * @param uvOffset is an optional vector2 used to offset UV.
  25122. * @param uvScale is an optional vector2 used to scale UV.
  25123. * @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.
  25124. * @returns the Mesh.
  25125. */
  25126. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25127. /**
  25128. * Modify the mesh to get a flat shading rendering.
  25129. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25130. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25131. * @returns current mesh
  25132. */
  25133. convertToFlatShadedMesh(): Mesh;
  25134. /**
  25135. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25136. * In other words, more vertices, no more indices and a single bigger VBO.
  25137. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25138. * @returns current mesh
  25139. */
  25140. convertToUnIndexedMesh(): Mesh;
  25141. /**
  25142. * Inverses facet orientations.
  25143. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25144. * @param flipNormals will also inverts the normals
  25145. * @returns current mesh
  25146. */
  25147. flipFaces(flipNormals?: boolean): Mesh;
  25148. /**
  25149. * Increase the number of facets and hence vertices in a mesh
  25150. * Vertex normals are interpolated from existing vertex normals
  25151. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25152. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25153. */
  25154. increaseVertices(numberPerEdge: number): void;
  25155. /**
  25156. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25157. * This will undo any application of covertToFlatShadedMesh
  25158. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25159. */
  25160. forceSharedVertices(): void;
  25161. /** @hidden */
  25162. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25163. /** @hidden */
  25164. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25165. /**
  25166. * Creates a new InstancedMesh object from the mesh model.
  25167. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25168. * @param name defines the name of the new instance
  25169. * @returns a new InstancedMesh
  25170. */
  25171. createInstance(name: string): InstancedMesh;
  25172. /**
  25173. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25174. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25175. * @returns the current mesh
  25176. */
  25177. synchronizeInstances(): Mesh;
  25178. /**
  25179. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25180. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25181. * This should be used together with the simplification to avoid disappearing triangles.
  25182. * @param successCallback an optional success callback to be called after the optimization finished.
  25183. * @returns the current mesh
  25184. */
  25185. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25186. /**
  25187. * Serialize current mesh
  25188. * @param serializationObject defines the object which will receive the serialization data
  25189. */
  25190. serialize(serializationObject: any): void;
  25191. /** @hidden */
  25192. _syncGeometryWithMorphTargetManager(): void;
  25193. /** @hidden */
  25194. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25195. /**
  25196. * Returns a new Mesh object parsed from the source provided.
  25197. * @param parsedMesh is the source
  25198. * @param scene defines the hosting scene
  25199. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25200. * @returns a new Mesh
  25201. */
  25202. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25203. /**
  25204. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25205. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25206. * @param name defines the name of the mesh to create
  25207. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25208. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25209. * @param closePath creates a seam between the first and the last points of each path of the path array
  25210. * @param offset is taken in account only if the `pathArray` is containing a single path
  25211. * @param scene defines the hosting scene
  25212. * @param updatable defines if the mesh must be flagged as updatable
  25213. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25214. * @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)
  25215. * @returns a new Mesh
  25216. */
  25217. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25218. /**
  25219. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25220. * @param name defines the name of the mesh to create
  25221. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25222. * @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
  25223. * @param scene defines the hosting scene
  25224. * @param updatable defines if the mesh must be flagged as updatable
  25225. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25226. * @returns a new Mesh
  25227. */
  25228. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25229. /**
  25230. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25231. * @param name defines the name of the mesh to create
  25232. * @param size sets the size (float) of each box side (default 1)
  25233. * @param scene defines the hosting scene
  25234. * @param updatable defines if the mesh must be flagged as updatable
  25235. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25236. * @returns a new Mesh
  25237. */
  25238. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25239. /**
  25240. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25241. * @param name defines the name of the mesh to create
  25242. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25243. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25244. * @param scene defines the hosting scene
  25245. * @param updatable defines if the mesh must be flagged as updatable
  25246. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25247. * @returns a new Mesh
  25248. */
  25249. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25250. /**
  25251. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25252. * @param name defines the name of the mesh to create
  25253. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25254. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25255. * @param scene defines the hosting scene
  25256. * @returns a new Mesh
  25257. */
  25258. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25259. /**
  25260. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25261. * @param name defines the name of the mesh to create
  25262. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25263. * @param diameterTop set the top cap diameter (floats, default 1)
  25264. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25265. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25266. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25267. * @param scene defines the hosting scene
  25268. * @param updatable defines if the mesh must be flagged as updatable
  25269. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25270. * @returns a new Mesh
  25271. */
  25272. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25273. /**
  25274. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25275. * @param name defines the name of the mesh to create
  25276. * @param diameter sets the diameter size (float) of the torus (default 1)
  25277. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25278. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25279. * @param scene defines the hosting scene
  25280. * @param updatable defines if the mesh must be flagged as updatable
  25281. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25282. * @returns a new Mesh
  25283. */
  25284. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25285. /**
  25286. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25287. * @param name defines the name of the mesh to create
  25288. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25289. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25290. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25291. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25292. * @param p the number of windings on X axis (positive integers, default 2)
  25293. * @param q the number of windings on Y axis (positive integers, default 3)
  25294. * @param scene defines the hosting scene
  25295. * @param updatable defines if the mesh must be flagged as updatable
  25296. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25297. * @returns a new Mesh
  25298. */
  25299. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25300. /**
  25301. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25302. * @param name defines the name of the mesh to create
  25303. * @param points is an array successive Vector3
  25304. * @param scene defines the hosting scene
  25305. * @param updatable defines if the mesh must be flagged as updatable
  25306. * @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).
  25307. * @returns a new Mesh
  25308. */
  25309. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25310. /**
  25311. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25312. * @param name defines the name of the mesh to create
  25313. * @param points is an array successive Vector3
  25314. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25315. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25316. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25317. * @param scene defines the hosting scene
  25318. * @param updatable defines if the mesh must be flagged as updatable
  25319. * @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)
  25320. * @returns a new Mesh
  25321. */
  25322. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25323. /**
  25324. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25325. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25326. * 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.
  25327. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25328. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25329. * Remember you can only change the shape positions, not their number when updating a polygon.
  25330. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25331. * @param name defines the name of the mesh to create
  25332. * @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
  25333. * @param scene defines the hosting scene
  25334. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25335. * @param updatable defines if the mesh must be flagged as updatable
  25336. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25337. * @param earcutInjection can be used to inject your own earcut reference
  25338. * @returns a new Mesh
  25339. */
  25340. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25341. /**
  25342. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25343. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25344. * @param name defines the name of the mesh to create
  25345. * @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
  25346. * @param depth defines the height of extrusion
  25347. * @param scene defines the hosting scene
  25348. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25349. * @param updatable defines if the mesh must be flagged as updatable
  25350. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25351. * @param earcutInjection can be used to inject your own earcut reference
  25352. * @returns a new Mesh
  25353. */
  25354. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25355. /**
  25356. * Creates an extruded shape mesh.
  25357. * 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
  25358. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25359. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25360. * @param name defines the name of the mesh to create
  25361. * @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
  25362. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25363. * @param scale is the value to scale the shape
  25364. * @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
  25365. * @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
  25366. * @param scene defines the hosting scene
  25367. * @param updatable defines if the mesh must be flagged as updatable
  25368. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25369. * @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)
  25370. * @returns a new Mesh
  25371. */
  25372. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25373. /**
  25374. * Creates an custom extruded shape mesh.
  25375. * The custom extrusion is a parametric shape.
  25376. * It has no predefined shape. Its final shape will depend on the input parameters.
  25377. * Please consider using the same method from the MeshBuilder class instead
  25378. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25379. * @param name defines the name of the mesh to create
  25380. * @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
  25381. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25382. * @param scaleFunction is a custom Javascript function called on each path point
  25383. * @param rotationFunction is a custom Javascript function called on each path point
  25384. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25385. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25386. * @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
  25387. * @param scene defines the hosting scene
  25388. * @param updatable defines if the mesh must be flagged as updatable
  25389. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25390. * @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)
  25391. * @returns a new Mesh
  25392. */
  25393. 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;
  25394. /**
  25395. * Creates lathe mesh.
  25396. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25397. * Please consider using the same method from the MeshBuilder class instead
  25398. * @param name defines the name of the mesh to create
  25399. * @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
  25400. * @param radius is the radius value of the lathe
  25401. * @param tessellation is the side number of the lathe.
  25402. * @param scene defines the hosting scene
  25403. * @param updatable defines if the mesh must be flagged as updatable
  25404. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25405. * @returns a new Mesh
  25406. */
  25407. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25408. /**
  25409. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25410. * @param name defines the name of the mesh to create
  25411. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25412. * @param scene defines the hosting scene
  25413. * @param updatable defines if the mesh must be flagged as updatable
  25414. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25415. * @returns a new Mesh
  25416. */
  25417. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25418. /**
  25419. * Creates a ground mesh.
  25420. * Please consider using the same method from the MeshBuilder class instead
  25421. * @param name defines the name of the mesh to create
  25422. * @param width set the width of the ground
  25423. * @param height set the height of the ground
  25424. * @param subdivisions sets the number of subdivisions per side
  25425. * @param scene defines the hosting scene
  25426. * @param updatable defines if the mesh must be flagged as updatable
  25427. * @returns a new Mesh
  25428. */
  25429. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25430. /**
  25431. * Creates a tiled ground mesh.
  25432. * Please consider using the same method from the MeshBuilder class instead
  25433. * @param name defines the name of the mesh to create
  25434. * @param xmin set the ground minimum X coordinate
  25435. * @param zmin set the ground minimum Y coordinate
  25436. * @param xmax set the ground maximum X coordinate
  25437. * @param zmax set the ground maximum Z coordinate
  25438. * @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
  25439. * @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
  25440. * @param scene defines the hosting scene
  25441. * @param updatable defines if the mesh must be flagged as updatable
  25442. * @returns a new Mesh
  25443. */
  25444. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25445. w: number;
  25446. h: number;
  25447. }, precision: {
  25448. w: number;
  25449. h: number;
  25450. }, scene: Scene, updatable?: boolean): Mesh;
  25451. /**
  25452. * Creates a ground mesh from a height map.
  25453. * Please consider using the same method from the MeshBuilder class instead
  25454. * @see http://doc.babylonjs.com/babylon101/height_map
  25455. * @param name defines the name of the mesh to create
  25456. * @param url sets the URL of the height map image resource
  25457. * @param width set the ground width size
  25458. * @param height set the ground height size
  25459. * @param subdivisions sets the number of subdivision per side
  25460. * @param minHeight is the minimum altitude on the ground
  25461. * @param maxHeight is the maximum altitude on the ground
  25462. * @param scene defines the hosting scene
  25463. * @param updatable defines if the mesh must be flagged as updatable
  25464. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25465. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25466. * @returns a new Mesh
  25467. */
  25468. 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;
  25469. /**
  25470. * Creates a tube mesh.
  25471. * The tube is a parametric shape.
  25472. * It has no predefined shape. Its final shape will depend on the input parameters.
  25473. * Please consider using the same method from the MeshBuilder class instead
  25474. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25475. * @param name defines the name of the mesh to create
  25476. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25477. * @param radius sets the tube radius size
  25478. * @param tessellation is the number of sides on the tubular surface
  25479. * @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
  25480. * @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
  25481. * @param scene defines the hosting scene
  25482. * @param updatable defines if the mesh must be flagged as updatable
  25483. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25484. * @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)
  25485. * @returns a new Mesh
  25486. */
  25487. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25488. (i: number, distance: number): number;
  25489. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25490. /**
  25491. * Creates a polyhedron mesh.
  25492. * Please consider using the same method from the MeshBuilder class instead.
  25493. * * 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
  25494. * * The parameter `size` (positive float, default 1) sets the polygon size
  25495. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25496. * * 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`
  25497. * * 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
  25498. * * 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)`)
  25499. * * 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
  25500. * * 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
  25501. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25502. * * 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
  25503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25504. * @param name defines the name of the mesh to create
  25505. * @param options defines the options used to create the mesh
  25506. * @param scene defines the hosting scene
  25507. * @returns a new Mesh
  25508. */
  25509. static CreatePolyhedron(name: string, options: {
  25510. type?: number;
  25511. size?: number;
  25512. sizeX?: number;
  25513. sizeY?: number;
  25514. sizeZ?: number;
  25515. custom?: any;
  25516. faceUV?: Vector4[];
  25517. faceColors?: Color4[];
  25518. updatable?: boolean;
  25519. sideOrientation?: number;
  25520. }, scene: Scene): Mesh;
  25521. /**
  25522. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25523. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25524. * * 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`)
  25525. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25526. * * 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
  25527. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25528. * * 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
  25529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25530. * @param name defines the name of the mesh
  25531. * @param options defines the options used to create the mesh
  25532. * @param scene defines the hosting scene
  25533. * @returns a new Mesh
  25534. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25535. */
  25536. static CreateIcoSphere(name: string, options: {
  25537. radius?: number;
  25538. flat?: boolean;
  25539. subdivisions?: number;
  25540. sideOrientation?: number;
  25541. updatable?: boolean;
  25542. }, scene: Scene): Mesh;
  25543. /**
  25544. * Creates a decal mesh.
  25545. * Please consider using the same method from the MeshBuilder class instead.
  25546. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25547. * @param name defines the name of the mesh
  25548. * @param sourceMesh defines the mesh receiving the decal
  25549. * @param position sets the position of the decal in world coordinates
  25550. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25551. * @param size sets the decal scaling
  25552. * @param angle sets the angle to rotate the decal
  25553. * @returns a new Mesh
  25554. */
  25555. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25556. /**
  25557. * Prepare internal position array for software CPU skinning
  25558. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25559. */
  25560. setPositionsForCPUSkinning(): Float32Array;
  25561. /**
  25562. * Prepare internal normal array for software CPU skinning
  25563. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25564. */
  25565. setNormalsForCPUSkinning(): Float32Array;
  25566. /**
  25567. * Updates the vertex buffer by applying transformation from the bones
  25568. * @param skeleton defines the skeleton to apply to current mesh
  25569. * @returns the current mesh
  25570. */
  25571. applySkeleton(skeleton: Skeleton): Mesh;
  25572. /**
  25573. * 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
  25574. * @param meshes defines the list of meshes to scan
  25575. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25576. */
  25577. static MinMax(meshes: AbstractMesh[]): {
  25578. min: Vector3;
  25579. max: Vector3;
  25580. };
  25581. /**
  25582. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25583. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25584. * @returns a vector3
  25585. */
  25586. static Center(meshesOrMinMaxVector: {
  25587. min: Vector3;
  25588. max: Vector3;
  25589. } | AbstractMesh[]): Vector3;
  25590. /**
  25591. * Merge the array of meshes into a single mesh for performance reasons.
  25592. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25593. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25594. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25595. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25596. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25597. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25598. * @returns a new mesh
  25599. */
  25600. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25601. /** @hidden */
  25602. addInstance(instance: InstancedMesh): void;
  25603. /** @hidden */
  25604. removeInstance(instance: InstancedMesh): void;
  25605. }
  25606. }
  25607. declare module BABYLON {
  25608. /**
  25609. * This is the base class of all the camera used in the application.
  25610. * @see http://doc.babylonjs.com/features/cameras
  25611. */
  25612. export class Camera extends Node {
  25613. /** @hidden */
  25614. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25615. /**
  25616. * This is the default projection mode used by the cameras.
  25617. * It helps recreating a feeling of perspective and better appreciate depth.
  25618. * This is the best way to simulate real life cameras.
  25619. */
  25620. static readonly PERSPECTIVE_CAMERA: number;
  25621. /**
  25622. * This helps creating camera with an orthographic mode.
  25623. * 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.
  25624. */
  25625. static readonly ORTHOGRAPHIC_CAMERA: number;
  25626. /**
  25627. * This is the default FOV mode for perspective cameras.
  25628. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25629. */
  25630. static readonly FOVMODE_VERTICAL_FIXED: number;
  25631. /**
  25632. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25633. */
  25634. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25635. /**
  25636. * This specifies ther is no need for a camera rig.
  25637. * Basically only one eye is rendered corresponding to the camera.
  25638. */
  25639. static readonly RIG_MODE_NONE: number;
  25640. /**
  25641. * Simulates a camera Rig with one blue eye and one red eye.
  25642. * This can be use with 3d blue and red glasses.
  25643. */
  25644. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25645. /**
  25646. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25647. */
  25648. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25649. /**
  25650. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25651. */
  25652. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25653. /**
  25654. * Defines that both eyes of the camera will be rendered over under each other.
  25655. */
  25656. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25657. /**
  25658. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25659. */
  25660. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25661. /**
  25662. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25663. */
  25664. static readonly RIG_MODE_VR: number;
  25665. /**
  25666. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25667. */
  25668. static readonly RIG_MODE_WEBVR: number;
  25669. /**
  25670. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25671. */
  25672. static readonly RIG_MODE_CUSTOM: number;
  25673. /**
  25674. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25675. */
  25676. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25677. /**
  25678. * Define the input manager associated with the camera.
  25679. */
  25680. inputs: CameraInputsManager<Camera>;
  25681. /** @hidden */
  25682. _position: Vector3;
  25683. /**
  25684. * Define the current local position of the camera in the scene
  25685. */
  25686. get position(): Vector3;
  25687. set position(newPosition: Vector3);
  25688. /**
  25689. * The vector the camera should consider as up.
  25690. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25691. */
  25692. upVector: Vector3;
  25693. /**
  25694. * Define the current limit on the left side for an orthographic camera
  25695. * In scene unit
  25696. */
  25697. orthoLeft: Nullable<number>;
  25698. /**
  25699. * Define the current limit on the right side for an orthographic camera
  25700. * In scene unit
  25701. */
  25702. orthoRight: Nullable<number>;
  25703. /**
  25704. * Define the current limit on the bottom side for an orthographic camera
  25705. * In scene unit
  25706. */
  25707. orthoBottom: Nullable<number>;
  25708. /**
  25709. * Define the current limit on the top side for an orthographic camera
  25710. * In scene unit
  25711. */
  25712. orthoTop: Nullable<number>;
  25713. /**
  25714. * Field Of View is set in Radians. (default is 0.8)
  25715. */
  25716. fov: number;
  25717. /**
  25718. * Define the minimum distance the camera can see from.
  25719. * This is important to note that the depth buffer are not infinite and the closer it starts
  25720. * the more your scene might encounter depth fighting issue.
  25721. */
  25722. minZ: number;
  25723. /**
  25724. * Define the maximum distance the camera can see to.
  25725. * This is important to note that the depth buffer are not infinite and the further it end
  25726. * the more your scene might encounter depth fighting issue.
  25727. */
  25728. maxZ: number;
  25729. /**
  25730. * Define the default inertia of the camera.
  25731. * This helps giving a smooth feeling to the camera movement.
  25732. */
  25733. inertia: number;
  25734. /**
  25735. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25736. */
  25737. mode: number;
  25738. /**
  25739. * Define whether the camera is intermediate.
  25740. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25741. */
  25742. isIntermediate: boolean;
  25743. /**
  25744. * Define the viewport of the camera.
  25745. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25746. */
  25747. viewport: Viewport;
  25748. /**
  25749. * Restricts the camera to viewing objects with the same layerMask.
  25750. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25751. */
  25752. layerMask: number;
  25753. /**
  25754. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25755. */
  25756. fovMode: number;
  25757. /**
  25758. * Rig mode of the camera.
  25759. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25760. * This is normally controlled byt the camera themselves as internal use.
  25761. */
  25762. cameraRigMode: number;
  25763. /**
  25764. * Defines the distance between both "eyes" in case of a RIG
  25765. */
  25766. interaxialDistance: number;
  25767. /**
  25768. * Defines if stereoscopic rendering is done side by side or over under.
  25769. */
  25770. isStereoscopicSideBySide: boolean;
  25771. /**
  25772. * 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
  25773. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25774. * else in the scene. (Eg. security camera)
  25775. *
  25776. * 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)
  25777. */
  25778. customRenderTargets: RenderTargetTexture[];
  25779. /**
  25780. * When set, the camera will render to this render target instead of the default canvas
  25781. *
  25782. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25783. */
  25784. outputRenderTarget: Nullable<RenderTargetTexture>;
  25785. /**
  25786. * Observable triggered when the camera view matrix has changed.
  25787. */
  25788. onViewMatrixChangedObservable: Observable<Camera>;
  25789. /**
  25790. * Observable triggered when the camera Projection matrix has changed.
  25791. */
  25792. onProjectionMatrixChangedObservable: Observable<Camera>;
  25793. /**
  25794. * Observable triggered when the inputs have been processed.
  25795. */
  25796. onAfterCheckInputsObservable: Observable<Camera>;
  25797. /**
  25798. * Observable triggered when reset has been called and applied to the camera.
  25799. */
  25800. onRestoreStateObservable: Observable<Camera>;
  25801. /**
  25802. * Is this camera a part of a rig system?
  25803. */
  25804. isRigCamera: boolean;
  25805. /**
  25806. * If isRigCamera set to true this will be set with the parent camera.
  25807. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25808. */
  25809. rigParent?: Camera;
  25810. /** @hidden */
  25811. _cameraRigParams: any;
  25812. /** @hidden */
  25813. _rigCameras: Camera[];
  25814. /** @hidden */
  25815. _rigPostProcess: Nullable<PostProcess>;
  25816. protected _webvrViewMatrix: Matrix;
  25817. /** @hidden */
  25818. _skipRendering: boolean;
  25819. /** @hidden */
  25820. _projectionMatrix: Matrix;
  25821. /** @hidden */
  25822. _postProcesses: Nullable<PostProcess>[];
  25823. /** @hidden */
  25824. _activeMeshes: SmartArray<AbstractMesh>;
  25825. protected _globalPosition: Vector3;
  25826. /** @hidden */
  25827. _computedViewMatrix: Matrix;
  25828. private _doNotComputeProjectionMatrix;
  25829. private _transformMatrix;
  25830. private _frustumPlanes;
  25831. private _refreshFrustumPlanes;
  25832. private _storedFov;
  25833. private _stateStored;
  25834. /**
  25835. * Instantiates a new camera object.
  25836. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25837. * @see http://doc.babylonjs.com/features/cameras
  25838. * @param name Defines the name of the camera in the scene
  25839. * @param position Defines the position of the camera
  25840. * @param scene Defines the scene the camera belongs too
  25841. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25842. */
  25843. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25844. /**
  25845. * Store current camera state (fov, position, etc..)
  25846. * @returns the camera
  25847. */
  25848. storeState(): Camera;
  25849. /**
  25850. * Restores the camera state values if it has been stored. You must call storeState() first
  25851. */
  25852. protected _restoreStateValues(): boolean;
  25853. /**
  25854. * Restored camera state. You must call storeState() first.
  25855. * @returns true if restored and false otherwise
  25856. */
  25857. restoreState(): boolean;
  25858. /**
  25859. * Gets the class name of the camera.
  25860. * @returns the class name
  25861. */
  25862. getClassName(): string;
  25863. /** @hidden */
  25864. readonly _isCamera: boolean;
  25865. /**
  25866. * Gets a string representation of the camera useful for debug purpose.
  25867. * @param fullDetails Defines that a more verboe level of logging is required
  25868. * @returns the string representation
  25869. */
  25870. toString(fullDetails?: boolean): string;
  25871. /**
  25872. * Gets the current world space position of the camera.
  25873. */
  25874. get globalPosition(): Vector3;
  25875. /**
  25876. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25877. * @returns the active meshe list
  25878. */
  25879. getActiveMeshes(): SmartArray<AbstractMesh>;
  25880. /**
  25881. * Check whether a mesh is part of the current active mesh list of the camera
  25882. * @param mesh Defines the mesh to check
  25883. * @returns true if active, false otherwise
  25884. */
  25885. isActiveMesh(mesh: Mesh): boolean;
  25886. /**
  25887. * Is this camera ready to be used/rendered
  25888. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25889. * @return true if the camera is ready
  25890. */
  25891. isReady(completeCheck?: boolean): boolean;
  25892. /** @hidden */
  25893. _initCache(): void;
  25894. /** @hidden */
  25895. _updateCache(ignoreParentClass?: boolean): void;
  25896. /** @hidden */
  25897. _isSynchronized(): boolean;
  25898. /** @hidden */
  25899. _isSynchronizedViewMatrix(): boolean;
  25900. /** @hidden */
  25901. _isSynchronizedProjectionMatrix(): boolean;
  25902. /**
  25903. * Attach the input controls to a specific dom element to get the input from.
  25904. * @param element Defines the element the controls should be listened from
  25905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25906. */
  25907. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25908. /**
  25909. * Detach the current controls from the specified dom element.
  25910. * @param element Defines the element to stop listening the inputs from
  25911. */
  25912. detachControl(element: HTMLElement): void;
  25913. /**
  25914. * Update the camera state according to the different inputs gathered during the frame.
  25915. */
  25916. update(): void;
  25917. /** @hidden */
  25918. _checkInputs(): void;
  25919. /** @hidden */
  25920. get rigCameras(): Camera[];
  25921. /**
  25922. * Gets the post process used by the rig cameras
  25923. */
  25924. get rigPostProcess(): Nullable<PostProcess>;
  25925. /**
  25926. * Internal, gets the first post proces.
  25927. * @returns the first post process to be run on this camera.
  25928. */
  25929. _getFirstPostProcess(): Nullable<PostProcess>;
  25930. private _cascadePostProcessesToRigCams;
  25931. /**
  25932. * Attach a post process to the camera.
  25933. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25934. * @param postProcess The post process to attach to the camera
  25935. * @param insertAt The position of the post process in case several of them are in use in the scene
  25936. * @returns the position the post process has been inserted at
  25937. */
  25938. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25939. /**
  25940. * Detach a post process to the camera.
  25941. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25942. * @param postProcess The post process to detach from the camera
  25943. */
  25944. detachPostProcess(postProcess: PostProcess): void;
  25945. /**
  25946. * Gets the current world matrix of the camera
  25947. */
  25948. getWorldMatrix(): Matrix;
  25949. /** @hidden */
  25950. _getViewMatrix(): Matrix;
  25951. /**
  25952. * Gets the current view matrix of the camera.
  25953. * @param force forces the camera to recompute the matrix without looking at the cached state
  25954. * @returns the view matrix
  25955. */
  25956. getViewMatrix(force?: boolean): Matrix;
  25957. /**
  25958. * Freeze the projection matrix.
  25959. * It will prevent the cache check of the camera projection compute and can speed up perf
  25960. * if no parameter of the camera are meant to change
  25961. * @param projection Defines manually a projection if necessary
  25962. */
  25963. freezeProjectionMatrix(projection?: Matrix): void;
  25964. /**
  25965. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25966. */
  25967. unfreezeProjectionMatrix(): void;
  25968. /**
  25969. * Gets the current projection matrix of the camera.
  25970. * @param force forces the camera to recompute the matrix without looking at the cached state
  25971. * @returns the projection matrix
  25972. */
  25973. getProjectionMatrix(force?: boolean): Matrix;
  25974. /**
  25975. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25976. * @returns a Matrix
  25977. */
  25978. getTransformationMatrix(): Matrix;
  25979. private _updateFrustumPlanes;
  25980. /**
  25981. * Checks if a cullable object (mesh...) is in the camera frustum
  25982. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25983. * @param target The object to check
  25984. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25985. * @returns true if the object is in frustum otherwise false
  25986. */
  25987. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25988. /**
  25989. * Checks if a cullable object (mesh...) is in the camera frustum
  25990. * Unlike isInFrustum this cheks the full bounding box
  25991. * @param target The object to check
  25992. * @returns true if the object is in frustum otherwise false
  25993. */
  25994. isCompletelyInFrustum(target: ICullable): boolean;
  25995. /**
  25996. * Gets a ray in the forward direction from the camera.
  25997. * @param length Defines the length of the ray to create
  25998. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25999. * @param origin Defines the start point of the ray which defaults to the camera position
  26000. * @returns the forward ray
  26001. */
  26002. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26003. /**
  26004. * Releases resources associated with this node.
  26005. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26006. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26007. */
  26008. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26009. /** @hidden */
  26010. _isLeftCamera: boolean;
  26011. /**
  26012. * Gets the left camera of a rig setup in case of Rigged Camera
  26013. */
  26014. get isLeftCamera(): boolean;
  26015. /** @hidden */
  26016. _isRightCamera: boolean;
  26017. /**
  26018. * Gets the right camera of a rig setup in case of Rigged Camera
  26019. */
  26020. get isRightCamera(): boolean;
  26021. /**
  26022. * Gets the left camera of a rig setup in case of Rigged Camera
  26023. */
  26024. get leftCamera(): Nullable<FreeCamera>;
  26025. /**
  26026. * Gets the right camera of a rig setup in case of Rigged Camera
  26027. */
  26028. get rightCamera(): Nullable<FreeCamera>;
  26029. /**
  26030. * Gets the left camera target of a rig setup in case of Rigged Camera
  26031. * @returns the target position
  26032. */
  26033. getLeftTarget(): Nullable<Vector3>;
  26034. /**
  26035. * Gets the right camera target of a rig setup in case of Rigged Camera
  26036. * @returns the target position
  26037. */
  26038. getRightTarget(): Nullable<Vector3>;
  26039. /**
  26040. * @hidden
  26041. */
  26042. setCameraRigMode(mode: number, rigParams: any): void;
  26043. /** @hidden */
  26044. static _setStereoscopicRigMode(camera: Camera): void;
  26045. /** @hidden */
  26046. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26047. /** @hidden */
  26048. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26049. /** @hidden */
  26050. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26051. /** @hidden */
  26052. _getVRProjectionMatrix(): Matrix;
  26053. protected _updateCameraRotationMatrix(): void;
  26054. protected _updateWebVRCameraRotationMatrix(): void;
  26055. /**
  26056. * This function MUST be overwritten by the different WebVR cameras available.
  26057. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26058. * @hidden
  26059. */
  26060. _getWebVRProjectionMatrix(): Matrix;
  26061. /**
  26062. * This function MUST be overwritten by the different WebVR cameras available.
  26063. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26064. * @hidden
  26065. */
  26066. _getWebVRViewMatrix(): Matrix;
  26067. /** @hidden */
  26068. setCameraRigParameter(name: string, value: any): void;
  26069. /**
  26070. * needs to be overridden by children so sub has required properties to be copied
  26071. * @hidden
  26072. */
  26073. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26074. /**
  26075. * May need to be overridden by children
  26076. * @hidden
  26077. */
  26078. _updateRigCameras(): void;
  26079. /** @hidden */
  26080. _setupInputs(): void;
  26081. /**
  26082. * Serialiaze the camera setup to a json represention
  26083. * @returns the JSON representation
  26084. */
  26085. serialize(): any;
  26086. /**
  26087. * Clones the current camera.
  26088. * @param name The cloned camera name
  26089. * @returns the cloned camera
  26090. */
  26091. clone(name: string): Camera;
  26092. /**
  26093. * Gets the direction of the camera relative to a given local axis.
  26094. * @param localAxis Defines the reference axis to provide a relative direction.
  26095. * @return the direction
  26096. */
  26097. getDirection(localAxis: Vector3): Vector3;
  26098. /**
  26099. * Returns the current camera absolute rotation
  26100. */
  26101. get absoluteRotation(): Quaternion;
  26102. /**
  26103. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26104. * @param localAxis Defines the reference axis to provide a relative direction.
  26105. * @param result Defines the vector to store the result in
  26106. */
  26107. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26108. /**
  26109. * Gets a camera constructor for a given camera type
  26110. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26111. * @param name The name of the camera the result will be able to instantiate
  26112. * @param scene The scene the result will construct the camera in
  26113. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26114. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26115. * @returns a factory method to construc the camera
  26116. */
  26117. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26118. /**
  26119. * Compute the world matrix of the camera.
  26120. * @returns the camera world matrix
  26121. */
  26122. computeWorldMatrix(): Matrix;
  26123. /**
  26124. * Parse a JSON and creates the camera from the parsed information
  26125. * @param parsedCamera The JSON to parse
  26126. * @param scene The scene to instantiate the camera in
  26127. * @returns the newly constructed camera
  26128. */
  26129. static Parse(parsedCamera: any, scene: Scene): Camera;
  26130. }
  26131. }
  26132. declare module BABYLON {
  26133. /**
  26134. * Class containing static functions to help procedurally build meshes
  26135. */
  26136. export class DiscBuilder {
  26137. /**
  26138. * Creates a plane polygonal mesh. By default, this is a disc
  26139. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26140. * * 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
  26141. * * 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
  26142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26143. * * 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
  26144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26145. * @param name defines the name of the mesh
  26146. * @param options defines the options used to create the mesh
  26147. * @param scene defines the hosting scene
  26148. * @returns the plane polygonal mesh
  26149. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26150. */
  26151. static CreateDisc(name: string, options: {
  26152. radius?: number;
  26153. tessellation?: number;
  26154. arc?: number;
  26155. updatable?: boolean;
  26156. sideOrientation?: number;
  26157. frontUVs?: Vector4;
  26158. backUVs?: Vector4;
  26159. }, scene?: Nullable<Scene>): Mesh;
  26160. }
  26161. }
  26162. declare module BABYLON {
  26163. /**
  26164. * Options to be used when creating a FresnelParameters.
  26165. */
  26166. export type IFresnelParametersCreationOptions = {
  26167. /**
  26168. * Define the color used on edges (grazing angle)
  26169. */
  26170. leftColor?: Color3;
  26171. /**
  26172. * Define the color used on center
  26173. */
  26174. rightColor?: Color3;
  26175. /**
  26176. * Define bias applied to computed fresnel term
  26177. */
  26178. bias?: number;
  26179. /**
  26180. * Defined the power exponent applied to fresnel term
  26181. */
  26182. power?: number;
  26183. /**
  26184. * Define if the fresnel effect is enable or not.
  26185. */
  26186. isEnabled?: boolean;
  26187. };
  26188. /**
  26189. * Serialized format for FresnelParameters.
  26190. */
  26191. export type IFresnelParametersSerialized = {
  26192. /**
  26193. * Define the color used on edges (grazing angle) [as an array]
  26194. */
  26195. leftColor: number[];
  26196. /**
  26197. * Define the color used on center [as an array]
  26198. */
  26199. rightColor: number[];
  26200. /**
  26201. * Define bias applied to computed fresnel term
  26202. */
  26203. bias: number;
  26204. /**
  26205. * Defined the power exponent applied to fresnel term
  26206. */
  26207. power?: number;
  26208. /**
  26209. * Define if the fresnel effect is enable or not.
  26210. */
  26211. isEnabled: boolean;
  26212. };
  26213. /**
  26214. * This represents all the required information to add a fresnel effect on a material:
  26215. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26216. */
  26217. export class FresnelParameters {
  26218. private _isEnabled;
  26219. /**
  26220. * Define if the fresnel effect is enable or not.
  26221. */
  26222. get isEnabled(): boolean;
  26223. set isEnabled(value: boolean);
  26224. /**
  26225. * Define the color used on edges (grazing angle)
  26226. */
  26227. leftColor: Color3;
  26228. /**
  26229. * Define the color used on center
  26230. */
  26231. rightColor: Color3;
  26232. /**
  26233. * Define bias applied to computed fresnel term
  26234. */
  26235. bias: number;
  26236. /**
  26237. * Defined the power exponent applied to fresnel term
  26238. */
  26239. power: number;
  26240. /**
  26241. * Creates a new FresnelParameters object.
  26242. *
  26243. * @param options provide your own settings to optionally to override defaults
  26244. */
  26245. constructor(options?: IFresnelParametersCreationOptions);
  26246. /**
  26247. * Clones the current fresnel and its valuues
  26248. * @returns a clone fresnel configuration
  26249. */
  26250. clone(): FresnelParameters;
  26251. /**
  26252. * Determines equality between FresnelParameters objects
  26253. * @param otherFresnelParameters defines the second operand
  26254. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26255. */
  26256. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26257. /**
  26258. * Serializes the current fresnel parameters to a JSON representation.
  26259. * @return the JSON serialization
  26260. */
  26261. serialize(): IFresnelParametersSerialized;
  26262. /**
  26263. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26264. * @param parsedFresnelParameters Define the JSON representation
  26265. * @returns the parsed parameters
  26266. */
  26267. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26268. }
  26269. }
  26270. declare module BABYLON {
  26271. /**
  26272. * Base class of materials working in push mode in babylon JS
  26273. * @hidden
  26274. */
  26275. export class PushMaterial extends Material {
  26276. protected _activeEffect: Effect;
  26277. protected _normalMatrix: Matrix;
  26278. /**
  26279. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26280. * This means that the material can keep using a previous shader while a new one is being compiled.
  26281. * This is mostly used when shader parallel compilation is supported (true by default)
  26282. */
  26283. allowShaderHotSwapping: boolean;
  26284. constructor(name: string, scene: Scene);
  26285. getEffect(): Effect;
  26286. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26287. /**
  26288. * Binds the given world matrix to the active effect
  26289. *
  26290. * @param world the matrix to bind
  26291. */
  26292. bindOnlyWorldMatrix(world: Matrix): void;
  26293. /**
  26294. * Binds the given normal matrix to the active effect
  26295. *
  26296. * @param normalMatrix the matrix to bind
  26297. */
  26298. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26299. bind(world: Matrix, mesh?: Mesh): void;
  26300. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26301. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26302. }
  26303. }
  26304. declare module BABYLON {
  26305. /**
  26306. * This groups all the flags used to control the materials channel.
  26307. */
  26308. export class MaterialFlags {
  26309. private static _DiffuseTextureEnabled;
  26310. /**
  26311. * Are diffuse textures enabled in the application.
  26312. */
  26313. static get DiffuseTextureEnabled(): boolean;
  26314. static set DiffuseTextureEnabled(value: boolean);
  26315. private static _AmbientTextureEnabled;
  26316. /**
  26317. * Are ambient textures enabled in the application.
  26318. */
  26319. static get AmbientTextureEnabled(): boolean;
  26320. static set AmbientTextureEnabled(value: boolean);
  26321. private static _OpacityTextureEnabled;
  26322. /**
  26323. * Are opacity textures enabled in the application.
  26324. */
  26325. static get OpacityTextureEnabled(): boolean;
  26326. static set OpacityTextureEnabled(value: boolean);
  26327. private static _ReflectionTextureEnabled;
  26328. /**
  26329. * Are reflection textures enabled in the application.
  26330. */
  26331. static get ReflectionTextureEnabled(): boolean;
  26332. static set ReflectionTextureEnabled(value: boolean);
  26333. private static _EmissiveTextureEnabled;
  26334. /**
  26335. * Are emissive textures enabled in the application.
  26336. */
  26337. static get EmissiveTextureEnabled(): boolean;
  26338. static set EmissiveTextureEnabled(value: boolean);
  26339. private static _SpecularTextureEnabled;
  26340. /**
  26341. * Are specular textures enabled in the application.
  26342. */
  26343. static get SpecularTextureEnabled(): boolean;
  26344. static set SpecularTextureEnabled(value: boolean);
  26345. private static _BumpTextureEnabled;
  26346. /**
  26347. * Are bump textures enabled in the application.
  26348. */
  26349. static get BumpTextureEnabled(): boolean;
  26350. static set BumpTextureEnabled(value: boolean);
  26351. private static _LightmapTextureEnabled;
  26352. /**
  26353. * Are lightmap textures enabled in the application.
  26354. */
  26355. static get LightmapTextureEnabled(): boolean;
  26356. static set LightmapTextureEnabled(value: boolean);
  26357. private static _RefractionTextureEnabled;
  26358. /**
  26359. * Are refraction textures enabled in the application.
  26360. */
  26361. static get RefractionTextureEnabled(): boolean;
  26362. static set RefractionTextureEnabled(value: boolean);
  26363. private static _ColorGradingTextureEnabled;
  26364. /**
  26365. * Are color grading textures enabled in the application.
  26366. */
  26367. static get ColorGradingTextureEnabled(): boolean;
  26368. static set ColorGradingTextureEnabled(value: boolean);
  26369. private static _FresnelEnabled;
  26370. /**
  26371. * Are fresnels enabled in the application.
  26372. */
  26373. static get FresnelEnabled(): boolean;
  26374. static set FresnelEnabled(value: boolean);
  26375. private static _ClearCoatTextureEnabled;
  26376. /**
  26377. * Are clear coat textures enabled in the application.
  26378. */
  26379. static get ClearCoatTextureEnabled(): boolean;
  26380. static set ClearCoatTextureEnabled(value: boolean);
  26381. private static _ClearCoatBumpTextureEnabled;
  26382. /**
  26383. * Are clear coat bump textures enabled in the application.
  26384. */
  26385. static get ClearCoatBumpTextureEnabled(): boolean;
  26386. static set ClearCoatBumpTextureEnabled(value: boolean);
  26387. private static _ClearCoatTintTextureEnabled;
  26388. /**
  26389. * Are clear coat tint textures enabled in the application.
  26390. */
  26391. static get ClearCoatTintTextureEnabled(): boolean;
  26392. static set ClearCoatTintTextureEnabled(value: boolean);
  26393. private static _SheenTextureEnabled;
  26394. /**
  26395. * Are sheen textures enabled in the application.
  26396. */
  26397. static get SheenTextureEnabled(): boolean;
  26398. static set SheenTextureEnabled(value: boolean);
  26399. private static _AnisotropicTextureEnabled;
  26400. /**
  26401. * Are anisotropic textures enabled in the application.
  26402. */
  26403. static get AnisotropicTextureEnabled(): boolean;
  26404. static set AnisotropicTextureEnabled(value: boolean);
  26405. private static _ThicknessTextureEnabled;
  26406. /**
  26407. * Are thickness textures enabled in the application.
  26408. */
  26409. static get ThicknessTextureEnabled(): boolean;
  26410. static set ThicknessTextureEnabled(value: boolean);
  26411. }
  26412. }
  26413. declare module BABYLON {
  26414. /** @hidden */
  26415. export var defaultFragmentDeclaration: {
  26416. name: string;
  26417. shader: string;
  26418. };
  26419. }
  26420. declare module BABYLON {
  26421. /** @hidden */
  26422. export var defaultUboDeclaration: {
  26423. name: string;
  26424. shader: string;
  26425. };
  26426. }
  26427. declare module BABYLON {
  26428. /** @hidden */
  26429. export var lightFragmentDeclaration: {
  26430. name: string;
  26431. shader: string;
  26432. };
  26433. }
  26434. declare module BABYLON {
  26435. /** @hidden */
  26436. export var lightUboDeclaration: {
  26437. name: string;
  26438. shader: string;
  26439. };
  26440. }
  26441. declare module BABYLON {
  26442. /** @hidden */
  26443. export var lightsFragmentFunctions: {
  26444. name: string;
  26445. shader: string;
  26446. };
  26447. }
  26448. declare module BABYLON {
  26449. /** @hidden */
  26450. export var shadowsFragmentFunctions: {
  26451. name: string;
  26452. shader: string;
  26453. };
  26454. }
  26455. declare module BABYLON {
  26456. /** @hidden */
  26457. export var fresnelFunction: {
  26458. name: string;
  26459. shader: string;
  26460. };
  26461. }
  26462. declare module BABYLON {
  26463. /** @hidden */
  26464. export var reflectionFunction: {
  26465. name: string;
  26466. shader: string;
  26467. };
  26468. }
  26469. declare module BABYLON {
  26470. /** @hidden */
  26471. export var bumpFragmentFunctions: {
  26472. name: string;
  26473. shader: string;
  26474. };
  26475. }
  26476. declare module BABYLON {
  26477. /** @hidden */
  26478. export var logDepthDeclaration: {
  26479. name: string;
  26480. shader: string;
  26481. };
  26482. }
  26483. declare module BABYLON {
  26484. /** @hidden */
  26485. export var bumpFragment: {
  26486. name: string;
  26487. shader: string;
  26488. };
  26489. }
  26490. declare module BABYLON {
  26491. /** @hidden */
  26492. export var depthPrePass: {
  26493. name: string;
  26494. shader: string;
  26495. };
  26496. }
  26497. declare module BABYLON {
  26498. /** @hidden */
  26499. export var lightFragment: {
  26500. name: string;
  26501. shader: string;
  26502. };
  26503. }
  26504. declare module BABYLON {
  26505. /** @hidden */
  26506. export var logDepthFragment: {
  26507. name: string;
  26508. shader: string;
  26509. };
  26510. }
  26511. declare module BABYLON {
  26512. /** @hidden */
  26513. export var defaultPixelShader: {
  26514. name: string;
  26515. shader: string;
  26516. };
  26517. }
  26518. declare module BABYLON {
  26519. /** @hidden */
  26520. export var defaultVertexDeclaration: {
  26521. name: string;
  26522. shader: string;
  26523. };
  26524. }
  26525. declare module BABYLON {
  26526. /** @hidden */
  26527. export var bumpVertexDeclaration: {
  26528. name: string;
  26529. shader: string;
  26530. };
  26531. }
  26532. declare module BABYLON {
  26533. /** @hidden */
  26534. export var bumpVertex: {
  26535. name: string;
  26536. shader: string;
  26537. };
  26538. }
  26539. declare module BABYLON {
  26540. /** @hidden */
  26541. export var fogVertex: {
  26542. name: string;
  26543. shader: string;
  26544. };
  26545. }
  26546. declare module BABYLON {
  26547. /** @hidden */
  26548. export var shadowsVertex: {
  26549. name: string;
  26550. shader: string;
  26551. };
  26552. }
  26553. declare module BABYLON {
  26554. /** @hidden */
  26555. export var pointCloudVertex: {
  26556. name: string;
  26557. shader: string;
  26558. };
  26559. }
  26560. declare module BABYLON {
  26561. /** @hidden */
  26562. export var logDepthVertex: {
  26563. name: string;
  26564. shader: string;
  26565. };
  26566. }
  26567. declare module BABYLON {
  26568. /** @hidden */
  26569. export var defaultVertexShader: {
  26570. name: string;
  26571. shader: string;
  26572. };
  26573. }
  26574. declare module BABYLON {
  26575. /** @hidden */
  26576. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26577. MAINUV1: boolean;
  26578. MAINUV2: boolean;
  26579. DIFFUSE: boolean;
  26580. DIFFUSEDIRECTUV: number;
  26581. AMBIENT: boolean;
  26582. AMBIENTDIRECTUV: number;
  26583. OPACITY: boolean;
  26584. OPACITYDIRECTUV: number;
  26585. OPACITYRGB: boolean;
  26586. REFLECTION: boolean;
  26587. EMISSIVE: boolean;
  26588. EMISSIVEDIRECTUV: number;
  26589. SPECULAR: boolean;
  26590. SPECULARDIRECTUV: number;
  26591. BUMP: boolean;
  26592. BUMPDIRECTUV: number;
  26593. PARALLAX: boolean;
  26594. PARALLAXOCCLUSION: boolean;
  26595. SPECULAROVERALPHA: boolean;
  26596. CLIPPLANE: boolean;
  26597. CLIPPLANE2: boolean;
  26598. CLIPPLANE3: boolean;
  26599. CLIPPLANE4: boolean;
  26600. CLIPPLANE5: boolean;
  26601. CLIPPLANE6: boolean;
  26602. ALPHATEST: boolean;
  26603. DEPTHPREPASS: boolean;
  26604. ALPHAFROMDIFFUSE: boolean;
  26605. POINTSIZE: boolean;
  26606. FOG: boolean;
  26607. SPECULARTERM: boolean;
  26608. DIFFUSEFRESNEL: boolean;
  26609. OPACITYFRESNEL: boolean;
  26610. REFLECTIONFRESNEL: boolean;
  26611. REFRACTIONFRESNEL: boolean;
  26612. EMISSIVEFRESNEL: boolean;
  26613. FRESNEL: boolean;
  26614. NORMAL: boolean;
  26615. UV1: boolean;
  26616. UV2: boolean;
  26617. VERTEXCOLOR: boolean;
  26618. VERTEXALPHA: boolean;
  26619. NUM_BONE_INFLUENCERS: number;
  26620. BonesPerMesh: number;
  26621. BONETEXTURE: boolean;
  26622. INSTANCES: boolean;
  26623. GLOSSINESS: boolean;
  26624. ROUGHNESS: boolean;
  26625. EMISSIVEASILLUMINATION: boolean;
  26626. LINKEMISSIVEWITHDIFFUSE: boolean;
  26627. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26628. LIGHTMAP: boolean;
  26629. LIGHTMAPDIRECTUV: number;
  26630. OBJECTSPACE_NORMALMAP: boolean;
  26631. USELIGHTMAPASSHADOWMAP: boolean;
  26632. REFLECTIONMAP_3D: boolean;
  26633. REFLECTIONMAP_SPHERICAL: boolean;
  26634. REFLECTIONMAP_PLANAR: boolean;
  26635. REFLECTIONMAP_CUBIC: boolean;
  26636. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26637. REFLECTIONMAP_PROJECTION: boolean;
  26638. REFLECTIONMAP_SKYBOX: boolean;
  26639. REFLECTIONMAP_EXPLICIT: boolean;
  26640. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26641. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26642. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26643. INVERTCUBICMAP: boolean;
  26644. LOGARITHMICDEPTH: boolean;
  26645. REFRACTION: boolean;
  26646. REFRACTIONMAP_3D: boolean;
  26647. REFLECTIONOVERALPHA: boolean;
  26648. TWOSIDEDLIGHTING: boolean;
  26649. SHADOWFLOAT: boolean;
  26650. MORPHTARGETS: boolean;
  26651. MORPHTARGETS_NORMAL: boolean;
  26652. MORPHTARGETS_TANGENT: boolean;
  26653. MORPHTARGETS_UV: boolean;
  26654. NUM_MORPH_INFLUENCERS: number;
  26655. NONUNIFORMSCALING: boolean;
  26656. PREMULTIPLYALPHA: boolean;
  26657. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26658. ALPHABLEND: boolean;
  26659. IMAGEPROCESSING: boolean;
  26660. VIGNETTE: boolean;
  26661. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26662. VIGNETTEBLENDMODEOPAQUE: boolean;
  26663. TONEMAPPING: boolean;
  26664. TONEMAPPING_ACES: boolean;
  26665. CONTRAST: boolean;
  26666. COLORCURVES: boolean;
  26667. COLORGRADING: boolean;
  26668. COLORGRADING3D: boolean;
  26669. SAMPLER3DGREENDEPTH: boolean;
  26670. SAMPLER3DBGRMAP: boolean;
  26671. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26672. MULTIVIEW: boolean;
  26673. /**
  26674. * If the reflection texture on this material is in linear color space
  26675. * @hidden
  26676. */
  26677. IS_REFLECTION_LINEAR: boolean;
  26678. /**
  26679. * If the refraction texture on this material is in linear color space
  26680. * @hidden
  26681. */
  26682. IS_REFRACTION_LINEAR: boolean;
  26683. EXPOSURE: boolean;
  26684. constructor();
  26685. setReflectionMode(modeToEnable: string): void;
  26686. }
  26687. /**
  26688. * This is the default material used in Babylon. It is the best trade off between quality
  26689. * and performances.
  26690. * @see http://doc.babylonjs.com/babylon101/materials
  26691. */
  26692. export class StandardMaterial extends PushMaterial {
  26693. private _diffuseTexture;
  26694. /**
  26695. * The basic texture of the material as viewed under a light.
  26696. */
  26697. diffuseTexture: Nullable<BaseTexture>;
  26698. private _ambientTexture;
  26699. /**
  26700. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26701. */
  26702. ambientTexture: Nullable<BaseTexture>;
  26703. private _opacityTexture;
  26704. /**
  26705. * Define the transparency of the material from a texture.
  26706. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26707. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26708. */
  26709. opacityTexture: Nullable<BaseTexture>;
  26710. private _reflectionTexture;
  26711. /**
  26712. * Define the texture used to display the reflection.
  26713. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26714. */
  26715. reflectionTexture: Nullable<BaseTexture>;
  26716. private _emissiveTexture;
  26717. /**
  26718. * Define texture of the material as if self lit.
  26719. * This will be mixed in the final result even in the absence of light.
  26720. */
  26721. emissiveTexture: Nullable<BaseTexture>;
  26722. private _specularTexture;
  26723. /**
  26724. * Define how the color and intensity of the highlight given by the light in the material.
  26725. */
  26726. specularTexture: Nullable<BaseTexture>;
  26727. private _bumpTexture;
  26728. /**
  26729. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26730. * 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.
  26731. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26732. */
  26733. bumpTexture: Nullable<BaseTexture>;
  26734. private _lightmapTexture;
  26735. /**
  26736. * Complex lighting can be computationally expensive to compute at runtime.
  26737. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26738. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26739. */
  26740. lightmapTexture: Nullable<BaseTexture>;
  26741. private _refractionTexture;
  26742. /**
  26743. * Define the texture used to display the refraction.
  26744. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26745. */
  26746. refractionTexture: Nullable<BaseTexture>;
  26747. /**
  26748. * The color of the material lit by the environmental background lighting.
  26749. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26750. */
  26751. ambientColor: Color3;
  26752. /**
  26753. * The basic color of the material as viewed under a light.
  26754. */
  26755. diffuseColor: Color3;
  26756. /**
  26757. * Define how the color and intensity of the highlight given by the light in the material.
  26758. */
  26759. specularColor: Color3;
  26760. /**
  26761. * Define the color of the material as if self lit.
  26762. * This will be mixed in the final result even in the absence of light.
  26763. */
  26764. emissiveColor: Color3;
  26765. /**
  26766. * Defines how sharp are the highlights in the material.
  26767. * The bigger the value the sharper giving a more glossy feeling to the result.
  26768. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26769. */
  26770. specularPower: number;
  26771. private _useAlphaFromDiffuseTexture;
  26772. /**
  26773. * Does the transparency come from the diffuse texture alpha channel.
  26774. */
  26775. useAlphaFromDiffuseTexture: boolean;
  26776. private _useEmissiveAsIllumination;
  26777. /**
  26778. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26779. */
  26780. useEmissiveAsIllumination: boolean;
  26781. private _linkEmissiveWithDiffuse;
  26782. /**
  26783. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26784. * the emissive level when the final color is close to one.
  26785. */
  26786. linkEmissiveWithDiffuse: boolean;
  26787. private _useSpecularOverAlpha;
  26788. /**
  26789. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26790. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26791. */
  26792. useSpecularOverAlpha: boolean;
  26793. private _useReflectionOverAlpha;
  26794. /**
  26795. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26796. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26797. */
  26798. useReflectionOverAlpha: boolean;
  26799. private _disableLighting;
  26800. /**
  26801. * Does lights from the scene impacts this material.
  26802. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26803. */
  26804. disableLighting: boolean;
  26805. private _useObjectSpaceNormalMap;
  26806. /**
  26807. * Allows using an object space normal map (instead of tangent space).
  26808. */
  26809. useObjectSpaceNormalMap: boolean;
  26810. private _useParallax;
  26811. /**
  26812. * Is parallax enabled or not.
  26813. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26814. */
  26815. useParallax: boolean;
  26816. private _useParallaxOcclusion;
  26817. /**
  26818. * Is parallax occlusion enabled or not.
  26819. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26820. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26821. */
  26822. useParallaxOcclusion: boolean;
  26823. /**
  26824. * 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.
  26825. */
  26826. parallaxScaleBias: number;
  26827. private _roughness;
  26828. /**
  26829. * Helps to define how blurry the reflections should appears in the material.
  26830. */
  26831. roughness: number;
  26832. /**
  26833. * In case of refraction, define the value of the index of refraction.
  26834. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26835. */
  26836. indexOfRefraction: number;
  26837. /**
  26838. * Invert the refraction texture alongside the y axis.
  26839. * It can be useful with procedural textures or probe for instance.
  26840. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26841. */
  26842. invertRefractionY: boolean;
  26843. /**
  26844. * Defines the alpha limits in alpha test mode.
  26845. */
  26846. alphaCutOff: number;
  26847. private _useLightmapAsShadowmap;
  26848. /**
  26849. * In case of light mapping, define whether the map contains light or shadow informations.
  26850. */
  26851. useLightmapAsShadowmap: boolean;
  26852. private _diffuseFresnelParameters;
  26853. /**
  26854. * Define the diffuse fresnel parameters of the material.
  26855. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26856. */
  26857. diffuseFresnelParameters: FresnelParameters;
  26858. private _opacityFresnelParameters;
  26859. /**
  26860. * Define the opacity fresnel parameters of the material.
  26861. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26862. */
  26863. opacityFresnelParameters: FresnelParameters;
  26864. private _reflectionFresnelParameters;
  26865. /**
  26866. * Define the reflection fresnel parameters of the material.
  26867. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26868. */
  26869. reflectionFresnelParameters: FresnelParameters;
  26870. private _refractionFresnelParameters;
  26871. /**
  26872. * Define the refraction fresnel parameters of the material.
  26873. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26874. */
  26875. refractionFresnelParameters: FresnelParameters;
  26876. private _emissiveFresnelParameters;
  26877. /**
  26878. * Define the emissive fresnel parameters of the material.
  26879. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26880. */
  26881. emissiveFresnelParameters: FresnelParameters;
  26882. private _useReflectionFresnelFromSpecular;
  26883. /**
  26884. * If true automatically deducts the fresnels values from the material specularity.
  26885. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26886. */
  26887. useReflectionFresnelFromSpecular: boolean;
  26888. private _useGlossinessFromSpecularMapAlpha;
  26889. /**
  26890. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26891. */
  26892. useGlossinessFromSpecularMapAlpha: boolean;
  26893. private _maxSimultaneousLights;
  26894. /**
  26895. * Defines the maximum number of lights that can be used in the material
  26896. */
  26897. maxSimultaneousLights: number;
  26898. private _invertNormalMapX;
  26899. /**
  26900. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26901. */
  26902. invertNormalMapX: boolean;
  26903. private _invertNormalMapY;
  26904. /**
  26905. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26906. */
  26907. invertNormalMapY: boolean;
  26908. private _twoSidedLighting;
  26909. /**
  26910. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26911. */
  26912. twoSidedLighting: boolean;
  26913. /**
  26914. * Default configuration related to image processing available in the standard Material.
  26915. */
  26916. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26917. /**
  26918. * Gets the image processing configuration used either in this material.
  26919. */
  26920. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26921. /**
  26922. * Sets the Default image processing configuration used either in the this material.
  26923. *
  26924. * If sets to null, the scene one is in use.
  26925. */
  26926. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26927. /**
  26928. * Keep track of the image processing observer to allow dispose and replace.
  26929. */
  26930. private _imageProcessingObserver;
  26931. /**
  26932. * Attaches a new image processing configuration to the Standard Material.
  26933. * @param configuration
  26934. */
  26935. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26936. /**
  26937. * Gets wether the color curves effect is enabled.
  26938. */
  26939. get cameraColorCurvesEnabled(): boolean;
  26940. /**
  26941. * Sets wether the color curves effect is enabled.
  26942. */
  26943. set cameraColorCurvesEnabled(value: boolean);
  26944. /**
  26945. * Gets wether the color grading effect is enabled.
  26946. */
  26947. get cameraColorGradingEnabled(): boolean;
  26948. /**
  26949. * Gets wether the color grading effect is enabled.
  26950. */
  26951. set cameraColorGradingEnabled(value: boolean);
  26952. /**
  26953. * Gets wether tonemapping is enabled or not.
  26954. */
  26955. get cameraToneMappingEnabled(): boolean;
  26956. /**
  26957. * Sets wether tonemapping is enabled or not
  26958. */
  26959. set cameraToneMappingEnabled(value: boolean);
  26960. /**
  26961. * The camera exposure used on this material.
  26962. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26963. * This corresponds to a photographic exposure.
  26964. */
  26965. get cameraExposure(): number;
  26966. /**
  26967. * The camera exposure used on this material.
  26968. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26969. * This corresponds to a photographic exposure.
  26970. */
  26971. set cameraExposure(value: number);
  26972. /**
  26973. * Gets The camera contrast used on this material.
  26974. */
  26975. get cameraContrast(): number;
  26976. /**
  26977. * Sets The camera contrast used on this material.
  26978. */
  26979. set cameraContrast(value: number);
  26980. /**
  26981. * Gets the Color Grading 2D Lookup Texture.
  26982. */
  26983. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26984. /**
  26985. * Sets the Color Grading 2D Lookup Texture.
  26986. */
  26987. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26988. /**
  26989. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26990. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26991. * 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;
  26992. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26993. */
  26994. get cameraColorCurves(): Nullable<ColorCurves>;
  26995. /**
  26996. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26997. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26998. * 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;
  26999. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27000. */
  27001. set cameraColorCurves(value: Nullable<ColorCurves>);
  27002. /**
  27003. * Custom callback helping to override the default shader used in the material.
  27004. */
  27005. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  27006. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27007. protected _worldViewProjectionMatrix: Matrix;
  27008. protected _globalAmbientColor: Color3;
  27009. protected _useLogarithmicDepth: boolean;
  27010. protected _rebuildInParallel: boolean;
  27011. /**
  27012. * Instantiates a new standard material.
  27013. * This is the default material used in Babylon. It is the best trade off between quality
  27014. * and performances.
  27015. * @see http://doc.babylonjs.com/babylon101/materials
  27016. * @param name Define the name of the material in the scene
  27017. * @param scene Define the scene the material belong to
  27018. */
  27019. constructor(name: string, scene: Scene);
  27020. /**
  27021. * Gets a boolean indicating that current material needs to register RTT
  27022. */
  27023. get hasRenderTargetTextures(): boolean;
  27024. /**
  27025. * Gets the current class name of the material e.g. "StandardMaterial"
  27026. * Mainly use in serialization.
  27027. * @returns the class name
  27028. */
  27029. getClassName(): string;
  27030. /**
  27031. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27032. * You can try switching to logarithmic depth.
  27033. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27034. */
  27035. get useLogarithmicDepth(): boolean;
  27036. set useLogarithmicDepth(value: boolean);
  27037. /**
  27038. * Specifies if the material will require alpha blending
  27039. * @returns a boolean specifying if alpha blending is needed
  27040. */
  27041. needAlphaBlending(): boolean;
  27042. /**
  27043. * Specifies if this material should be rendered in alpha test mode
  27044. * @returns a boolean specifying if an alpha test is needed.
  27045. */
  27046. needAlphaTesting(): boolean;
  27047. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27048. /**
  27049. * Get the texture used for alpha test purpose.
  27050. * @returns the diffuse texture in case of the standard material.
  27051. */
  27052. getAlphaTestTexture(): Nullable<BaseTexture>;
  27053. /**
  27054. * Get if the submesh is ready to be used and all its information available.
  27055. * Child classes can use it to update shaders
  27056. * @param mesh defines the mesh to check
  27057. * @param subMesh defines which submesh to check
  27058. * @param useInstances specifies that instances should be used
  27059. * @returns a boolean indicating that the submesh is ready or not
  27060. */
  27061. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27062. /**
  27063. * Builds the material UBO layouts.
  27064. * Used internally during the effect preparation.
  27065. */
  27066. buildUniformLayout(): void;
  27067. /**
  27068. * Unbinds the material from the mesh
  27069. */
  27070. unbind(): void;
  27071. /**
  27072. * Binds the submesh to this material by preparing the effect and shader to draw
  27073. * @param world defines the world transformation matrix
  27074. * @param mesh defines the mesh containing the submesh
  27075. * @param subMesh defines the submesh to bind the material to
  27076. */
  27077. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27078. /**
  27079. * Get the list of animatables in the material.
  27080. * @returns the list of animatables object used in the material
  27081. */
  27082. getAnimatables(): IAnimatable[];
  27083. /**
  27084. * Gets the active textures from the material
  27085. * @returns an array of textures
  27086. */
  27087. getActiveTextures(): BaseTexture[];
  27088. /**
  27089. * Specifies if the material uses a texture
  27090. * @param texture defines the texture to check against the material
  27091. * @returns a boolean specifying if the material uses the texture
  27092. */
  27093. hasTexture(texture: BaseTexture): boolean;
  27094. /**
  27095. * Disposes the material
  27096. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27097. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27098. */
  27099. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27100. /**
  27101. * Makes a duplicate of the material, and gives it a new name
  27102. * @param name defines the new name for the duplicated material
  27103. * @returns the cloned material
  27104. */
  27105. clone(name: string): StandardMaterial;
  27106. /**
  27107. * Serializes this material in a JSON representation
  27108. * @returns the serialized material object
  27109. */
  27110. serialize(): any;
  27111. /**
  27112. * Creates a standard material from parsed material data
  27113. * @param source defines the JSON representation of the material
  27114. * @param scene defines the hosting scene
  27115. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27116. * @returns a new standard material
  27117. */
  27118. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27119. /**
  27120. * Are diffuse textures enabled in the application.
  27121. */
  27122. static get DiffuseTextureEnabled(): boolean;
  27123. static set DiffuseTextureEnabled(value: boolean);
  27124. /**
  27125. * Are ambient textures enabled in the application.
  27126. */
  27127. static get AmbientTextureEnabled(): boolean;
  27128. static set AmbientTextureEnabled(value: boolean);
  27129. /**
  27130. * Are opacity textures enabled in the application.
  27131. */
  27132. static get OpacityTextureEnabled(): boolean;
  27133. static set OpacityTextureEnabled(value: boolean);
  27134. /**
  27135. * Are reflection textures enabled in the application.
  27136. */
  27137. static get ReflectionTextureEnabled(): boolean;
  27138. static set ReflectionTextureEnabled(value: boolean);
  27139. /**
  27140. * Are emissive textures enabled in the application.
  27141. */
  27142. static get EmissiveTextureEnabled(): boolean;
  27143. static set EmissiveTextureEnabled(value: boolean);
  27144. /**
  27145. * Are specular textures enabled in the application.
  27146. */
  27147. static get SpecularTextureEnabled(): boolean;
  27148. static set SpecularTextureEnabled(value: boolean);
  27149. /**
  27150. * Are bump textures enabled in the application.
  27151. */
  27152. static get BumpTextureEnabled(): boolean;
  27153. static set BumpTextureEnabled(value: boolean);
  27154. /**
  27155. * Are lightmap textures enabled in the application.
  27156. */
  27157. static get LightmapTextureEnabled(): boolean;
  27158. static set LightmapTextureEnabled(value: boolean);
  27159. /**
  27160. * Are refraction textures enabled in the application.
  27161. */
  27162. static get RefractionTextureEnabled(): boolean;
  27163. static set RefractionTextureEnabled(value: boolean);
  27164. /**
  27165. * Are color grading textures enabled in the application.
  27166. */
  27167. static get ColorGradingTextureEnabled(): boolean;
  27168. static set ColorGradingTextureEnabled(value: boolean);
  27169. /**
  27170. * Are fresnels enabled in the application.
  27171. */
  27172. static get FresnelEnabled(): boolean;
  27173. static set FresnelEnabled(value: boolean);
  27174. }
  27175. }
  27176. declare module BABYLON {
  27177. /**
  27178. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27179. *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.
  27180. * The SPS is also a particle system. It provides some methods to manage the particles.
  27181. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27182. *
  27183. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27184. */
  27185. export class SolidParticleSystem implements IDisposable {
  27186. /**
  27187. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27188. * Example : var p = SPS.particles[i];
  27189. */
  27190. particles: SolidParticle[];
  27191. /**
  27192. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27193. */
  27194. nbParticles: number;
  27195. /**
  27196. * If the particles must ever face the camera (default false). Useful for planar particles.
  27197. */
  27198. billboard: boolean;
  27199. /**
  27200. * Recompute normals when adding a shape
  27201. */
  27202. recomputeNormals: boolean;
  27203. /**
  27204. * This a counter ofr your own usage. It's not set by any SPS functions.
  27205. */
  27206. counter: number;
  27207. /**
  27208. * The SPS name. This name is also given to the underlying mesh.
  27209. */
  27210. name: string;
  27211. /**
  27212. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27213. */
  27214. mesh: Mesh;
  27215. /**
  27216. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27217. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27218. */
  27219. vars: any;
  27220. /**
  27221. * This array is populated when the SPS is set as 'pickable'.
  27222. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27223. * Each element of this array is an object `{idx: int, faceId: int}`.
  27224. * `idx` is the picked particle index in the `SPS.particles` array
  27225. * `faceId` is the picked face index counted within this particle.
  27226. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27227. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27228. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27229. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27230. */
  27231. pickedParticles: {
  27232. idx: number;
  27233. faceId: number;
  27234. }[];
  27235. /**
  27236. * This array is populated when the SPS is set as 'pickable'
  27237. * Each key of this array is a submesh index.
  27238. * Each element of this array is a second array defined like this :
  27239. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27240. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27241. * `idx` is the picked particle index in the `SPS.particles` array
  27242. * `faceId` is the picked face index counted within this particle.
  27243. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27244. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27245. */
  27246. pickedBySubMesh: {
  27247. idx: number;
  27248. faceId: number;
  27249. }[][];
  27250. /**
  27251. * This array is populated when `enableDepthSort` is set to true.
  27252. * Each element of this array is an instance of the class DepthSortedParticle.
  27253. */
  27254. depthSortedParticles: DepthSortedParticle[];
  27255. /**
  27256. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27257. * @hidden
  27258. */
  27259. _bSphereOnly: boolean;
  27260. /**
  27261. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27262. * @hidden
  27263. */
  27264. _bSphereRadiusFactor: number;
  27265. private _scene;
  27266. private _positions;
  27267. private _indices;
  27268. private _normals;
  27269. private _colors;
  27270. private _uvs;
  27271. private _indices32;
  27272. private _positions32;
  27273. private _normals32;
  27274. private _fixedNormal32;
  27275. private _colors32;
  27276. private _uvs32;
  27277. private _index;
  27278. private _updatable;
  27279. private _pickable;
  27280. private _isVisibilityBoxLocked;
  27281. private _alwaysVisible;
  27282. private _depthSort;
  27283. private _expandable;
  27284. private _shapeCounter;
  27285. private _copy;
  27286. private _color;
  27287. private _computeParticleColor;
  27288. private _computeParticleTexture;
  27289. private _computeParticleRotation;
  27290. private _computeParticleVertex;
  27291. private _computeBoundingBox;
  27292. private _depthSortParticles;
  27293. private _camera;
  27294. private _mustUnrotateFixedNormals;
  27295. private _particlesIntersect;
  27296. private _needs32Bits;
  27297. private _isNotBuilt;
  27298. private _lastParticleId;
  27299. private _idxOfId;
  27300. private _multimaterialEnabled;
  27301. private _useModelMaterial;
  27302. private _indicesByMaterial;
  27303. private _materialIndexes;
  27304. private _depthSortFunction;
  27305. private _materialSortFunction;
  27306. private _materials;
  27307. private _multimaterial;
  27308. private _materialIndexesById;
  27309. private _defaultMaterial;
  27310. private _autoUpdateSubMeshes;
  27311. /**
  27312. * Creates a SPS (Solid Particle System) object.
  27313. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27314. * @param scene (Scene) is the scene in which the SPS is added.
  27315. * @param options defines the options of the sps e.g.
  27316. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27317. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27318. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27319. * * 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.
  27320. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27321. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27322. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27323. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27324. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27325. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27326. */
  27327. constructor(name: string, scene: Scene, options?: {
  27328. updatable?: boolean;
  27329. isPickable?: boolean;
  27330. enableDepthSort?: boolean;
  27331. particleIntersection?: boolean;
  27332. boundingSphereOnly?: boolean;
  27333. bSphereRadiusFactor?: number;
  27334. expandable?: boolean;
  27335. useModelMaterial?: boolean;
  27336. enableMultiMaterial?: boolean;
  27337. });
  27338. /**
  27339. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27340. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27341. * @returns the created mesh
  27342. */
  27343. buildMesh(): Mesh;
  27344. /**
  27345. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27346. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27347. * Thus the particles generated from `digest()` have their property `position` set yet.
  27348. * @param mesh ( Mesh ) is the mesh to be digested
  27349. * @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
  27350. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27351. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27352. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27353. * @returns the current SPS
  27354. */
  27355. digest(mesh: Mesh, options?: {
  27356. facetNb?: number;
  27357. number?: number;
  27358. delta?: number;
  27359. storage?: [];
  27360. }): SolidParticleSystem;
  27361. /**
  27362. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27363. * @hidden
  27364. */
  27365. private _unrotateFixedNormals;
  27366. /**
  27367. * Resets the temporary working copy particle
  27368. * @hidden
  27369. */
  27370. private _resetCopy;
  27371. /**
  27372. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27373. * @param p the current index in the positions array to be updated
  27374. * @param ind the current index in the indices array
  27375. * @param shape a Vector3 array, the shape geometry
  27376. * @param positions the positions array to be updated
  27377. * @param meshInd the shape indices array
  27378. * @param indices the indices array to be updated
  27379. * @param meshUV the shape uv array
  27380. * @param uvs the uv array to be updated
  27381. * @param meshCol the shape color array
  27382. * @param colors the color array to be updated
  27383. * @param meshNor the shape normals array
  27384. * @param normals the normals array to be updated
  27385. * @param idx the particle index
  27386. * @param idxInShape the particle index in its shape
  27387. * @param options the addShape() method passed options
  27388. * @model the particle model
  27389. * @hidden
  27390. */
  27391. private _meshBuilder;
  27392. /**
  27393. * Returns a shape Vector3 array from positions float array
  27394. * @param positions float array
  27395. * @returns a vector3 array
  27396. * @hidden
  27397. */
  27398. private _posToShape;
  27399. /**
  27400. * Returns a shapeUV array from a float uvs (array deep copy)
  27401. * @param uvs as a float array
  27402. * @returns a shapeUV array
  27403. * @hidden
  27404. */
  27405. private _uvsToShapeUV;
  27406. /**
  27407. * Adds a new particle object in the particles array
  27408. * @param idx particle index in particles array
  27409. * @param id particle id
  27410. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27411. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27412. * @param model particle ModelShape object
  27413. * @param shapeId model shape identifier
  27414. * @param idxInShape index of the particle in the current model
  27415. * @param bInfo model bounding info object
  27416. * @param storage target storage array, if any
  27417. * @hidden
  27418. */
  27419. private _addParticle;
  27420. /**
  27421. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27422. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27423. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27424. * @param nb (positive integer) the number of particles to be created from this model
  27425. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27426. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27427. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27428. * @returns the number of shapes in the system
  27429. */
  27430. addShape(mesh: Mesh, nb: number, options?: {
  27431. positionFunction?: any;
  27432. vertexFunction?: any;
  27433. storage?: [];
  27434. }): number;
  27435. /**
  27436. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27437. * @hidden
  27438. */
  27439. private _rebuildParticle;
  27440. /**
  27441. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27442. * @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.
  27443. * @returns the SPS.
  27444. */
  27445. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27446. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27447. * Returns an array with the removed particles.
  27448. * 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.
  27449. * The SPS can't be empty so at least one particle needs to remain in place.
  27450. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27451. * @param start index of the first particle to remove
  27452. * @param end index of the last particle to remove (included)
  27453. * @returns an array populated with the removed particles
  27454. */
  27455. removeParticles(start: number, end: number): SolidParticle[];
  27456. /**
  27457. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27458. * @param solidParticleArray an array populated with Solid Particles objects
  27459. * @returns the SPS
  27460. */
  27461. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27462. /**
  27463. * Creates a new particle and modifies the SPS mesh geometry :
  27464. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27465. * - calls _addParticle() to populate the particle array
  27466. * factorized code from addShape() and insertParticlesFromArray()
  27467. * @param idx particle index in the particles array
  27468. * @param i particle index in its shape
  27469. * @param modelShape particle ModelShape object
  27470. * @param shape shape vertex array
  27471. * @param meshInd shape indices array
  27472. * @param meshUV shape uv array
  27473. * @param meshCol shape color array
  27474. * @param meshNor shape normals array
  27475. * @param bbInfo shape bounding info
  27476. * @param storage target particle storage
  27477. * @options addShape() passed options
  27478. * @hidden
  27479. */
  27480. private _insertNewParticle;
  27481. /**
  27482. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27483. * This method calls `updateParticle()` for each particle of the SPS.
  27484. * For an animated SPS, it is usually called within the render loop.
  27485. * 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.
  27486. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27487. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27488. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27489. * @returns the SPS.
  27490. */
  27491. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27492. /**
  27493. * Disposes the SPS.
  27494. */
  27495. dispose(): void;
  27496. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27497. * idx is the particle index in the SPS
  27498. * faceId is the picked face index counted within this particle.
  27499. * Returns null if the pickInfo can't identify a picked particle.
  27500. * @param pickingInfo (PickingInfo object)
  27501. * @returns {idx: number, faceId: number} or null
  27502. */
  27503. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27504. idx: number;
  27505. faceId: number;
  27506. }>;
  27507. /**
  27508. * Returns a SolidParticle object from its identifier : particle.id
  27509. * @param id (integer) the particle Id
  27510. * @returns the searched particle or null if not found in the SPS.
  27511. */
  27512. getParticleById(id: number): Nullable<SolidParticle>;
  27513. /**
  27514. * Returns a new array populated with the particles having the passed shapeId.
  27515. * @param shapeId (integer) the shape identifier
  27516. * @returns a new solid particle array
  27517. */
  27518. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27519. /**
  27520. * Populates the passed array "ref" with the particles having the passed shapeId.
  27521. * @param shapeId the shape identifier
  27522. * @returns the SPS
  27523. * @param ref
  27524. */
  27525. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27526. /**
  27527. * Computes the required SubMeshes according the materials assigned to the particles.
  27528. * @returns the solid particle system.
  27529. * Does nothing if called before the SPS mesh is built.
  27530. */
  27531. computeSubMeshes(): SolidParticleSystem;
  27532. /**
  27533. * Sorts the solid particles by material when MultiMaterial is enabled.
  27534. * Updates the indices32 array.
  27535. * Updates the indicesByMaterial array.
  27536. * Updates the mesh indices array.
  27537. * @returns the SPS
  27538. * @hidden
  27539. */
  27540. private _sortParticlesByMaterial;
  27541. /**
  27542. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27543. * @hidden
  27544. */
  27545. private _setMaterialIndexesById;
  27546. /**
  27547. * Returns an array with unique values of Materials from the passed array
  27548. * @param array the material array to be checked and filtered
  27549. * @hidden
  27550. */
  27551. private _filterUniqueMaterialId;
  27552. /**
  27553. * Sets a new Standard Material as _defaultMaterial if not already set.
  27554. * @hidden
  27555. */
  27556. private _setDefaultMaterial;
  27557. /**
  27558. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27559. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27560. * @returns the SPS.
  27561. */
  27562. refreshVisibleSize(): SolidParticleSystem;
  27563. /**
  27564. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27565. * @param size the size (float) of the visibility box
  27566. * note : this doesn't lock the SPS mesh bounding box.
  27567. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27568. */
  27569. setVisibilityBox(size: number): void;
  27570. /**
  27571. * Gets whether the SPS as always visible or not
  27572. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27573. */
  27574. get isAlwaysVisible(): boolean;
  27575. /**
  27576. * Sets the SPS as always visible or not
  27577. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27578. */
  27579. set isAlwaysVisible(val: boolean);
  27580. /**
  27581. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27582. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27583. */
  27584. set isVisibilityBoxLocked(val: boolean);
  27585. /**
  27586. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27587. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27588. */
  27589. get isVisibilityBoxLocked(): boolean;
  27590. /**
  27591. * Tells to `setParticles()` to compute the particle rotations or not.
  27592. * Default value : true. The SPS is faster when it's set to false.
  27593. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27594. */
  27595. set computeParticleRotation(val: boolean);
  27596. /**
  27597. * Tells to `setParticles()` to compute the particle colors or not.
  27598. * Default value : true. The SPS is faster when it's set to false.
  27599. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27600. */
  27601. set computeParticleColor(val: boolean);
  27602. set computeParticleTexture(val: boolean);
  27603. /**
  27604. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27605. * Default value : false. The SPS is faster when it's set to false.
  27606. * Note : the particle custom vertex positions aren't stored values.
  27607. */
  27608. set computeParticleVertex(val: boolean);
  27609. /**
  27610. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27611. */
  27612. set computeBoundingBox(val: boolean);
  27613. /**
  27614. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27615. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27616. * Default : `true`
  27617. */
  27618. set depthSortParticles(val: boolean);
  27619. /**
  27620. * Gets if `setParticles()` computes the particle rotations or not.
  27621. * Default value : true. The SPS is faster when it's set to false.
  27622. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27623. */
  27624. get computeParticleRotation(): boolean;
  27625. /**
  27626. * Gets if `setParticles()` computes the particle colors or not.
  27627. * Default value : true. The SPS is faster when it's set to false.
  27628. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27629. */
  27630. get computeParticleColor(): boolean;
  27631. /**
  27632. * Gets if `setParticles()` computes the particle textures or not.
  27633. * Default value : true. The SPS is faster when it's set to false.
  27634. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27635. */
  27636. get computeParticleTexture(): boolean;
  27637. /**
  27638. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27639. * Default value : false. The SPS is faster when it's set to false.
  27640. * Note : the particle custom vertex positions aren't stored values.
  27641. */
  27642. get computeParticleVertex(): boolean;
  27643. /**
  27644. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27645. */
  27646. get computeBoundingBox(): boolean;
  27647. /**
  27648. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27649. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27650. * Default : `true`
  27651. */
  27652. get depthSortParticles(): boolean;
  27653. /**
  27654. * Gets if the SPS is created as expandable at construction time.
  27655. * Default : `false`
  27656. */
  27657. get expandable(): boolean;
  27658. /**
  27659. * Gets if the SPS supports the Multi Materials
  27660. */
  27661. get multimaterialEnabled(): boolean;
  27662. /**
  27663. * Gets if the SPS uses the model materials for its own multimaterial.
  27664. */
  27665. get useModelMaterial(): boolean;
  27666. /**
  27667. * The SPS used material array.
  27668. */
  27669. get materials(): Material[];
  27670. /**
  27671. * Sets the SPS MultiMaterial from the passed materials.
  27672. * Note : the passed array is internally copied and not used then by reference.
  27673. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27674. */
  27675. setMultiMaterial(materials: Material[]): void;
  27676. /**
  27677. * The SPS computed multimaterial object
  27678. */
  27679. get multimaterial(): MultiMaterial;
  27680. set multimaterial(mm: MultiMaterial);
  27681. /**
  27682. * If the subMeshes must be updated on the next call to setParticles()
  27683. */
  27684. get autoUpdateSubMeshes(): boolean;
  27685. set autoUpdateSubMeshes(val: boolean);
  27686. /**
  27687. * This function does nothing. It may be overwritten to set all the particle first values.
  27688. * The SPS doesn't call this function, you may have to call it by your own.
  27689. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27690. */
  27691. initParticles(): void;
  27692. /**
  27693. * This function does nothing. It may be overwritten to recycle a particle.
  27694. * The SPS doesn't call this function, you may have to call it by your own.
  27695. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27696. * @param particle The particle to recycle
  27697. * @returns the recycled particle
  27698. */
  27699. recycleParticle(particle: SolidParticle): SolidParticle;
  27700. /**
  27701. * Updates a particle : this function should be overwritten by the user.
  27702. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27703. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27704. * @example : just set a particle position or velocity and recycle conditions
  27705. * @param particle The particle to update
  27706. * @returns the updated particle
  27707. */
  27708. updateParticle(particle: SolidParticle): SolidParticle;
  27709. /**
  27710. * Updates a vertex of a particle : it can be overwritten by the user.
  27711. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27712. * @param particle the current particle
  27713. * @param vertex the current index of the current particle
  27714. * @param pt the index of the current vertex in the particle shape
  27715. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27716. * @example : just set a vertex particle position
  27717. * @returns the updated vertex
  27718. */
  27719. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27720. /**
  27721. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27722. * This does nothing and may be overwritten by the user.
  27723. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27724. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27725. * @param update the boolean update value actually passed to setParticles()
  27726. */
  27727. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27728. /**
  27729. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27730. * This will be passed three parameters.
  27731. * This does nothing and may be overwritten by the user.
  27732. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27733. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27734. * @param update the boolean update value actually passed to setParticles()
  27735. */
  27736. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27737. }
  27738. }
  27739. declare module BABYLON {
  27740. /**
  27741. * Represents one particle of a solid particle system.
  27742. */
  27743. export class SolidParticle {
  27744. /**
  27745. * particle global index
  27746. */
  27747. idx: number;
  27748. /**
  27749. * particle identifier
  27750. */
  27751. id: number;
  27752. /**
  27753. * The color of the particle
  27754. */
  27755. color: Nullable<Color4>;
  27756. /**
  27757. * The world space position of the particle.
  27758. */
  27759. position: Vector3;
  27760. /**
  27761. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27762. */
  27763. rotation: Vector3;
  27764. /**
  27765. * The world space rotation quaternion of the particle.
  27766. */
  27767. rotationQuaternion: Nullable<Quaternion>;
  27768. /**
  27769. * The scaling of the particle.
  27770. */
  27771. scaling: Vector3;
  27772. /**
  27773. * The uvs of the particle.
  27774. */
  27775. uvs: Vector4;
  27776. /**
  27777. * The current speed of the particle.
  27778. */
  27779. velocity: Vector3;
  27780. /**
  27781. * The pivot point in the particle local space.
  27782. */
  27783. pivot: Vector3;
  27784. /**
  27785. * Must the particle be translated from its pivot point in its local space ?
  27786. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27787. * Default : false
  27788. */
  27789. translateFromPivot: boolean;
  27790. /**
  27791. * Is the particle active or not ?
  27792. */
  27793. alive: boolean;
  27794. /**
  27795. * Is the particle visible or not ?
  27796. */
  27797. isVisible: boolean;
  27798. /**
  27799. * Index of this particle in the global "positions" array (Internal use)
  27800. * @hidden
  27801. */
  27802. _pos: number;
  27803. /**
  27804. * @hidden Index of this particle in the global "indices" array (Internal use)
  27805. */
  27806. _ind: number;
  27807. /**
  27808. * @hidden ModelShape of this particle (Internal use)
  27809. */
  27810. _model: ModelShape;
  27811. /**
  27812. * ModelShape id of this particle
  27813. */
  27814. shapeId: number;
  27815. /**
  27816. * Index of the particle in its shape id
  27817. */
  27818. idxInShape: number;
  27819. /**
  27820. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27821. */
  27822. _modelBoundingInfo: BoundingInfo;
  27823. /**
  27824. * @hidden Particle BoundingInfo object (Internal use)
  27825. */
  27826. _boundingInfo: BoundingInfo;
  27827. /**
  27828. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27829. */
  27830. _sps: SolidParticleSystem;
  27831. /**
  27832. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27833. */
  27834. _stillInvisible: boolean;
  27835. /**
  27836. * @hidden Last computed particle rotation matrix
  27837. */
  27838. _rotationMatrix: number[];
  27839. /**
  27840. * Parent particle Id, if any.
  27841. * Default null.
  27842. */
  27843. parentId: Nullable<number>;
  27844. /**
  27845. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27846. */
  27847. materialIndex: Nullable<number>;
  27848. /**
  27849. * Custom object or properties.
  27850. */
  27851. props: Nullable<any>;
  27852. /**
  27853. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27854. * The possible values are :
  27855. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27856. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27857. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27858. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27859. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27860. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27861. * */
  27862. cullingStrategy: number;
  27863. /**
  27864. * @hidden Internal global position in the SPS.
  27865. */
  27866. _globalPosition: Vector3;
  27867. /**
  27868. * Creates a Solid Particle object.
  27869. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27870. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27871. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27872. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27873. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27874. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27875. * @param shapeId (integer) is the model shape identifier in the SPS.
  27876. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27877. * @param sps defines the sps it is associated to
  27878. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27879. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27880. */
  27881. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27882. /**
  27883. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27884. * @param target the particle target
  27885. * @returns the current particle
  27886. */
  27887. copyToRef(target: SolidParticle): SolidParticle;
  27888. /**
  27889. * Legacy support, changed scale to scaling
  27890. */
  27891. get scale(): Vector3;
  27892. /**
  27893. * Legacy support, changed scale to scaling
  27894. */
  27895. set scale(scale: Vector3);
  27896. /**
  27897. * Legacy support, changed quaternion to rotationQuaternion
  27898. */
  27899. get quaternion(): Nullable<Quaternion>;
  27900. /**
  27901. * Legacy support, changed quaternion to rotationQuaternion
  27902. */
  27903. set quaternion(q: Nullable<Quaternion>);
  27904. /**
  27905. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27906. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27907. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27908. * @returns true if it intersects
  27909. */
  27910. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27911. /**
  27912. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27913. * A particle is in the frustum if its bounding box intersects the frustum
  27914. * @param frustumPlanes defines the frustum to test
  27915. * @returns true if the particle is in the frustum planes
  27916. */
  27917. isInFrustum(frustumPlanes: Plane[]): boolean;
  27918. /**
  27919. * get the rotation matrix of the particle
  27920. * @hidden
  27921. */
  27922. getRotationMatrix(m: Matrix): void;
  27923. }
  27924. /**
  27925. * Represents the shape of the model used by one particle of a solid particle system.
  27926. * SPS internal tool, don't use it manually.
  27927. */
  27928. export class ModelShape {
  27929. /**
  27930. * The shape id
  27931. * @hidden
  27932. */
  27933. shapeID: number;
  27934. /**
  27935. * flat array of model positions (internal use)
  27936. * @hidden
  27937. */
  27938. _shape: Vector3[];
  27939. /**
  27940. * flat array of model UVs (internal use)
  27941. * @hidden
  27942. */
  27943. _shapeUV: number[];
  27944. /**
  27945. * color array of the model
  27946. * @hidden
  27947. */
  27948. _shapeColors: number[];
  27949. /**
  27950. * indices array of the model
  27951. * @hidden
  27952. */
  27953. _indices: number[];
  27954. /**
  27955. * normals array of the model
  27956. * @hidden
  27957. */
  27958. _normals: number[];
  27959. /**
  27960. * length of the shape in the model indices array (internal use)
  27961. * @hidden
  27962. */
  27963. _indicesLength: number;
  27964. /**
  27965. * Custom position function (internal use)
  27966. * @hidden
  27967. */
  27968. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27969. /**
  27970. * Custom vertex function (internal use)
  27971. * @hidden
  27972. */
  27973. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27974. /**
  27975. * Model material (internal use)
  27976. * @hidden
  27977. */
  27978. _material: Nullable<Material>;
  27979. /**
  27980. * 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.
  27981. * SPS internal tool, don't use it manually.
  27982. * @hidden
  27983. */
  27984. 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>);
  27985. }
  27986. /**
  27987. * Represents a Depth Sorted Particle in the solid particle system.
  27988. * @hidden
  27989. */
  27990. export class DepthSortedParticle {
  27991. /**
  27992. * Particle index
  27993. */
  27994. idx: number;
  27995. /**
  27996. * Index of the particle in the "indices" array
  27997. */
  27998. ind: number;
  27999. /**
  28000. * Length of the particle shape in the "indices" array
  28001. */
  28002. indicesLength: number;
  28003. /**
  28004. * Squared distance from the particle to the camera
  28005. */
  28006. sqDistance: number;
  28007. /**
  28008. * Material index when used with MultiMaterials
  28009. */
  28010. materialIndex: number;
  28011. /**
  28012. * Creates a new sorted particle
  28013. * @param materialIndex
  28014. */
  28015. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28016. }
  28017. }
  28018. declare module BABYLON {
  28019. /**
  28020. * @hidden
  28021. */
  28022. export class _MeshCollisionData {
  28023. _checkCollisions: boolean;
  28024. _collisionMask: number;
  28025. _collisionGroup: number;
  28026. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28027. _collider: Nullable<Collider>;
  28028. _oldPositionForCollisions: Vector3;
  28029. _diffPositionForCollisions: Vector3;
  28030. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28031. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28032. }
  28033. }
  28034. declare module BABYLON {
  28035. /** @hidden */
  28036. class _FacetDataStorage {
  28037. facetPositions: Vector3[];
  28038. facetNormals: Vector3[];
  28039. facetPartitioning: number[][];
  28040. facetNb: number;
  28041. partitioningSubdivisions: number;
  28042. partitioningBBoxRatio: number;
  28043. facetDataEnabled: boolean;
  28044. facetParameters: any;
  28045. bbSize: Vector3;
  28046. subDiv: {
  28047. max: number;
  28048. X: number;
  28049. Y: number;
  28050. Z: number;
  28051. };
  28052. facetDepthSort: boolean;
  28053. facetDepthSortEnabled: boolean;
  28054. depthSortedIndices: IndicesArray;
  28055. depthSortedFacets: {
  28056. ind: number;
  28057. sqDistance: number;
  28058. }[];
  28059. facetDepthSortFunction: (f1: {
  28060. ind: number;
  28061. sqDistance: number;
  28062. }, f2: {
  28063. ind: number;
  28064. sqDistance: number;
  28065. }) => number;
  28066. facetDepthSortFrom: Vector3;
  28067. facetDepthSortOrigin: Vector3;
  28068. invertedMatrix: Matrix;
  28069. }
  28070. /**
  28071. * @hidden
  28072. **/
  28073. class _InternalAbstractMeshDataInfo {
  28074. _hasVertexAlpha: boolean;
  28075. _useVertexColors: boolean;
  28076. _numBoneInfluencers: number;
  28077. _applyFog: boolean;
  28078. _receiveShadows: boolean;
  28079. _facetData: _FacetDataStorage;
  28080. _visibility: number;
  28081. _skeleton: Nullable<Skeleton>;
  28082. _layerMask: number;
  28083. _computeBonesUsingShaders: boolean;
  28084. _isActive: boolean;
  28085. _onlyForInstances: boolean;
  28086. _isActiveIntermediate: boolean;
  28087. _onlyForInstancesIntermediate: boolean;
  28088. _actAsRegularMesh: boolean;
  28089. }
  28090. /**
  28091. * Class used to store all common mesh properties
  28092. */
  28093. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28094. /** No occlusion */
  28095. static OCCLUSION_TYPE_NONE: number;
  28096. /** Occlusion set to optimisitic */
  28097. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28098. /** Occlusion set to strict */
  28099. static OCCLUSION_TYPE_STRICT: number;
  28100. /** Use an accurante occlusion algorithm */
  28101. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28102. /** Use a conservative occlusion algorithm */
  28103. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28104. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28105. * Test order :
  28106. * Is the bounding sphere outside the frustum ?
  28107. * If not, are the bounding box vertices outside the frustum ?
  28108. * It not, then the cullable object is in the frustum.
  28109. */
  28110. static readonly CULLINGSTRATEGY_STANDARD: number;
  28111. /** Culling strategy : Bounding Sphere Only.
  28112. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28113. * It's also less accurate than the standard because some not visible objects can still be selected.
  28114. * Test : is the bounding sphere outside the frustum ?
  28115. * If not, then the cullable object is in the frustum.
  28116. */
  28117. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28118. /** Culling strategy : Optimistic Inclusion.
  28119. * This in an inclusion test first, then the standard exclusion test.
  28120. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28121. * 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.
  28122. * Anyway, it's as accurate as the standard strategy.
  28123. * Test :
  28124. * Is the cullable object bounding sphere center in the frustum ?
  28125. * If not, apply the default culling strategy.
  28126. */
  28127. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28128. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28129. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28130. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28131. * 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.
  28132. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28133. * Test :
  28134. * Is the cullable object bounding sphere center in the frustum ?
  28135. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28136. */
  28137. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28138. /**
  28139. * No billboard
  28140. */
  28141. static get BILLBOARDMODE_NONE(): number;
  28142. /** Billboard on X axis */
  28143. static get BILLBOARDMODE_X(): number;
  28144. /** Billboard on Y axis */
  28145. static get BILLBOARDMODE_Y(): number;
  28146. /** Billboard on Z axis */
  28147. static get BILLBOARDMODE_Z(): number;
  28148. /** Billboard on all axes */
  28149. static get BILLBOARDMODE_ALL(): number;
  28150. /** Billboard on using position instead of orientation */
  28151. static get BILLBOARDMODE_USE_POSITION(): number;
  28152. /** @hidden */
  28153. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28154. /**
  28155. * The culling strategy to use to check whether the mesh must be rendered or not.
  28156. * This value can be changed at any time and will be used on the next render mesh selection.
  28157. * The possible values are :
  28158. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28159. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28160. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28161. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28162. * Please read each static variable documentation to get details about the culling process.
  28163. * */
  28164. cullingStrategy: number;
  28165. /**
  28166. * Gets the number of facets in the mesh
  28167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28168. */
  28169. get facetNb(): number;
  28170. /**
  28171. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28173. */
  28174. get partitioningSubdivisions(): number;
  28175. set partitioningSubdivisions(nb: number);
  28176. /**
  28177. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28178. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28179. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28180. */
  28181. get partitioningBBoxRatio(): number;
  28182. set partitioningBBoxRatio(ratio: number);
  28183. /**
  28184. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28185. * Works only for updatable meshes.
  28186. * Doesn't work with multi-materials
  28187. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28188. */
  28189. get mustDepthSortFacets(): boolean;
  28190. set mustDepthSortFacets(sort: boolean);
  28191. /**
  28192. * The location (Vector3) where the facet depth sort must be computed from.
  28193. * By default, the active camera position.
  28194. * Used only when facet depth sort is enabled
  28195. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28196. */
  28197. get facetDepthSortFrom(): Vector3;
  28198. set facetDepthSortFrom(location: Vector3);
  28199. /**
  28200. * gets a boolean indicating if facetData is enabled
  28201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28202. */
  28203. get isFacetDataEnabled(): boolean;
  28204. /** @hidden */
  28205. _updateNonUniformScalingState(value: boolean): boolean;
  28206. /**
  28207. * An event triggered when this mesh collides with another one
  28208. */
  28209. onCollideObservable: Observable<AbstractMesh>;
  28210. /** Set a function to call when this mesh collides with another one */
  28211. set onCollide(callback: () => void);
  28212. /**
  28213. * An event triggered when the collision's position changes
  28214. */
  28215. onCollisionPositionChangeObservable: Observable<Vector3>;
  28216. /** Set a function to call when the collision's position changes */
  28217. set onCollisionPositionChange(callback: () => void);
  28218. /**
  28219. * An event triggered when material is changed
  28220. */
  28221. onMaterialChangedObservable: Observable<AbstractMesh>;
  28222. /**
  28223. * Gets or sets the orientation for POV movement & rotation
  28224. */
  28225. definedFacingForward: boolean;
  28226. /** @hidden */
  28227. _occlusionQuery: Nullable<WebGLQuery>;
  28228. /** @hidden */
  28229. _renderingGroup: Nullable<RenderingGroup>;
  28230. /**
  28231. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28232. */
  28233. get visibility(): number;
  28234. /**
  28235. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28236. */
  28237. set visibility(value: number);
  28238. /** Gets or sets the alpha index used to sort transparent meshes
  28239. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28240. */
  28241. alphaIndex: number;
  28242. /**
  28243. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28244. */
  28245. isVisible: boolean;
  28246. /**
  28247. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28248. */
  28249. isPickable: boolean;
  28250. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28251. showSubMeshesBoundingBox: boolean;
  28252. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28253. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28254. */
  28255. isBlocker: boolean;
  28256. /**
  28257. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28258. */
  28259. enablePointerMoveEvents: boolean;
  28260. /**
  28261. * Specifies the rendering group id for this mesh (0 by default)
  28262. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28263. */
  28264. renderingGroupId: number;
  28265. private _material;
  28266. /** Gets or sets current material */
  28267. get material(): Nullable<Material>;
  28268. set material(value: Nullable<Material>);
  28269. /**
  28270. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28271. * @see http://doc.babylonjs.com/babylon101/shadows
  28272. */
  28273. get receiveShadows(): boolean;
  28274. set receiveShadows(value: boolean);
  28275. /** Defines color to use when rendering outline */
  28276. outlineColor: Color3;
  28277. /** Define width to use when rendering outline */
  28278. outlineWidth: number;
  28279. /** Defines color to use when rendering overlay */
  28280. overlayColor: Color3;
  28281. /** Defines alpha to use when rendering overlay */
  28282. overlayAlpha: number;
  28283. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28284. get hasVertexAlpha(): boolean;
  28285. set hasVertexAlpha(value: boolean);
  28286. /** 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) */
  28287. get useVertexColors(): boolean;
  28288. set useVertexColors(value: boolean);
  28289. /**
  28290. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28291. */
  28292. get computeBonesUsingShaders(): boolean;
  28293. set computeBonesUsingShaders(value: boolean);
  28294. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28295. get numBoneInfluencers(): number;
  28296. set numBoneInfluencers(value: number);
  28297. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28298. get applyFog(): boolean;
  28299. set applyFog(value: boolean);
  28300. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28301. useOctreeForRenderingSelection: boolean;
  28302. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28303. useOctreeForPicking: boolean;
  28304. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28305. useOctreeForCollisions: boolean;
  28306. /**
  28307. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28308. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28309. */
  28310. get layerMask(): number;
  28311. set layerMask(value: number);
  28312. /**
  28313. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28314. */
  28315. alwaysSelectAsActiveMesh: boolean;
  28316. /**
  28317. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28318. */
  28319. doNotSyncBoundingInfo: boolean;
  28320. /**
  28321. * Gets or sets the current action manager
  28322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28323. */
  28324. actionManager: Nullable<AbstractActionManager>;
  28325. private _meshCollisionData;
  28326. /**
  28327. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28328. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28329. */
  28330. ellipsoid: Vector3;
  28331. /**
  28332. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28333. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28334. */
  28335. ellipsoidOffset: Vector3;
  28336. /**
  28337. * Gets or sets a collision mask used to mask collisions (default is -1).
  28338. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28339. */
  28340. get collisionMask(): number;
  28341. set collisionMask(mask: number);
  28342. /**
  28343. * Gets or sets the current collision group mask (-1 by default).
  28344. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28345. */
  28346. get collisionGroup(): number;
  28347. set collisionGroup(mask: number);
  28348. /**
  28349. * Gets or sets current surrounding meshes (null by default).
  28350. *
  28351. * By default collision detection is tested against every mesh in the scene.
  28352. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28353. * meshes will be tested for the collision.
  28354. *
  28355. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28356. */
  28357. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28358. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28359. /**
  28360. * Defines edge width used when edgesRenderer is enabled
  28361. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28362. */
  28363. edgesWidth: number;
  28364. /**
  28365. * Defines edge color used when edgesRenderer is enabled
  28366. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28367. */
  28368. edgesColor: Color4;
  28369. /** @hidden */
  28370. _edgesRenderer: Nullable<IEdgesRenderer>;
  28371. /** @hidden */
  28372. _masterMesh: Nullable<AbstractMesh>;
  28373. /** @hidden */
  28374. _boundingInfo: Nullable<BoundingInfo>;
  28375. /** @hidden */
  28376. _renderId: number;
  28377. /**
  28378. * Gets or sets the list of subMeshes
  28379. * @see http://doc.babylonjs.com/how_to/multi_materials
  28380. */
  28381. subMeshes: SubMesh[];
  28382. /** @hidden */
  28383. _intersectionsInProgress: AbstractMesh[];
  28384. /** @hidden */
  28385. _unIndexed: boolean;
  28386. /** @hidden */
  28387. _lightSources: Light[];
  28388. /** Gets the list of lights affecting that mesh */
  28389. get lightSources(): Light[];
  28390. /** @hidden */
  28391. get _positions(): Nullable<Vector3[]>;
  28392. /** @hidden */
  28393. _waitingData: {
  28394. lods: Nullable<any>;
  28395. actions: Nullable<any>;
  28396. freezeWorldMatrix: Nullable<boolean>;
  28397. };
  28398. /** @hidden */
  28399. _bonesTransformMatrices: Nullable<Float32Array>;
  28400. /** @hidden */
  28401. _transformMatrixTexture: Nullable<RawTexture>;
  28402. /**
  28403. * Gets or sets a skeleton to apply skining transformations
  28404. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28405. */
  28406. set skeleton(value: Nullable<Skeleton>);
  28407. get skeleton(): Nullable<Skeleton>;
  28408. /**
  28409. * An event triggered when the mesh is rebuilt.
  28410. */
  28411. onRebuildObservable: Observable<AbstractMesh>;
  28412. /**
  28413. * Creates a new AbstractMesh
  28414. * @param name defines the name of the mesh
  28415. * @param scene defines the hosting scene
  28416. */
  28417. constructor(name: string, scene?: Nullable<Scene>);
  28418. /**
  28419. * Returns the string "AbstractMesh"
  28420. * @returns "AbstractMesh"
  28421. */
  28422. getClassName(): string;
  28423. /**
  28424. * Gets a string representation of the current mesh
  28425. * @param fullDetails defines a boolean indicating if full details must be included
  28426. * @returns a string representation of the current mesh
  28427. */
  28428. toString(fullDetails?: boolean): string;
  28429. /**
  28430. * @hidden
  28431. */
  28432. protected _getEffectiveParent(): Nullable<Node>;
  28433. /** @hidden */
  28434. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28435. /** @hidden */
  28436. _rebuild(): void;
  28437. /** @hidden */
  28438. _resyncLightSources(): void;
  28439. /** @hidden */
  28440. _resyncLightSource(light: Light): void;
  28441. /** @hidden */
  28442. _unBindEffect(): void;
  28443. /** @hidden */
  28444. _removeLightSource(light: Light, dispose: boolean): void;
  28445. private _markSubMeshesAsDirty;
  28446. /** @hidden */
  28447. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28448. /** @hidden */
  28449. _markSubMeshesAsAttributesDirty(): void;
  28450. /** @hidden */
  28451. _markSubMeshesAsMiscDirty(): void;
  28452. /**
  28453. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28454. */
  28455. get scaling(): Vector3;
  28456. set scaling(newScaling: Vector3);
  28457. /**
  28458. * Returns true if the mesh is blocked. Implemented by child classes
  28459. */
  28460. get isBlocked(): boolean;
  28461. /**
  28462. * Returns the mesh itself by default. Implemented by child classes
  28463. * @param camera defines the camera to use to pick the right LOD level
  28464. * @returns the currentAbstractMesh
  28465. */
  28466. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28467. /**
  28468. * Returns 0 by default. Implemented by child classes
  28469. * @returns an integer
  28470. */
  28471. getTotalVertices(): number;
  28472. /**
  28473. * Returns a positive integer : the total number of indices in this mesh geometry.
  28474. * @returns the numner of indices or zero if the mesh has no geometry.
  28475. */
  28476. getTotalIndices(): number;
  28477. /**
  28478. * Returns null by default. Implemented by child classes
  28479. * @returns null
  28480. */
  28481. getIndices(): Nullable<IndicesArray>;
  28482. /**
  28483. * Returns the array of the requested vertex data kind. Implemented by child classes
  28484. * @param kind defines the vertex data kind to use
  28485. * @returns null
  28486. */
  28487. getVerticesData(kind: string): Nullable<FloatArray>;
  28488. /**
  28489. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28490. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28491. * Note that a new underlying VertexBuffer object is created each call.
  28492. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28493. * @param kind defines vertex data kind:
  28494. * * VertexBuffer.PositionKind
  28495. * * VertexBuffer.UVKind
  28496. * * VertexBuffer.UV2Kind
  28497. * * VertexBuffer.UV3Kind
  28498. * * VertexBuffer.UV4Kind
  28499. * * VertexBuffer.UV5Kind
  28500. * * VertexBuffer.UV6Kind
  28501. * * VertexBuffer.ColorKind
  28502. * * VertexBuffer.MatricesIndicesKind
  28503. * * VertexBuffer.MatricesIndicesExtraKind
  28504. * * VertexBuffer.MatricesWeightsKind
  28505. * * VertexBuffer.MatricesWeightsExtraKind
  28506. * @param data defines the data source
  28507. * @param updatable defines if the data must be flagged as updatable (or static)
  28508. * @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
  28509. * @returns the current mesh
  28510. */
  28511. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28512. /**
  28513. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28514. * If the mesh has no geometry, it is simply returned as it is.
  28515. * @param kind defines vertex data kind:
  28516. * * VertexBuffer.PositionKind
  28517. * * VertexBuffer.UVKind
  28518. * * VertexBuffer.UV2Kind
  28519. * * VertexBuffer.UV3Kind
  28520. * * VertexBuffer.UV4Kind
  28521. * * VertexBuffer.UV5Kind
  28522. * * VertexBuffer.UV6Kind
  28523. * * VertexBuffer.ColorKind
  28524. * * VertexBuffer.MatricesIndicesKind
  28525. * * VertexBuffer.MatricesIndicesExtraKind
  28526. * * VertexBuffer.MatricesWeightsKind
  28527. * * VertexBuffer.MatricesWeightsExtraKind
  28528. * @param data defines the data source
  28529. * @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
  28530. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28531. * @returns the current mesh
  28532. */
  28533. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28534. /**
  28535. * Sets the mesh indices,
  28536. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28537. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28538. * @param totalVertices Defines the total number of vertices
  28539. * @returns the current mesh
  28540. */
  28541. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28542. /**
  28543. * Gets a boolean indicating if specific vertex data is present
  28544. * @param kind defines the vertex data kind to use
  28545. * @returns true is data kind is present
  28546. */
  28547. isVerticesDataPresent(kind: string): boolean;
  28548. /**
  28549. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28550. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28551. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28552. * @returns a BoundingInfo
  28553. */
  28554. getBoundingInfo(): BoundingInfo;
  28555. /**
  28556. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28557. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28558. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28559. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28560. * @returns the current mesh
  28561. */
  28562. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28563. /**
  28564. * Overwrite the current bounding info
  28565. * @param boundingInfo defines the new bounding info
  28566. * @returns the current mesh
  28567. */
  28568. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28569. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28570. get useBones(): boolean;
  28571. /** @hidden */
  28572. _preActivate(): void;
  28573. /** @hidden */
  28574. _preActivateForIntermediateRendering(renderId: number): void;
  28575. /** @hidden */
  28576. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28577. /** @hidden */
  28578. _postActivate(): void;
  28579. /** @hidden */
  28580. _freeze(): void;
  28581. /** @hidden */
  28582. _unFreeze(): void;
  28583. /**
  28584. * Gets the current world matrix
  28585. * @returns a Matrix
  28586. */
  28587. getWorldMatrix(): Matrix;
  28588. /** @hidden */
  28589. _getWorldMatrixDeterminant(): number;
  28590. /**
  28591. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28592. */
  28593. get isAnInstance(): boolean;
  28594. /**
  28595. * Gets a boolean indicating if this mesh has instances
  28596. */
  28597. get hasInstances(): boolean;
  28598. /**
  28599. * Perform relative position change from the point of view of behind the front of the mesh.
  28600. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28601. * Supports definition of mesh facing forward or backward
  28602. * @param amountRight defines the distance on the right axis
  28603. * @param amountUp defines the distance on the up axis
  28604. * @param amountForward defines the distance on the forward axis
  28605. * @returns the current mesh
  28606. */
  28607. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28608. /**
  28609. * Calculate relative position change from the point of view of behind the front of the mesh.
  28610. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28611. * Supports definition of mesh facing forward or backward
  28612. * @param amountRight defines the distance on the right axis
  28613. * @param amountUp defines the distance on the up axis
  28614. * @param amountForward defines the distance on the forward axis
  28615. * @returns the new displacement vector
  28616. */
  28617. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28618. /**
  28619. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28620. * Supports definition of mesh facing forward or backward
  28621. * @param flipBack defines the flip
  28622. * @param twirlClockwise defines the twirl
  28623. * @param tiltRight defines the tilt
  28624. * @returns the current mesh
  28625. */
  28626. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28627. /**
  28628. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28629. * Supports definition of mesh facing forward or backward.
  28630. * @param flipBack defines the flip
  28631. * @param twirlClockwise defines the twirl
  28632. * @param tiltRight defines the tilt
  28633. * @returns the new rotation vector
  28634. */
  28635. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28636. /**
  28637. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28638. * This means the mesh underlying bounding box and sphere are recomputed.
  28639. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28640. * @returns the current mesh
  28641. */
  28642. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28643. /** @hidden */
  28644. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28645. /** @hidden */
  28646. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28647. /** @hidden */
  28648. _updateBoundingInfo(): AbstractMesh;
  28649. /** @hidden */
  28650. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28651. /** @hidden */
  28652. protected _afterComputeWorldMatrix(): void;
  28653. /** @hidden */
  28654. get _effectiveMesh(): AbstractMesh;
  28655. /**
  28656. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28657. * A mesh is in the frustum if its bounding box intersects the frustum
  28658. * @param frustumPlanes defines the frustum to test
  28659. * @returns true if the mesh is in the frustum planes
  28660. */
  28661. isInFrustum(frustumPlanes: Plane[]): boolean;
  28662. /**
  28663. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28664. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28665. * @param frustumPlanes defines the frustum to test
  28666. * @returns true if the mesh is completely in the frustum planes
  28667. */
  28668. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28669. /**
  28670. * True if the mesh intersects another mesh or a SolidParticle object
  28671. * @param mesh defines a target mesh or SolidParticle to test
  28672. * @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)
  28673. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28674. * @returns true if there is an intersection
  28675. */
  28676. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28677. /**
  28678. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28679. * @param point defines the point to test
  28680. * @returns true if there is an intersection
  28681. */
  28682. intersectsPoint(point: Vector3): boolean;
  28683. /**
  28684. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28685. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28686. */
  28687. get checkCollisions(): boolean;
  28688. set checkCollisions(collisionEnabled: boolean);
  28689. /**
  28690. * Gets Collider object used to compute collisions (not physics)
  28691. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28692. */
  28693. get collider(): Nullable<Collider>;
  28694. /**
  28695. * Move the mesh using collision engine
  28696. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28697. * @param displacement defines the requested displacement vector
  28698. * @returns the current mesh
  28699. */
  28700. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28701. private _onCollisionPositionChange;
  28702. /** @hidden */
  28703. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28704. /** @hidden */
  28705. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28706. /** @hidden */
  28707. _checkCollision(collider: Collider): AbstractMesh;
  28708. /** @hidden */
  28709. _generatePointsArray(): boolean;
  28710. /**
  28711. * Checks if the passed Ray intersects with the mesh
  28712. * @param ray defines the ray to use
  28713. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28714. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28715. * @returns the picking info
  28716. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28717. */
  28718. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28719. /**
  28720. * Clones the current mesh
  28721. * @param name defines the mesh name
  28722. * @param newParent defines the new mesh parent
  28723. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28724. * @returns the new mesh
  28725. */
  28726. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28727. /**
  28728. * Disposes all the submeshes of the current meshnp
  28729. * @returns the current mesh
  28730. */
  28731. releaseSubMeshes(): AbstractMesh;
  28732. /**
  28733. * Releases resources associated with this abstract mesh.
  28734. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28735. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28736. */
  28737. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28738. /**
  28739. * Adds the passed mesh as a child to the current mesh
  28740. * @param mesh defines the child mesh
  28741. * @returns the current mesh
  28742. */
  28743. addChild(mesh: AbstractMesh): AbstractMesh;
  28744. /**
  28745. * Removes the passed mesh from the current mesh children list
  28746. * @param mesh defines the child mesh
  28747. * @returns the current mesh
  28748. */
  28749. removeChild(mesh: AbstractMesh): AbstractMesh;
  28750. /** @hidden */
  28751. private _initFacetData;
  28752. /**
  28753. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28754. * This method can be called within the render loop.
  28755. * 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
  28756. * @returns the current mesh
  28757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28758. */
  28759. updateFacetData(): AbstractMesh;
  28760. /**
  28761. * Returns the facetLocalNormals array.
  28762. * The normals are expressed in the mesh local spac
  28763. * @returns an array of Vector3
  28764. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28765. */
  28766. getFacetLocalNormals(): Vector3[];
  28767. /**
  28768. * Returns the facetLocalPositions array.
  28769. * The facet positions are expressed in the mesh local space
  28770. * @returns an array of Vector3
  28771. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28772. */
  28773. getFacetLocalPositions(): Vector3[];
  28774. /**
  28775. * Returns the facetLocalPartioning array
  28776. * @returns an array of array of numbers
  28777. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28778. */
  28779. getFacetLocalPartitioning(): number[][];
  28780. /**
  28781. * Returns the i-th facet position in the world system.
  28782. * This method allocates a new Vector3 per call
  28783. * @param i defines the facet index
  28784. * @returns a new Vector3
  28785. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28786. */
  28787. getFacetPosition(i: number): Vector3;
  28788. /**
  28789. * Sets the reference Vector3 with the i-th facet position in the world system
  28790. * @param i defines the facet index
  28791. * @param ref defines the target vector
  28792. * @returns the current mesh
  28793. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28794. */
  28795. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28796. /**
  28797. * Returns the i-th facet normal in the world system.
  28798. * This method allocates a new Vector3 per call
  28799. * @param i defines the facet index
  28800. * @returns a new Vector3
  28801. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28802. */
  28803. getFacetNormal(i: number): Vector3;
  28804. /**
  28805. * Sets the reference Vector3 with the i-th facet normal in the world system
  28806. * @param i defines the facet index
  28807. * @param ref defines the target vector
  28808. * @returns the current mesh
  28809. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28810. */
  28811. getFacetNormalToRef(i: number, ref: Vector3): this;
  28812. /**
  28813. * 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)
  28814. * @param x defines x coordinate
  28815. * @param y defines y coordinate
  28816. * @param z defines z coordinate
  28817. * @returns the array of facet indexes
  28818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28819. */
  28820. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28821. /**
  28822. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28823. * @param projected sets as the (x,y,z) world projection on the facet
  28824. * @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
  28825. * @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
  28826. * @param x defines x coordinate
  28827. * @param y defines y coordinate
  28828. * @param z defines z coordinate
  28829. * @returns the face index if found (or null instead)
  28830. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28831. */
  28832. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28833. /**
  28834. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28835. * @param projected sets as the (x,y,z) local projection on the facet
  28836. * @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
  28837. * @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
  28838. * @param x defines x coordinate
  28839. * @param y defines y coordinate
  28840. * @param z defines z coordinate
  28841. * @returns the face index if found (or null instead)
  28842. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28843. */
  28844. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28845. /**
  28846. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28847. * @returns the parameters
  28848. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28849. */
  28850. getFacetDataParameters(): any;
  28851. /**
  28852. * Disables the feature FacetData and frees the related memory
  28853. * @returns the current mesh
  28854. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28855. */
  28856. disableFacetData(): AbstractMesh;
  28857. /**
  28858. * Updates the AbstractMesh indices array
  28859. * @param indices defines the data source
  28860. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28861. * @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)
  28862. * @returns the current mesh
  28863. */
  28864. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28865. /**
  28866. * Creates new normals data for the mesh
  28867. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28868. * @returns the current mesh
  28869. */
  28870. createNormals(updatable: boolean): AbstractMesh;
  28871. /**
  28872. * Align the mesh with a normal
  28873. * @param normal defines the normal to use
  28874. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28875. * @returns the current mesh
  28876. */
  28877. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28878. /** @hidden */
  28879. _checkOcclusionQuery(): boolean;
  28880. /**
  28881. * Disables the mesh edge rendering mode
  28882. * @returns the currentAbstractMesh
  28883. */
  28884. disableEdgesRendering(): AbstractMesh;
  28885. /**
  28886. * Enables the edge rendering mode on the mesh.
  28887. * This mode makes the mesh edges visible
  28888. * @param epsilon defines the maximal distance between two angles to detect a face
  28889. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28890. * @returns the currentAbstractMesh
  28891. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28892. */
  28893. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28894. }
  28895. }
  28896. declare module BABYLON {
  28897. /**
  28898. * Interface used to define ActionEvent
  28899. */
  28900. export interface IActionEvent {
  28901. /** The mesh or sprite that triggered the action */
  28902. source: any;
  28903. /** The X mouse cursor position at the time of the event */
  28904. pointerX: number;
  28905. /** The Y mouse cursor position at the time of the event */
  28906. pointerY: number;
  28907. /** The mesh that is currently pointed at (can be null) */
  28908. meshUnderPointer: Nullable<AbstractMesh>;
  28909. /** the original (browser) event that triggered the ActionEvent */
  28910. sourceEvent?: any;
  28911. /** additional data for the event */
  28912. additionalData?: any;
  28913. }
  28914. /**
  28915. * ActionEvent is the event being sent when an action is triggered.
  28916. */
  28917. export class ActionEvent implements IActionEvent {
  28918. /** The mesh or sprite that triggered the action */
  28919. source: any;
  28920. /** The X mouse cursor position at the time of the event */
  28921. pointerX: number;
  28922. /** The Y mouse cursor position at the time of the event */
  28923. pointerY: number;
  28924. /** The mesh that is currently pointed at (can be null) */
  28925. meshUnderPointer: Nullable<AbstractMesh>;
  28926. /** the original (browser) event that triggered the ActionEvent */
  28927. sourceEvent?: any;
  28928. /** additional data for the event */
  28929. additionalData?: any;
  28930. /**
  28931. * Creates a new ActionEvent
  28932. * @param source The mesh or sprite that triggered the action
  28933. * @param pointerX The X mouse cursor position at the time of the event
  28934. * @param pointerY The Y mouse cursor position at the time of the event
  28935. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28936. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28937. * @param additionalData additional data for the event
  28938. */
  28939. constructor(
  28940. /** The mesh or sprite that triggered the action */
  28941. source: any,
  28942. /** The X mouse cursor position at the time of the event */
  28943. pointerX: number,
  28944. /** The Y mouse cursor position at the time of the event */
  28945. pointerY: number,
  28946. /** The mesh that is currently pointed at (can be null) */
  28947. meshUnderPointer: Nullable<AbstractMesh>,
  28948. /** the original (browser) event that triggered the ActionEvent */
  28949. sourceEvent?: any,
  28950. /** additional data for the event */
  28951. additionalData?: any);
  28952. /**
  28953. * Helper function to auto-create an ActionEvent from a source mesh.
  28954. * @param source The source mesh that triggered the event
  28955. * @param evt The original (browser) event
  28956. * @param additionalData additional data for the event
  28957. * @returns the new ActionEvent
  28958. */
  28959. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28960. /**
  28961. * Helper function to auto-create an ActionEvent from a source sprite
  28962. * @param source The source sprite that triggered the event
  28963. * @param scene Scene associated with the sprite
  28964. * @param evt The original (browser) event
  28965. * @param additionalData additional data for the event
  28966. * @returns the new ActionEvent
  28967. */
  28968. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28969. /**
  28970. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28971. * @param scene the scene where the event occurred
  28972. * @param evt The original (browser) event
  28973. * @returns the new ActionEvent
  28974. */
  28975. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28976. /**
  28977. * Helper function to auto-create an ActionEvent from a primitive
  28978. * @param prim defines the target primitive
  28979. * @param pointerPos defines the pointer position
  28980. * @param evt The original (browser) event
  28981. * @param additionalData additional data for the event
  28982. * @returns the new ActionEvent
  28983. */
  28984. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28985. }
  28986. }
  28987. declare module BABYLON {
  28988. /**
  28989. * Abstract class used to decouple action Manager from scene and meshes.
  28990. * Do not instantiate.
  28991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28992. */
  28993. export abstract class AbstractActionManager implements IDisposable {
  28994. /** Gets the list of active triggers */
  28995. static Triggers: {
  28996. [key: string]: number;
  28997. };
  28998. /** Gets the cursor to use when hovering items */
  28999. hoverCursor: string;
  29000. /** Gets the list of actions */
  29001. actions: IAction[];
  29002. /**
  29003. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29004. */
  29005. isRecursive: boolean;
  29006. /**
  29007. * Releases all associated resources
  29008. */
  29009. abstract dispose(): void;
  29010. /**
  29011. * Does this action manager has pointer triggers
  29012. */
  29013. abstract get hasPointerTriggers(): boolean;
  29014. /**
  29015. * Does this action manager has pick triggers
  29016. */
  29017. abstract get hasPickTriggers(): boolean;
  29018. /**
  29019. * Process a specific trigger
  29020. * @param trigger defines the trigger to process
  29021. * @param evt defines the event details to be processed
  29022. */
  29023. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29024. /**
  29025. * Does this action manager handles actions of any of the given triggers
  29026. * @param triggers defines the triggers to be tested
  29027. * @return a boolean indicating whether one (or more) of the triggers is handled
  29028. */
  29029. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29030. /**
  29031. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29032. * speed.
  29033. * @param triggerA defines the trigger to be tested
  29034. * @param triggerB defines the trigger to be tested
  29035. * @return a boolean indicating whether one (or more) of the triggers is handled
  29036. */
  29037. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29038. /**
  29039. * Does this action manager handles actions of a given trigger
  29040. * @param trigger defines the trigger to be tested
  29041. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29042. * @return whether the trigger is handled
  29043. */
  29044. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29045. /**
  29046. * Serialize this manager to a JSON object
  29047. * @param name defines the property name to store this manager
  29048. * @returns a JSON representation of this manager
  29049. */
  29050. abstract serialize(name: string): any;
  29051. /**
  29052. * Registers an action to this action manager
  29053. * @param action defines the action to be registered
  29054. * @return the action amended (prepared) after registration
  29055. */
  29056. abstract registerAction(action: IAction): Nullable<IAction>;
  29057. /**
  29058. * Unregisters an action to this action manager
  29059. * @param action defines the action to be unregistered
  29060. * @return a boolean indicating whether the action has been unregistered
  29061. */
  29062. abstract unregisterAction(action: IAction): Boolean;
  29063. /**
  29064. * Does exist one action manager with at least one trigger
  29065. **/
  29066. static get HasTriggers(): boolean;
  29067. /**
  29068. * Does exist one action manager with at least one pick trigger
  29069. **/
  29070. static get HasPickTriggers(): boolean;
  29071. /**
  29072. * Does exist one action manager that handles actions of a given trigger
  29073. * @param trigger defines the trigger to be tested
  29074. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29075. **/
  29076. static HasSpecificTrigger(trigger: number): boolean;
  29077. }
  29078. }
  29079. declare module BABYLON {
  29080. /**
  29081. * Defines how a node can be built from a string name.
  29082. */
  29083. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29084. /**
  29085. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29086. */
  29087. export class Node implements IBehaviorAware<Node> {
  29088. /** @hidden */
  29089. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29090. private static _NodeConstructors;
  29091. /**
  29092. * Add a new node constructor
  29093. * @param type defines the type name of the node to construct
  29094. * @param constructorFunc defines the constructor function
  29095. */
  29096. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29097. /**
  29098. * Returns a node constructor based on type name
  29099. * @param type defines the type name
  29100. * @param name defines the new node name
  29101. * @param scene defines the hosting scene
  29102. * @param options defines optional options to transmit to constructors
  29103. * @returns the new constructor or null
  29104. */
  29105. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29106. /**
  29107. * Gets or sets the name of the node
  29108. */
  29109. name: string;
  29110. /**
  29111. * Gets or sets the id of the node
  29112. */
  29113. id: string;
  29114. /**
  29115. * Gets or sets the unique id of the node
  29116. */
  29117. uniqueId: number;
  29118. /**
  29119. * Gets or sets a string used to store user defined state for the node
  29120. */
  29121. state: string;
  29122. /**
  29123. * Gets or sets an object used to store user defined information for the node
  29124. */
  29125. metadata: any;
  29126. /**
  29127. * For internal use only. Please do not use.
  29128. */
  29129. reservedDataStore: any;
  29130. /**
  29131. * List of inspectable custom properties (used by the Inspector)
  29132. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29133. */
  29134. inspectableCustomProperties: IInspectable[];
  29135. private _doNotSerialize;
  29136. /**
  29137. * Gets or sets a boolean used to define if the node must be serialized
  29138. */
  29139. get doNotSerialize(): boolean;
  29140. set doNotSerialize(value: boolean);
  29141. /** @hidden */
  29142. _isDisposed: boolean;
  29143. /**
  29144. * Gets a list of Animations associated with the node
  29145. */
  29146. animations: Animation[];
  29147. protected _ranges: {
  29148. [name: string]: Nullable<AnimationRange>;
  29149. };
  29150. /**
  29151. * Callback raised when the node is ready to be used
  29152. */
  29153. onReady: Nullable<(node: Node) => void>;
  29154. private _isEnabled;
  29155. private _isParentEnabled;
  29156. private _isReady;
  29157. /** @hidden */
  29158. _currentRenderId: number;
  29159. private _parentUpdateId;
  29160. /** @hidden */
  29161. _childUpdateId: number;
  29162. /** @hidden */
  29163. _waitingParentId: Nullable<string>;
  29164. /** @hidden */
  29165. _scene: Scene;
  29166. /** @hidden */
  29167. _cache: any;
  29168. private _parentNode;
  29169. private _children;
  29170. /** @hidden */
  29171. _worldMatrix: Matrix;
  29172. /** @hidden */
  29173. _worldMatrixDeterminant: number;
  29174. /** @hidden */
  29175. _worldMatrixDeterminantIsDirty: boolean;
  29176. /** @hidden */
  29177. private _sceneRootNodesIndex;
  29178. /**
  29179. * Gets a boolean indicating if the node has been disposed
  29180. * @returns true if the node was disposed
  29181. */
  29182. isDisposed(): boolean;
  29183. /**
  29184. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29185. * @see https://doc.babylonjs.com/how_to/parenting
  29186. */
  29187. set parent(parent: Nullable<Node>);
  29188. get parent(): Nullable<Node>;
  29189. /** @hidden */
  29190. _addToSceneRootNodes(): void;
  29191. /** @hidden */
  29192. _removeFromSceneRootNodes(): void;
  29193. private _animationPropertiesOverride;
  29194. /**
  29195. * Gets or sets the animation properties override
  29196. */
  29197. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29198. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29199. /**
  29200. * Gets a string idenfifying the name of the class
  29201. * @returns "Node" string
  29202. */
  29203. getClassName(): string;
  29204. /** @hidden */
  29205. readonly _isNode: boolean;
  29206. /**
  29207. * An event triggered when the mesh is disposed
  29208. */
  29209. onDisposeObservable: Observable<Node>;
  29210. private _onDisposeObserver;
  29211. /**
  29212. * Sets a callback that will be raised when the node will be disposed
  29213. */
  29214. set onDispose(callback: () => void);
  29215. /**
  29216. * Creates a new Node
  29217. * @param name the name and id to be given to this node
  29218. * @param scene the scene this node will be added to
  29219. */
  29220. constructor(name: string, scene?: Nullable<Scene>);
  29221. /**
  29222. * Gets the scene of the node
  29223. * @returns a scene
  29224. */
  29225. getScene(): Scene;
  29226. /**
  29227. * Gets the engine of the node
  29228. * @returns a Engine
  29229. */
  29230. getEngine(): Engine;
  29231. private _behaviors;
  29232. /**
  29233. * Attach a behavior to the node
  29234. * @see http://doc.babylonjs.com/features/behaviour
  29235. * @param behavior defines the behavior to attach
  29236. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29237. * @returns the current Node
  29238. */
  29239. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29240. /**
  29241. * Remove an attached behavior
  29242. * @see http://doc.babylonjs.com/features/behaviour
  29243. * @param behavior defines the behavior to attach
  29244. * @returns the current Node
  29245. */
  29246. removeBehavior(behavior: Behavior<Node>): Node;
  29247. /**
  29248. * Gets the list of attached behaviors
  29249. * @see http://doc.babylonjs.com/features/behaviour
  29250. */
  29251. get behaviors(): Behavior<Node>[];
  29252. /**
  29253. * Gets an attached behavior by name
  29254. * @param name defines the name of the behavior to look for
  29255. * @see http://doc.babylonjs.com/features/behaviour
  29256. * @returns null if behavior was not found else the requested behavior
  29257. */
  29258. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29259. /**
  29260. * Returns the latest update of the World matrix
  29261. * @returns a Matrix
  29262. */
  29263. getWorldMatrix(): Matrix;
  29264. /** @hidden */
  29265. _getWorldMatrixDeterminant(): number;
  29266. /**
  29267. * Returns directly the latest state of the mesh World matrix.
  29268. * A Matrix is returned.
  29269. */
  29270. get worldMatrixFromCache(): Matrix;
  29271. /** @hidden */
  29272. _initCache(): void;
  29273. /** @hidden */
  29274. updateCache(force?: boolean): void;
  29275. /** @hidden */
  29276. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29277. /** @hidden */
  29278. _updateCache(ignoreParentClass?: boolean): void;
  29279. /** @hidden */
  29280. _isSynchronized(): boolean;
  29281. /** @hidden */
  29282. _markSyncedWithParent(): void;
  29283. /** @hidden */
  29284. isSynchronizedWithParent(): boolean;
  29285. /** @hidden */
  29286. isSynchronized(): boolean;
  29287. /**
  29288. * Is this node ready to be used/rendered
  29289. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29290. * @return true if the node is ready
  29291. */
  29292. isReady(completeCheck?: boolean): boolean;
  29293. /**
  29294. * Is this node enabled?
  29295. * 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
  29296. * @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
  29297. * @return whether this node (and its parent) is enabled
  29298. */
  29299. isEnabled(checkAncestors?: boolean): boolean;
  29300. /** @hidden */
  29301. protected _syncParentEnabledState(): void;
  29302. /**
  29303. * Set the enabled state of this node
  29304. * @param value defines the new enabled state
  29305. */
  29306. setEnabled(value: boolean): void;
  29307. /**
  29308. * Is this node a descendant of the given node?
  29309. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29310. * @param ancestor defines the parent node to inspect
  29311. * @returns a boolean indicating if this node is a descendant of the given node
  29312. */
  29313. isDescendantOf(ancestor: Node): boolean;
  29314. /** @hidden */
  29315. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29316. /**
  29317. * Will return all nodes that have this node as ascendant
  29318. * @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
  29319. * @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
  29320. * @return all children nodes of all types
  29321. */
  29322. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29323. /**
  29324. * Get all child-meshes of this node
  29325. * @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)
  29326. * @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
  29327. * @returns an array of AbstractMesh
  29328. */
  29329. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29330. /**
  29331. * Get all direct children of this node
  29332. * @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
  29333. * @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)
  29334. * @returns an array of Node
  29335. */
  29336. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29337. /** @hidden */
  29338. _setReady(state: boolean): void;
  29339. /**
  29340. * Get an animation by name
  29341. * @param name defines the name of the animation to look for
  29342. * @returns null if not found else the requested animation
  29343. */
  29344. getAnimationByName(name: string): Nullable<Animation>;
  29345. /**
  29346. * Creates an animation range for this node
  29347. * @param name defines the name of the range
  29348. * @param from defines the starting key
  29349. * @param to defines the end key
  29350. */
  29351. createAnimationRange(name: string, from: number, to: number): void;
  29352. /**
  29353. * Delete a specific animation range
  29354. * @param name defines the name of the range to delete
  29355. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29356. */
  29357. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29358. /**
  29359. * Get an animation range by name
  29360. * @param name defines the name of the animation range to look for
  29361. * @returns null if not found else the requested animation range
  29362. */
  29363. getAnimationRange(name: string): Nullable<AnimationRange>;
  29364. /**
  29365. * Gets the list of all animation ranges defined on this node
  29366. * @returns an array
  29367. */
  29368. getAnimationRanges(): Nullable<AnimationRange>[];
  29369. /**
  29370. * Will start the animation sequence
  29371. * @param name defines the range frames for animation sequence
  29372. * @param loop defines if the animation should loop (false by default)
  29373. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29374. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29375. * @returns the object created for this animation. If range does not exist, it will return null
  29376. */
  29377. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29378. /**
  29379. * Serialize animation ranges into a JSON compatible object
  29380. * @returns serialization object
  29381. */
  29382. serializeAnimationRanges(): any;
  29383. /**
  29384. * Computes the world matrix of the node
  29385. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29386. * @returns the world matrix
  29387. */
  29388. computeWorldMatrix(force?: boolean): Matrix;
  29389. /**
  29390. * Releases resources associated with this node.
  29391. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29392. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29393. */
  29394. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29395. /**
  29396. * Parse animation range data from a serialization object and store them into a given node
  29397. * @param node defines where to store the animation ranges
  29398. * @param parsedNode defines the serialization object to read data from
  29399. * @param scene defines the hosting scene
  29400. */
  29401. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29402. /**
  29403. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29404. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29405. * @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
  29406. * @returns the new bounding vectors
  29407. */
  29408. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29409. min: Vector3;
  29410. max: Vector3;
  29411. };
  29412. }
  29413. }
  29414. declare module BABYLON {
  29415. /**
  29416. * @hidden
  29417. */
  29418. export class _IAnimationState {
  29419. key: number;
  29420. repeatCount: number;
  29421. workValue?: any;
  29422. loopMode?: number;
  29423. offsetValue?: any;
  29424. highLimitValue?: any;
  29425. }
  29426. /**
  29427. * Class used to store any kind of animation
  29428. */
  29429. export class Animation {
  29430. /**Name of the animation */
  29431. name: string;
  29432. /**Property to animate */
  29433. targetProperty: string;
  29434. /**The frames per second of the animation */
  29435. framePerSecond: number;
  29436. /**The data type of the animation */
  29437. dataType: number;
  29438. /**The loop mode of the animation */
  29439. loopMode?: number | undefined;
  29440. /**Specifies if blending should be enabled */
  29441. enableBlending?: boolean | undefined;
  29442. /**
  29443. * Use matrix interpolation instead of using direct key value when animating matrices
  29444. */
  29445. static AllowMatricesInterpolation: boolean;
  29446. /**
  29447. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29448. */
  29449. static AllowMatrixDecomposeForInterpolation: boolean;
  29450. /**
  29451. * Stores the key frames of the animation
  29452. */
  29453. private _keys;
  29454. /**
  29455. * Stores the easing function of the animation
  29456. */
  29457. private _easingFunction;
  29458. /**
  29459. * @hidden Internal use only
  29460. */
  29461. _runtimeAnimations: RuntimeAnimation[];
  29462. /**
  29463. * The set of event that will be linked to this animation
  29464. */
  29465. private _events;
  29466. /**
  29467. * Stores an array of target property paths
  29468. */
  29469. targetPropertyPath: string[];
  29470. /**
  29471. * Stores the blending speed of the animation
  29472. */
  29473. blendingSpeed: number;
  29474. /**
  29475. * Stores the animation ranges for the animation
  29476. */
  29477. private _ranges;
  29478. /**
  29479. * @hidden Internal use
  29480. */
  29481. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29482. /**
  29483. * Sets up an animation
  29484. * @param property The property to animate
  29485. * @param animationType The animation type to apply
  29486. * @param framePerSecond The frames per second of the animation
  29487. * @param easingFunction The easing function used in the animation
  29488. * @returns The created animation
  29489. */
  29490. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29491. /**
  29492. * Create and start an animation on a node
  29493. * @param name defines the name of the global animation that will be run on all nodes
  29494. * @param node defines the root node where the animation will take place
  29495. * @param targetProperty defines property to animate
  29496. * @param framePerSecond defines the number of frame per second yo use
  29497. * @param totalFrame defines the number of frames in total
  29498. * @param from defines the initial value
  29499. * @param to defines the final value
  29500. * @param loopMode defines which loop mode you want to use (off by default)
  29501. * @param easingFunction defines the easing function to use (linear by default)
  29502. * @param onAnimationEnd defines the callback to call when animation end
  29503. * @returns the animatable created for this animation
  29504. */
  29505. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29506. /**
  29507. * Create and start an animation on a node and its descendants
  29508. * @param name defines the name of the global animation that will be run on all nodes
  29509. * @param node defines the root node where the animation will take place
  29510. * @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
  29511. * @param targetProperty defines property to animate
  29512. * @param framePerSecond defines the number of frame per second to use
  29513. * @param totalFrame defines the number of frames in total
  29514. * @param from defines the initial value
  29515. * @param to defines the final value
  29516. * @param loopMode defines which loop mode you want to use (off by default)
  29517. * @param easingFunction defines the easing function to use (linear by default)
  29518. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29519. * @returns the list of animatables created for all nodes
  29520. * @example https://www.babylonjs-playground.com/#MH0VLI
  29521. */
  29522. 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[]>;
  29523. /**
  29524. * Creates a new animation, merges it with the existing animations and starts it
  29525. * @param name Name of the animation
  29526. * @param node Node which contains the scene that begins the animations
  29527. * @param targetProperty Specifies which property to animate
  29528. * @param framePerSecond The frames per second of the animation
  29529. * @param totalFrame The total number of frames
  29530. * @param from The frame at the beginning of the animation
  29531. * @param to The frame at the end of the animation
  29532. * @param loopMode Specifies the loop mode of the animation
  29533. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29534. * @param onAnimationEnd Callback to run once the animation is complete
  29535. * @returns Nullable animation
  29536. */
  29537. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29538. /**
  29539. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29540. * @param sourceAnimation defines the Animation containing keyframes to convert
  29541. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29542. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29543. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29544. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29545. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29546. */
  29547. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29548. /**
  29549. * Transition property of an host to the target Value
  29550. * @param property The property to transition
  29551. * @param targetValue The target Value of the property
  29552. * @param host The object where the property to animate belongs
  29553. * @param scene Scene used to run the animation
  29554. * @param frameRate Framerate (in frame/s) to use
  29555. * @param transition The transition type we want to use
  29556. * @param duration The duration of the animation, in milliseconds
  29557. * @param onAnimationEnd Callback trigger at the end of the animation
  29558. * @returns Nullable animation
  29559. */
  29560. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29561. /**
  29562. * Return the array of runtime animations currently using this animation
  29563. */
  29564. get runtimeAnimations(): RuntimeAnimation[];
  29565. /**
  29566. * Specifies if any of the runtime animations are currently running
  29567. */
  29568. get hasRunningRuntimeAnimations(): boolean;
  29569. /**
  29570. * Initializes the animation
  29571. * @param name Name of the animation
  29572. * @param targetProperty Property to animate
  29573. * @param framePerSecond The frames per second of the animation
  29574. * @param dataType The data type of the animation
  29575. * @param loopMode The loop mode of the animation
  29576. * @param enableBlending Specifies if blending should be enabled
  29577. */
  29578. constructor(
  29579. /**Name of the animation */
  29580. name: string,
  29581. /**Property to animate */
  29582. targetProperty: string,
  29583. /**The frames per second of the animation */
  29584. framePerSecond: number,
  29585. /**The data type of the animation */
  29586. dataType: number,
  29587. /**The loop mode of the animation */
  29588. loopMode?: number | undefined,
  29589. /**Specifies if blending should be enabled */
  29590. enableBlending?: boolean | undefined);
  29591. /**
  29592. * Converts the animation to a string
  29593. * @param fullDetails support for multiple levels of logging within scene loading
  29594. * @returns String form of the animation
  29595. */
  29596. toString(fullDetails?: boolean): string;
  29597. /**
  29598. * Add an event to this animation
  29599. * @param event Event to add
  29600. */
  29601. addEvent(event: AnimationEvent): void;
  29602. /**
  29603. * Remove all events found at the given frame
  29604. * @param frame The frame to remove events from
  29605. */
  29606. removeEvents(frame: number): void;
  29607. /**
  29608. * Retrieves all the events from the animation
  29609. * @returns Events from the animation
  29610. */
  29611. getEvents(): AnimationEvent[];
  29612. /**
  29613. * Creates an animation range
  29614. * @param name Name of the animation range
  29615. * @param from Starting frame of the animation range
  29616. * @param to Ending frame of the animation
  29617. */
  29618. createRange(name: string, from: number, to: number): void;
  29619. /**
  29620. * Deletes an animation range by name
  29621. * @param name Name of the animation range to delete
  29622. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29623. */
  29624. deleteRange(name: string, deleteFrames?: boolean): void;
  29625. /**
  29626. * Gets the animation range by name, or null if not defined
  29627. * @param name Name of the animation range
  29628. * @returns Nullable animation range
  29629. */
  29630. getRange(name: string): Nullable<AnimationRange>;
  29631. /**
  29632. * Gets the key frames from the animation
  29633. * @returns The key frames of the animation
  29634. */
  29635. getKeys(): Array<IAnimationKey>;
  29636. /**
  29637. * Gets the highest frame rate of the animation
  29638. * @returns Highest frame rate of the animation
  29639. */
  29640. getHighestFrame(): number;
  29641. /**
  29642. * Gets the easing function of the animation
  29643. * @returns Easing function of the animation
  29644. */
  29645. getEasingFunction(): IEasingFunction;
  29646. /**
  29647. * Sets the easing function of the animation
  29648. * @param easingFunction A custom mathematical formula for animation
  29649. */
  29650. setEasingFunction(easingFunction: EasingFunction): void;
  29651. /**
  29652. * Interpolates a scalar linearly
  29653. * @param startValue Start value of the animation curve
  29654. * @param endValue End value of the animation curve
  29655. * @param gradient Scalar amount to interpolate
  29656. * @returns Interpolated scalar value
  29657. */
  29658. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29659. /**
  29660. * Interpolates a scalar cubically
  29661. * @param startValue Start value of the animation curve
  29662. * @param outTangent End tangent of the animation
  29663. * @param endValue End value of the animation curve
  29664. * @param inTangent Start tangent of the animation curve
  29665. * @param gradient Scalar amount to interpolate
  29666. * @returns Interpolated scalar value
  29667. */
  29668. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29669. /**
  29670. * Interpolates a quaternion using a spherical linear interpolation
  29671. * @param startValue Start value of the animation curve
  29672. * @param endValue End value of the animation curve
  29673. * @param gradient Scalar amount to interpolate
  29674. * @returns Interpolated quaternion value
  29675. */
  29676. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29677. /**
  29678. * Interpolates a quaternion cubically
  29679. * @param startValue Start value of the animation curve
  29680. * @param outTangent End tangent of the animation curve
  29681. * @param endValue End value of the animation curve
  29682. * @param inTangent Start tangent of the animation curve
  29683. * @param gradient Scalar amount to interpolate
  29684. * @returns Interpolated quaternion value
  29685. */
  29686. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29687. /**
  29688. * Interpolates a Vector3 linearl
  29689. * @param startValue Start value of the animation curve
  29690. * @param endValue End value of the animation curve
  29691. * @param gradient Scalar amount to interpolate
  29692. * @returns Interpolated scalar value
  29693. */
  29694. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29695. /**
  29696. * Interpolates a Vector3 cubically
  29697. * @param startValue Start value of the animation curve
  29698. * @param outTangent End tangent of the animation
  29699. * @param endValue End value of the animation curve
  29700. * @param inTangent Start tangent of the animation curve
  29701. * @param gradient Scalar amount to interpolate
  29702. * @returns InterpolatedVector3 value
  29703. */
  29704. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29705. /**
  29706. * Interpolates a Vector2 linearly
  29707. * @param startValue Start value of the animation curve
  29708. * @param endValue End value of the animation curve
  29709. * @param gradient Scalar amount to interpolate
  29710. * @returns Interpolated Vector2 value
  29711. */
  29712. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29713. /**
  29714. * Interpolates a Vector2 cubically
  29715. * @param startValue Start value of the animation curve
  29716. * @param outTangent End tangent of the animation
  29717. * @param endValue End value of the animation curve
  29718. * @param inTangent Start tangent of the animation curve
  29719. * @param gradient Scalar amount to interpolate
  29720. * @returns Interpolated Vector2 value
  29721. */
  29722. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29723. /**
  29724. * Interpolates a size linearly
  29725. * @param startValue Start value of the animation curve
  29726. * @param endValue End value of the animation curve
  29727. * @param gradient Scalar amount to interpolate
  29728. * @returns Interpolated Size value
  29729. */
  29730. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29731. /**
  29732. * Interpolates a Color3 linearly
  29733. * @param startValue Start value of the animation curve
  29734. * @param endValue End value of the animation curve
  29735. * @param gradient Scalar amount to interpolate
  29736. * @returns Interpolated Color3 value
  29737. */
  29738. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29739. /**
  29740. * Interpolates a Color4 linearly
  29741. * @param startValue Start value of the animation curve
  29742. * @param endValue End value of the animation curve
  29743. * @param gradient Scalar amount to interpolate
  29744. * @returns Interpolated Color3 value
  29745. */
  29746. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29747. /**
  29748. * @hidden Internal use only
  29749. */
  29750. _getKeyValue(value: any): any;
  29751. /**
  29752. * @hidden Internal use only
  29753. */
  29754. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29755. /**
  29756. * Defines the function to use to interpolate matrices
  29757. * @param startValue defines the start matrix
  29758. * @param endValue defines the end matrix
  29759. * @param gradient defines the gradient between both matrices
  29760. * @param result defines an optional target matrix where to store the interpolation
  29761. * @returns the interpolated matrix
  29762. */
  29763. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29764. /**
  29765. * Makes a copy of the animation
  29766. * @returns Cloned animation
  29767. */
  29768. clone(): Animation;
  29769. /**
  29770. * Sets the key frames of the animation
  29771. * @param values The animation key frames to set
  29772. */
  29773. setKeys(values: Array<IAnimationKey>): void;
  29774. /**
  29775. * Serializes the animation to an object
  29776. * @returns Serialized object
  29777. */
  29778. serialize(): any;
  29779. /**
  29780. * Float animation type
  29781. */
  29782. static readonly ANIMATIONTYPE_FLOAT: number;
  29783. /**
  29784. * Vector3 animation type
  29785. */
  29786. static readonly ANIMATIONTYPE_VECTOR3: number;
  29787. /**
  29788. * Quaternion animation type
  29789. */
  29790. static readonly ANIMATIONTYPE_QUATERNION: number;
  29791. /**
  29792. * Matrix animation type
  29793. */
  29794. static readonly ANIMATIONTYPE_MATRIX: number;
  29795. /**
  29796. * Color3 animation type
  29797. */
  29798. static readonly ANIMATIONTYPE_COLOR3: number;
  29799. /**
  29800. * Color3 animation type
  29801. */
  29802. static readonly ANIMATIONTYPE_COLOR4: number;
  29803. /**
  29804. * Vector2 animation type
  29805. */
  29806. static readonly ANIMATIONTYPE_VECTOR2: number;
  29807. /**
  29808. * Size animation type
  29809. */
  29810. static readonly ANIMATIONTYPE_SIZE: number;
  29811. /**
  29812. * Relative Loop Mode
  29813. */
  29814. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29815. /**
  29816. * Cycle Loop Mode
  29817. */
  29818. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29819. /**
  29820. * Constant Loop Mode
  29821. */
  29822. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29823. /** @hidden */
  29824. static _UniversalLerp(left: any, right: any, amount: number): any;
  29825. /**
  29826. * Parses an animation object and creates an animation
  29827. * @param parsedAnimation Parsed animation object
  29828. * @returns Animation object
  29829. */
  29830. static Parse(parsedAnimation: any): Animation;
  29831. /**
  29832. * Appends the serialized animations from the source animations
  29833. * @param source Source containing the animations
  29834. * @param destination Target to store the animations
  29835. */
  29836. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29837. }
  29838. }
  29839. declare module BABYLON {
  29840. /**
  29841. * Interface containing an array of animations
  29842. */
  29843. export interface IAnimatable {
  29844. /**
  29845. * Array of animations
  29846. */
  29847. animations: Nullable<Array<Animation>>;
  29848. }
  29849. }
  29850. declare module BABYLON {
  29851. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29852. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29853. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29854. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29855. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29856. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29857. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29858. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29859. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29860. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29861. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29862. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29863. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29864. /**
  29865. * Decorator used to define property that can be serialized as reference to a camera
  29866. * @param sourceName defines the name of the property to decorate
  29867. */
  29868. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29869. /**
  29870. * Class used to help serialization objects
  29871. */
  29872. export class SerializationHelper {
  29873. /** @hidden */
  29874. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29875. /** @hidden */
  29876. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29877. /** @hidden */
  29878. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29879. /** @hidden */
  29880. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29881. /**
  29882. * Appends the serialized animations from the source animations
  29883. * @param source Source containing the animations
  29884. * @param destination Target to store the animations
  29885. */
  29886. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29887. /**
  29888. * Static function used to serialized a specific entity
  29889. * @param entity defines the entity to serialize
  29890. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29891. * @returns a JSON compatible object representing the serialization of the entity
  29892. */
  29893. static Serialize<T>(entity: T, serializationObject?: any): any;
  29894. /**
  29895. * Creates a new entity from a serialization data object
  29896. * @param creationFunction defines a function used to instanciated the new entity
  29897. * @param source defines the source serialization data
  29898. * @param scene defines the hosting scene
  29899. * @param rootUrl defines the root url for resources
  29900. * @returns a new entity
  29901. */
  29902. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29903. /**
  29904. * Clones an object
  29905. * @param creationFunction defines the function used to instanciate the new object
  29906. * @param source defines the source object
  29907. * @returns the cloned object
  29908. */
  29909. static Clone<T>(creationFunction: () => T, source: T): T;
  29910. /**
  29911. * Instanciates a new object based on a source one (some data will be shared between both object)
  29912. * @param creationFunction defines the function used to instanciate the new object
  29913. * @param source defines the source object
  29914. * @returns the new object
  29915. */
  29916. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29917. }
  29918. }
  29919. declare module BABYLON {
  29920. /**
  29921. * Class used to manipulate GUIDs
  29922. */
  29923. export class GUID {
  29924. /**
  29925. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29926. * Be aware Math.random() could cause collisions, but:
  29927. * "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"
  29928. * @returns a pseudo random id
  29929. */
  29930. static RandomId(): string;
  29931. }
  29932. }
  29933. declare module BABYLON {
  29934. /**
  29935. * Base class of all the textures in babylon.
  29936. * It groups all the common properties the materials, post process, lights... might need
  29937. * in order to make a correct use of the texture.
  29938. */
  29939. export class BaseTexture implements IAnimatable {
  29940. /**
  29941. * Default anisotropic filtering level for the application.
  29942. * It is set to 4 as a good tradeoff between perf and quality.
  29943. */
  29944. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29945. /**
  29946. * Gets or sets the unique id of the texture
  29947. */
  29948. uniqueId: number;
  29949. /**
  29950. * Define the name of the texture.
  29951. */
  29952. name: string;
  29953. /**
  29954. * Gets or sets an object used to store user defined information.
  29955. */
  29956. metadata: any;
  29957. /**
  29958. * For internal use only. Please do not use.
  29959. */
  29960. reservedDataStore: any;
  29961. private _hasAlpha;
  29962. /**
  29963. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29964. */
  29965. set hasAlpha(value: boolean);
  29966. get hasAlpha(): boolean;
  29967. /**
  29968. * Defines if the alpha value should be determined via the rgb values.
  29969. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29970. */
  29971. getAlphaFromRGB: boolean;
  29972. /**
  29973. * Intensity or strength of the texture.
  29974. * It is commonly used by materials to fine tune the intensity of the texture
  29975. */
  29976. level: number;
  29977. /**
  29978. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29979. * This is part of the texture as textures usually maps to one uv set.
  29980. */
  29981. coordinatesIndex: number;
  29982. private _coordinatesMode;
  29983. /**
  29984. * How a texture is mapped.
  29985. *
  29986. * | Value | Type | Description |
  29987. * | ----- | ----------------------------------- | ----------- |
  29988. * | 0 | EXPLICIT_MODE | |
  29989. * | 1 | SPHERICAL_MODE | |
  29990. * | 2 | PLANAR_MODE | |
  29991. * | 3 | CUBIC_MODE | |
  29992. * | 4 | PROJECTION_MODE | |
  29993. * | 5 | SKYBOX_MODE | |
  29994. * | 6 | INVCUBIC_MODE | |
  29995. * | 7 | EQUIRECTANGULAR_MODE | |
  29996. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29997. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29998. */
  29999. set coordinatesMode(value: number);
  30000. get coordinatesMode(): number;
  30001. /**
  30002. * | Value | Type | Description |
  30003. * | ----- | ------------------ | ----------- |
  30004. * | 0 | CLAMP_ADDRESSMODE | |
  30005. * | 1 | WRAP_ADDRESSMODE | |
  30006. * | 2 | MIRROR_ADDRESSMODE | |
  30007. */
  30008. wrapU: number;
  30009. /**
  30010. * | Value | Type | Description |
  30011. * | ----- | ------------------ | ----------- |
  30012. * | 0 | CLAMP_ADDRESSMODE | |
  30013. * | 1 | WRAP_ADDRESSMODE | |
  30014. * | 2 | MIRROR_ADDRESSMODE | |
  30015. */
  30016. wrapV: number;
  30017. /**
  30018. * | Value | Type | Description |
  30019. * | ----- | ------------------ | ----------- |
  30020. * | 0 | CLAMP_ADDRESSMODE | |
  30021. * | 1 | WRAP_ADDRESSMODE | |
  30022. * | 2 | MIRROR_ADDRESSMODE | |
  30023. */
  30024. wrapR: number;
  30025. /**
  30026. * With compliant hardware and browser (supporting anisotropic filtering)
  30027. * this defines the level of anisotropic filtering in the texture.
  30028. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30029. */
  30030. anisotropicFilteringLevel: number;
  30031. /**
  30032. * Define if the texture is a cube texture or if false a 2d texture.
  30033. */
  30034. get isCube(): boolean;
  30035. set isCube(value: boolean);
  30036. /**
  30037. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30038. */
  30039. get is3D(): boolean;
  30040. set is3D(value: boolean);
  30041. /**
  30042. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30043. */
  30044. get is2DArray(): boolean;
  30045. set is2DArray(value: boolean);
  30046. /**
  30047. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30048. * HDR texture are usually stored in linear space.
  30049. * This only impacts the PBR and Background materials
  30050. */
  30051. gammaSpace: boolean;
  30052. /**
  30053. * Gets or sets whether or not the texture contains RGBD data.
  30054. */
  30055. get isRGBD(): boolean;
  30056. set isRGBD(value: boolean);
  30057. /**
  30058. * Is Z inverted in the texture (useful in a cube texture).
  30059. */
  30060. invertZ: boolean;
  30061. /**
  30062. * Are mip maps generated for this texture or not.
  30063. */
  30064. get noMipmap(): boolean;
  30065. /**
  30066. * @hidden
  30067. */
  30068. lodLevelInAlpha: boolean;
  30069. /**
  30070. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30071. */
  30072. get lodGenerationOffset(): number;
  30073. set lodGenerationOffset(value: number);
  30074. /**
  30075. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30076. */
  30077. get lodGenerationScale(): number;
  30078. set lodGenerationScale(value: number);
  30079. /**
  30080. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30081. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30082. * average roughness values.
  30083. */
  30084. get linearSpecularLOD(): boolean;
  30085. set linearSpecularLOD(value: boolean);
  30086. /**
  30087. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30088. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30089. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30090. */
  30091. get irradianceTexture(): Nullable<BaseTexture>;
  30092. set irradianceTexture(value: Nullable<BaseTexture>);
  30093. /**
  30094. * Define if the texture is a render target.
  30095. */
  30096. isRenderTarget: boolean;
  30097. /**
  30098. * Define the unique id of the texture in the scene.
  30099. */
  30100. get uid(): string;
  30101. /**
  30102. * Return a string representation of the texture.
  30103. * @returns the texture as a string
  30104. */
  30105. toString(): string;
  30106. /**
  30107. * Get the class name of the texture.
  30108. * @returns "BaseTexture"
  30109. */
  30110. getClassName(): string;
  30111. /**
  30112. * Define the list of animation attached to the texture.
  30113. */
  30114. animations: Animation[];
  30115. /**
  30116. * An event triggered when the texture is disposed.
  30117. */
  30118. onDisposeObservable: Observable<BaseTexture>;
  30119. private _onDisposeObserver;
  30120. /**
  30121. * Callback triggered when the texture has been disposed.
  30122. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30123. */
  30124. set onDispose(callback: () => void);
  30125. /**
  30126. * Define the current state of the loading sequence when in delayed load mode.
  30127. */
  30128. delayLoadState: number;
  30129. private _scene;
  30130. /** @hidden */
  30131. _texture: Nullable<InternalTexture>;
  30132. private _uid;
  30133. /**
  30134. * Define if the texture is preventinga material to render or not.
  30135. * If not and the texture is not ready, the engine will use a default black texture instead.
  30136. */
  30137. get isBlocking(): boolean;
  30138. /**
  30139. * Instantiates a new BaseTexture.
  30140. * Base class of all the textures in babylon.
  30141. * It groups all the common properties the materials, post process, lights... might need
  30142. * in order to make a correct use of the texture.
  30143. * @param scene Define the scene the texture blongs to
  30144. */
  30145. constructor(scene: Nullable<Scene>);
  30146. /**
  30147. * Get the scene the texture belongs to.
  30148. * @returns the scene or null if undefined
  30149. */
  30150. getScene(): Nullable<Scene>;
  30151. /**
  30152. * Get the texture transform matrix used to offset tile the texture for istance.
  30153. * @returns the transformation matrix
  30154. */
  30155. getTextureMatrix(): Matrix;
  30156. /**
  30157. * Get the texture reflection matrix used to rotate/transform the reflection.
  30158. * @returns the reflection matrix
  30159. */
  30160. getReflectionTextureMatrix(): Matrix;
  30161. /**
  30162. * Get the underlying lower level texture from Babylon.
  30163. * @returns the insternal texture
  30164. */
  30165. getInternalTexture(): Nullable<InternalTexture>;
  30166. /**
  30167. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30168. * @returns true if ready or not blocking
  30169. */
  30170. isReadyOrNotBlocking(): boolean;
  30171. /**
  30172. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30173. * @returns true if fully ready
  30174. */
  30175. isReady(): boolean;
  30176. private _cachedSize;
  30177. /**
  30178. * Get the size of the texture.
  30179. * @returns the texture size.
  30180. */
  30181. getSize(): ISize;
  30182. /**
  30183. * Get the base size of the texture.
  30184. * It can be different from the size if the texture has been resized for POT for instance
  30185. * @returns the base size
  30186. */
  30187. getBaseSize(): ISize;
  30188. /**
  30189. * Update the sampling mode of the texture.
  30190. * Default is Trilinear mode.
  30191. *
  30192. * | Value | Type | Description |
  30193. * | ----- | ------------------ | ----------- |
  30194. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30195. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30196. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30197. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30198. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30199. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30200. * | 7 | NEAREST_LINEAR | |
  30201. * | 8 | NEAREST_NEAREST | |
  30202. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30203. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30204. * | 11 | LINEAR_LINEAR | |
  30205. * | 12 | LINEAR_NEAREST | |
  30206. *
  30207. * > _mag_: magnification filter (close to the viewer)
  30208. * > _min_: minification filter (far from the viewer)
  30209. * > _mip_: filter used between mip map levels
  30210. *@param samplingMode Define the new sampling mode of the texture
  30211. */
  30212. updateSamplingMode(samplingMode: number): void;
  30213. /**
  30214. * Scales the texture if is `canRescale()`
  30215. * @param ratio the resize factor we want to use to rescale
  30216. */
  30217. scale(ratio: number): void;
  30218. /**
  30219. * Get if the texture can rescale.
  30220. */
  30221. get canRescale(): boolean;
  30222. /** @hidden */
  30223. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30224. /** @hidden */
  30225. _rebuild(): void;
  30226. /**
  30227. * Triggers the load sequence in delayed load mode.
  30228. */
  30229. delayLoad(): void;
  30230. /**
  30231. * Clones the texture.
  30232. * @returns the cloned texture
  30233. */
  30234. clone(): Nullable<BaseTexture>;
  30235. /**
  30236. * Get the texture underlying type (INT, FLOAT...)
  30237. */
  30238. get textureType(): number;
  30239. /**
  30240. * Get the texture underlying format (RGB, RGBA...)
  30241. */
  30242. get textureFormat(): number;
  30243. /**
  30244. * Indicates that textures need to be re-calculated for all materials
  30245. */
  30246. protected _markAllSubMeshesAsTexturesDirty(): void;
  30247. /**
  30248. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30249. * This will returns an RGBA array buffer containing either in values (0-255) or
  30250. * float values (0-1) depending of the underlying buffer type.
  30251. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30252. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30253. * @param buffer defines a user defined buffer to fill with data (can be null)
  30254. * @returns The Array buffer containing the pixels data.
  30255. */
  30256. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30257. /**
  30258. * Release and destroy the underlying lower level texture aka internalTexture.
  30259. */
  30260. releaseInternalTexture(): void;
  30261. /** @hidden */
  30262. get _lodTextureHigh(): Nullable<BaseTexture>;
  30263. /** @hidden */
  30264. get _lodTextureMid(): Nullable<BaseTexture>;
  30265. /** @hidden */
  30266. get _lodTextureLow(): Nullable<BaseTexture>;
  30267. /**
  30268. * Dispose the texture and release its associated resources.
  30269. */
  30270. dispose(): void;
  30271. /**
  30272. * Serialize the texture into a JSON representation that can be parsed later on.
  30273. * @returns the JSON representation of the texture
  30274. */
  30275. serialize(): any;
  30276. /**
  30277. * Helper function to be called back once a list of texture contains only ready textures.
  30278. * @param textures Define the list of textures to wait for
  30279. * @param callback Define the callback triggered once the entire list will be ready
  30280. */
  30281. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30282. }
  30283. }
  30284. declare module BABYLON {
  30285. /**
  30286. * Options to be used when creating an effect.
  30287. */
  30288. export interface IEffectCreationOptions {
  30289. /**
  30290. * Atrributes that will be used in the shader.
  30291. */
  30292. attributes: string[];
  30293. /**
  30294. * Uniform varible names that will be set in the shader.
  30295. */
  30296. uniformsNames: string[];
  30297. /**
  30298. * Uniform buffer variable names that will be set in the shader.
  30299. */
  30300. uniformBuffersNames: string[];
  30301. /**
  30302. * Sampler texture variable names that will be set in the shader.
  30303. */
  30304. samplers: string[];
  30305. /**
  30306. * Define statements that will be set in the shader.
  30307. */
  30308. defines: any;
  30309. /**
  30310. * Possible fallbacks for this effect to improve performance when needed.
  30311. */
  30312. fallbacks: Nullable<IEffectFallbacks>;
  30313. /**
  30314. * Callback that will be called when the shader is compiled.
  30315. */
  30316. onCompiled: Nullable<(effect: Effect) => void>;
  30317. /**
  30318. * Callback that will be called if an error occurs during shader compilation.
  30319. */
  30320. onError: Nullable<(effect: Effect, errors: string) => void>;
  30321. /**
  30322. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30323. */
  30324. indexParameters?: any;
  30325. /**
  30326. * Max number of lights that can be used in the shader.
  30327. */
  30328. maxSimultaneousLights?: number;
  30329. /**
  30330. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30331. */
  30332. transformFeedbackVaryings?: Nullable<string[]>;
  30333. }
  30334. /**
  30335. * Effect containing vertex and fragment shader that can be executed on an object.
  30336. */
  30337. export class Effect implements IDisposable {
  30338. /**
  30339. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30340. */
  30341. static ShadersRepository: string;
  30342. /**
  30343. * Enable logging of the shader code when a compilation error occurs
  30344. */
  30345. static LogShaderCodeOnCompilationError: boolean;
  30346. /**
  30347. * Name of the effect.
  30348. */
  30349. name: any;
  30350. /**
  30351. * String container all the define statements that should be set on the shader.
  30352. */
  30353. defines: string;
  30354. /**
  30355. * Callback that will be called when the shader is compiled.
  30356. */
  30357. onCompiled: Nullable<(effect: Effect) => void>;
  30358. /**
  30359. * Callback that will be called if an error occurs during shader compilation.
  30360. */
  30361. onError: Nullable<(effect: Effect, errors: string) => void>;
  30362. /**
  30363. * Callback that will be called when effect is bound.
  30364. */
  30365. onBind: Nullable<(effect: Effect) => void>;
  30366. /**
  30367. * Unique ID of the effect.
  30368. */
  30369. uniqueId: number;
  30370. /**
  30371. * Observable that will be called when the shader is compiled.
  30372. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30373. */
  30374. onCompileObservable: Observable<Effect>;
  30375. /**
  30376. * Observable that will be called if an error occurs during shader compilation.
  30377. */
  30378. onErrorObservable: Observable<Effect>;
  30379. /** @hidden */
  30380. _onBindObservable: Nullable<Observable<Effect>>;
  30381. /**
  30382. * @hidden
  30383. * Specifies if the effect was previously ready
  30384. */
  30385. _wasPreviouslyReady: boolean;
  30386. /**
  30387. * Observable that will be called when effect is bound.
  30388. */
  30389. get onBindObservable(): Observable<Effect>;
  30390. /** @hidden */
  30391. _bonesComputationForcedToCPU: boolean;
  30392. private static _uniqueIdSeed;
  30393. private _engine;
  30394. private _uniformBuffersNames;
  30395. private _uniformsNames;
  30396. private _samplerList;
  30397. private _samplers;
  30398. private _isReady;
  30399. private _compilationError;
  30400. private _allFallbacksProcessed;
  30401. private _attributesNames;
  30402. private _attributes;
  30403. private _attributeLocationByName;
  30404. private _uniforms;
  30405. /**
  30406. * Key for the effect.
  30407. * @hidden
  30408. */
  30409. _key: string;
  30410. private _indexParameters;
  30411. private _fallbacks;
  30412. private _vertexSourceCode;
  30413. private _fragmentSourceCode;
  30414. private _vertexSourceCodeOverride;
  30415. private _fragmentSourceCodeOverride;
  30416. private _transformFeedbackVaryings;
  30417. /**
  30418. * Compiled shader to webGL program.
  30419. * @hidden
  30420. */
  30421. _pipelineContext: Nullable<IPipelineContext>;
  30422. private _valueCache;
  30423. private static _baseCache;
  30424. /**
  30425. * Instantiates an effect.
  30426. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30427. * @param baseName Name of the effect.
  30428. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30429. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30430. * @param samplers List of sampler variables that will be passed to the shader.
  30431. * @param engine Engine to be used to render the effect
  30432. * @param defines Define statements to be added to the shader.
  30433. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30434. * @param onCompiled Callback that will be called when the shader is compiled.
  30435. * @param onError Callback that will be called if an error occurs during shader compilation.
  30436. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30437. */
  30438. 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);
  30439. private _useFinalCode;
  30440. /**
  30441. * Unique key for this effect
  30442. */
  30443. get key(): string;
  30444. /**
  30445. * If the effect has been compiled and prepared.
  30446. * @returns if the effect is compiled and prepared.
  30447. */
  30448. isReady(): boolean;
  30449. private _isReadyInternal;
  30450. /**
  30451. * The engine the effect was initialized with.
  30452. * @returns the engine.
  30453. */
  30454. getEngine(): Engine;
  30455. /**
  30456. * The pipeline context for this effect
  30457. * @returns the associated pipeline context
  30458. */
  30459. getPipelineContext(): Nullable<IPipelineContext>;
  30460. /**
  30461. * The set of names of attribute variables for the shader.
  30462. * @returns An array of attribute names.
  30463. */
  30464. getAttributesNames(): string[];
  30465. /**
  30466. * Returns the attribute at the given index.
  30467. * @param index The index of the attribute.
  30468. * @returns The location of the attribute.
  30469. */
  30470. getAttributeLocation(index: number): number;
  30471. /**
  30472. * Returns the attribute based on the name of the variable.
  30473. * @param name of the attribute to look up.
  30474. * @returns the attribute location.
  30475. */
  30476. getAttributeLocationByName(name: string): number;
  30477. /**
  30478. * The number of attributes.
  30479. * @returns the numnber of attributes.
  30480. */
  30481. getAttributesCount(): number;
  30482. /**
  30483. * Gets the index of a uniform variable.
  30484. * @param uniformName of the uniform to look up.
  30485. * @returns the index.
  30486. */
  30487. getUniformIndex(uniformName: string): number;
  30488. /**
  30489. * Returns the attribute based on the name of the variable.
  30490. * @param uniformName of the uniform to look up.
  30491. * @returns the location of the uniform.
  30492. */
  30493. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30494. /**
  30495. * Returns an array of sampler variable names
  30496. * @returns The array of sampler variable neames.
  30497. */
  30498. getSamplers(): string[];
  30499. /**
  30500. * The error from the last compilation.
  30501. * @returns the error string.
  30502. */
  30503. getCompilationError(): string;
  30504. /**
  30505. * Gets a boolean indicating that all fallbacks were used during compilation
  30506. * @returns true if all fallbacks were used
  30507. */
  30508. allFallbacksProcessed(): boolean;
  30509. /**
  30510. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30511. * @param func The callback to be used.
  30512. */
  30513. executeWhenCompiled(func: (effect: Effect) => void): void;
  30514. private _checkIsReady;
  30515. private _loadShader;
  30516. /**
  30517. * Recompiles the webGL program
  30518. * @param vertexSourceCode The source code for the vertex shader.
  30519. * @param fragmentSourceCode The source code for the fragment shader.
  30520. * @param onCompiled Callback called when completed.
  30521. * @param onError Callback called on error.
  30522. * @hidden
  30523. */
  30524. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30525. /**
  30526. * Prepares the effect
  30527. * @hidden
  30528. */
  30529. _prepareEffect(): void;
  30530. private _getShaderCodeAndErrorLine;
  30531. private _processCompilationErrors;
  30532. /**
  30533. * Checks if the effect is supported. (Must be called after compilation)
  30534. */
  30535. get isSupported(): boolean;
  30536. /**
  30537. * Binds a texture to the engine to be used as output of the shader.
  30538. * @param channel Name of the output variable.
  30539. * @param texture Texture to bind.
  30540. * @hidden
  30541. */
  30542. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30543. /**
  30544. * Sets a texture on the engine to be used in the shader.
  30545. * @param channel Name of the sampler variable.
  30546. * @param texture Texture to set.
  30547. */
  30548. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30549. /**
  30550. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30551. * @param channel Name of the sampler variable.
  30552. * @param texture Texture to set.
  30553. */
  30554. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30555. /**
  30556. * Sets an array of textures on the engine to be used in the shader.
  30557. * @param channel Name of the variable.
  30558. * @param textures Textures to set.
  30559. */
  30560. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30561. /**
  30562. * 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)
  30563. * @param channel Name of the sampler variable.
  30564. * @param postProcess Post process to get the input texture from.
  30565. */
  30566. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30567. /**
  30568. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30569. * 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)
  30570. * @param channel Name of the sampler variable.
  30571. * @param postProcess Post process to get the output texture from.
  30572. */
  30573. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30574. /** @hidden */
  30575. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30576. /** @hidden */
  30577. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30578. /** @hidden */
  30579. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30580. /** @hidden */
  30581. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30582. /**
  30583. * Binds a buffer to a uniform.
  30584. * @param buffer Buffer to bind.
  30585. * @param name Name of the uniform variable to bind to.
  30586. */
  30587. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30588. /**
  30589. * Binds block to a uniform.
  30590. * @param blockName Name of the block to bind.
  30591. * @param index Index to bind.
  30592. */
  30593. bindUniformBlock(blockName: string, index: number): void;
  30594. /**
  30595. * Sets an interger value on a uniform variable.
  30596. * @param uniformName Name of the variable.
  30597. * @param value Value to be set.
  30598. * @returns this effect.
  30599. */
  30600. setInt(uniformName: string, value: number): Effect;
  30601. /**
  30602. * Sets an int array on a uniform variable.
  30603. * @param uniformName Name of the variable.
  30604. * @param array array to be set.
  30605. * @returns this effect.
  30606. */
  30607. setIntArray(uniformName: string, array: Int32Array): Effect;
  30608. /**
  30609. * 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)
  30610. * @param uniformName Name of the variable.
  30611. * @param array array to be set.
  30612. * @returns this effect.
  30613. */
  30614. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30615. /**
  30616. * 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)
  30617. * @param uniformName Name of the variable.
  30618. * @param array array to be set.
  30619. * @returns this effect.
  30620. */
  30621. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30622. /**
  30623. * 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)
  30624. * @param uniformName Name of the variable.
  30625. * @param array array to be set.
  30626. * @returns this effect.
  30627. */
  30628. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30629. /**
  30630. * Sets an float array on a uniform variable.
  30631. * @param uniformName Name of the variable.
  30632. * @param array array to be set.
  30633. * @returns this effect.
  30634. */
  30635. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30636. /**
  30637. * 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)
  30638. * @param uniformName Name of the variable.
  30639. * @param array array to be set.
  30640. * @returns this effect.
  30641. */
  30642. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30643. /**
  30644. * 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)
  30645. * @param uniformName Name of the variable.
  30646. * @param array array to be set.
  30647. * @returns this effect.
  30648. */
  30649. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30650. /**
  30651. * 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)
  30652. * @param uniformName Name of the variable.
  30653. * @param array array to be set.
  30654. * @returns this effect.
  30655. */
  30656. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30657. /**
  30658. * Sets an array on a uniform variable.
  30659. * @param uniformName Name of the variable.
  30660. * @param array array to be set.
  30661. * @returns this effect.
  30662. */
  30663. setArray(uniformName: string, array: number[]): Effect;
  30664. /**
  30665. * 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)
  30666. * @param uniformName Name of the variable.
  30667. * @param array array to be set.
  30668. * @returns this effect.
  30669. */
  30670. setArray2(uniformName: string, array: number[]): Effect;
  30671. /**
  30672. * 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)
  30673. * @param uniformName Name of the variable.
  30674. * @param array array to be set.
  30675. * @returns this effect.
  30676. */
  30677. setArray3(uniformName: string, array: number[]): Effect;
  30678. /**
  30679. * 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)
  30680. * @param uniformName Name of the variable.
  30681. * @param array array to be set.
  30682. * @returns this effect.
  30683. */
  30684. setArray4(uniformName: string, array: number[]): Effect;
  30685. /**
  30686. * Sets matrices on a uniform variable.
  30687. * @param uniformName Name of the variable.
  30688. * @param matrices matrices to be set.
  30689. * @returns this effect.
  30690. */
  30691. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30692. /**
  30693. * Sets matrix on a uniform variable.
  30694. * @param uniformName Name of the variable.
  30695. * @param matrix matrix to be set.
  30696. * @returns this effect.
  30697. */
  30698. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30699. /**
  30700. * 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)
  30701. * @param uniformName Name of the variable.
  30702. * @param matrix matrix to be set.
  30703. * @returns this effect.
  30704. */
  30705. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30706. /**
  30707. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30708. * @param uniformName Name of the variable.
  30709. * @param matrix matrix to be set.
  30710. * @returns this effect.
  30711. */
  30712. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30713. /**
  30714. * Sets a float on a uniform variable.
  30715. * @param uniformName Name of the variable.
  30716. * @param value value to be set.
  30717. * @returns this effect.
  30718. */
  30719. setFloat(uniformName: string, value: number): Effect;
  30720. /**
  30721. * Sets a boolean on a uniform variable.
  30722. * @param uniformName Name of the variable.
  30723. * @param bool value to be set.
  30724. * @returns this effect.
  30725. */
  30726. setBool(uniformName: string, bool: boolean): Effect;
  30727. /**
  30728. * Sets a Vector2 on a uniform variable.
  30729. * @param uniformName Name of the variable.
  30730. * @param vector2 vector2 to be set.
  30731. * @returns this effect.
  30732. */
  30733. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30734. /**
  30735. * Sets a float2 on a uniform variable.
  30736. * @param uniformName Name of the variable.
  30737. * @param x First float in float2.
  30738. * @param y Second float in float2.
  30739. * @returns this effect.
  30740. */
  30741. setFloat2(uniformName: string, x: number, y: number): Effect;
  30742. /**
  30743. * Sets a Vector3 on a uniform variable.
  30744. * @param uniformName Name of the variable.
  30745. * @param vector3 Value to be set.
  30746. * @returns this effect.
  30747. */
  30748. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30749. /**
  30750. * Sets a float3 on a uniform variable.
  30751. * @param uniformName Name of the variable.
  30752. * @param x First float in float3.
  30753. * @param y Second float in float3.
  30754. * @param z Third float in float3.
  30755. * @returns this effect.
  30756. */
  30757. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30758. /**
  30759. * Sets a Vector4 on a uniform variable.
  30760. * @param uniformName Name of the variable.
  30761. * @param vector4 Value to be set.
  30762. * @returns this effect.
  30763. */
  30764. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30765. /**
  30766. * Sets a float4 on a uniform variable.
  30767. * @param uniformName Name of the variable.
  30768. * @param x First float in float4.
  30769. * @param y Second float in float4.
  30770. * @param z Third float in float4.
  30771. * @param w Fourth float in float4.
  30772. * @returns this effect.
  30773. */
  30774. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30775. /**
  30776. * Sets a Color3 on a uniform variable.
  30777. * @param uniformName Name of the variable.
  30778. * @param color3 Value to be set.
  30779. * @returns this effect.
  30780. */
  30781. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30782. /**
  30783. * Sets a Color4 on a uniform variable.
  30784. * @param uniformName Name of the variable.
  30785. * @param color3 Value to be set.
  30786. * @param alpha Alpha value to be set.
  30787. * @returns this effect.
  30788. */
  30789. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30790. /**
  30791. * Sets a Color4 on a uniform variable
  30792. * @param uniformName defines the name of the variable
  30793. * @param color4 defines the value to be set
  30794. * @returns this effect.
  30795. */
  30796. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30797. /** Release all associated resources */
  30798. dispose(): void;
  30799. /**
  30800. * This function will add a new shader to the shader store
  30801. * @param name the name of the shader
  30802. * @param pixelShader optional pixel shader content
  30803. * @param vertexShader optional vertex shader content
  30804. */
  30805. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30806. /**
  30807. * Store of each shader (The can be looked up using effect.key)
  30808. */
  30809. static ShadersStore: {
  30810. [key: string]: string;
  30811. };
  30812. /**
  30813. * Store of each included file for a shader (The can be looked up using effect.key)
  30814. */
  30815. static IncludesShadersStore: {
  30816. [key: string]: string;
  30817. };
  30818. /**
  30819. * Resets the cache of effects.
  30820. */
  30821. static ResetCache(): void;
  30822. }
  30823. }
  30824. declare module BABYLON {
  30825. /**
  30826. * Interface used to describe the capabilities of the engine relatively to the current browser
  30827. */
  30828. export interface EngineCapabilities {
  30829. /** Maximum textures units per fragment shader */
  30830. maxTexturesImageUnits: number;
  30831. /** Maximum texture units per vertex shader */
  30832. maxVertexTextureImageUnits: number;
  30833. /** Maximum textures units in the entire pipeline */
  30834. maxCombinedTexturesImageUnits: number;
  30835. /** Maximum texture size */
  30836. maxTextureSize: number;
  30837. /** Maximum texture samples */
  30838. maxSamples?: number;
  30839. /** Maximum cube texture size */
  30840. maxCubemapTextureSize: number;
  30841. /** Maximum render texture size */
  30842. maxRenderTextureSize: number;
  30843. /** Maximum number of vertex attributes */
  30844. maxVertexAttribs: number;
  30845. /** Maximum number of varyings */
  30846. maxVaryingVectors: number;
  30847. /** Maximum number of uniforms per vertex shader */
  30848. maxVertexUniformVectors: number;
  30849. /** Maximum number of uniforms per fragment shader */
  30850. maxFragmentUniformVectors: number;
  30851. /** Defines if standard derivates (dx/dy) are supported */
  30852. standardDerivatives: boolean;
  30853. /** Defines if s3tc texture compression is supported */
  30854. s3tc?: WEBGL_compressed_texture_s3tc;
  30855. /** Defines if pvrtc texture compression is supported */
  30856. pvrtc: any;
  30857. /** Defines if etc1 texture compression is supported */
  30858. etc1: any;
  30859. /** Defines if etc2 texture compression is supported */
  30860. etc2: any;
  30861. /** Defines if astc texture compression is supported */
  30862. astc: any;
  30863. /** Defines if float textures are supported */
  30864. textureFloat: boolean;
  30865. /** Defines if vertex array objects are supported */
  30866. vertexArrayObject: boolean;
  30867. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30868. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30869. /** Gets the maximum level of anisotropy supported */
  30870. maxAnisotropy: number;
  30871. /** Defines if instancing is supported */
  30872. instancedArrays: boolean;
  30873. /** Defines if 32 bits indices are supported */
  30874. uintIndices: boolean;
  30875. /** Defines if high precision shaders are supported */
  30876. highPrecisionShaderSupported: boolean;
  30877. /** Defines if depth reading in the fragment shader is supported */
  30878. fragmentDepthSupported: boolean;
  30879. /** Defines if float texture linear filtering is supported*/
  30880. textureFloatLinearFiltering: boolean;
  30881. /** Defines if rendering to float textures is supported */
  30882. textureFloatRender: boolean;
  30883. /** Defines if half float textures are supported*/
  30884. textureHalfFloat: boolean;
  30885. /** Defines if half float texture linear filtering is supported*/
  30886. textureHalfFloatLinearFiltering: boolean;
  30887. /** Defines if rendering to half float textures is supported */
  30888. textureHalfFloatRender: boolean;
  30889. /** Defines if textureLOD shader command is supported */
  30890. textureLOD: boolean;
  30891. /** Defines if draw buffers extension is supported */
  30892. drawBuffersExtension: boolean;
  30893. /** Defines if depth textures are supported */
  30894. depthTextureExtension: boolean;
  30895. /** Defines if float color buffer are supported */
  30896. colorBufferFloat: boolean;
  30897. /** Gets disjoint timer query extension (null if not supported) */
  30898. timerQuery?: EXT_disjoint_timer_query;
  30899. /** Defines if timestamp can be used with timer query */
  30900. canUseTimestampForTimerQuery: boolean;
  30901. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30902. multiview?: any;
  30903. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30904. oculusMultiview?: any;
  30905. /** Function used to let the system compiles shaders in background */
  30906. parallelShaderCompile?: {
  30907. COMPLETION_STATUS_KHR: number;
  30908. };
  30909. /** Max number of texture samples for MSAA */
  30910. maxMSAASamples: number;
  30911. /** Defines if the blend min max extension is supported */
  30912. blendMinMax: boolean;
  30913. }
  30914. }
  30915. declare module BABYLON {
  30916. /**
  30917. * @hidden
  30918. **/
  30919. export class DepthCullingState {
  30920. private _isDepthTestDirty;
  30921. private _isDepthMaskDirty;
  30922. private _isDepthFuncDirty;
  30923. private _isCullFaceDirty;
  30924. private _isCullDirty;
  30925. private _isZOffsetDirty;
  30926. private _isFrontFaceDirty;
  30927. private _depthTest;
  30928. private _depthMask;
  30929. private _depthFunc;
  30930. private _cull;
  30931. private _cullFace;
  30932. private _zOffset;
  30933. private _frontFace;
  30934. /**
  30935. * Initializes the state.
  30936. */
  30937. constructor();
  30938. get isDirty(): boolean;
  30939. get zOffset(): number;
  30940. set zOffset(value: number);
  30941. get cullFace(): Nullable<number>;
  30942. set cullFace(value: Nullable<number>);
  30943. get cull(): Nullable<boolean>;
  30944. set cull(value: Nullable<boolean>);
  30945. get depthFunc(): Nullable<number>;
  30946. set depthFunc(value: Nullable<number>);
  30947. get depthMask(): boolean;
  30948. set depthMask(value: boolean);
  30949. get depthTest(): boolean;
  30950. set depthTest(value: boolean);
  30951. get frontFace(): Nullable<number>;
  30952. set frontFace(value: Nullable<number>);
  30953. reset(): void;
  30954. apply(gl: WebGLRenderingContext): void;
  30955. }
  30956. }
  30957. declare module BABYLON {
  30958. /**
  30959. * @hidden
  30960. **/
  30961. export class StencilState {
  30962. /** 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 */
  30963. static readonly ALWAYS: number;
  30964. /** Passed to stencilOperation to specify that stencil value must be kept */
  30965. static readonly KEEP: number;
  30966. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30967. static readonly REPLACE: number;
  30968. private _isStencilTestDirty;
  30969. private _isStencilMaskDirty;
  30970. private _isStencilFuncDirty;
  30971. private _isStencilOpDirty;
  30972. private _stencilTest;
  30973. private _stencilMask;
  30974. private _stencilFunc;
  30975. private _stencilFuncRef;
  30976. private _stencilFuncMask;
  30977. private _stencilOpStencilFail;
  30978. private _stencilOpDepthFail;
  30979. private _stencilOpStencilDepthPass;
  30980. get isDirty(): boolean;
  30981. get stencilFunc(): number;
  30982. set stencilFunc(value: number);
  30983. get stencilFuncRef(): number;
  30984. set stencilFuncRef(value: number);
  30985. get stencilFuncMask(): number;
  30986. set stencilFuncMask(value: number);
  30987. get stencilOpStencilFail(): number;
  30988. set stencilOpStencilFail(value: number);
  30989. get stencilOpDepthFail(): number;
  30990. set stencilOpDepthFail(value: number);
  30991. get stencilOpStencilDepthPass(): number;
  30992. set stencilOpStencilDepthPass(value: number);
  30993. get stencilMask(): number;
  30994. set stencilMask(value: number);
  30995. get stencilTest(): boolean;
  30996. set stencilTest(value: boolean);
  30997. constructor();
  30998. reset(): void;
  30999. apply(gl: WebGLRenderingContext): void;
  31000. }
  31001. }
  31002. declare module BABYLON {
  31003. /**
  31004. * @hidden
  31005. **/
  31006. export class AlphaState {
  31007. private _isAlphaBlendDirty;
  31008. private _isBlendFunctionParametersDirty;
  31009. private _isBlendEquationParametersDirty;
  31010. private _isBlendConstantsDirty;
  31011. private _alphaBlend;
  31012. private _blendFunctionParameters;
  31013. private _blendEquationParameters;
  31014. private _blendConstants;
  31015. /**
  31016. * Initializes the state.
  31017. */
  31018. constructor();
  31019. get isDirty(): boolean;
  31020. get alphaBlend(): boolean;
  31021. set alphaBlend(value: boolean);
  31022. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31023. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31024. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31025. reset(): void;
  31026. apply(gl: WebGLRenderingContext): void;
  31027. }
  31028. }
  31029. declare module BABYLON {
  31030. /** @hidden */
  31031. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31032. attributeProcessor(attribute: string): string;
  31033. varyingProcessor(varying: string, isFragment: boolean): string;
  31034. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31035. }
  31036. }
  31037. declare module BABYLON {
  31038. /**
  31039. * Interface for attribute information associated with buffer instanciation
  31040. */
  31041. export interface InstancingAttributeInfo {
  31042. /**
  31043. * Name of the GLSL attribute
  31044. * if attribute index is not specified, this is used to retrieve the index from the effect
  31045. */
  31046. attributeName: string;
  31047. /**
  31048. * Index/offset of the attribute in the vertex shader
  31049. * if not specified, this will be computes from the name.
  31050. */
  31051. index?: number;
  31052. /**
  31053. * size of the attribute, 1, 2, 3 or 4
  31054. */
  31055. attributeSize: number;
  31056. /**
  31057. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31058. */
  31059. offset: number;
  31060. /**
  31061. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31062. * default to 1
  31063. */
  31064. divisor?: number;
  31065. /**
  31066. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31067. * default is FLOAT
  31068. */
  31069. attributeType?: number;
  31070. /**
  31071. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31072. */
  31073. normalized?: boolean;
  31074. }
  31075. }
  31076. declare module BABYLON {
  31077. interface ThinEngine {
  31078. /**
  31079. * Update a video texture
  31080. * @param texture defines the texture to update
  31081. * @param video defines the video element to use
  31082. * @param invertY defines if data must be stored with Y axis inverted
  31083. */
  31084. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31085. }
  31086. }
  31087. declare module BABYLON {
  31088. /**
  31089. * Settings for finer control over video usage
  31090. */
  31091. export interface VideoTextureSettings {
  31092. /**
  31093. * Applies `autoplay` to video, if specified
  31094. */
  31095. autoPlay?: boolean;
  31096. /**
  31097. * Applies `loop` to video, if specified
  31098. */
  31099. loop?: boolean;
  31100. /**
  31101. * Automatically updates internal texture from video at every frame in the render loop
  31102. */
  31103. autoUpdateTexture: boolean;
  31104. /**
  31105. * Image src displayed during the video loading or until the user interacts with the video.
  31106. */
  31107. poster?: string;
  31108. }
  31109. /**
  31110. * If you want to display a video in your scene, this is the special texture for that.
  31111. * This special texture works similar to other textures, with the exception of a few parameters.
  31112. * @see https://doc.babylonjs.com/how_to/video_texture
  31113. */
  31114. export class VideoTexture extends Texture {
  31115. /**
  31116. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31117. */
  31118. readonly autoUpdateTexture: boolean;
  31119. /**
  31120. * The video instance used by the texture internally
  31121. */
  31122. readonly video: HTMLVideoElement;
  31123. private _onUserActionRequestedObservable;
  31124. /**
  31125. * Event triggerd when a dom action is required by the user to play the video.
  31126. * This happens due to recent changes in browser policies preventing video to auto start.
  31127. */
  31128. get onUserActionRequestedObservable(): Observable<Texture>;
  31129. private _generateMipMaps;
  31130. private _engine;
  31131. private _stillImageCaptured;
  31132. private _displayingPosterTexture;
  31133. private _settings;
  31134. private _createInternalTextureOnEvent;
  31135. private _frameId;
  31136. private _currentSrc;
  31137. /**
  31138. * Creates a video texture.
  31139. * If you want to display a video in your scene, this is the special texture for that.
  31140. * This special texture works similar to other textures, with the exception of a few parameters.
  31141. * @see https://doc.babylonjs.com/how_to/video_texture
  31142. * @param name optional name, will detect from video source, if not defined
  31143. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31144. * @param scene is obviously the current scene.
  31145. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31146. * @param invertY is false by default but can be used to invert video on Y axis
  31147. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31148. * @param settings allows finer control over video usage
  31149. */
  31150. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31151. private _getName;
  31152. private _getVideo;
  31153. private _createInternalTexture;
  31154. private reset;
  31155. /**
  31156. * @hidden Internal method to initiate `update`.
  31157. */
  31158. _rebuild(): void;
  31159. /**
  31160. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31161. */
  31162. update(): void;
  31163. /**
  31164. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31165. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31166. */
  31167. updateTexture(isVisible: boolean): void;
  31168. protected _updateInternalTexture: () => void;
  31169. /**
  31170. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31171. * @param url New url.
  31172. */
  31173. updateURL(url: string): void;
  31174. /**
  31175. * Clones the texture.
  31176. * @returns the cloned texture
  31177. */
  31178. clone(): VideoTexture;
  31179. /**
  31180. * Dispose the texture and release its associated resources.
  31181. */
  31182. dispose(): void;
  31183. /**
  31184. * Creates a video texture straight from a stream.
  31185. * @param scene Define the scene the texture should be created in
  31186. * @param stream Define the stream the texture should be created from
  31187. * @returns The created video texture as a promise
  31188. */
  31189. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31190. /**
  31191. * Creates a video texture straight from your WebCam video feed.
  31192. * @param scene Define the scene the texture should be created in
  31193. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31194. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31195. * @returns The created video texture as a promise
  31196. */
  31197. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31198. minWidth: number;
  31199. maxWidth: number;
  31200. minHeight: number;
  31201. maxHeight: number;
  31202. deviceId: string;
  31203. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31204. /**
  31205. * Creates a video texture straight from your WebCam video feed.
  31206. * @param scene Define the scene the texture should be created in
  31207. * @param onReady Define a callback to triggered once the texture will be ready
  31208. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31209. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31210. */
  31211. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31212. minWidth: number;
  31213. maxWidth: number;
  31214. minHeight: number;
  31215. maxHeight: number;
  31216. deviceId: string;
  31217. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31218. }
  31219. }
  31220. declare module BABYLON {
  31221. /**
  31222. * Defines the interface used by objects working like Scene
  31223. * @hidden
  31224. */
  31225. export interface ISceneLike {
  31226. _addPendingData(data: any): void;
  31227. _removePendingData(data: any): void;
  31228. offlineProvider: IOfflineProvider;
  31229. }
  31230. /** Interface defining initialization parameters for Engine class */
  31231. export interface EngineOptions extends WebGLContextAttributes {
  31232. /**
  31233. * Defines if the engine should no exceed a specified device ratio
  31234. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31235. */
  31236. limitDeviceRatio?: number;
  31237. /**
  31238. * Defines if webvr should be enabled automatically
  31239. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31240. */
  31241. autoEnableWebVR?: boolean;
  31242. /**
  31243. * Defines if webgl2 should be turned off even if supported
  31244. * @see http://doc.babylonjs.com/features/webgl2
  31245. */
  31246. disableWebGL2Support?: boolean;
  31247. /**
  31248. * Defines if webaudio should be initialized as well
  31249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31250. */
  31251. audioEngine?: boolean;
  31252. /**
  31253. * Defines if animations should run using a deterministic lock step
  31254. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31255. */
  31256. deterministicLockstep?: boolean;
  31257. /** Defines the maximum steps to use with deterministic lock step mode */
  31258. lockstepMaxSteps?: number;
  31259. /** Defines the seconds between each deterministic lock step */
  31260. timeStep?: number;
  31261. /**
  31262. * Defines that engine should ignore context lost events
  31263. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31264. */
  31265. doNotHandleContextLost?: boolean;
  31266. /**
  31267. * Defines that engine should ignore modifying touch action attribute and style
  31268. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31269. */
  31270. doNotHandleTouchAction?: boolean;
  31271. /**
  31272. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31273. */
  31274. useHighPrecisionFloats?: boolean;
  31275. }
  31276. /**
  31277. * The base engine class (root of all engines)
  31278. */
  31279. export class ThinEngine {
  31280. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31281. static ExceptionList: ({
  31282. key: string;
  31283. capture: string;
  31284. captureConstraint: number;
  31285. targets: string[];
  31286. } | {
  31287. key: string;
  31288. capture: null;
  31289. captureConstraint: null;
  31290. targets: string[];
  31291. })[];
  31292. /** @hidden */
  31293. static _TextureLoaders: IInternalTextureLoader[];
  31294. /**
  31295. * Returns the current npm package of the sdk
  31296. */
  31297. static get NpmPackage(): string;
  31298. /**
  31299. * Returns the current version of the framework
  31300. */
  31301. static get Version(): string;
  31302. /**
  31303. * Returns a string describing the current engine
  31304. */
  31305. get description(): string;
  31306. /**
  31307. * Gets or sets the epsilon value used by collision engine
  31308. */
  31309. static CollisionsEpsilon: number;
  31310. /**
  31311. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31312. */
  31313. static get ShadersRepository(): string;
  31314. static set ShadersRepository(value: string);
  31315. /** @hidden */
  31316. _shaderProcessor: IShaderProcessor;
  31317. /**
  31318. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31319. */
  31320. forcePOTTextures: boolean;
  31321. /**
  31322. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31323. */
  31324. isFullscreen: boolean;
  31325. /**
  31326. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31327. */
  31328. cullBackFaces: boolean;
  31329. /**
  31330. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31331. */
  31332. renderEvenInBackground: boolean;
  31333. /**
  31334. * Gets or sets a boolean indicating that cache can be kept between frames
  31335. */
  31336. preventCacheWipeBetweenFrames: boolean;
  31337. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31338. validateShaderPrograms: boolean;
  31339. /**
  31340. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31341. * This can provide greater z depth for distant objects.
  31342. */
  31343. useReverseDepthBuffer: boolean;
  31344. /**
  31345. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31346. */
  31347. disableUniformBuffers: boolean;
  31348. /** @hidden */
  31349. _uniformBuffers: UniformBuffer[];
  31350. /**
  31351. * Gets a boolean indicating that the engine supports uniform buffers
  31352. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31353. */
  31354. get supportsUniformBuffers(): boolean;
  31355. /** @hidden */
  31356. _gl: WebGLRenderingContext;
  31357. /** @hidden */
  31358. _webGLVersion: number;
  31359. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31360. protected _windowIsBackground: boolean;
  31361. protected _creationOptions: EngineOptions;
  31362. protected _highPrecisionShadersAllowed: boolean;
  31363. /** @hidden */
  31364. get _shouldUseHighPrecisionShader(): boolean;
  31365. /**
  31366. * Gets a boolean indicating that only power of 2 textures are supported
  31367. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31368. */
  31369. get needPOTTextures(): boolean;
  31370. /** @hidden */
  31371. _badOS: boolean;
  31372. /** @hidden */
  31373. _badDesktopOS: boolean;
  31374. private _hardwareScalingLevel;
  31375. /** @hidden */
  31376. _caps: EngineCapabilities;
  31377. private _isStencilEnable;
  31378. private _glVersion;
  31379. private _glRenderer;
  31380. private _glVendor;
  31381. /** @hidden */
  31382. _videoTextureSupported: boolean;
  31383. protected _renderingQueueLaunched: boolean;
  31384. protected _activeRenderLoops: (() => void)[];
  31385. /**
  31386. * Observable signaled when a context lost event is raised
  31387. */
  31388. onContextLostObservable: Observable<ThinEngine>;
  31389. /**
  31390. * Observable signaled when a context restored event is raised
  31391. */
  31392. onContextRestoredObservable: Observable<ThinEngine>;
  31393. private _onContextLost;
  31394. private _onContextRestored;
  31395. protected _contextWasLost: boolean;
  31396. /** @hidden */
  31397. _doNotHandleContextLost: boolean;
  31398. /**
  31399. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31400. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31401. */
  31402. get doNotHandleContextLost(): boolean;
  31403. set doNotHandleContextLost(value: boolean);
  31404. /**
  31405. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31406. */
  31407. disableVertexArrayObjects: boolean;
  31408. /** @hidden */
  31409. protected _colorWrite: boolean;
  31410. /** @hidden */
  31411. protected _colorWriteChanged: boolean;
  31412. /** @hidden */
  31413. protected _depthCullingState: DepthCullingState;
  31414. /** @hidden */
  31415. protected _stencilState: StencilState;
  31416. /** @hidden */
  31417. _alphaState: AlphaState;
  31418. /** @hidden */
  31419. _alphaMode: number;
  31420. /** @hidden */
  31421. _alphaEquation: number;
  31422. /** @hidden */
  31423. _internalTexturesCache: InternalTexture[];
  31424. /** @hidden */
  31425. protected _activeChannel: number;
  31426. private _currentTextureChannel;
  31427. /** @hidden */
  31428. protected _boundTexturesCache: {
  31429. [key: string]: Nullable<InternalTexture>;
  31430. };
  31431. /** @hidden */
  31432. protected _currentEffect: Nullable<Effect>;
  31433. /** @hidden */
  31434. protected _currentProgram: Nullable<WebGLProgram>;
  31435. private _compiledEffects;
  31436. private _vertexAttribArraysEnabled;
  31437. /** @hidden */
  31438. protected _cachedViewport: Nullable<IViewportLike>;
  31439. private _cachedVertexArrayObject;
  31440. /** @hidden */
  31441. protected _cachedVertexBuffers: any;
  31442. /** @hidden */
  31443. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31444. /** @hidden */
  31445. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31446. /** @hidden */
  31447. _currentRenderTarget: Nullable<InternalTexture>;
  31448. private _uintIndicesCurrentlySet;
  31449. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31450. /** @hidden */
  31451. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31452. private _currentBufferPointers;
  31453. private _currentInstanceLocations;
  31454. private _currentInstanceBuffers;
  31455. private _textureUnits;
  31456. /** @hidden */
  31457. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31458. /** @hidden */
  31459. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31460. /** @hidden */
  31461. _boundRenderFunction: any;
  31462. private _vaoRecordInProgress;
  31463. private _mustWipeVertexAttributes;
  31464. private _emptyTexture;
  31465. private _emptyCubeTexture;
  31466. private _emptyTexture3D;
  31467. private _emptyTexture2DArray;
  31468. /** @hidden */
  31469. _frameHandler: number;
  31470. private _nextFreeTextureSlots;
  31471. private _maxSimultaneousTextures;
  31472. private _activeRequests;
  31473. /** @hidden */
  31474. _transformTextureUrl: Nullable<(url: string) => string>;
  31475. protected get _supportsHardwareTextureRescaling(): boolean;
  31476. private _framebufferDimensionsObject;
  31477. /**
  31478. * sets the object from which width and height will be taken from when getting render width and height
  31479. * Will fallback to the gl object
  31480. * @param dimensions the framebuffer width and height that will be used.
  31481. */
  31482. set framebufferDimensionsObject(dimensions: Nullable<{
  31483. framebufferWidth: number;
  31484. framebufferHeight: number;
  31485. }>);
  31486. /**
  31487. * Gets the current viewport
  31488. */
  31489. get currentViewport(): Nullable<IViewportLike>;
  31490. /**
  31491. * Gets the default empty texture
  31492. */
  31493. get emptyTexture(): InternalTexture;
  31494. /**
  31495. * Gets the default empty 3D texture
  31496. */
  31497. get emptyTexture3D(): InternalTexture;
  31498. /**
  31499. * Gets the default empty 2D array texture
  31500. */
  31501. get emptyTexture2DArray(): InternalTexture;
  31502. /**
  31503. * Gets the default empty cube texture
  31504. */
  31505. get emptyCubeTexture(): InternalTexture;
  31506. /**
  31507. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31508. */
  31509. readonly premultipliedAlpha: boolean;
  31510. /**
  31511. * Observable event triggered before each texture is initialized
  31512. */
  31513. onBeforeTextureInitObservable: Observable<Texture>;
  31514. /**
  31515. * Creates a new engine
  31516. * @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
  31517. * @param antialias defines enable antialiasing (default: false)
  31518. * @param options defines further options to be sent to the getContext() function
  31519. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31520. */
  31521. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31522. private _rebuildInternalTextures;
  31523. private _rebuildEffects;
  31524. /**
  31525. * Gets a boolean indicating if all created effects are ready
  31526. * @returns true if all effects are ready
  31527. */
  31528. areAllEffectsReady(): boolean;
  31529. protected _rebuildBuffers(): void;
  31530. protected _initGLContext(): void;
  31531. /**
  31532. * Gets version of the current webGL context
  31533. */
  31534. get webGLVersion(): number;
  31535. /**
  31536. * Gets a string idenfifying the name of the class
  31537. * @returns "Engine" string
  31538. */
  31539. getClassName(): string;
  31540. /**
  31541. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31542. */
  31543. get isStencilEnable(): boolean;
  31544. /** @hidden */
  31545. _prepareWorkingCanvas(): void;
  31546. /**
  31547. * Reset the texture cache to empty state
  31548. */
  31549. resetTextureCache(): void;
  31550. /**
  31551. * Gets an object containing information about the current webGL context
  31552. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31553. */
  31554. getGlInfo(): {
  31555. vendor: string;
  31556. renderer: string;
  31557. version: string;
  31558. };
  31559. /**
  31560. * Defines the hardware scaling level.
  31561. * By default the hardware scaling level is computed from the window device ratio.
  31562. * 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.
  31563. * @param level defines the level to use
  31564. */
  31565. setHardwareScalingLevel(level: number): void;
  31566. /**
  31567. * Gets the current hardware scaling level.
  31568. * By default the hardware scaling level is computed from the window device ratio.
  31569. * 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.
  31570. * @returns a number indicating the current hardware scaling level
  31571. */
  31572. getHardwareScalingLevel(): number;
  31573. /**
  31574. * Gets the list of loaded textures
  31575. * @returns an array containing all loaded textures
  31576. */
  31577. getLoadedTexturesCache(): InternalTexture[];
  31578. /**
  31579. * Gets the object containing all engine capabilities
  31580. * @returns the EngineCapabilities object
  31581. */
  31582. getCaps(): EngineCapabilities;
  31583. /**
  31584. * stop executing a render loop function and remove it from the execution array
  31585. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31586. */
  31587. stopRenderLoop(renderFunction?: () => void): void;
  31588. /** @hidden */
  31589. _renderLoop(): void;
  31590. /**
  31591. * Gets the HTML canvas attached with the current webGL context
  31592. * @returns a HTML canvas
  31593. */
  31594. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31595. /**
  31596. * Gets host window
  31597. * @returns the host window object
  31598. */
  31599. getHostWindow(): Nullable<Window>;
  31600. /**
  31601. * Gets the current render width
  31602. * @param useScreen defines if screen size must be used (or the current render target if any)
  31603. * @returns a number defining the current render width
  31604. */
  31605. getRenderWidth(useScreen?: boolean): number;
  31606. /**
  31607. * Gets the current render height
  31608. * @param useScreen defines if screen size must be used (or the current render target if any)
  31609. * @returns a number defining the current render height
  31610. */
  31611. getRenderHeight(useScreen?: boolean): number;
  31612. /**
  31613. * Can be used to override the current requestAnimationFrame requester.
  31614. * @hidden
  31615. */
  31616. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31617. /**
  31618. * Register and execute a render loop. The engine can have more than one render function
  31619. * @param renderFunction defines the function to continuously execute
  31620. */
  31621. runRenderLoop(renderFunction: () => void): void;
  31622. /**
  31623. * Clear the current render buffer or the current render target (if any is set up)
  31624. * @param color defines the color to use
  31625. * @param backBuffer defines if the back buffer must be cleared
  31626. * @param depth defines if the depth buffer must be cleared
  31627. * @param stencil defines if the stencil buffer must be cleared
  31628. */
  31629. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31630. private _viewportCached;
  31631. /** @hidden */
  31632. _viewport(x: number, y: number, width: number, height: number): void;
  31633. /**
  31634. * Set the WebGL's viewport
  31635. * @param viewport defines the viewport element to be used
  31636. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31637. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31638. */
  31639. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31640. /**
  31641. * Begin a new frame
  31642. */
  31643. beginFrame(): void;
  31644. /**
  31645. * Enf the current frame
  31646. */
  31647. endFrame(): void;
  31648. /**
  31649. * Resize the view according to the canvas' size
  31650. */
  31651. resize(): void;
  31652. /**
  31653. * Force a specific size of the canvas
  31654. * @param width defines the new canvas' width
  31655. * @param height defines the new canvas' height
  31656. */
  31657. setSize(width: number, height: number): void;
  31658. /**
  31659. * Binds the frame buffer to the specified texture.
  31660. * @param texture The texture to render to or null for the default canvas
  31661. * @param faceIndex The face of the texture to render to in case of cube texture
  31662. * @param requiredWidth The width of the target to render to
  31663. * @param requiredHeight The height of the target to render to
  31664. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31665. * @param lodLevel defines the lod level to bind to the frame buffer
  31666. * @param layer defines the 2d array index to bind to frame buffer to
  31667. */
  31668. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31669. /** @hidden */
  31670. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31671. /**
  31672. * Unbind the current render target texture from the webGL context
  31673. * @param texture defines the render target texture to unbind
  31674. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31675. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31676. */
  31677. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31678. /**
  31679. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31680. */
  31681. flushFramebuffer(): void;
  31682. /**
  31683. * Unbind the current render target and bind the default framebuffer
  31684. */
  31685. restoreDefaultFramebuffer(): void;
  31686. /** @hidden */
  31687. protected _resetVertexBufferBinding(): void;
  31688. /**
  31689. * Creates a vertex buffer
  31690. * @param data the data for the vertex buffer
  31691. * @returns the new WebGL static buffer
  31692. */
  31693. createVertexBuffer(data: DataArray): DataBuffer;
  31694. private _createVertexBuffer;
  31695. /**
  31696. * Creates a dynamic vertex buffer
  31697. * @param data the data for the dynamic vertex buffer
  31698. * @returns the new WebGL dynamic buffer
  31699. */
  31700. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31701. protected _resetIndexBufferBinding(): void;
  31702. /**
  31703. * Creates a new index buffer
  31704. * @param indices defines the content of the index buffer
  31705. * @param updatable defines if the index buffer must be updatable
  31706. * @returns a new webGL buffer
  31707. */
  31708. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31709. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31710. /**
  31711. * Bind a webGL buffer to the webGL context
  31712. * @param buffer defines the buffer to bind
  31713. */
  31714. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31715. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31716. private bindBuffer;
  31717. /**
  31718. * update the bound buffer with the given data
  31719. * @param data defines the data to update
  31720. */
  31721. updateArrayBuffer(data: Float32Array): void;
  31722. private _vertexAttribPointer;
  31723. /** @hidden */
  31724. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31725. private _bindVertexBuffersAttributes;
  31726. /**
  31727. * Records a vertex array object
  31728. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31729. * @param vertexBuffers defines the list of vertex buffers to store
  31730. * @param indexBuffer defines the index buffer to store
  31731. * @param effect defines the effect to store
  31732. * @returns the new vertex array object
  31733. */
  31734. recordVertexArrayObject(vertexBuffers: {
  31735. [key: string]: VertexBuffer;
  31736. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31737. /**
  31738. * Bind a specific vertex array object
  31739. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31740. * @param vertexArrayObject defines the vertex array object to bind
  31741. * @param indexBuffer defines the index buffer to bind
  31742. */
  31743. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31744. /**
  31745. * Bind webGl buffers directly to the webGL context
  31746. * @param vertexBuffer defines the vertex buffer to bind
  31747. * @param indexBuffer defines the index buffer to bind
  31748. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31749. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31750. * @param effect defines the effect associated with the vertex buffer
  31751. */
  31752. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31753. private _unbindVertexArrayObject;
  31754. /**
  31755. * Bind a list of vertex buffers to the webGL context
  31756. * @param vertexBuffers defines the list of vertex buffers to bind
  31757. * @param indexBuffer defines the index buffer to bind
  31758. * @param effect defines the effect associated with the vertex buffers
  31759. */
  31760. bindBuffers(vertexBuffers: {
  31761. [key: string]: Nullable<VertexBuffer>;
  31762. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31763. /**
  31764. * Unbind all instance attributes
  31765. */
  31766. unbindInstanceAttributes(): void;
  31767. /**
  31768. * Release and free the memory of a vertex array object
  31769. * @param vao defines the vertex array object to delete
  31770. */
  31771. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31772. /** @hidden */
  31773. _releaseBuffer(buffer: DataBuffer): boolean;
  31774. protected _deleteBuffer(buffer: DataBuffer): void;
  31775. /**
  31776. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31777. * @param instancesBuffer defines the webGL buffer to update and bind
  31778. * @param data defines the data to store in the buffer
  31779. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31780. */
  31781. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31782. /**
  31783. * Bind the content of a webGL buffer used with instantiation
  31784. * @param instancesBuffer defines the webGL buffer to bind
  31785. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31786. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31787. */
  31788. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31789. /**
  31790. * Disable the instance attribute corresponding to the name in parameter
  31791. * @param name defines the name of the attribute to disable
  31792. */
  31793. disableInstanceAttributeByName(name: string): void;
  31794. /**
  31795. * Disable the instance attribute corresponding to the location in parameter
  31796. * @param attributeLocation defines the attribute location of the attribute to disable
  31797. */
  31798. disableInstanceAttribute(attributeLocation: number): void;
  31799. /**
  31800. * Disable the attribute corresponding to the location in parameter
  31801. * @param attributeLocation defines the attribute location of the attribute to disable
  31802. */
  31803. disableAttributeByIndex(attributeLocation: number): void;
  31804. /**
  31805. * Send a draw order
  31806. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31807. * @param indexStart defines the starting index
  31808. * @param indexCount defines the number of index to draw
  31809. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31810. */
  31811. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31812. /**
  31813. * Draw a list of points
  31814. * @param verticesStart defines the index of first vertex to draw
  31815. * @param verticesCount defines the count of vertices to draw
  31816. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31817. */
  31818. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31819. /**
  31820. * Draw a list of unindexed primitives
  31821. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31822. * @param verticesStart defines the index of first vertex to draw
  31823. * @param verticesCount defines the count of vertices to draw
  31824. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31825. */
  31826. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31827. /**
  31828. * Draw a list of indexed primitives
  31829. * @param fillMode defines the primitive to use
  31830. * @param indexStart defines the starting index
  31831. * @param indexCount defines the number of index to draw
  31832. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31833. */
  31834. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31835. /**
  31836. * Draw a list of unindexed primitives
  31837. * @param fillMode defines the primitive to use
  31838. * @param verticesStart defines the index of first vertex to draw
  31839. * @param verticesCount defines the count of vertices to draw
  31840. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31841. */
  31842. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31843. private _drawMode;
  31844. /** @hidden */
  31845. protected _reportDrawCall(): void;
  31846. /** @hidden */
  31847. _releaseEffect(effect: Effect): void;
  31848. /** @hidden */
  31849. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31850. /**
  31851. * Create a new effect (used to store vertex/fragment shaders)
  31852. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31853. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31854. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31855. * @param samplers defines an array of string used to represent textures
  31856. * @param defines defines the string containing the defines to use to compile the shaders
  31857. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31858. * @param onCompiled defines a function to call when the effect creation is successful
  31859. * @param onError defines a function to call when the effect creation has failed
  31860. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31861. * @returns the new Effect
  31862. */
  31863. 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;
  31864. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31865. private _compileShader;
  31866. private _compileRawShader;
  31867. /** @hidden */
  31868. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31869. /**
  31870. * Directly creates a webGL program
  31871. * @param pipelineContext defines the pipeline context to attach to
  31872. * @param vertexCode defines the vertex shader code to use
  31873. * @param fragmentCode defines the fragment shader code to use
  31874. * @param context defines the webGL context to use (if not set, the current one will be used)
  31875. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31876. * @returns the new webGL program
  31877. */
  31878. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31879. /**
  31880. * Creates a webGL program
  31881. * @param pipelineContext defines the pipeline context to attach to
  31882. * @param vertexCode defines the vertex shader code to use
  31883. * @param fragmentCode defines the fragment shader code to use
  31884. * @param defines defines the string containing the defines to use to compile the shaders
  31885. * @param context defines the webGL context to use (if not set, the current one will be used)
  31886. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31887. * @returns the new webGL program
  31888. */
  31889. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31890. /**
  31891. * Creates a new pipeline context
  31892. * @returns the new pipeline
  31893. */
  31894. createPipelineContext(): IPipelineContext;
  31895. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31896. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31897. /** @hidden */
  31898. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31899. /** @hidden */
  31900. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31901. /** @hidden */
  31902. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31903. /**
  31904. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31905. * @param pipelineContext defines the pipeline context to use
  31906. * @param uniformsNames defines the list of uniform names
  31907. * @returns an array of webGL uniform locations
  31908. */
  31909. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31910. /**
  31911. * Gets the lsit of active attributes for a given webGL program
  31912. * @param pipelineContext defines the pipeline context to use
  31913. * @param attributesNames defines the list of attribute names to get
  31914. * @returns an array of indices indicating the offset of each attribute
  31915. */
  31916. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31917. /**
  31918. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31919. * @param effect defines the effect to activate
  31920. */
  31921. enableEffect(effect: Nullable<Effect>): void;
  31922. /**
  31923. * Set the value of an uniform to a number (int)
  31924. * @param uniform defines the webGL uniform location where to store the value
  31925. * @param value defines the int number to store
  31926. */
  31927. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31928. /**
  31929. * Set the value of an uniform to an array of int32
  31930. * @param uniform defines the webGL uniform location where to store the value
  31931. * @param array defines the array of int32 to store
  31932. */
  31933. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31934. /**
  31935. * Set the value of an uniform to an array of int32 (stored as vec2)
  31936. * @param uniform defines the webGL uniform location where to store the value
  31937. * @param array defines the array of int32 to store
  31938. */
  31939. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31940. /**
  31941. * Set the value of an uniform to an array of int32 (stored as vec3)
  31942. * @param uniform defines the webGL uniform location where to store the value
  31943. * @param array defines the array of int32 to store
  31944. */
  31945. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31946. /**
  31947. * Set the value of an uniform to an array of int32 (stored as vec4)
  31948. * @param uniform defines the webGL uniform location where to store the value
  31949. * @param array defines the array of int32 to store
  31950. */
  31951. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31952. /**
  31953. * Set the value of an uniform to an array of number
  31954. * @param uniform defines the webGL uniform location where to store the value
  31955. * @param array defines the array of number to store
  31956. */
  31957. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31958. /**
  31959. * Set the value of an uniform to an array of number (stored as vec2)
  31960. * @param uniform defines the webGL uniform location where to store the value
  31961. * @param array defines the array of number to store
  31962. */
  31963. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31964. /**
  31965. * Set the value of an uniform to an array of number (stored as vec3)
  31966. * @param uniform defines the webGL uniform location where to store the value
  31967. * @param array defines the array of number to store
  31968. */
  31969. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31970. /**
  31971. * Set the value of an uniform to an array of number (stored as vec4)
  31972. * @param uniform defines the webGL uniform location where to store the value
  31973. * @param array defines the array of number to store
  31974. */
  31975. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31976. /**
  31977. * Set the value of an uniform to an array of float32 (stored as matrices)
  31978. * @param uniform defines the webGL uniform location where to store the value
  31979. * @param matrices defines the array of float32 to store
  31980. */
  31981. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31982. /**
  31983. * Set the value of an uniform to a matrix (3x3)
  31984. * @param uniform defines the webGL uniform location where to store the value
  31985. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31986. */
  31987. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31988. /**
  31989. * Set the value of an uniform to a matrix (2x2)
  31990. * @param uniform defines the webGL uniform location where to store the value
  31991. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31992. */
  31993. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31994. /**
  31995. * Set the value of an uniform to a number (float)
  31996. * @param uniform defines the webGL uniform location where to store the value
  31997. * @param value defines the float number to store
  31998. */
  31999. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32000. /**
  32001. * Set the value of an uniform to a vec2
  32002. * @param uniform defines the webGL uniform location where to store the value
  32003. * @param x defines the 1st component of the value
  32004. * @param y defines the 2nd component of the value
  32005. */
  32006. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32007. /**
  32008. * Set the value of an uniform to a vec3
  32009. * @param uniform defines the webGL uniform location where to store the value
  32010. * @param x defines the 1st component of the value
  32011. * @param y defines the 2nd component of the value
  32012. * @param z defines the 3rd component of the value
  32013. */
  32014. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32015. /**
  32016. * Set the value of an uniform to a vec4
  32017. * @param uniform defines the webGL uniform location where to store the value
  32018. * @param x defines the 1st component of the value
  32019. * @param y defines the 2nd component of the value
  32020. * @param z defines the 3rd component of the value
  32021. * @param w defines the 4th component of the value
  32022. */
  32023. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32024. /**
  32025. * Apply all cached states (depth, culling, stencil and alpha)
  32026. */
  32027. applyStates(): void;
  32028. /**
  32029. * Enable or disable color writing
  32030. * @param enable defines the state to set
  32031. */
  32032. setColorWrite(enable: boolean): void;
  32033. /**
  32034. * Gets a boolean indicating if color writing is enabled
  32035. * @returns the current color writing state
  32036. */
  32037. getColorWrite(): boolean;
  32038. /**
  32039. * Gets the depth culling state manager
  32040. */
  32041. get depthCullingState(): DepthCullingState;
  32042. /**
  32043. * Gets the alpha state manager
  32044. */
  32045. get alphaState(): AlphaState;
  32046. /**
  32047. * Gets the stencil state manager
  32048. */
  32049. get stencilState(): StencilState;
  32050. /**
  32051. * Clears the list of texture accessible through engine.
  32052. * This can help preventing texture load conflict due to name collision.
  32053. */
  32054. clearInternalTexturesCache(): void;
  32055. /**
  32056. * Force the entire cache to be cleared
  32057. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32058. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32059. */
  32060. wipeCaches(bruteForce?: boolean): void;
  32061. /** @hidden */
  32062. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32063. min: number;
  32064. mag: number;
  32065. };
  32066. /** @hidden */
  32067. _createTexture(): WebGLTexture;
  32068. /**
  32069. * Usually called from Texture.ts.
  32070. * Passed information to create a WebGLTexture
  32071. * @param url defines a value which contains one of the following:
  32072. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32073. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32074. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32075. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32076. * @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)
  32077. * @param scene needed for loading to the correct scene
  32078. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32079. * @param onLoad optional callback to be called upon successful completion
  32080. * @param onError optional callback to be called upon failure
  32081. * @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
  32082. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32083. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32084. * @param forcedExtension defines the extension to use to pick the right loader
  32085. * @param mimeType defines an optional mime type
  32086. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32087. */
  32088. 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;
  32089. /**
  32090. * Loads an image as an HTMLImageElement.
  32091. * @param input url string, ArrayBuffer, or Blob to load
  32092. * @param onLoad callback called when the image successfully loads
  32093. * @param onError callback called when the image fails to load
  32094. * @param offlineProvider offline provider for caching
  32095. * @param mimeType optional mime type
  32096. * @returns the HTMLImageElement of the loaded image
  32097. * @hidden
  32098. */
  32099. 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>;
  32100. /**
  32101. * @hidden
  32102. */
  32103. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32104. /**
  32105. * Creates a raw texture
  32106. * @param data defines the data to store in the texture
  32107. * @param width defines the width of the texture
  32108. * @param height defines the height of the texture
  32109. * @param format defines the format of the data
  32110. * @param generateMipMaps defines if the engine should generate the mip levels
  32111. * @param invertY defines if data must be stored with Y axis inverted
  32112. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32113. * @param compression defines the compression used (null by default)
  32114. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32115. * @returns the raw texture inside an InternalTexture
  32116. */
  32117. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32118. /**
  32119. * Creates a new raw cube texture
  32120. * @param data defines the array of data to use to create each face
  32121. * @param size defines the size of the textures
  32122. * @param format defines the format of the data
  32123. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32124. * @param generateMipMaps defines if the engine should generate the mip levels
  32125. * @param invertY defines if data must be stored with Y axis inverted
  32126. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32127. * @param compression defines the compression used (null by default)
  32128. * @returns the cube texture as an InternalTexture
  32129. */
  32130. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32131. /**
  32132. * Creates a new raw 3D texture
  32133. * @param data defines the data used to create the texture
  32134. * @param width defines the width of the texture
  32135. * @param height defines the height of the texture
  32136. * @param depth defines the depth of the texture
  32137. * @param format defines the format of the texture
  32138. * @param generateMipMaps defines if the engine must generate mip levels
  32139. * @param invertY defines if data must be stored with Y axis inverted
  32140. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32141. * @param compression defines the compressed used (can be null)
  32142. * @param textureType defines the compressed used (can be null)
  32143. * @returns a new raw 3D texture (stored in an InternalTexture)
  32144. */
  32145. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32146. /**
  32147. * Creates a new raw 2D array texture
  32148. * @param data defines the data used to create the texture
  32149. * @param width defines the width of the texture
  32150. * @param height defines the height of the texture
  32151. * @param depth defines the number of layers of the texture
  32152. * @param format defines the format of the texture
  32153. * @param generateMipMaps defines if the engine must generate mip levels
  32154. * @param invertY defines if data must be stored with Y axis inverted
  32155. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32156. * @param compression defines the compressed used (can be null)
  32157. * @param textureType defines the compressed used (can be null)
  32158. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32159. */
  32160. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32161. private _unpackFlipYCached;
  32162. /**
  32163. * In case you are sharing the context with other applications, it might
  32164. * be interested to not cache the unpack flip y state to ensure a consistent
  32165. * value would be set.
  32166. */
  32167. enableUnpackFlipYCached: boolean;
  32168. /** @hidden */
  32169. _unpackFlipY(value: boolean): void;
  32170. /** @hidden */
  32171. _getUnpackAlignement(): number;
  32172. private _getTextureTarget;
  32173. /**
  32174. * Update the sampling mode of a given texture
  32175. * @param samplingMode defines the required sampling mode
  32176. * @param texture defines the texture to update
  32177. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32178. */
  32179. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32180. /**
  32181. * Update the sampling mode of a given texture
  32182. * @param texture defines the texture to update
  32183. * @param wrapU defines the texture wrap mode of the u coordinates
  32184. * @param wrapV defines the texture wrap mode of the v coordinates
  32185. * @param wrapR defines the texture wrap mode of the r coordinates
  32186. */
  32187. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32188. /** @hidden */
  32189. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32190. width: number;
  32191. height: number;
  32192. layers?: number;
  32193. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32194. /** @hidden */
  32195. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32196. /** @hidden */
  32197. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32198. /**
  32199. * Update a portion of an internal texture
  32200. * @param texture defines the texture to update
  32201. * @param imageData defines the data to store into the texture
  32202. * @param xOffset defines the x coordinates of the update rectangle
  32203. * @param yOffset defines the y coordinates of the update rectangle
  32204. * @param width defines the width of the update rectangle
  32205. * @param height defines the height of the update rectangle
  32206. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32207. * @param lod defines the lod level to update (0 by default)
  32208. */
  32209. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32210. /** @hidden */
  32211. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32212. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32213. private _prepareWebGLTexture;
  32214. /** @hidden */
  32215. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32216. private _getDepthStencilBuffer;
  32217. /** @hidden */
  32218. _releaseFramebufferObjects(texture: InternalTexture): void;
  32219. /** @hidden */
  32220. _releaseTexture(texture: InternalTexture): void;
  32221. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32222. protected _setProgram(program: WebGLProgram): void;
  32223. protected _boundUniforms: {
  32224. [key: number]: WebGLUniformLocation;
  32225. };
  32226. /**
  32227. * Binds an effect to the webGL context
  32228. * @param effect defines the effect to bind
  32229. */
  32230. bindSamplers(effect: Effect): void;
  32231. private _activateCurrentTexture;
  32232. /** @hidden */
  32233. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32234. /** @hidden */
  32235. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32236. /**
  32237. * Unbind all textures from the webGL context
  32238. */
  32239. unbindAllTextures(): void;
  32240. /**
  32241. * Sets a texture to the according uniform.
  32242. * @param channel The texture channel
  32243. * @param uniform The uniform to set
  32244. * @param texture The texture to apply
  32245. */
  32246. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32247. private _bindSamplerUniformToChannel;
  32248. private _getTextureWrapMode;
  32249. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32250. /**
  32251. * Sets an array of texture to the webGL context
  32252. * @param channel defines the channel where the texture array must be set
  32253. * @param uniform defines the associated uniform location
  32254. * @param textures defines the array of textures to bind
  32255. */
  32256. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32257. /** @hidden */
  32258. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32259. private _setTextureParameterFloat;
  32260. private _setTextureParameterInteger;
  32261. /**
  32262. * Unbind all vertex attributes from the webGL context
  32263. */
  32264. unbindAllAttributes(): void;
  32265. /**
  32266. * 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
  32267. */
  32268. releaseEffects(): void;
  32269. /**
  32270. * Dispose and release all associated resources
  32271. */
  32272. dispose(): void;
  32273. /**
  32274. * Attach a new callback raised when context lost event is fired
  32275. * @param callback defines the callback to call
  32276. */
  32277. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32278. /**
  32279. * Attach a new callback raised when context restored event is fired
  32280. * @param callback defines the callback to call
  32281. */
  32282. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32283. /**
  32284. * Get the current error code of the webGL context
  32285. * @returns the error code
  32286. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32287. */
  32288. getError(): number;
  32289. private _canRenderToFloatFramebuffer;
  32290. private _canRenderToHalfFloatFramebuffer;
  32291. private _canRenderToFramebuffer;
  32292. /** @hidden */
  32293. _getWebGLTextureType(type: number): number;
  32294. /** @hidden */
  32295. _getInternalFormat(format: number): number;
  32296. /** @hidden */
  32297. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32298. /** @hidden */
  32299. _getRGBAMultiSampleBufferFormat(type: number): number;
  32300. /** @hidden */
  32301. _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;
  32302. /**
  32303. * Loads a file from a url
  32304. * @param url url to load
  32305. * @param onSuccess callback called when the file successfully loads
  32306. * @param onProgress callback called while file is loading (if the server supports this mode)
  32307. * @param offlineProvider defines the offline provider for caching
  32308. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32309. * @param onError callback called when the file fails to load
  32310. * @returns a file request object
  32311. * @hidden
  32312. */
  32313. 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;
  32314. /**
  32315. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32316. * @param x defines the x coordinate of the rectangle where pixels must be read
  32317. * @param y defines the y coordinate of the rectangle where pixels must be read
  32318. * @param width defines the width of the rectangle where pixels must be read
  32319. * @param height defines the height of the rectangle where pixels must be read
  32320. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32321. * @returns a Uint8Array containing RGBA colors
  32322. */
  32323. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32324. private static _isSupported;
  32325. /**
  32326. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32327. * @returns true if the engine can be created
  32328. * @ignorenaming
  32329. */
  32330. static isSupported(): boolean;
  32331. /**
  32332. * Find the next highest power of two.
  32333. * @param x Number to start search from.
  32334. * @return Next highest power of two.
  32335. */
  32336. static CeilingPOT(x: number): number;
  32337. /**
  32338. * Find the next lowest power of two.
  32339. * @param x Number to start search from.
  32340. * @return Next lowest power of two.
  32341. */
  32342. static FloorPOT(x: number): number;
  32343. /**
  32344. * Find the nearest power of two.
  32345. * @param x Number to start search from.
  32346. * @return Next nearest power of two.
  32347. */
  32348. static NearestPOT(x: number): number;
  32349. /**
  32350. * Get the closest exponent of two
  32351. * @param value defines the value to approximate
  32352. * @param max defines the maximum value to return
  32353. * @param mode defines how to define the closest value
  32354. * @returns closest exponent of two of the given value
  32355. */
  32356. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32357. /**
  32358. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32359. * @param func - the function to be called
  32360. * @param requester - the object that will request the next frame. Falls back to window.
  32361. * @returns frame number
  32362. */
  32363. static QueueNewFrame(func: () => void, requester?: any): number;
  32364. /**
  32365. * Gets host document
  32366. * @returns the host document object
  32367. */
  32368. getHostDocument(): Nullable<Document>;
  32369. }
  32370. }
  32371. declare module BABYLON {
  32372. /**
  32373. * Class representing spherical harmonics coefficients to the 3rd degree
  32374. */
  32375. export class SphericalHarmonics {
  32376. /**
  32377. * Defines whether or not the harmonics have been prescaled for rendering.
  32378. */
  32379. preScaled: boolean;
  32380. /**
  32381. * The l0,0 coefficients of the spherical harmonics
  32382. */
  32383. l00: Vector3;
  32384. /**
  32385. * The l1,-1 coefficients of the spherical harmonics
  32386. */
  32387. l1_1: Vector3;
  32388. /**
  32389. * The l1,0 coefficients of the spherical harmonics
  32390. */
  32391. l10: Vector3;
  32392. /**
  32393. * The l1,1 coefficients of the spherical harmonics
  32394. */
  32395. l11: Vector3;
  32396. /**
  32397. * The l2,-2 coefficients of the spherical harmonics
  32398. */
  32399. l2_2: Vector3;
  32400. /**
  32401. * The l2,-1 coefficients of the spherical harmonics
  32402. */
  32403. l2_1: Vector3;
  32404. /**
  32405. * The l2,0 coefficients of the spherical harmonics
  32406. */
  32407. l20: Vector3;
  32408. /**
  32409. * The l2,1 coefficients of the spherical harmonics
  32410. */
  32411. l21: Vector3;
  32412. /**
  32413. * The l2,2 coefficients of the spherical harmonics
  32414. */
  32415. l22: Vector3;
  32416. /**
  32417. * Adds a light to the spherical harmonics
  32418. * @param direction the direction of the light
  32419. * @param color the color of the light
  32420. * @param deltaSolidAngle the delta solid angle of the light
  32421. */
  32422. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32423. /**
  32424. * Scales the spherical harmonics by the given amount
  32425. * @param scale the amount to scale
  32426. */
  32427. scaleInPlace(scale: number): void;
  32428. /**
  32429. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32430. *
  32431. * ```
  32432. * E_lm = A_l * L_lm
  32433. * ```
  32434. *
  32435. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32436. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32437. * the scaling factors are given in equation 9.
  32438. */
  32439. convertIncidentRadianceToIrradiance(): void;
  32440. /**
  32441. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32442. *
  32443. * ```
  32444. * L = (1/pi) * E * rho
  32445. * ```
  32446. *
  32447. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32448. */
  32449. convertIrradianceToLambertianRadiance(): void;
  32450. /**
  32451. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32452. * required operations at run time.
  32453. *
  32454. * This is simply done by scaling back the SH with Ylm constants parameter.
  32455. * The trigonometric part being applied by the shader at run time.
  32456. */
  32457. preScaleForRendering(): void;
  32458. /**
  32459. * Constructs a spherical harmonics from an array.
  32460. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32461. * @returns the spherical harmonics
  32462. */
  32463. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32464. /**
  32465. * Gets the spherical harmonics from polynomial
  32466. * @param polynomial the spherical polynomial
  32467. * @returns the spherical harmonics
  32468. */
  32469. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32470. }
  32471. /**
  32472. * Class representing spherical polynomial coefficients to the 3rd degree
  32473. */
  32474. export class SphericalPolynomial {
  32475. private _harmonics;
  32476. /**
  32477. * The spherical harmonics used to create the polynomials.
  32478. */
  32479. get preScaledHarmonics(): SphericalHarmonics;
  32480. /**
  32481. * The x coefficients of the spherical polynomial
  32482. */
  32483. x: Vector3;
  32484. /**
  32485. * The y coefficients of the spherical polynomial
  32486. */
  32487. y: Vector3;
  32488. /**
  32489. * The z coefficients of the spherical polynomial
  32490. */
  32491. z: Vector3;
  32492. /**
  32493. * The xx coefficients of the spherical polynomial
  32494. */
  32495. xx: Vector3;
  32496. /**
  32497. * The yy coefficients of the spherical polynomial
  32498. */
  32499. yy: Vector3;
  32500. /**
  32501. * The zz coefficients of the spherical polynomial
  32502. */
  32503. zz: Vector3;
  32504. /**
  32505. * The xy coefficients of the spherical polynomial
  32506. */
  32507. xy: Vector3;
  32508. /**
  32509. * The yz coefficients of the spherical polynomial
  32510. */
  32511. yz: Vector3;
  32512. /**
  32513. * The zx coefficients of the spherical polynomial
  32514. */
  32515. zx: Vector3;
  32516. /**
  32517. * Adds an ambient color to the spherical polynomial
  32518. * @param color the color to add
  32519. */
  32520. addAmbient(color: Color3): void;
  32521. /**
  32522. * Scales the spherical polynomial by the given amount
  32523. * @param scale the amount to scale
  32524. */
  32525. scaleInPlace(scale: number): void;
  32526. /**
  32527. * Gets the spherical polynomial from harmonics
  32528. * @param harmonics the spherical harmonics
  32529. * @returns the spherical polynomial
  32530. */
  32531. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32532. /**
  32533. * Constructs a spherical polynomial from an array.
  32534. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32535. * @returns the spherical polynomial
  32536. */
  32537. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32538. }
  32539. }
  32540. declare module BABYLON {
  32541. /**
  32542. * Defines the source of the internal texture
  32543. */
  32544. export enum InternalTextureSource {
  32545. /**
  32546. * The source of the texture data is unknown
  32547. */
  32548. Unknown = 0,
  32549. /**
  32550. * Texture data comes from an URL
  32551. */
  32552. Url = 1,
  32553. /**
  32554. * Texture data is only used for temporary storage
  32555. */
  32556. Temp = 2,
  32557. /**
  32558. * Texture data comes from raw data (ArrayBuffer)
  32559. */
  32560. Raw = 3,
  32561. /**
  32562. * Texture content is dynamic (video or dynamic texture)
  32563. */
  32564. Dynamic = 4,
  32565. /**
  32566. * Texture content is generated by rendering to it
  32567. */
  32568. RenderTarget = 5,
  32569. /**
  32570. * Texture content is part of a multi render target process
  32571. */
  32572. MultiRenderTarget = 6,
  32573. /**
  32574. * Texture data comes from a cube data file
  32575. */
  32576. Cube = 7,
  32577. /**
  32578. * Texture data comes from a raw cube data
  32579. */
  32580. CubeRaw = 8,
  32581. /**
  32582. * Texture data come from a prefiltered cube data file
  32583. */
  32584. CubePrefiltered = 9,
  32585. /**
  32586. * Texture content is raw 3D data
  32587. */
  32588. Raw3D = 10,
  32589. /**
  32590. * Texture content is raw 2D array data
  32591. */
  32592. Raw2DArray = 11,
  32593. /**
  32594. * Texture content is a depth texture
  32595. */
  32596. Depth = 12,
  32597. /**
  32598. * Texture data comes from a raw cube data encoded with RGBD
  32599. */
  32600. CubeRawRGBD = 13
  32601. }
  32602. /**
  32603. * Class used to store data associated with WebGL texture data for the engine
  32604. * This class should not be used directly
  32605. */
  32606. export class InternalTexture {
  32607. /** @hidden */
  32608. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32609. /**
  32610. * Defines if the texture is ready
  32611. */
  32612. isReady: boolean;
  32613. /**
  32614. * Defines if the texture is a cube texture
  32615. */
  32616. isCube: boolean;
  32617. /**
  32618. * Defines if the texture contains 3D data
  32619. */
  32620. is3D: boolean;
  32621. /**
  32622. * Defines if the texture contains 2D array data
  32623. */
  32624. is2DArray: boolean;
  32625. /**
  32626. * Defines if the texture contains multiview data
  32627. */
  32628. isMultiview: boolean;
  32629. /**
  32630. * Gets the URL used to load this texture
  32631. */
  32632. url: string;
  32633. /**
  32634. * Gets the sampling mode of the texture
  32635. */
  32636. samplingMode: number;
  32637. /**
  32638. * Gets a boolean indicating if the texture needs mipmaps generation
  32639. */
  32640. generateMipMaps: boolean;
  32641. /**
  32642. * Gets the number of samples used by the texture (WebGL2+ only)
  32643. */
  32644. samples: number;
  32645. /**
  32646. * Gets the type of the texture (int, float...)
  32647. */
  32648. type: number;
  32649. /**
  32650. * Gets the format of the texture (RGB, RGBA...)
  32651. */
  32652. format: number;
  32653. /**
  32654. * Observable called when the texture is loaded
  32655. */
  32656. onLoadedObservable: Observable<InternalTexture>;
  32657. /**
  32658. * Gets the width of the texture
  32659. */
  32660. width: number;
  32661. /**
  32662. * Gets the height of the texture
  32663. */
  32664. height: number;
  32665. /**
  32666. * Gets the depth of the texture
  32667. */
  32668. depth: number;
  32669. /**
  32670. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32671. */
  32672. baseWidth: number;
  32673. /**
  32674. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32675. */
  32676. baseHeight: number;
  32677. /**
  32678. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32679. */
  32680. baseDepth: number;
  32681. /**
  32682. * Gets a boolean indicating if the texture is inverted on Y axis
  32683. */
  32684. invertY: boolean;
  32685. /** @hidden */
  32686. _invertVScale: boolean;
  32687. /** @hidden */
  32688. _associatedChannel: number;
  32689. /** @hidden */
  32690. _source: InternalTextureSource;
  32691. /** @hidden */
  32692. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32693. /** @hidden */
  32694. _bufferView: Nullable<ArrayBufferView>;
  32695. /** @hidden */
  32696. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32697. /** @hidden */
  32698. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32699. /** @hidden */
  32700. _size: number;
  32701. /** @hidden */
  32702. _extension: string;
  32703. /** @hidden */
  32704. _files: Nullable<string[]>;
  32705. /** @hidden */
  32706. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32707. /** @hidden */
  32708. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32709. /** @hidden */
  32710. _framebuffer: Nullable<WebGLFramebuffer>;
  32711. /** @hidden */
  32712. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32713. /** @hidden */
  32714. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32715. /** @hidden */
  32716. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32717. /** @hidden */
  32718. _attachments: Nullable<number[]>;
  32719. /** @hidden */
  32720. _cachedCoordinatesMode: Nullable<number>;
  32721. /** @hidden */
  32722. _cachedWrapU: Nullable<number>;
  32723. /** @hidden */
  32724. _cachedWrapV: Nullable<number>;
  32725. /** @hidden */
  32726. _cachedWrapR: Nullable<number>;
  32727. /** @hidden */
  32728. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32729. /** @hidden */
  32730. _isDisabled: boolean;
  32731. /** @hidden */
  32732. _compression: Nullable<string>;
  32733. /** @hidden */
  32734. _generateStencilBuffer: boolean;
  32735. /** @hidden */
  32736. _generateDepthBuffer: boolean;
  32737. /** @hidden */
  32738. _comparisonFunction: number;
  32739. /** @hidden */
  32740. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32741. /** @hidden */
  32742. _lodGenerationScale: number;
  32743. /** @hidden */
  32744. _lodGenerationOffset: number;
  32745. /** @hidden */
  32746. _depthStencilTexture: Nullable<InternalTexture>;
  32747. /** @hidden */
  32748. _colorTextureArray: Nullable<WebGLTexture>;
  32749. /** @hidden */
  32750. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32751. /** @hidden */
  32752. _lodTextureHigh: Nullable<BaseTexture>;
  32753. /** @hidden */
  32754. _lodTextureMid: Nullable<BaseTexture>;
  32755. /** @hidden */
  32756. _lodTextureLow: Nullable<BaseTexture>;
  32757. /** @hidden */
  32758. _isRGBD: boolean;
  32759. /** @hidden */
  32760. _linearSpecularLOD: boolean;
  32761. /** @hidden */
  32762. _irradianceTexture: Nullable<BaseTexture>;
  32763. /** @hidden */
  32764. _webGLTexture: Nullable<WebGLTexture>;
  32765. /** @hidden */
  32766. _references: number;
  32767. private _engine;
  32768. /**
  32769. * Gets the Engine the texture belongs to.
  32770. * @returns The babylon engine
  32771. */
  32772. getEngine(): ThinEngine;
  32773. /**
  32774. * Gets the data source type of the texture
  32775. */
  32776. get source(): InternalTextureSource;
  32777. /**
  32778. * Creates a new InternalTexture
  32779. * @param engine defines the engine to use
  32780. * @param source defines the type of data that will be used
  32781. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32782. */
  32783. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32784. /**
  32785. * Increments the number of references (ie. the number of Texture that point to it)
  32786. */
  32787. incrementReferences(): void;
  32788. /**
  32789. * Change the size of the texture (not the size of the content)
  32790. * @param width defines the new width
  32791. * @param height defines the new height
  32792. * @param depth defines the new depth (1 by default)
  32793. */
  32794. updateSize(width: int, height: int, depth?: int): void;
  32795. /** @hidden */
  32796. _rebuild(): void;
  32797. /** @hidden */
  32798. _swapAndDie(target: InternalTexture): void;
  32799. /**
  32800. * Dispose the current allocated resources
  32801. */
  32802. dispose(): void;
  32803. }
  32804. }
  32805. declare module BABYLON {
  32806. /**
  32807. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32809. */
  32810. export class Analyser {
  32811. /**
  32812. * Gets or sets the smoothing
  32813. * @ignorenaming
  32814. */
  32815. SMOOTHING: number;
  32816. /**
  32817. * Gets or sets the FFT table size
  32818. * @ignorenaming
  32819. */
  32820. FFT_SIZE: number;
  32821. /**
  32822. * Gets or sets the bar graph amplitude
  32823. * @ignorenaming
  32824. */
  32825. BARGRAPHAMPLITUDE: number;
  32826. /**
  32827. * Gets or sets the position of the debug canvas
  32828. * @ignorenaming
  32829. */
  32830. DEBUGCANVASPOS: {
  32831. x: number;
  32832. y: number;
  32833. };
  32834. /**
  32835. * Gets or sets the debug canvas size
  32836. * @ignorenaming
  32837. */
  32838. DEBUGCANVASSIZE: {
  32839. width: number;
  32840. height: number;
  32841. };
  32842. private _byteFreqs;
  32843. private _byteTime;
  32844. private _floatFreqs;
  32845. private _webAudioAnalyser;
  32846. private _debugCanvas;
  32847. private _debugCanvasContext;
  32848. private _scene;
  32849. private _registerFunc;
  32850. private _audioEngine;
  32851. /**
  32852. * Creates a new analyser
  32853. * @param scene defines hosting scene
  32854. */
  32855. constructor(scene: Scene);
  32856. /**
  32857. * Get the number of data values you will have to play with for the visualization
  32858. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32859. * @returns a number
  32860. */
  32861. getFrequencyBinCount(): number;
  32862. /**
  32863. * Gets the current frequency data as a byte array
  32864. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32865. * @returns a Uint8Array
  32866. */
  32867. getByteFrequencyData(): Uint8Array;
  32868. /**
  32869. * Gets the current waveform as a byte array
  32870. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32871. * @returns a Uint8Array
  32872. */
  32873. getByteTimeDomainData(): Uint8Array;
  32874. /**
  32875. * Gets the current frequency data as a float array
  32876. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32877. * @returns a Float32Array
  32878. */
  32879. getFloatFrequencyData(): Float32Array;
  32880. /**
  32881. * Renders the debug canvas
  32882. */
  32883. drawDebugCanvas(): void;
  32884. /**
  32885. * Stops rendering the debug canvas and removes it
  32886. */
  32887. stopDebugCanvas(): void;
  32888. /**
  32889. * Connects two audio nodes
  32890. * @param inputAudioNode defines first node to connect
  32891. * @param outputAudioNode defines second node to connect
  32892. */
  32893. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32894. /**
  32895. * Releases all associated resources
  32896. */
  32897. dispose(): void;
  32898. }
  32899. }
  32900. declare module BABYLON {
  32901. /**
  32902. * This represents an audio engine and it is responsible
  32903. * to play, synchronize and analyse sounds throughout the application.
  32904. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32905. */
  32906. export interface IAudioEngine extends IDisposable {
  32907. /**
  32908. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32909. */
  32910. readonly canUseWebAudio: boolean;
  32911. /**
  32912. * Gets the current AudioContext if available.
  32913. */
  32914. readonly audioContext: Nullable<AudioContext>;
  32915. /**
  32916. * The master gain node defines the global audio volume of your audio engine.
  32917. */
  32918. readonly masterGain: GainNode;
  32919. /**
  32920. * Gets whether or not mp3 are supported by your browser.
  32921. */
  32922. readonly isMP3supported: boolean;
  32923. /**
  32924. * Gets whether or not ogg are supported by your browser.
  32925. */
  32926. readonly isOGGsupported: boolean;
  32927. /**
  32928. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32929. * @ignoreNaming
  32930. */
  32931. WarnedWebAudioUnsupported: boolean;
  32932. /**
  32933. * Defines if the audio engine relies on a custom unlocked button.
  32934. * In this case, the embedded button will not be displayed.
  32935. */
  32936. useCustomUnlockedButton: boolean;
  32937. /**
  32938. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32939. */
  32940. readonly unlocked: boolean;
  32941. /**
  32942. * Event raised when audio has been unlocked on the browser.
  32943. */
  32944. onAudioUnlockedObservable: Observable<AudioEngine>;
  32945. /**
  32946. * Event raised when audio has been locked on the browser.
  32947. */
  32948. onAudioLockedObservable: Observable<AudioEngine>;
  32949. /**
  32950. * Flags the audio engine in Locked state.
  32951. * This happens due to new browser policies preventing audio to autoplay.
  32952. */
  32953. lock(): void;
  32954. /**
  32955. * Unlocks the audio engine once a user action has been done on the dom.
  32956. * This is helpful to resume play once browser policies have been satisfied.
  32957. */
  32958. unlock(): void;
  32959. /**
  32960. * Gets the global volume sets on the master gain.
  32961. * @returns the global volume if set or -1 otherwise
  32962. */
  32963. getGlobalVolume(): number;
  32964. /**
  32965. * Sets the global volume of your experience (sets on the master gain).
  32966. * @param newVolume Defines the new global volume of the application
  32967. */
  32968. setGlobalVolume(newVolume: number): void;
  32969. /**
  32970. * Connect the audio engine to an audio analyser allowing some amazing
  32971. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32972. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32973. * @param analyser The analyser to connect to the engine
  32974. */
  32975. connectToAnalyser(analyser: Analyser): void;
  32976. }
  32977. /**
  32978. * This represents the default audio engine used in babylon.
  32979. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32981. */
  32982. export class AudioEngine implements IAudioEngine {
  32983. private _audioContext;
  32984. private _audioContextInitialized;
  32985. private _muteButton;
  32986. private _hostElement;
  32987. /**
  32988. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32989. */
  32990. canUseWebAudio: boolean;
  32991. /**
  32992. * The master gain node defines the global audio volume of your audio engine.
  32993. */
  32994. masterGain: GainNode;
  32995. /**
  32996. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32997. * @ignoreNaming
  32998. */
  32999. WarnedWebAudioUnsupported: boolean;
  33000. /**
  33001. * Gets whether or not mp3 are supported by your browser.
  33002. */
  33003. isMP3supported: boolean;
  33004. /**
  33005. * Gets whether or not ogg are supported by your browser.
  33006. */
  33007. isOGGsupported: boolean;
  33008. /**
  33009. * Gets whether audio has been unlocked on the device.
  33010. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33011. * a user interaction has happened.
  33012. */
  33013. unlocked: boolean;
  33014. /**
  33015. * Defines if the audio engine relies on a custom unlocked button.
  33016. * In this case, the embedded button will not be displayed.
  33017. */
  33018. useCustomUnlockedButton: boolean;
  33019. /**
  33020. * Event raised when audio has been unlocked on the browser.
  33021. */
  33022. onAudioUnlockedObservable: Observable<AudioEngine>;
  33023. /**
  33024. * Event raised when audio has been locked on the browser.
  33025. */
  33026. onAudioLockedObservable: Observable<AudioEngine>;
  33027. /**
  33028. * Gets the current AudioContext if available.
  33029. */
  33030. get audioContext(): Nullable<AudioContext>;
  33031. private _connectedAnalyser;
  33032. /**
  33033. * Instantiates a new audio engine.
  33034. *
  33035. * There should be only one per page as some browsers restrict the number
  33036. * of audio contexts you can create.
  33037. * @param hostElement defines the host element where to display the mute icon if necessary
  33038. */
  33039. constructor(hostElement?: Nullable<HTMLElement>);
  33040. /**
  33041. * Flags the audio engine in Locked state.
  33042. * This happens due to new browser policies preventing audio to autoplay.
  33043. */
  33044. lock(): void;
  33045. /**
  33046. * Unlocks the audio engine once a user action has been done on the dom.
  33047. * This is helpful to resume play once browser policies have been satisfied.
  33048. */
  33049. unlock(): void;
  33050. private _resumeAudioContext;
  33051. private _initializeAudioContext;
  33052. private _tryToRun;
  33053. private _triggerRunningState;
  33054. private _triggerSuspendedState;
  33055. private _displayMuteButton;
  33056. private _moveButtonToTopLeft;
  33057. private _onResize;
  33058. private _hideMuteButton;
  33059. /**
  33060. * Destroy and release the resources associated with the audio ccontext.
  33061. */
  33062. dispose(): void;
  33063. /**
  33064. * Gets the global volume sets on the master gain.
  33065. * @returns the global volume if set or -1 otherwise
  33066. */
  33067. getGlobalVolume(): number;
  33068. /**
  33069. * Sets the global volume of your experience (sets on the master gain).
  33070. * @param newVolume Defines the new global volume of the application
  33071. */
  33072. setGlobalVolume(newVolume: number): void;
  33073. /**
  33074. * Connect the audio engine to an audio analyser allowing some amazing
  33075. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33077. * @param analyser The analyser to connect to the engine
  33078. */
  33079. connectToAnalyser(analyser: Analyser): void;
  33080. }
  33081. }
  33082. declare module BABYLON {
  33083. /**
  33084. * Interface used to present a loading screen while loading a scene
  33085. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33086. */
  33087. export interface ILoadingScreen {
  33088. /**
  33089. * Function called to display the loading screen
  33090. */
  33091. displayLoadingUI: () => void;
  33092. /**
  33093. * Function called to hide the loading screen
  33094. */
  33095. hideLoadingUI: () => void;
  33096. /**
  33097. * Gets or sets the color to use for the background
  33098. */
  33099. loadingUIBackgroundColor: string;
  33100. /**
  33101. * Gets or sets the text to display while loading
  33102. */
  33103. loadingUIText: string;
  33104. }
  33105. /**
  33106. * Class used for the default loading screen
  33107. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33108. */
  33109. export class DefaultLoadingScreen implements ILoadingScreen {
  33110. private _renderingCanvas;
  33111. private _loadingText;
  33112. private _loadingDivBackgroundColor;
  33113. private _loadingDiv;
  33114. private _loadingTextDiv;
  33115. /** Gets or sets the logo url to use for the default loading screen */
  33116. static DefaultLogoUrl: string;
  33117. /** Gets or sets the spinner url to use for the default loading screen */
  33118. static DefaultSpinnerUrl: string;
  33119. /**
  33120. * Creates a new default loading screen
  33121. * @param _renderingCanvas defines the canvas used to render the scene
  33122. * @param _loadingText defines the default text to display
  33123. * @param _loadingDivBackgroundColor defines the default background color
  33124. */
  33125. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33126. /**
  33127. * Function called to display the loading screen
  33128. */
  33129. displayLoadingUI(): void;
  33130. /**
  33131. * Function called to hide the loading screen
  33132. */
  33133. hideLoadingUI(): void;
  33134. /**
  33135. * Gets or sets the text to display while loading
  33136. */
  33137. set loadingUIText(text: string);
  33138. get loadingUIText(): string;
  33139. /**
  33140. * Gets or sets the color to use for the background
  33141. */
  33142. get loadingUIBackgroundColor(): string;
  33143. set loadingUIBackgroundColor(color: string);
  33144. private _resizeLoadingUI;
  33145. }
  33146. }
  33147. declare module BABYLON {
  33148. /**
  33149. * Interface for any object that can request an animation frame
  33150. */
  33151. export interface ICustomAnimationFrameRequester {
  33152. /**
  33153. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33154. */
  33155. renderFunction?: Function;
  33156. /**
  33157. * Called to request the next frame to render to
  33158. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33159. */
  33160. requestAnimationFrame: Function;
  33161. /**
  33162. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33163. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33164. */
  33165. requestID?: number;
  33166. }
  33167. }
  33168. declare module BABYLON {
  33169. /**
  33170. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33171. */
  33172. export class PerformanceMonitor {
  33173. private _enabled;
  33174. private _rollingFrameTime;
  33175. private _lastFrameTimeMs;
  33176. /**
  33177. * constructor
  33178. * @param frameSampleSize The number of samples required to saturate the sliding window
  33179. */
  33180. constructor(frameSampleSize?: number);
  33181. /**
  33182. * Samples current frame
  33183. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33184. */
  33185. sampleFrame(timeMs?: number): void;
  33186. /**
  33187. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33188. */
  33189. get averageFrameTime(): number;
  33190. /**
  33191. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33192. */
  33193. get averageFrameTimeVariance(): number;
  33194. /**
  33195. * Returns the frame time of the most recent frame
  33196. */
  33197. get instantaneousFrameTime(): number;
  33198. /**
  33199. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33200. */
  33201. get averageFPS(): number;
  33202. /**
  33203. * Returns the average framerate in frames per second using the most recent frame time
  33204. */
  33205. get instantaneousFPS(): number;
  33206. /**
  33207. * Returns true if enough samples have been taken to completely fill the sliding window
  33208. */
  33209. get isSaturated(): boolean;
  33210. /**
  33211. * Enables contributions to the sliding window sample set
  33212. */
  33213. enable(): void;
  33214. /**
  33215. * Disables contributions to the sliding window sample set
  33216. * Samples will not be interpolated over the disabled period
  33217. */
  33218. disable(): void;
  33219. /**
  33220. * Returns true if sampling is enabled
  33221. */
  33222. get isEnabled(): boolean;
  33223. /**
  33224. * Resets performance monitor
  33225. */
  33226. reset(): void;
  33227. }
  33228. /**
  33229. * RollingAverage
  33230. *
  33231. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33232. */
  33233. export class RollingAverage {
  33234. /**
  33235. * Current average
  33236. */
  33237. average: number;
  33238. /**
  33239. * Current variance
  33240. */
  33241. variance: number;
  33242. protected _samples: Array<number>;
  33243. protected _sampleCount: number;
  33244. protected _pos: number;
  33245. protected _m2: number;
  33246. /**
  33247. * constructor
  33248. * @param length The number of samples required to saturate the sliding window
  33249. */
  33250. constructor(length: number);
  33251. /**
  33252. * Adds a sample to the sample set
  33253. * @param v The sample value
  33254. */
  33255. add(v: number): void;
  33256. /**
  33257. * Returns previously added values or null if outside of history or outside the sliding window domain
  33258. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33259. * @return Value previously recorded with add() or null if outside of range
  33260. */
  33261. history(i: number): number;
  33262. /**
  33263. * Returns true if enough samples have been taken to completely fill the sliding window
  33264. * @return true if sample-set saturated
  33265. */
  33266. isSaturated(): boolean;
  33267. /**
  33268. * Resets the rolling average (equivalent to 0 samples taken so far)
  33269. */
  33270. reset(): void;
  33271. /**
  33272. * Wraps a value around the sample range boundaries
  33273. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33274. * @return Wrapped position in sample range
  33275. */
  33276. protected _wrapPosition(i: number): number;
  33277. }
  33278. }
  33279. declare module BABYLON {
  33280. /**
  33281. * This class is used to track a performance counter which is number based.
  33282. * The user has access to many properties which give statistics of different nature.
  33283. *
  33284. * The implementer can track two kinds of Performance Counter: time and count.
  33285. * 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.
  33286. * 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.
  33287. */
  33288. export class PerfCounter {
  33289. /**
  33290. * Gets or sets a global boolean to turn on and off all the counters
  33291. */
  33292. static Enabled: boolean;
  33293. /**
  33294. * Returns the smallest value ever
  33295. */
  33296. get min(): number;
  33297. /**
  33298. * Returns the biggest value ever
  33299. */
  33300. get max(): number;
  33301. /**
  33302. * Returns the average value since the performance counter is running
  33303. */
  33304. get average(): number;
  33305. /**
  33306. * Returns the average value of the last second the counter was monitored
  33307. */
  33308. get lastSecAverage(): number;
  33309. /**
  33310. * Returns the current value
  33311. */
  33312. get current(): number;
  33313. /**
  33314. * Gets the accumulated total
  33315. */
  33316. get total(): number;
  33317. /**
  33318. * Gets the total value count
  33319. */
  33320. get count(): number;
  33321. /**
  33322. * Creates a new counter
  33323. */
  33324. constructor();
  33325. /**
  33326. * Call this method to start monitoring a new frame.
  33327. * 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.
  33328. */
  33329. fetchNewFrame(): void;
  33330. /**
  33331. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33332. * @param newCount the count value to add to the monitored count
  33333. * @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.
  33334. */
  33335. addCount(newCount: number, fetchResult: boolean): void;
  33336. /**
  33337. * Start monitoring this performance counter
  33338. */
  33339. beginMonitoring(): void;
  33340. /**
  33341. * Compute the time lapsed since the previous beginMonitoring() call.
  33342. * @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
  33343. */
  33344. endMonitoring(newFrame?: boolean): void;
  33345. private _fetchResult;
  33346. private _startMonitoringTime;
  33347. private _min;
  33348. private _max;
  33349. private _average;
  33350. private _current;
  33351. private _totalValueCount;
  33352. private _totalAccumulated;
  33353. private _lastSecAverage;
  33354. private _lastSecAccumulated;
  33355. private _lastSecTime;
  33356. private _lastSecValueCount;
  33357. }
  33358. }
  33359. declare module BABYLON {
  33360. interface ThinEngine {
  33361. /**
  33362. * Sets alpha constants used by some alpha blending modes
  33363. * @param r defines the red component
  33364. * @param g defines the green component
  33365. * @param b defines the blue component
  33366. * @param a defines the alpha component
  33367. */
  33368. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33369. /**
  33370. * Sets the current alpha mode
  33371. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33372. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33373. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33374. */
  33375. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33376. /**
  33377. * Gets the current alpha mode
  33378. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33379. * @returns the current alpha mode
  33380. */
  33381. getAlphaMode(): number;
  33382. /**
  33383. * Sets the current alpha equation
  33384. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33385. */
  33386. setAlphaEquation(equation: number): void;
  33387. /**
  33388. * Gets the current alpha equation.
  33389. * @returns the current alpha equation
  33390. */
  33391. getAlphaEquation(): number;
  33392. }
  33393. }
  33394. declare module BABYLON {
  33395. /**
  33396. * Defines the interface used by display changed events
  33397. */
  33398. export interface IDisplayChangedEventArgs {
  33399. /** Gets the vrDisplay object (if any) */
  33400. vrDisplay: Nullable<any>;
  33401. /** Gets a boolean indicating if webVR is supported */
  33402. vrSupported: boolean;
  33403. }
  33404. /**
  33405. * Defines the interface used by objects containing a viewport (like a camera)
  33406. */
  33407. interface IViewportOwnerLike {
  33408. /**
  33409. * Gets or sets the viewport
  33410. */
  33411. viewport: IViewportLike;
  33412. }
  33413. /**
  33414. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33415. */
  33416. export class Engine extends ThinEngine {
  33417. /** Defines that alpha blending is disabled */
  33418. static readonly ALPHA_DISABLE: number;
  33419. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33420. static readonly ALPHA_ADD: number;
  33421. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33422. static readonly ALPHA_COMBINE: number;
  33423. /** Defines that alpha blending to DEST - SRC * DEST */
  33424. static readonly ALPHA_SUBTRACT: number;
  33425. /** Defines that alpha blending to SRC * DEST */
  33426. static readonly ALPHA_MULTIPLY: number;
  33427. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33428. static readonly ALPHA_MAXIMIZED: number;
  33429. /** Defines that alpha blending to SRC + DEST */
  33430. static readonly ALPHA_ONEONE: number;
  33431. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33432. static readonly ALPHA_PREMULTIPLIED: number;
  33433. /**
  33434. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33435. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33436. */
  33437. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33438. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33439. static readonly ALPHA_INTERPOLATE: number;
  33440. /**
  33441. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33442. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33443. */
  33444. static readonly ALPHA_SCREENMODE: number;
  33445. /** Defines that the ressource is not delayed*/
  33446. static readonly DELAYLOADSTATE_NONE: number;
  33447. /** Defines that the ressource was successfully delay loaded */
  33448. static readonly DELAYLOADSTATE_LOADED: number;
  33449. /** Defines that the ressource is currently delay loading */
  33450. static readonly DELAYLOADSTATE_LOADING: number;
  33451. /** Defines that the ressource is delayed and has not started loading */
  33452. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33453. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33454. static readonly NEVER: number;
  33455. /** 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 */
  33456. static readonly ALWAYS: number;
  33457. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33458. static readonly LESS: number;
  33459. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33460. static readonly EQUAL: number;
  33461. /** 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 */
  33462. static readonly LEQUAL: number;
  33463. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33464. static readonly GREATER: number;
  33465. /** 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 */
  33466. static readonly GEQUAL: number;
  33467. /** 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 */
  33468. static readonly NOTEQUAL: number;
  33469. /** Passed to stencilOperation to specify that stencil value must be kept */
  33470. static readonly KEEP: number;
  33471. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33472. static readonly REPLACE: number;
  33473. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33474. static readonly INCR: number;
  33475. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33476. static readonly DECR: number;
  33477. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33478. static readonly INVERT: number;
  33479. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33480. static readonly INCR_WRAP: number;
  33481. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33482. static readonly DECR_WRAP: number;
  33483. /** Texture is not repeating outside of 0..1 UVs */
  33484. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33485. /** Texture is repeating outside of 0..1 UVs */
  33486. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33487. /** Texture is repeating and mirrored */
  33488. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33489. /** ALPHA */
  33490. static readonly TEXTUREFORMAT_ALPHA: number;
  33491. /** LUMINANCE */
  33492. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33493. /** LUMINANCE_ALPHA */
  33494. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33495. /** RGB */
  33496. static readonly TEXTUREFORMAT_RGB: number;
  33497. /** RGBA */
  33498. static readonly TEXTUREFORMAT_RGBA: number;
  33499. /** RED */
  33500. static readonly TEXTUREFORMAT_RED: number;
  33501. /** RED (2nd reference) */
  33502. static readonly TEXTUREFORMAT_R: number;
  33503. /** RG */
  33504. static readonly TEXTUREFORMAT_RG: number;
  33505. /** RED_INTEGER */
  33506. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33507. /** RED_INTEGER (2nd reference) */
  33508. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33509. /** RG_INTEGER */
  33510. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33511. /** RGB_INTEGER */
  33512. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33513. /** RGBA_INTEGER */
  33514. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33515. /** UNSIGNED_BYTE */
  33516. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33517. /** UNSIGNED_BYTE (2nd reference) */
  33518. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33519. /** FLOAT */
  33520. static readonly TEXTURETYPE_FLOAT: number;
  33521. /** HALF_FLOAT */
  33522. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33523. /** BYTE */
  33524. static readonly TEXTURETYPE_BYTE: number;
  33525. /** SHORT */
  33526. static readonly TEXTURETYPE_SHORT: number;
  33527. /** UNSIGNED_SHORT */
  33528. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33529. /** INT */
  33530. static readonly TEXTURETYPE_INT: number;
  33531. /** UNSIGNED_INT */
  33532. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33533. /** UNSIGNED_SHORT_4_4_4_4 */
  33534. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33535. /** UNSIGNED_SHORT_5_5_5_1 */
  33536. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33537. /** UNSIGNED_SHORT_5_6_5 */
  33538. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33539. /** UNSIGNED_INT_2_10_10_10_REV */
  33540. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33541. /** UNSIGNED_INT_24_8 */
  33542. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33543. /** UNSIGNED_INT_10F_11F_11F_REV */
  33544. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33545. /** UNSIGNED_INT_5_9_9_9_REV */
  33546. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33547. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33548. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33549. /** nearest is mag = nearest and min = nearest and mip = linear */
  33550. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33551. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33552. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33553. /** Trilinear is mag = linear and min = linear and mip = linear */
  33554. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33555. /** nearest is mag = nearest and min = nearest and mip = linear */
  33556. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33557. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33558. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33559. /** Trilinear is mag = linear and min = linear and mip = linear */
  33560. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33561. /** mag = nearest and min = nearest and mip = nearest */
  33562. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33563. /** mag = nearest and min = linear and mip = nearest */
  33564. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33565. /** mag = nearest and min = linear and mip = linear */
  33566. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33567. /** mag = nearest and min = linear and mip = none */
  33568. static readonly TEXTURE_NEAREST_LINEAR: number;
  33569. /** mag = nearest and min = nearest and mip = none */
  33570. static readonly TEXTURE_NEAREST_NEAREST: number;
  33571. /** mag = linear and min = nearest and mip = nearest */
  33572. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33573. /** mag = linear and min = nearest and mip = linear */
  33574. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33575. /** mag = linear and min = linear and mip = none */
  33576. static readonly TEXTURE_LINEAR_LINEAR: number;
  33577. /** mag = linear and min = nearest and mip = none */
  33578. static readonly TEXTURE_LINEAR_NEAREST: number;
  33579. /** Explicit coordinates mode */
  33580. static readonly TEXTURE_EXPLICIT_MODE: number;
  33581. /** Spherical coordinates mode */
  33582. static readonly TEXTURE_SPHERICAL_MODE: number;
  33583. /** Planar coordinates mode */
  33584. static readonly TEXTURE_PLANAR_MODE: number;
  33585. /** Cubic coordinates mode */
  33586. static readonly TEXTURE_CUBIC_MODE: number;
  33587. /** Projection coordinates mode */
  33588. static readonly TEXTURE_PROJECTION_MODE: number;
  33589. /** Skybox coordinates mode */
  33590. static readonly TEXTURE_SKYBOX_MODE: number;
  33591. /** Inverse Cubic coordinates mode */
  33592. static readonly TEXTURE_INVCUBIC_MODE: number;
  33593. /** Equirectangular coordinates mode */
  33594. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33595. /** Equirectangular Fixed coordinates mode */
  33596. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33597. /** Equirectangular Fixed Mirrored coordinates mode */
  33598. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33599. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33600. static readonly SCALEMODE_FLOOR: number;
  33601. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33602. static readonly SCALEMODE_NEAREST: number;
  33603. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33604. static readonly SCALEMODE_CEILING: number;
  33605. /**
  33606. * Returns the current npm package of the sdk
  33607. */
  33608. static get NpmPackage(): string;
  33609. /**
  33610. * Returns the current version of the framework
  33611. */
  33612. static get Version(): string;
  33613. /** Gets the list of created engines */
  33614. static get Instances(): Engine[];
  33615. /**
  33616. * Gets the latest created engine
  33617. */
  33618. static get LastCreatedEngine(): Nullable<Engine>;
  33619. /**
  33620. * Gets the latest created scene
  33621. */
  33622. static get LastCreatedScene(): Nullable<Scene>;
  33623. /**
  33624. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33625. * @param flag defines which part of the materials must be marked as dirty
  33626. * @param predicate defines a predicate used to filter which materials should be affected
  33627. */
  33628. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33629. /**
  33630. * Method called to create the default loading screen.
  33631. * This can be overriden in your own app.
  33632. * @param canvas The rendering canvas element
  33633. * @returns The loading screen
  33634. */
  33635. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33636. /**
  33637. * Method called to create the default rescale post process on each engine.
  33638. */
  33639. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33640. /**
  33641. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33642. **/
  33643. enableOfflineSupport: boolean;
  33644. /**
  33645. * 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)
  33646. **/
  33647. disableManifestCheck: boolean;
  33648. /**
  33649. * Gets the list of created scenes
  33650. */
  33651. scenes: Scene[];
  33652. /**
  33653. * Event raised when a new scene is created
  33654. */
  33655. onNewSceneAddedObservable: Observable<Scene>;
  33656. /**
  33657. * Gets the list of created postprocesses
  33658. */
  33659. postProcesses: PostProcess[];
  33660. /**
  33661. * Gets a boolean indicating if the pointer is currently locked
  33662. */
  33663. isPointerLock: boolean;
  33664. /**
  33665. * Observable event triggered each time the rendering canvas is resized
  33666. */
  33667. onResizeObservable: Observable<Engine>;
  33668. /**
  33669. * Observable event triggered each time the canvas loses focus
  33670. */
  33671. onCanvasBlurObservable: Observable<Engine>;
  33672. /**
  33673. * Observable event triggered each time the canvas gains focus
  33674. */
  33675. onCanvasFocusObservable: Observable<Engine>;
  33676. /**
  33677. * Observable event triggered each time the canvas receives pointerout event
  33678. */
  33679. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33680. /**
  33681. * Observable raised when the engine begins a new frame
  33682. */
  33683. onBeginFrameObservable: Observable<Engine>;
  33684. /**
  33685. * If set, will be used to request the next animation frame for the render loop
  33686. */
  33687. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33688. /**
  33689. * Observable raised when the engine ends the current frame
  33690. */
  33691. onEndFrameObservable: Observable<Engine>;
  33692. /**
  33693. * Observable raised when the engine is about to compile a shader
  33694. */
  33695. onBeforeShaderCompilationObservable: Observable<Engine>;
  33696. /**
  33697. * Observable raised when the engine has jsut compiled a shader
  33698. */
  33699. onAfterShaderCompilationObservable: Observable<Engine>;
  33700. /**
  33701. * Gets the audio engine
  33702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33703. * @ignorenaming
  33704. */
  33705. static audioEngine: IAudioEngine;
  33706. /**
  33707. * Default AudioEngine factory responsible of creating the Audio Engine.
  33708. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33709. */
  33710. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33711. /**
  33712. * Default offline support factory responsible of creating a tool used to store data locally.
  33713. * By default, this will create a Database object if the workload has been embedded.
  33714. */
  33715. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33716. private _loadingScreen;
  33717. private _pointerLockRequested;
  33718. private _dummyFramebuffer;
  33719. private _rescalePostProcess;
  33720. private _deterministicLockstep;
  33721. private _lockstepMaxSteps;
  33722. private _timeStep;
  33723. protected get _supportsHardwareTextureRescaling(): boolean;
  33724. private _fps;
  33725. private _deltaTime;
  33726. /** @hidden */
  33727. _drawCalls: PerfCounter;
  33728. /** 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 */
  33729. canvasTabIndex: number;
  33730. /**
  33731. * Turn this value on if you want to pause FPS computation when in background
  33732. */
  33733. disablePerformanceMonitorInBackground: boolean;
  33734. private _performanceMonitor;
  33735. /**
  33736. * Gets the performance monitor attached to this engine
  33737. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33738. */
  33739. get performanceMonitor(): PerformanceMonitor;
  33740. private _onFocus;
  33741. private _onBlur;
  33742. private _onCanvasPointerOut;
  33743. private _onCanvasBlur;
  33744. private _onCanvasFocus;
  33745. private _onFullscreenChange;
  33746. private _onPointerLockChange;
  33747. /**
  33748. * Gets the HTML element used to attach event listeners
  33749. * @returns a HTML element
  33750. */
  33751. getInputElement(): Nullable<HTMLElement>;
  33752. /**
  33753. * Creates a new engine
  33754. * @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
  33755. * @param antialias defines enable antialiasing (default: false)
  33756. * @param options defines further options to be sent to the getContext() function
  33757. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33758. */
  33759. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33760. /**
  33761. * Gets current aspect ratio
  33762. * @param viewportOwner defines the camera to use to get the aspect ratio
  33763. * @param useScreen defines if screen size must be used (or the current render target if any)
  33764. * @returns a number defining the aspect ratio
  33765. */
  33766. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33767. /**
  33768. * Gets current screen aspect ratio
  33769. * @returns a number defining the aspect ratio
  33770. */
  33771. getScreenAspectRatio(): number;
  33772. /**
  33773. * Gets the client rect of the HTML canvas attached with the current webGL context
  33774. * @returns a client rectanglee
  33775. */
  33776. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33777. /**
  33778. * Gets the client rect of the HTML element used for events
  33779. * @returns a client rectanglee
  33780. */
  33781. getInputElementClientRect(): Nullable<ClientRect>;
  33782. /**
  33783. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33784. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33785. * @returns true if engine is in deterministic lock step mode
  33786. */
  33787. isDeterministicLockStep(): boolean;
  33788. /**
  33789. * Gets the max steps when engine is running in deterministic lock step
  33790. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33791. * @returns the max steps
  33792. */
  33793. getLockstepMaxSteps(): number;
  33794. /**
  33795. * Returns the time in ms between steps when using deterministic lock step.
  33796. * @returns time step in (ms)
  33797. */
  33798. getTimeStep(): number;
  33799. /**
  33800. * Force the mipmap generation for the given render target texture
  33801. * @param texture defines the render target texture to use
  33802. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33803. */
  33804. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33805. /** States */
  33806. /**
  33807. * Set various states to the webGL context
  33808. * @param culling defines backface culling state
  33809. * @param zOffset defines the value to apply to zOffset (0 by default)
  33810. * @param force defines if states must be applied even if cache is up to date
  33811. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33812. */
  33813. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33814. /**
  33815. * Set the z offset to apply to current rendering
  33816. * @param value defines the offset to apply
  33817. */
  33818. setZOffset(value: number): void;
  33819. /**
  33820. * Gets the current value of the zOffset
  33821. * @returns the current zOffset state
  33822. */
  33823. getZOffset(): number;
  33824. /**
  33825. * Enable or disable depth buffering
  33826. * @param enable defines the state to set
  33827. */
  33828. setDepthBuffer(enable: boolean): void;
  33829. /**
  33830. * Gets a boolean indicating if depth writing is enabled
  33831. * @returns the current depth writing state
  33832. */
  33833. getDepthWrite(): boolean;
  33834. /**
  33835. * Enable or disable depth writing
  33836. * @param enable defines the state to set
  33837. */
  33838. setDepthWrite(enable: boolean): void;
  33839. /**
  33840. * Gets a boolean indicating if stencil buffer is enabled
  33841. * @returns the current stencil buffer state
  33842. */
  33843. getStencilBuffer(): boolean;
  33844. /**
  33845. * Enable or disable the stencil buffer
  33846. * @param enable defines if the stencil buffer must be enabled or disabled
  33847. */
  33848. setStencilBuffer(enable: boolean): void;
  33849. /**
  33850. * Gets the current stencil mask
  33851. * @returns a number defining the new stencil mask to use
  33852. */
  33853. getStencilMask(): number;
  33854. /**
  33855. * Sets the current stencil mask
  33856. * @param mask defines the new stencil mask to use
  33857. */
  33858. setStencilMask(mask: number): void;
  33859. /**
  33860. * Gets the current stencil function
  33861. * @returns a number defining the stencil function to use
  33862. */
  33863. getStencilFunction(): number;
  33864. /**
  33865. * Gets the current stencil reference value
  33866. * @returns a number defining the stencil reference value to use
  33867. */
  33868. getStencilFunctionReference(): number;
  33869. /**
  33870. * Gets the current stencil mask
  33871. * @returns a number defining the stencil mask to use
  33872. */
  33873. getStencilFunctionMask(): number;
  33874. /**
  33875. * Sets the current stencil function
  33876. * @param stencilFunc defines the new stencil function to use
  33877. */
  33878. setStencilFunction(stencilFunc: number): void;
  33879. /**
  33880. * Sets the current stencil reference
  33881. * @param reference defines the new stencil reference to use
  33882. */
  33883. setStencilFunctionReference(reference: number): void;
  33884. /**
  33885. * Sets the current stencil mask
  33886. * @param mask defines the new stencil mask to use
  33887. */
  33888. setStencilFunctionMask(mask: number): void;
  33889. /**
  33890. * Gets the current stencil operation when stencil fails
  33891. * @returns a number defining stencil operation to use when stencil fails
  33892. */
  33893. getStencilOperationFail(): number;
  33894. /**
  33895. * Gets the current stencil operation when depth fails
  33896. * @returns a number defining stencil operation to use when depth fails
  33897. */
  33898. getStencilOperationDepthFail(): number;
  33899. /**
  33900. * Gets the current stencil operation when stencil passes
  33901. * @returns a number defining stencil operation to use when stencil passes
  33902. */
  33903. getStencilOperationPass(): number;
  33904. /**
  33905. * Sets the stencil operation to use when stencil fails
  33906. * @param operation defines the stencil operation to use when stencil fails
  33907. */
  33908. setStencilOperationFail(operation: number): void;
  33909. /**
  33910. * Sets the stencil operation to use when depth fails
  33911. * @param operation defines the stencil operation to use when depth fails
  33912. */
  33913. setStencilOperationDepthFail(operation: number): void;
  33914. /**
  33915. * Sets the stencil operation to use when stencil passes
  33916. * @param operation defines the stencil operation to use when stencil passes
  33917. */
  33918. setStencilOperationPass(operation: number): void;
  33919. /**
  33920. * Sets a boolean indicating if the dithering state is enabled or disabled
  33921. * @param value defines the dithering state
  33922. */
  33923. setDitheringState(value: boolean): void;
  33924. /**
  33925. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33926. * @param value defines the rasterizer state
  33927. */
  33928. setRasterizerState(value: boolean): void;
  33929. /**
  33930. * Gets the current depth function
  33931. * @returns a number defining the depth function
  33932. */
  33933. getDepthFunction(): Nullable<number>;
  33934. /**
  33935. * Sets the current depth function
  33936. * @param depthFunc defines the function to use
  33937. */
  33938. setDepthFunction(depthFunc: number): void;
  33939. /**
  33940. * Sets the current depth function to GREATER
  33941. */
  33942. setDepthFunctionToGreater(): void;
  33943. /**
  33944. * Sets the current depth function to GEQUAL
  33945. */
  33946. setDepthFunctionToGreaterOrEqual(): void;
  33947. /**
  33948. * Sets the current depth function to LESS
  33949. */
  33950. setDepthFunctionToLess(): void;
  33951. /**
  33952. * Sets the current depth function to LEQUAL
  33953. */
  33954. setDepthFunctionToLessOrEqual(): void;
  33955. private _cachedStencilBuffer;
  33956. private _cachedStencilFunction;
  33957. private _cachedStencilMask;
  33958. private _cachedStencilOperationPass;
  33959. private _cachedStencilOperationFail;
  33960. private _cachedStencilOperationDepthFail;
  33961. private _cachedStencilReference;
  33962. /**
  33963. * Caches the the state of the stencil buffer
  33964. */
  33965. cacheStencilState(): void;
  33966. /**
  33967. * Restores the state of the stencil buffer
  33968. */
  33969. restoreStencilState(): void;
  33970. /**
  33971. * Directly set the WebGL Viewport
  33972. * @param x defines the x coordinate of the viewport (in screen space)
  33973. * @param y defines the y coordinate of the viewport (in screen space)
  33974. * @param width defines the width of the viewport (in screen space)
  33975. * @param height defines the height of the viewport (in screen space)
  33976. * @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
  33977. */
  33978. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33979. /**
  33980. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33981. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33982. * @param y defines the y-coordinate of the corner of the clear rectangle
  33983. * @param width defines the width of the clear rectangle
  33984. * @param height defines the height of the clear rectangle
  33985. * @param clearColor defines the clear color
  33986. */
  33987. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33988. /**
  33989. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33990. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33991. * @param y defines the y-coordinate of the corner of the clear rectangle
  33992. * @param width defines the width of the clear rectangle
  33993. * @param height defines the height of the clear rectangle
  33994. */
  33995. enableScissor(x: number, y: number, width: number, height: number): void;
  33996. /**
  33997. * Disable previously set scissor test rectangle
  33998. */
  33999. disableScissor(): void;
  34000. protected _reportDrawCall(): void;
  34001. /**
  34002. * Initializes a webVR display and starts listening to display change events
  34003. * The onVRDisplayChangedObservable will be notified upon these changes
  34004. * @returns The onVRDisplayChangedObservable
  34005. */
  34006. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34007. /** @hidden */
  34008. _prepareVRComponent(): void;
  34009. /** @hidden */
  34010. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34011. /** @hidden */
  34012. _submitVRFrame(): void;
  34013. /**
  34014. * Call this function to leave webVR mode
  34015. * Will do nothing if webVR is not supported or if there is no webVR device
  34016. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34017. */
  34018. disableVR(): void;
  34019. /**
  34020. * Gets a boolean indicating that the system is in VR mode and is presenting
  34021. * @returns true if VR mode is engaged
  34022. */
  34023. isVRPresenting(): boolean;
  34024. /** @hidden */
  34025. _requestVRFrame(): void;
  34026. /** @hidden */
  34027. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34028. /**
  34029. * Gets the source code of the vertex shader associated with a specific webGL program
  34030. * @param program defines the program to use
  34031. * @returns a string containing the source code of the vertex shader associated with the program
  34032. */
  34033. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34034. /**
  34035. * Gets the source code of the fragment shader associated with a specific webGL program
  34036. * @param program defines the program to use
  34037. * @returns a string containing the source code of the fragment shader associated with the program
  34038. */
  34039. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34040. /**
  34041. * Sets a depth stencil texture from a render target to the according uniform.
  34042. * @param channel The texture channel
  34043. * @param uniform The uniform to set
  34044. * @param texture The render target texture containing the depth stencil texture to apply
  34045. */
  34046. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34047. /**
  34048. * Sets a texture to the webGL context from a postprocess
  34049. * @param channel defines the channel to use
  34050. * @param postProcess defines the source postprocess
  34051. */
  34052. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34053. /**
  34054. * Binds the output of the passed in post process to the texture channel specified
  34055. * @param channel The channel the texture should be bound to
  34056. * @param postProcess The post process which's output should be bound
  34057. */
  34058. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34059. /** @hidden */
  34060. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34061. protected _rebuildBuffers(): void;
  34062. /** @hidden */
  34063. _renderFrame(): void;
  34064. _renderLoop(): void;
  34065. /** @hidden */
  34066. _renderViews(): boolean;
  34067. /**
  34068. * Toggle full screen mode
  34069. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34070. */
  34071. switchFullscreen(requestPointerLock: boolean): void;
  34072. /**
  34073. * Enters full screen mode
  34074. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34075. */
  34076. enterFullscreen(requestPointerLock: boolean): void;
  34077. /**
  34078. * Exits full screen mode
  34079. */
  34080. exitFullscreen(): void;
  34081. /**
  34082. * Enters Pointerlock mode
  34083. */
  34084. enterPointerlock(): void;
  34085. /**
  34086. * Exits Pointerlock mode
  34087. */
  34088. exitPointerlock(): void;
  34089. /**
  34090. * Begin a new frame
  34091. */
  34092. beginFrame(): void;
  34093. /**
  34094. * Enf the current frame
  34095. */
  34096. endFrame(): void;
  34097. resize(): void;
  34098. /**
  34099. * Force a specific size of the canvas
  34100. * @param width defines the new canvas' width
  34101. * @param height defines the new canvas' height
  34102. */
  34103. setSize(width: number, height: number): void;
  34104. /**
  34105. * Updates a dynamic vertex buffer.
  34106. * @param vertexBuffer the vertex buffer to update
  34107. * @param data the data used to update the vertex buffer
  34108. * @param byteOffset the byte offset of the data
  34109. * @param byteLength the byte length of the data
  34110. */
  34111. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34112. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34113. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34114. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34115. _releaseTexture(texture: InternalTexture): void;
  34116. /**
  34117. * @hidden
  34118. * Rescales a texture
  34119. * @param source input texutre
  34120. * @param destination destination texture
  34121. * @param scene scene to use to render the resize
  34122. * @param internalFormat format to use when resizing
  34123. * @param onComplete callback to be called when resize has completed
  34124. */
  34125. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34126. /**
  34127. * Gets the current framerate
  34128. * @returns a number representing the framerate
  34129. */
  34130. getFps(): number;
  34131. /**
  34132. * Gets the time spent between current and previous frame
  34133. * @returns a number representing the delta time in ms
  34134. */
  34135. getDeltaTime(): number;
  34136. private _measureFps;
  34137. /** @hidden */
  34138. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34139. /**
  34140. * Update a dynamic index buffer
  34141. * @param indexBuffer defines the target index buffer
  34142. * @param indices defines the data to update
  34143. * @param offset defines the offset in the target index buffer where update should start
  34144. */
  34145. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34146. /**
  34147. * Updates the sample count of a render target texture
  34148. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34149. * @param texture defines the texture to update
  34150. * @param samples defines the sample count to set
  34151. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34152. */
  34153. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34154. /**
  34155. * Updates a depth texture Comparison Mode and Function.
  34156. * If the comparison Function is equal to 0, the mode will be set to none.
  34157. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34158. * @param texture The texture to set the comparison function for
  34159. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34160. */
  34161. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34162. /**
  34163. * Creates a webGL buffer to use with instanciation
  34164. * @param capacity defines the size of the buffer
  34165. * @returns the webGL buffer
  34166. */
  34167. createInstancesBuffer(capacity: number): DataBuffer;
  34168. /**
  34169. * Delete a webGL buffer used with instanciation
  34170. * @param buffer defines the webGL buffer to delete
  34171. */
  34172. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34173. private _clientWaitAsync;
  34174. /** @hidden */
  34175. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34176. /** @hidden */
  34177. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34178. dispose(): void;
  34179. private _disableTouchAction;
  34180. /**
  34181. * Display the loading screen
  34182. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34183. */
  34184. displayLoadingUI(): void;
  34185. /**
  34186. * Hide the loading screen
  34187. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34188. */
  34189. hideLoadingUI(): void;
  34190. /**
  34191. * Gets the current loading screen object
  34192. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34193. */
  34194. get loadingScreen(): ILoadingScreen;
  34195. /**
  34196. * Sets the current loading screen object
  34197. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34198. */
  34199. set loadingScreen(loadingScreen: ILoadingScreen);
  34200. /**
  34201. * Sets the current loading screen text
  34202. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34203. */
  34204. set loadingUIText(text: string);
  34205. /**
  34206. * Sets the current loading screen background color
  34207. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34208. */
  34209. set loadingUIBackgroundColor(color: string);
  34210. /** Pointerlock and fullscreen */
  34211. /**
  34212. * Ask the browser to promote the current element to pointerlock mode
  34213. * @param element defines the DOM element to promote
  34214. */
  34215. static _RequestPointerlock(element: HTMLElement): void;
  34216. /**
  34217. * Asks the browser to exit pointerlock mode
  34218. */
  34219. static _ExitPointerlock(): void;
  34220. /**
  34221. * Ask the browser to promote the current element to fullscreen rendering mode
  34222. * @param element defines the DOM element to promote
  34223. */
  34224. static _RequestFullscreen(element: HTMLElement): void;
  34225. /**
  34226. * Asks the browser to exit fullscreen mode
  34227. */
  34228. static _ExitFullscreen(): void;
  34229. }
  34230. }
  34231. declare module BABYLON {
  34232. /**
  34233. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34234. * during the life time of the application.
  34235. */
  34236. export class EngineStore {
  34237. /** Gets the list of created engines */
  34238. static Instances: Engine[];
  34239. /** @hidden */
  34240. static _LastCreatedScene: Nullable<Scene>;
  34241. /**
  34242. * Gets the latest created engine
  34243. */
  34244. static get LastCreatedEngine(): Nullable<Engine>;
  34245. /**
  34246. * Gets the latest created scene
  34247. */
  34248. static get LastCreatedScene(): Nullable<Scene>;
  34249. /**
  34250. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34251. * @ignorenaming
  34252. */
  34253. static UseFallbackTexture: boolean;
  34254. /**
  34255. * Texture content used if a texture cannot loaded
  34256. * @ignorenaming
  34257. */
  34258. static FallbackTexture: string;
  34259. }
  34260. }
  34261. declare module BABYLON {
  34262. /**
  34263. * Helper class that provides a small promise polyfill
  34264. */
  34265. export class PromisePolyfill {
  34266. /**
  34267. * Static function used to check if the polyfill is required
  34268. * If this is the case then the function will inject the polyfill to window.Promise
  34269. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34270. */
  34271. static Apply(force?: boolean): void;
  34272. }
  34273. }
  34274. declare module BABYLON {
  34275. /**
  34276. * Interface for screenshot methods with describe argument called `size` as object with options
  34277. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34278. */
  34279. export interface IScreenshotSize {
  34280. /**
  34281. * number in pixels for canvas height
  34282. */
  34283. height?: number;
  34284. /**
  34285. * multiplier allowing render at a higher or lower resolution
  34286. * If value is defined then height and width will be ignored and taken from camera
  34287. */
  34288. precision?: number;
  34289. /**
  34290. * number in pixels for canvas width
  34291. */
  34292. width?: number;
  34293. }
  34294. }
  34295. declare module BABYLON {
  34296. interface IColor4Like {
  34297. r: float;
  34298. g: float;
  34299. b: float;
  34300. a: float;
  34301. }
  34302. /**
  34303. * Class containing a set of static utilities functions
  34304. */
  34305. export class Tools {
  34306. /**
  34307. * Gets or sets the base URL to use to load assets
  34308. */
  34309. static get BaseUrl(): string;
  34310. static set BaseUrl(value: string);
  34311. /**
  34312. * Enable/Disable Custom HTTP Request Headers globally.
  34313. * default = false
  34314. * @see CustomRequestHeaders
  34315. */
  34316. static UseCustomRequestHeaders: boolean;
  34317. /**
  34318. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34319. * i.e. when loading files, where the server/service expects an Authorization header
  34320. */
  34321. static CustomRequestHeaders: {
  34322. [key: string]: string;
  34323. };
  34324. /**
  34325. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34326. */
  34327. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34328. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34329. /**
  34330. * Default behaviour for cors in the application.
  34331. * It can be a string if the expected behavior is identical in the entire app.
  34332. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34333. */
  34334. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34335. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34336. /**
  34337. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34338. * @ignorenaming
  34339. */
  34340. static get UseFallbackTexture(): boolean;
  34341. static set UseFallbackTexture(value: boolean);
  34342. /**
  34343. * Use this object to register external classes like custom textures or material
  34344. * to allow the laoders to instantiate them
  34345. */
  34346. static get RegisteredExternalClasses(): {
  34347. [key: string]: Object;
  34348. };
  34349. static set RegisteredExternalClasses(classes: {
  34350. [key: string]: Object;
  34351. });
  34352. /**
  34353. * Texture content used if a texture cannot loaded
  34354. * @ignorenaming
  34355. */
  34356. static get fallbackTexture(): string;
  34357. static set fallbackTexture(value: string);
  34358. /**
  34359. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34360. * @param u defines the coordinate on X axis
  34361. * @param v defines the coordinate on Y axis
  34362. * @param width defines the width of the source data
  34363. * @param height defines the height of the source data
  34364. * @param pixels defines the source byte array
  34365. * @param color defines the output color
  34366. */
  34367. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34368. /**
  34369. * Interpolates between a and b via alpha
  34370. * @param a The lower value (returned when alpha = 0)
  34371. * @param b The upper value (returned when alpha = 1)
  34372. * @param alpha The interpolation-factor
  34373. * @return The mixed value
  34374. */
  34375. static Mix(a: number, b: number, alpha: number): number;
  34376. /**
  34377. * Tries to instantiate a new object from a given class name
  34378. * @param className defines the class name to instantiate
  34379. * @returns the new object or null if the system was not able to do the instantiation
  34380. */
  34381. static Instantiate(className: string): any;
  34382. /**
  34383. * Provides a slice function that will work even on IE
  34384. * @param data defines the array to slice
  34385. * @param start defines the start of the data (optional)
  34386. * @param end defines the end of the data (optional)
  34387. * @returns the new sliced array
  34388. */
  34389. static Slice<T>(data: T, start?: number, end?: number): T;
  34390. /**
  34391. * Polyfill for setImmediate
  34392. * @param action defines the action to execute after the current execution block
  34393. */
  34394. static SetImmediate(action: () => void): void;
  34395. /**
  34396. * Function indicating if a number is an exponent of 2
  34397. * @param value defines the value to test
  34398. * @returns true if the value is an exponent of 2
  34399. */
  34400. static IsExponentOfTwo(value: number): boolean;
  34401. private static _tmpFloatArray;
  34402. /**
  34403. * Returns the nearest 32-bit single precision float representation of a Number
  34404. * @param value A Number. If the parameter is of a different type, it will get converted
  34405. * to a number or to NaN if it cannot be converted
  34406. * @returns number
  34407. */
  34408. static FloatRound(value: number): number;
  34409. /**
  34410. * Extracts the filename from a path
  34411. * @param path defines the path to use
  34412. * @returns the filename
  34413. */
  34414. static GetFilename(path: string): string;
  34415. /**
  34416. * Extracts the "folder" part of a path (everything before the filename).
  34417. * @param uri The URI to extract the info from
  34418. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34419. * @returns The "folder" part of the path
  34420. */
  34421. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34422. /**
  34423. * Extracts text content from a DOM element hierarchy
  34424. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34425. */
  34426. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34427. /**
  34428. * Convert an angle in radians to degrees
  34429. * @param angle defines the angle to convert
  34430. * @returns the angle in degrees
  34431. */
  34432. static ToDegrees(angle: number): number;
  34433. /**
  34434. * Convert an angle in degrees to radians
  34435. * @param angle defines the angle to convert
  34436. * @returns the angle in radians
  34437. */
  34438. static ToRadians(angle: number): number;
  34439. /**
  34440. * Returns an array if obj is not an array
  34441. * @param obj defines the object to evaluate as an array
  34442. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34443. * @returns either obj directly if obj is an array or a new array containing obj
  34444. */
  34445. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34446. /**
  34447. * Gets the pointer prefix to use
  34448. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34449. */
  34450. static GetPointerPrefix(): string;
  34451. /**
  34452. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34453. * @param url define the url we are trying
  34454. * @param element define the dom element where to configure the cors policy
  34455. */
  34456. static SetCorsBehavior(url: string | string[], element: {
  34457. crossOrigin: string | null;
  34458. }): void;
  34459. /**
  34460. * Removes unwanted characters from an url
  34461. * @param url defines the url to clean
  34462. * @returns the cleaned url
  34463. */
  34464. static CleanUrl(url: string): string;
  34465. /**
  34466. * Gets or sets a function used to pre-process url before using them to load assets
  34467. */
  34468. static get PreprocessUrl(): (url: string) => string;
  34469. static set PreprocessUrl(processor: (url: string) => string);
  34470. /**
  34471. * Loads an image as an HTMLImageElement.
  34472. * @param input url string, ArrayBuffer, or Blob to load
  34473. * @param onLoad callback called when the image successfully loads
  34474. * @param onError callback called when the image fails to load
  34475. * @param offlineProvider offline provider for caching
  34476. * @param mimeType optional mime type
  34477. * @returns the HTMLImageElement of the loaded image
  34478. */
  34479. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34480. /**
  34481. * Loads a file from a url
  34482. * @param url url string, ArrayBuffer, or Blob to load
  34483. * @param onSuccess callback called when the file successfully loads
  34484. * @param onProgress callback called while file is loading (if the server supports this mode)
  34485. * @param offlineProvider defines the offline provider for caching
  34486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34487. * @param onError callback called when the file fails to load
  34488. * @returns a file request object
  34489. */
  34490. 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;
  34491. /**
  34492. * Loads a file from a url
  34493. * @param url the file url to load
  34494. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34495. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34496. */
  34497. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34498. /**
  34499. * Load a script (identified by an url). When the url returns, the
  34500. * content of this file is added into a new script element, attached to the DOM (body element)
  34501. * @param scriptUrl defines the url of the script to laod
  34502. * @param onSuccess defines the callback called when the script is loaded
  34503. * @param onError defines the callback to call if an error occurs
  34504. * @param scriptId defines the id of the script element
  34505. */
  34506. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34507. /**
  34508. * Load an asynchronous script (identified by an url). When the url returns, the
  34509. * content of this file is added into a new script element, attached to the DOM (body element)
  34510. * @param scriptUrl defines the url of the script to laod
  34511. * @param scriptId defines the id of the script element
  34512. * @returns a promise request object
  34513. */
  34514. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34515. /**
  34516. * Loads a file from a blob
  34517. * @param fileToLoad defines the blob to use
  34518. * @param callback defines the callback to call when data is loaded
  34519. * @param progressCallback defines the callback to call during loading process
  34520. * @returns a file request object
  34521. */
  34522. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34523. /**
  34524. * Reads a file from a File object
  34525. * @param file defines the file to load
  34526. * @param onSuccess defines the callback to call when data is loaded
  34527. * @param onProgress defines the callback to call during loading process
  34528. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34529. * @param onError defines the callback to call when an error occurs
  34530. * @returns a file request object
  34531. */
  34532. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34533. /**
  34534. * Creates a data url from a given string content
  34535. * @param content defines the content to convert
  34536. * @returns the new data url link
  34537. */
  34538. static FileAsURL(content: string): string;
  34539. /**
  34540. * Format the given number to a specific decimal format
  34541. * @param value defines the number to format
  34542. * @param decimals defines the number of decimals to use
  34543. * @returns the formatted string
  34544. */
  34545. static Format(value: number, decimals?: number): string;
  34546. /**
  34547. * Tries to copy an object by duplicating every property
  34548. * @param source defines the source object
  34549. * @param destination defines the target object
  34550. * @param doNotCopyList defines a list of properties to avoid
  34551. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34552. */
  34553. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34554. /**
  34555. * Gets a boolean indicating if the given object has no own property
  34556. * @param obj defines the object to test
  34557. * @returns true if object has no own property
  34558. */
  34559. static IsEmpty(obj: any): boolean;
  34560. /**
  34561. * Function used to register events at window level
  34562. * @param windowElement defines the Window object to use
  34563. * @param events defines the events to register
  34564. */
  34565. static RegisterTopRootEvents(windowElement: Window, events: {
  34566. name: string;
  34567. handler: Nullable<(e: FocusEvent) => any>;
  34568. }[]): void;
  34569. /**
  34570. * Function used to unregister events from window level
  34571. * @param windowElement defines the Window object to use
  34572. * @param events defines the events to unregister
  34573. */
  34574. static UnregisterTopRootEvents(windowElement: Window, events: {
  34575. name: string;
  34576. handler: Nullable<(e: FocusEvent) => any>;
  34577. }[]): void;
  34578. /**
  34579. * @ignore
  34580. */
  34581. static _ScreenshotCanvas: HTMLCanvasElement;
  34582. /**
  34583. * Dumps the current bound framebuffer
  34584. * @param width defines the rendering width
  34585. * @param height defines the rendering height
  34586. * @param engine defines the hosting engine
  34587. * @param successCallback defines the callback triggered once the data are available
  34588. * @param mimeType defines the mime type of the result
  34589. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34590. */
  34591. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34592. /**
  34593. * Converts the canvas data to blob.
  34594. * This acts as a polyfill for browsers not supporting the to blob function.
  34595. * @param canvas Defines the canvas to extract the data from
  34596. * @param successCallback Defines the callback triggered once the data are available
  34597. * @param mimeType Defines the mime type of the result
  34598. */
  34599. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34600. /**
  34601. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34602. * @param successCallback defines the callback triggered once the data are available
  34603. * @param mimeType defines the mime type of the result
  34604. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34605. */
  34606. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34607. /**
  34608. * Downloads a blob in the browser
  34609. * @param blob defines the blob to download
  34610. * @param fileName defines the name of the downloaded file
  34611. */
  34612. static Download(blob: Blob, fileName: string): void;
  34613. /**
  34614. * Captures a screenshot of the current rendering
  34615. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34616. * @param engine defines the rendering engine
  34617. * @param camera defines the source camera
  34618. * @param size This parameter can be set to a single number or to an object with the
  34619. * following (optional) properties: precision, width, height. If a single number is passed,
  34620. * it will be used for both width and height. If an object is passed, the screenshot size
  34621. * will be derived from the parameters. The precision property is a multiplier allowing
  34622. * rendering at a higher or lower resolution
  34623. * @param successCallback defines the callback receives a single parameter which contains the
  34624. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34625. * src parameter of an <img> to display it
  34626. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34627. * Check your browser for supported MIME types
  34628. */
  34629. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34630. /**
  34631. * Captures a screenshot of the current rendering
  34632. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34633. * @param engine defines the rendering engine
  34634. * @param camera defines the source camera
  34635. * @param size This parameter can be set to a single number or to an object with the
  34636. * following (optional) properties: precision, width, height. If a single number is passed,
  34637. * it will be used for both width and height. If an object is passed, the screenshot size
  34638. * will be derived from the parameters. The precision property is a multiplier allowing
  34639. * rendering at a higher or lower resolution
  34640. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34641. * Check your browser for supported MIME types
  34642. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34643. * to the src parameter of an <img> to display it
  34644. */
  34645. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34646. /**
  34647. * Generates an image screenshot from the specified camera.
  34648. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34649. * @param engine The engine to use for rendering
  34650. * @param camera The camera to use for rendering
  34651. * @param size This parameter can be set to a single number or to an object with the
  34652. * following (optional) properties: precision, width, height. If a single number is passed,
  34653. * it will be used for both width and height. If an object is passed, the screenshot size
  34654. * will be derived from the parameters. The precision property is a multiplier allowing
  34655. * rendering at a higher or lower resolution
  34656. * @param successCallback The callback receives a single parameter which contains the
  34657. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34658. * src parameter of an <img> to display it
  34659. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34660. * Check your browser for supported MIME types
  34661. * @param samples Texture samples (default: 1)
  34662. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34663. * @param fileName A name for for the downloaded file.
  34664. */
  34665. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34666. /**
  34667. * Generates an image screenshot from the specified camera.
  34668. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34669. * @param engine The engine to use for rendering
  34670. * @param camera The camera to use for rendering
  34671. * @param size This parameter can be set to a single number or to an object with the
  34672. * following (optional) properties: precision, width, height. If a single number is passed,
  34673. * it will be used for both width and height. If an object is passed, the screenshot size
  34674. * will be derived from the parameters. The precision property is a multiplier allowing
  34675. * rendering at a higher or lower resolution
  34676. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34677. * Check your browser for supported MIME types
  34678. * @param samples Texture samples (default: 1)
  34679. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34680. * @param fileName A name for for the downloaded file.
  34681. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34682. * to the src parameter of an <img> to display it
  34683. */
  34684. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34685. /**
  34686. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34687. * Be aware Math.random() could cause collisions, but:
  34688. * "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"
  34689. * @returns a pseudo random id
  34690. */
  34691. static RandomId(): string;
  34692. /**
  34693. * Test if the given uri is a base64 string
  34694. * @param uri The uri to test
  34695. * @return True if the uri is a base64 string or false otherwise
  34696. */
  34697. static IsBase64(uri: string): boolean;
  34698. /**
  34699. * Decode the given base64 uri.
  34700. * @param uri The uri to decode
  34701. * @return The decoded base64 data.
  34702. */
  34703. static DecodeBase64(uri: string): ArrayBuffer;
  34704. /**
  34705. * Gets the absolute url.
  34706. * @param url the input url
  34707. * @return the absolute url
  34708. */
  34709. static GetAbsoluteUrl(url: string): string;
  34710. /**
  34711. * No log
  34712. */
  34713. static readonly NoneLogLevel: number;
  34714. /**
  34715. * Only message logs
  34716. */
  34717. static readonly MessageLogLevel: number;
  34718. /**
  34719. * Only warning logs
  34720. */
  34721. static readonly WarningLogLevel: number;
  34722. /**
  34723. * Only error logs
  34724. */
  34725. static readonly ErrorLogLevel: number;
  34726. /**
  34727. * All logs
  34728. */
  34729. static readonly AllLogLevel: number;
  34730. /**
  34731. * Gets a value indicating the number of loading errors
  34732. * @ignorenaming
  34733. */
  34734. static get errorsCount(): number;
  34735. /**
  34736. * Callback called when a new log is added
  34737. */
  34738. static OnNewCacheEntry: (entry: string) => void;
  34739. /**
  34740. * Log a message to the console
  34741. * @param message defines the message to log
  34742. */
  34743. static Log(message: string): void;
  34744. /**
  34745. * Write a warning message to the console
  34746. * @param message defines the message to log
  34747. */
  34748. static Warn(message: string): void;
  34749. /**
  34750. * Write an error message to the console
  34751. * @param message defines the message to log
  34752. */
  34753. static Error(message: string): void;
  34754. /**
  34755. * Gets current log cache (list of logs)
  34756. */
  34757. static get LogCache(): string;
  34758. /**
  34759. * Clears the log cache
  34760. */
  34761. static ClearLogCache(): void;
  34762. /**
  34763. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34764. */
  34765. static set LogLevels(level: number);
  34766. /**
  34767. * Checks if the window object exists
  34768. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34769. */
  34770. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34771. /**
  34772. * No performance log
  34773. */
  34774. static readonly PerformanceNoneLogLevel: number;
  34775. /**
  34776. * Use user marks to log performance
  34777. */
  34778. static readonly PerformanceUserMarkLogLevel: number;
  34779. /**
  34780. * Log performance to the console
  34781. */
  34782. static readonly PerformanceConsoleLogLevel: number;
  34783. private static _performance;
  34784. /**
  34785. * Sets the current performance log level
  34786. */
  34787. static set PerformanceLogLevel(level: number);
  34788. private static _StartPerformanceCounterDisabled;
  34789. private static _EndPerformanceCounterDisabled;
  34790. private static _StartUserMark;
  34791. private static _EndUserMark;
  34792. private static _StartPerformanceConsole;
  34793. private static _EndPerformanceConsole;
  34794. /**
  34795. * Starts a performance counter
  34796. */
  34797. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34798. /**
  34799. * Ends a specific performance coutner
  34800. */
  34801. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34802. /**
  34803. * Gets either window.performance.now() if supported or Date.now() else
  34804. */
  34805. static get Now(): number;
  34806. /**
  34807. * This method will return the name of the class used to create the instance of the given object.
  34808. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34809. * @param object the object to get the class name from
  34810. * @param isType defines if the object is actually a type
  34811. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34812. */
  34813. static GetClassName(object: any, isType?: boolean): string;
  34814. /**
  34815. * Gets the first element of an array satisfying a given predicate
  34816. * @param array defines the array to browse
  34817. * @param predicate defines the predicate to use
  34818. * @returns null if not found or the element
  34819. */
  34820. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34821. /**
  34822. * This method will return the name of the full name of the class, including its owning module (if any).
  34823. * 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).
  34824. * @param object the object to get the class name from
  34825. * @param isType defines if the object is actually a type
  34826. * @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.
  34827. * @ignorenaming
  34828. */
  34829. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34830. /**
  34831. * Returns a promise that resolves after the given amount of time.
  34832. * @param delay Number of milliseconds to delay
  34833. * @returns Promise that resolves after the given amount of time
  34834. */
  34835. static DelayAsync(delay: number): Promise<void>;
  34836. /**
  34837. * Utility function to detect if the current user agent is Safari
  34838. * @returns whether or not the current user agent is safari
  34839. */
  34840. static IsSafari(): boolean;
  34841. }
  34842. /**
  34843. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34844. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34845. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34846. * @param name The name of the class, case should be preserved
  34847. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34848. */
  34849. export function className(name: string, module?: string): (target: Object) => void;
  34850. /**
  34851. * An implementation of a loop for asynchronous functions.
  34852. */
  34853. export class AsyncLoop {
  34854. /**
  34855. * Defines the number of iterations for the loop
  34856. */
  34857. iterations: number;
  34858. /**
  34859. * Defines the current index of the loop.
  34860. */
  34861. index: number;
  34862. private _done;
  34863. private _fn;
  34864. private _successCallback;
  34865. /**
  34866. * Constructor.
  34867. * @param iterations the number of iterations.
  34868. * @param func the function to run each iteration
  34869. * @param successCallback the callback that will be called upon succesful execution
  34870. * @param offset starting offset.
  34871. */
  34872. constructor(
  34873. /**
  34874. * Defines the number of iterations for the loop
  34875. */
  34876. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34877. /**
  34878. * Execute the next iteration. Must be called after the last iteration was finished.
  34879. */
  34880. executeNext(): void;
  34881. /**
  34882. * Break the loop and run the success callback.
  34883. */
  34884. breakLoop(): void;
  34885. /**
  34886. * Create and run an async loop.
  34887. * @param iterations the number of iterations.
  34888. * @param fn the function to run each iteration
  34889. * @param successCallback the callback that will be called upon succesful execution
  34890. * @param offset starting offset.
  34891. * @returns the created async loop object
  34892. */
  34893. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34894. /**
  34895. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34896. * @param iterations total number of iterations
  34897. * @param syncedIterations number of synchronous iterations in each async iteration.
  34898. * @param fn the function to call each iteration.
  34899. * @param callback a success call back that will be called when iterating stops.
  34900. * @param breakFunction a break condition (optional)
  34901. * @param timeout timeout settings for the setTimeout function. default - 0.
  34902. * @returns the created async loop object
  34903. */
  34904. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34905. }
  34906. }
  34907. declare module BABYLON {
  34908. /**
  34909. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34910. * The underlying implementation relies on an associative array to ensure the best performances.
  34911. * The value can be anything including 'null' but except 'undefined'
  34912. */
  34913. export class StringDictionary<T> {
  34914. /**
  34915. * This will clear this dictionary and copy the content from the 'source' one.
  34916. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34917. * @param source the dictionary to take the content from and copy to this dictionary
  34918. */
  34919. copyFrom(source: StringDictionary<T>): void;
  34920. /**
  34921. * Get a value based from its key
  34922. * @param key the given key to get the matching value from
  34923. * @return the value if found, otherwise undefined is returned
  34924. */
  34925. get(key: string): T | undefined;
  34926. /**
  34927. * Get a value from its key or add it if it doesn't exist.
  34928. * This method will ensure you that a given key/data will be present in the dictionary.
  34929. * @param key the given key to get the matching value from
  34930. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34931. * The factory will only be invoked if there's no data for the given key.
  34932. * @return the value corresponding to the key.
  34933. */
  34934. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34935. /**
  34936. * Get a value from its key if present in the dictionary otherwise add it
  34937. * @param key the key to get the value from
  34938. * @param val if there's no such key/value pair in the dictionary add it with this value
  34939. * @return the value corresponding to the key
  34940. */
  34941. getOrAdd(key: string, val: T): T;
  34942. /**
  34943. * Check if there's a given key in the dictionary
  34944. * @param key the key to check for
  34945. * @return true if the key is present, false otherwise
  34946. */
  34947. contains(key: string): boolean;
  34948. /**
  34949. * Add a new key and its corresponding value
  34950. * @param key the key to add
  34951. * @param value the value corresponding to the key
  34952. * @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
  34953. */
  34954. add(key: string, value: T): boolean;
  34955. /**
  34956. * Update a specific value associated to a key
  34957. * @param key defines the key to use
  34958. * @param value defines the value to store
  34959. * @returns true if the value was updated (or false if the key was not found)
  34960. */
  34961. set(key: string, value: T): boolean;
  34962. /**
  34963. * Get the element of the given key and remove it from the dictionary
  34964. * @param key defines the key to search
  34965. * @returns the value associated with the key or null if not found
  34966. */
  34967. getAndRemove(key: string): Nullable<T>;
  34968. /**
  34969. * Remove a key/value from the dictionary.
  34970. * @param key the key to remove
  34971. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34972. */
  34973. remove(key: string): boolean;
  34974. /**
  34975. * Clear the whole content of the dictionary
  34976. */
  34977. clear(): void;
  34978. /**
  34979. * Gets the current count
  34980. */
  34981. get count(): number;
  34982. /**
  34983. * Execute a callback on each key/val of the dictionary.
  34984. * Note that you can remove any element in this dictionary in the callback implementation
  34985. * @param callback the callback to execute on a given key/value pair
  34986. */
  34987. forEach(callback: (key: string, val: T) => void): void;
  34988. /**
  34989. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34990. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34991. * Note that you can remove any element in this dictionary in the callback implementation
  34992. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34993. * @returns the first item
  34994. */
  34995. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34996. private _count;
  34997. private _data;
  34998. }
  34999. }
  35000. declare module BABYLON {
  35001. /** @hidden */
  35002. export interface ICollisionCoordinator {
  35003. createCollider(): Collider;
  35004. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35005. init(scene: Scene): void;
  35006. }
  35007. /** @hidden */
  35008. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35009. private _scene;
  35010. private _scaledPosition;
  35011. private _scaledVelocity;
  35012. private _finalPosition;
  35013. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35014. createCollider(): Collider;
  35015. init(scene: Scene): void;
  35016. private _collideWithWorld;
  35017. }
  35018. }
  35019. declare module BABYLON {
  35020. /**
  35021. * Class used to manage all inputs for the scene.
  35022. */
  35023. export class InputManager {
  35024. /** The distance in pixel that you have to move to prevent some events */
  35025. static DragMovementThreshold: number;
  35026. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35027. static LongPressDelay: number;
  35028. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35029. static DoubleClickDelay: number;
  35030. /** If you need to check double click without raising a single click at first click, enable this flag */
  35031. static ExclusiveDoubleClickMode: boolean;
  35032. private _wheelEventName;
  35033. private _onPointerMove;
  35034. private _onPointerDown;
  35035. private _onPointerUp;
  35036. private _initClickEvent;
  35037. private _initActionManager;
  35038. private _delayedSimpleClick;
  35039. private _delayedSimpleClickTimeout;
  35040. private _previousDelayedSimpleClickTimeout;
  35041. private _meshPickProceed;
  35042. private _previousButtonPressed;
  35043. private _currentPickResult;
  35044. private _previousPickResult;
  35045. private _totalPointersPressed;
  35046. private _doubleClickOccured;
  35047. private _pointerOverMesh;
  35048. private _pickedDownMesh;
  35049. private _pickedUpMesh;
  35050. private _pointerX;
  35051. private _pointerY;
  35052. private _unTranslatedPointerX;
  35053. private _unTranslatedPointerY;
  35054. private _startingPointerPosition;
  35055. private _previousStartingPointerPosition;
  35056. private _startingPointerTime;
  35057. private _previousStartingPointerTime;
  35058. private _pointerCaptures;
  35059. private _onKeyDown;
  35060. private _onKeyUp;
  35061. private _onCanvasFocusObserver;
  35062. private _onCanvasBlurObserver;
  35063. private _scene;
  35064. /**
  35065. * Creates a new InputManager
  35066. * @param scene defines the hosting scene
  35067. */
  35068. constructor(scene: Scene);
  35069. /**
  35070. * Gets the mesh that is currently under the pointer
  35071. */
  35072. get meshUnderPointer(): Nullable<AbstractMesh>;
  35073. /**
  35074. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35075. */
  35076. get unTranslatedPointer(): Vector2;
  35077. /**
  35078. * Gets or sets the current on-screen X position of the pointer
  35079. */
  35080. get pointerX(): number;
  35081. set pointerX(value: number);
  35082. /**
  35083. * Gets or sets the current on-screen Y position of the pointer
  35084. */
  35085. get pointerY(): number;
  35086. set pointerY(value: number);
  35087. private _updatePointerPosition;
  35088. private _processPointerMove;
  35089. private _setRayOnPointerInfo;
  35090. private _checkPrePointerObservable;
  35091. /**
  35092. * Use this method to simulate a pointer move on a mesh
  35093. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35094. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35095. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35096. */
  35097. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35098. /**
  35099. * Use this method to simulate a pointer down on a mesh
  35100. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35101. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35102. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35103. */
  35104. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35105. private _processPointerDown;
  35106. /** @hidden */
  35107. _isPointerSwiping(): boolean;
  35108. /**
  35109. * Use this method to simulate a pointer up on a mesh
  35110. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35111. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35112. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35113. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35114. */
  35115. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35116. private _processPointerUp;
  35117. /**
  35118. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35119. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35120. * @returns true if the pointer was captured
  35121. */
  35122. isPointerCaptured(pointerId?: number): boolean;
  35123. /**
  35124. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35125. * @param attachUp defines if you want to attach events to pointerup
  35126. * @param attachDown defines if you want to attach events to pointerdown
  35127. * @param attachMove defines if you want to attach events to pointermove
  35128. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35129. */
  35130. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35131. /**
  35132. * Detaches all event handlers
  35133. */
  35134. detachControl(): void;
  35135. /**
  35136. * Force the value of meshUnderPointer
  35137. * @param mesh defines the mesh to use
  35138. */
  35139. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35140. /**
  35141. * Gets the mesh under the pointer
  35142. * @returns a Mesh or null if no mesh is under the pointer
  35143. */
  35144. getPointerOverMesh(): Nullable<AbstractMesh>;
  35145. }
  35146. }
  35147. declare module BABYLON {
  35148. /**
  35149. * Helper class used to generate session unique ID
  35150. */
  35151. export class UniqueIdGenerator {
  35152. private static _UniqueIdCounter;
  35153. /**
  35154. * Gets an unique (relatively to the current scene) Id
  35155. */
  35156. static get UniqueId(): number;
  35157. }
  35158. }
  35159. declare module BABYLON {
  35160. /**
  35161. * This class defines the direct association between an animation and a target
  35162. */
  35163. export class TargetedAnimation {
  35164. /**
  35165. * Animation to perform
  35166. */
  35167. animation: Animation;
  35168. /**
  35169. * Target to animate
  35170. */
  35171. target: any;
  35172. /**
  35173. * Serialize the object
  35174. * @returns the JSON object representing the current entity
  35175. */
  35176. serialize(): any;
  35177. }
  35178. /**
  35179. * Use this class to create coordinated animations on multiple targets
  35180. */
  35181. export class AnimationGroup implements IDisposable {
  35182. /** The name of the animation group */
  35183. name: string;
  35184. private _scene;
  35185. private _targetedAnimations;
  35186. private _animatables;
  35187. private _from;
  35188. private _to;
  35189. private _isStarted;
  35190. private _isPaused;
  35191. private _speedRatio;
  35192. private _loopAnimation;
  35193. private _isAdditive;
  35194. /**
  35195. * Gets or sets the unique id of the node
  35196. */
  35197. uniqueId: number;
  35198. /**
  35199. * This observable will notify when one animation have ended
  35200. */
  35201. onAnimationEndObservable: Observable<TargetedAnimation>;
  35202. /**
  35203. * Observer raised when one animation loops
  35204. */
  35205. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35206. /**
  35207. * Observer raised when all animations have looped
  35208. */
  35209. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35210. /**
  35211. * This observable will notify when all animations have ended.
  35212. */
  35213. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35214. /**
  35215. * This observable will notify when all animations have paused.
  35216. */
  35217. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35218. /**
  35219. * This observable will notify when all animations are playing.
  35220. */
  35221. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35222. /**
  35223. * Gets the first frame
  35224. */
  35225. get from(): number;
  35226. /**
  35227. * Gets the last frame
  35228. */
  35229. get to(): number;
  35230. /**
  35231. * Define if the animations are started
  35232. */
  35233. get isStarted(): boolean;
  35234. /**
  35235. * Gets a value indicating that the current group is playing
  35236. */
  35237. get isPlaying(): boolean;
  35238. /**
  35239. * Gets or sets the speed ratio to use for all animations
  35240. */
  35241. get speedRatio(): number;
  35242. /**
  35243. * Gets or sets the speed ratio to use for all animations
  35244. */
  35245. set speedRatio(value: number);
  35246. /**
  35247. * Gets or sets if all animations should loop or not
  35248. */
  35249. get loopAnimation(): boolean;
  35250. set loopAnimation(value: boolean);
  35251. /**
  35252. * Gets or sets if all animations should be evaluated additively
  35253. */
  35254. get isAdditive(): boolean;
  35255. set isAdditive(value: boolean);
  35256. /**
  35257. * Gets the targeted animations for this animation group
  35258. */
  35259. get targetedAnimations(): Array<TargetedAnimation>;
  35260. /**
  35261. * returning the list of animatables controlled by this animation group.
  35262. */
  35263. get animatables(): Array<Animatable>;
  35264. /**
  35265. * Instantiates a new Animation Group.
  35266. * This helps managing several animations at once.
  35267. * @see http://doc.babylonjs.com/how_to/group
  35268. * @param name Defines the name of the group
  35269. * @param scene Defines the scene the group belongs to
  35270. */
  35271. constructor(
  35272. /** The name of the animation group */
  35273. name: string, scene?: Nullable<Scene>);
  35274. /**
  35275. * Add an animation (with its target) in the group
  35276. * @param animation defines the animation we want to add
  35277. * @param target defines the target of the animation
  35278. * @returns the TargetedAnimation object
  35279. */
  35280. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35281. /**
  35282. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35283. * It can add constant keys at begin or end
  35284. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35285. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35286. * @returns the animation group
  35287. */
  35288. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35289. private _animationLoopCount;
  35290. private _animationLoopFlags;
  35291. private _processLoop;
  35292. /**
  35293. * Start all animations on given targets
  35294. * @param loop defines if animations must loop
  35295. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35296. * @param from defines the from key (optional)
  35297. * @param to defines the to key (optional)
  35298. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35299. * @returns the current animation group
  35300. */
  35301. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35302. /**
  35303. * Pause all animations
  35304. * @returns the animation group
  35305. */
  35306. pause(): AnimationGroup;
  35307. /**
  35308. * Play all animations to initial state
  35309. * This function will start() the animations if they were not started or will restart() them if they were paused
  35310. * @param loop defines if animations must loop
  35311. * @returns the animation group
  35312. */
  35313. play(loop?: boolean): AnimationGroup;
  35314. /**
  35315. * Reset all animations to initial state
  35316. * @returns the animation group
  35317. */
  35318. reset(): AnimationGroup;
  35319. /**
  35320. * Restart animations from key 0
  35321. * @returns the animation group
  35322. */
  35323. restart(): AnimationGroup;
  35324. /**
  35325. * Stop all animations
  35326. * @returns the animation group
  35327. */
  35328. stop(): AnimationGroup;
  35329. /**
  35330. * Set animation weight for all animatables
  35331. * @param weight defines the weight to use
  35332. * @return the animationGroup
  35333. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35334. */
  35335. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35336. /**
  35337. * Synchronize and normalize all animatables with a source animatable
  35338. * @param root defines the root animatable to synchronize with
  35339. * @return the animationGroup
  35340. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35341. */
  35342. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35343. /**
  35344. * Goes to a specific frame in this animation group
  35345. * @param frame the frame number to go to
  35346. * @return the animationGroup
  35347. */
  35348. goToFrame(frame: number): AnimationGroup;
  35349. /**
  35350. * Dispose all associated resources
  35351. */
  35352. dispose(): void;
  35353. private _checkAnimationGroupEnded;
  35354. /**
  35355. * Clone the current animation group and returns a copy
  35356. * @param newName defines the name of the new group
  35357. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35358. * @returns the new aniamtion group
  35359. */
  35360. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35361. /**
  35362. * Serializes the animationGroup to an object
  35363. * @returns Serialized object
  35364. */
  35365. serialize(): any;
  35366. /**
  35367. * Returns a new AnimationGroup object parsed from the source provided.
  35368. * @param parsedAnimationGroup defines the source
  35369. * @param scene defines the scene that will receive the animationGroup
  35370. * @returns a new AnimationGroup
  35371. */
  35372. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35373. /**
  35374. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35375. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35376. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35377. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35378. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35379. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35380. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35381. */
  35382. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35383. /**
  35384. * Returns the string "AnimationGroup"
  35385. * @returns "AnimationGroup"
  35386. */
  35387. getClassName(): string;
  35388. /**
  35389. * Creates a detailled string about the object
  35390. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35391. * @returns a string representing the object
  35392. */
  35393. toString(fullDetails?: boolean): string;
  35394. }
  35395. }
  35396. declare module BABYLON {
  35397. /**
  35398. * Define an interface for all classes that will hold resources
  35399. */
  35400. export interface IDisposable {
  35401. /**
  35402. * Releases all held resources
  35403. */
  35404. dispose(): void;
  35405. }
  35406. /** Interface defining initialization parameters for Scene class */
  35407. export interface SceneOptions {
  35408. /**
  35409. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35410. * It will improve performance when the number of geometries becomes important.
  35411. */
  35412. useGeometryUniqueIdsMap?: boolean;
  35413. /**
  35414. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35415. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35416. */
  35417. useMaterialMeshMap?: boolean;
  35418. /**
  35419. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35420. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35421. */
  35422. useClonedMeshMap?: boolean;
  35423. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35424. virtual?: boolean;
  35425. }
  35426. /**
  35427. * Represents a scene to be rendered by the engine.
  35428. * @see http://doc.babylonjs.com/features/scene
  35429. */
  35430. export class Scene extends AbstractScene implements IAnimatable {
  35431. /** The fog is deactivated */
  35432. static readonly FOGMODE_NONE: number;
  35433. /** The fog density is following an exponential function */
  35434. static readonly FOGMODE_EXP: number;
  35435. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35436. static readonly FOGMODE_EXP2: number;
  35437. /** The fog density is following a linear function. */
  35438. static readonly FOGMODE_LINEAR: number;
  35439. /**
  35440. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35441. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35442. */
  35443. static MinDeltaTime: number;
  35444. /**
  35445. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35446. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35447. */
  35448. static MaxDeltaTime: number;
  35449. /**
  35450. * Factory used to create the default material.
  35451. * @param name The name of the material to create
  35452. * @param scene The scene to create the material for
  35453. * @returns The default material
  35454. */
  35455. static DefaultMaterialFactory(scene: Scene): Material;
  35456. /**
  35457. * Factory used to create the a collision coordinator.
  35458. * @returns The collision coordinator
  35459. */
  35460. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35461. /** @hidden */
  35462. _inputManager: InputManager;
  35463. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35464. cameraToUseForPointers: Nullable<Camera>;
  35465. /** @hidden */
  35466. readonly _isScene: boolean;
  35467. /** @hidden */
  35468. _blockEntityCollection: boolean;
  35469. /**
  35470. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35471. */
  35472. autoClear: boolean;
  35473. /**
  35474. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35475. */
  35476. autoClearDepthAndStencil: boolean;
  35477. /**
  35478. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35479. */
  35480. clearColor: Color4;
  35481. /**
  35482. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35483. */
  35484. ambientColor: Color3;
  35485. /**
  35486. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35487. * It should only be one of the following (if not the default embedded one):
  35488. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35489. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35490. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35491. * The material properties need to be setup according to the type of texture in use.
  35492. */
  35493. environmentBRDFTexture: BaseTexture;
  35494. /** @hidden */
  35495. protected _environmentTexture: Nullable<BaseTexture>;
  35496. /**
  35497. * Texture used in all pbr material as the reflection texture.
  35498. * As in the majority of the scene they are the same (exception for multi room and so on),
  35499. * this is easier to reference from here than from all the materials.
  35500. */
  35501. get environmentTexture(): Nullable<BaseTexture>;
  35502. /**
  35503. * Texture used in all pbr material as the reflection texture.
  35504. * As in the majority of the scene they are the same (exception for multi room and so on),
  35505. * this is easier to set here than in all the materials.
  35506. */
  35507. set environmentTexture(value: Nullable<BaseTexture>);
  35508. /** @hidden */
  35509. protected _environmentIntensity: number;
  35510. /**
  35511. * Intensity of the environment in all pbr material.
  35512. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35513. * As in the majority of the scene they are the same (exception for multi room and so on),
  35514. * this is easier to reference from here than from all the materials.
  35515. */
  35516. get environmentIntensity(): number;
  35517. /**
  35518. * Intensity of the environment in all pbr material.
  35519. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35520. * As in the majority of the scene they are the same (exception for multi room and so on),
  35521. * this is easier to set here than in all the materials.
  35522. */
  35523. set environmentIntensity(value: number);
  35524. /** @hidden */
  35525. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35526. /**
  35527. * Default image processing configuration used either in the rendering
  35528. * Forward main pass or through the imageProcessingPostProcess if present.
  35529. * As in the majority of the scene they are the same (exception for multi camera),
  35530. * this is easier to reference from here than from all the materials and post process.
  35531. *
  35532. * No setter as we it is a shared configuration, you can set the values instead.
  35533. */
  35534. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35535. private _forceWireframe;
  35536. /**
  35537. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35538. */
  35539. set forceWireframe(value: boolean);
  35540. get forceWireframe(): boolean;
  35541. private _skipFrustumClipping;
  35542. /**
  35543. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35544. */
  35545. set skipFrustumClipping(value: boolean);
  35546. get skipFrustumClipping(): boolean;
  35547. private _forcePointsCloud;
  35548. /**
  35549. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35550. */
  35551. set forcePointsCloud(value: boolean);
  35552. get forcePointsCloud(): boolean;
  35553. /**
  35554. * Gets or sets the active clipplane 1
  35555. */
  35556. clipPlane: Nullable<Plane>;
  35557. /**
  35558. * Gets or sets the active clipplane 2
  35559. */
  35560. clipPlane2: Nullable<Plane>;
  35561. /**
  35562. * Gets or sets the active clipplane 3
  35563. */
  35564. clipPlane3: Nullable<Plane>;
  35565. /**
  35566. * Gets or sets the active clipplane 4
  35567. */
  35568. clipPlane4: Nullable<Plane>;
  35569. /**
  35570. * Gets or sets the active clipplane 5
  35571. */
  35572. clipPlane5: Nullable<Plane>;
  35573. /**
  35574. * Gets or sets the active clipplane 6
  35575. */
  35576. clipPlane6: Nullable<Plane>;
  35577. /**
  35578. * Gets or sets a boolean indicating if animations are enabled
  35579. */
  35580. animationsEnabled: boolean;
  35581. private _animationPropertiesOverride;
  35582. /**
  35583. * Gets or sets the animation properties override
  35584. */
  35585. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35586. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35587. /**
  35588. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35589. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35590. */
  35591. useConstantAnimationDeltaTime: boolean;
  35592. /**
  35593. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35594. * Please note that it requires to run a ray cast through the scene on every frame
  35595. */
  35596. constantlyUpdateMeshUnderPointer: boolean;
  35597. /**
  35598. * Defines the HTML cursor to use when hovering over interactive elements
  35599. */
  35600. hoverCursor: string;
  35601. /**
  35602. * Defines the HTML default cursor to use (empty by default)
  35603. */
  35604. defaultCursor: string;
  35605. /**
  35606. * Defines whether cursors are handled by the scene.
  35607. */
  35608. doNotHandleCursors: boolean;
  35609. /**
  35610. * This is used to call preventDefault() on pointer down
  35611. * in order to block unwanted artifacts like system double clicks
  35612. */
  35613. preventDefaultOnPointerDown: boolean;
  35614. /**
  35615. * This is used to call preventDefault() on pointer up
  35616. * in order to block unwanted artifacts like system double clicks
  35617. */
  35618. preventDefaultOnPointerUp: boolean;
  35619. /**
  35620. * Gets or sets user defined metadata
  35621. */
  35622. metadata: any;
  35623. /**
  35624. * For internal use only. Please do not use.
  35625. */
  35626. reservedDataStore: any;
  35627. /**
  35628. * Gets the name of the plugin used to load this scene (null by default)
  35629. */
  35630. loadingPluginName: string;
  35631. /**
  35632. * Use this array to add regular expressions used to disable offline support for specific urls
  35633. */
  35634. disableOfflineSupportExceptionRules: RegExp[];
  35635. /**
  35636. * An event triggered when the scene is disposed.
  35637. */
  35638. onDisposeObservable: Observable<Scene>;
  35639. private _onDisposeObserver;
  35640. /** Sets a function to be executed when this scene is disposed. */
  35641. set onDispose(callback: () => void);
  35642. /**
  35643. * An event triggered before rendering the scene (right after animations and physics)
  35644. */
  35645. onBeforeRenderObservable: Observable<Scene>;
  35646. private _onBeforeRenderObserver;
  35647. /** Sets a function to be executed before rendering this scene */
  35648. set beforeRender(callback: Nullable<() => void>);
  35649. /**
  35650. * An event triggered after rendering the scene
  35651. */
  35652. onAfterRenderObservable: Observable<Scene>;
  35653. /**
  35654. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35655. */
  35656. onAfterRenderCameraObservable: Observable<Camera>;
  35657. private _onAfterRenderObserver;
  35658. /** Sets a function to be executed after rendering this scene */
  35659. set afterRender(callback: Nullable<() => void>);
  35660. /**
  35661. * An event triggered before animating the scene
  35662. */
  35663. onBeforeAnimationsObservable: Observable<Scene>;
  35664. /**
  35665. * An event triggered after animations processing
  35666. */
  35667. onAfterAnimationsObservable: Observable<Scene>;
  35668. /**
  35669. * An event triggered before draw calls are ready to be sent
  35670. */
  35671. onBeforeDrawPhaseObservable: Observable<Scene>;
  35672. /**
  35673. * An event triggered after draw calls have been sent
  35674. */
  35675. onAfterDrawPhaseObservable: Observable<Scene>;
  35676. /**
  35677. * An event triggered when the scene is ready
  35678. */
  35679. onReadyObservable: Observable<Scene>;
  35680. /**
  35681. * An event triggered before rendering a camera
  35682. */
  35683. onBeforeCameraRenderObservable: Observable<Camera>;
  35684. private _onBeforeCameraRenderObserver;
  35685. /** Sets a function to be executed before rendering a camera*/
  35686. set beforeCameraRender(callback: () => void);
  35687. /**
  35688. * An event triggered after rendering a camera
  35689. */
  35690. onAfterCameraRenderObservable: Observable<Camera>;
  35691. private _onAfterCameraRenderObserver;
  35692. /** Sets a function to be executed after rendering a camera*/
  35693. set afterCameraRender(callback: () => void);
  35694. /**
  35695. * An event triggered when active meshes evaluation is about to start
  35696. */
  35697. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35698. /**
  35699. * An event triggered when active meshes evaluation is done
  35700. */
  35701. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35702. /**
  35703. * An event triggered when particles rendering is about to start
  35704. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35705. */
  35706. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35707. /**
  35708. * An event triggered when particles rendering is done
  35709. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35710. */
  35711. onAfterParticlesRenderingObservable: Observable<Scene>;
  35712. /**
  35713. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35714. */
  35715. onDataLoadedObservable: Observable<Scene>;
  35716. /**
  35717. * An event triggered when a camera is created
  35718. */
  35719. onNewCameraAddedObservable: Observable<Camera>;
  35720. /**
  35721. * An event triggered when a camera is removed
  35722. */
  35723. onCameraRemovedObservable: Observable<Camera>;
  35724. /**
  35725. * An event triggered when a light is created
  35726. */
  35727. onNewLightAddedObservable: Observable<Light>;
  35728. /**
  35729. * An event triggered when a light is removed
  35730. */
  35731. onLightRemovedObservable: Observable<Light>;
  35732. /**
  35733. * An event triggered when a geometry is created
  35734. */
  35735. onNewGeometryAddedObservable: Observable<Geometry>;
  35736. /**
  35737. * An event triggered when a geometry is removed
  35738. */
  35739. onGeometryRemovedObservable: Observable<Geometry>;
  35740. /**
  35741. * An event triggered when a transform node is created
  35742. */
  35743. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35744. /**
  35745. * An event triggered when a transform node is removed
  35746. */
  35747. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35748. /**
  35749. * An event triggered when a mesh is created
  35750. */
  35751. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35752. /**
  35753. * An event triggered when a mesh is removed
  35754. */
  35755. onMeshRemovedObservable: Observable<AbstractMesh>;
  35756. /**
  35757. * An event triggered when a skeleton is created
  35758. */
  35759. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35760. /**
  35761. * An event triggered when a skeleton is removed
  35762. */
  35763. onSkeletonRemovedObservable: Observable<Skeleton>;
  35764. /**
  35765. * An event triggered when a material is created
  35766. */
  35767. onNewMaterialAddedObservable: Observable<Material>;
  35768. /**
  35769. * An event triggered when a material is removed
  35770. */
  35771. onMaterialRemovedObservable: Observable<Material>;
  35772. /**
  35773. * An event triggered when a texture is created
  35774. */
  35775. onNewTextureAddedObservable: Observable<BaseTexture>;
  35776. /**
  35777. * An event triggered when a texture is removed
  35778. */
  35779. onTextureRemovedObservable: Observable<BaseTexture>;
  35780. /**
  35781. * An event triggered when render targets are about to be rendered
  35782. * Can happen multiple times per frame.
  35783. */
  35784. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35785. /**
  35786. * An event triggered when render targets were rendered.
  35787. * Can happen multiple times per frame.
  35788. */
  35789. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35790. /**
  35791. * An event triggered before calculating deterministic simulation step
  35792. */
  35793. onBeforeStepObservable: Observable<Scene>;
  35794. /**
  35795. * An event triggered after calculating deterministic simulation step
  35796. */
  35797. onAfterStepObservable: Observable<Scene>;
  35798. /**
  35799. * An event triggered when the activeCamera property is updated
  35800. */
  35801. onActiveCameraChanged: Observable<Scene>;
  35802. /**
  35803. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35804. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35805. * 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)
  35806. */
  35807. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35808. /**
  35809. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35810. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35811. * 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)
  35812. */
  35813. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35814. /**
  35815. * This Observable will when a mesh has been imported into the scene.
  35816. */
  35817. onMeshImportedObservable: Observable<AbstractMesh>;
  35818. /**
  35819. * This Observable will when an animation file has been imported into the scene.
  35820. */
  35821. onAnimationFileImportedObservable: Observable<Scene>;
  35822. /**
  35823. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35824. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35825. */
  35826. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35827. /** @hidden */
  35828. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35829. /**
  35830. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35831. */
  35832. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35833. /**
  35834. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35835. */
  35836. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35837. /**
  35838. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35839. */
  35840. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35841. /** Callback called when a pointer move is detected */
  35842. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35843. /** Callback called when a pointer down is detected */
  35844. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35845. /** Callback called when a pointer up is detected */
  35846. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35847. /** Callback called when a pointer pick is detected */
  35848. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35849. /**
  35850. * 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).
  35851. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35852. */
  35853. onPrePointerObservable: Observable<PointerInfoPre>;
  35854. /**
  35855. * Observable event triggered each time an input event is received from the rendering canvas
  35856. */
  35857. onPointerObservable: Observable<PointerInfo>;
  35858. /**
  35859. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35860. */
  35861. get unTranslatedPointer(): Vector2;
  35862. /**
  35863. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35864. */
  35865. static get DragMovementThreshold(): number;
  35866. static set DragMovementThreshold(value: number);
  35867. /**
  35868. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35869. */
  35870. static get LongPressDelay(): number;
  35871. static set LongPressDelay(value: number);
  35872. /**
  35873. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35874. */
  35875. static get DoubleClickDelay(): number;
  35876. static set DoubleClickDelay(value: number);
  35877. /** If you need to check double click without raising a single click at first click, enable this flag */
  35878. static get ExclusiveDoubleClickMode(): boolean;
  35879. static set ExclusiveDoubleClickMode(value: boolean);
  35880. /** @hidden */
  35881. _mirroredCameraPosition: Nullable<Vector3>;
  35882. /**
  35883. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35884. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35885. */
  35886. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35887. /**
  35888. * Observable event triggered each time an keyboard event is received from the hosting window
  35889. */
  35890. onKeyboardObservable: Observable<KeyboardInfo>;
  35891. private _useRightHandedSystem;
  35892. /**
  35893. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35894. */
  35895. set useRightHandedSystem(value: boolean);
  35896. get useRightHandedSystem(): boolean;
  35897. private _timeAccumulator;
  35898. private _currentStepId;
  35899. private _currentInternalStep;
  35900. /**
  35901. * Sets the step Id used by deterministic lock step
  35902. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35903. * @param newStepId defines the step Id
  35904. */
  35905. setStepId(newStepId: number): void;
  35906. /**
  35907. * Gets the step Id used by deterministic lock step
  35908. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35909. * @returns the step Id
  35910. */
  35911. getStepId(): number;
  35912. /**
  35913. * Gets the internal step used by deterministic lock step
  35914. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35915. * @returns the internal step
  35916. */
  35917. getInternalStep(): number;
  35918. private _fogEnabled;
  35919. /**
  35920. * Gets or sets a boolean indicating if fog is enabled on this scene
  35921. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35922. * (Default is true)
  35923. */
  35924. set fogEnabled(value: boolean);
  35925. get fogEnabled(): boolean;
  35926. private _fogMode;
  35927. /**
  35928. * Gets or sets the fog mode to use
  35929. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35930. * | mode | value |
  35931. * | --- | --- |
  35932. * | FOGMODE_NONE | 0 |
  35933. * | FOGMODE_EXP | 1 |
  35934. * | FOGMODE_EXP2 | 2 |
  35935. * | FOGMODE_LINEAR | 3 |
  35936. */
  35937. set fogMode(value: number);
  35938. get fogMode(): number;
  35939. /**
  35940. * Gets or sets the fog color to use
  35941. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35942. * (Default is Color3(0.2, 0.2, 0.3))
  35943. */
  35944. fogColor: Color3;
  35945. /**
  35946. * Gets or sets the fog density to use
  35947. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35948. * (Default is 0.1)
  35949. */
  35950. fogDensity: number;
  35951. /**
  35952. * Gets or sets the fog start distance to use
  35953. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35954. * (Default is 0)
  35955. */
  35956. fogStart: number;
  35957. /**
  35958. * Gets or sets the fog end distance to use
  35959. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35960. * (Default is 1000)
  35961. */
  35962. fogEnd: number;
  35963. private _shadowsEnabled;
  35964. /**
  35965. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35966. */
  35967. set shadowsEnabled(value: boolean);
  35968. get shadowsEnabled(): boolean;
  35969. private _lightsEnabled;
  35970. /**
  35971. * Gets or sets a boolean indicating if lights are enabled on this scene
  35972. */
  35973. set lightsEnabled(value: boolean);
  35974. get lightsEnabled(): boolean;
  35975. /** All of the active cameras added to this scene. */
  35976. activeCameras: Camera[];
  35977. /** @hidden */
  35978. _activeCamera: Nullable<Camera>;
  35979. /** Gets or sets the current active camera */
  35980. get activeCamera(): Nullable<Camera>;
  35981. set activeCamera(value: Nullable<Camera>);
  35982. private _defaultMaterial;
  35983. /** The default material used on meshes when no material is affected */
  35984. get defaultMaterial(): Material;
  35985. /** The default material used on meshes when no material is affected */
  35986. set defaultMaterial(value: Material);
  35987. private _texturesEnabled;
  35988. /**
  35989. * Gets or sets a boolean indicating if textures are enabled on this scene
  35990. */
  35991. set texturesEnabled(value: boolean);
  35992. get texturesEnabled(): boolean;
  35993. /**
  35994. * Gets or sets a boolean indicating if particles are enabled on this scene
  35995. */
  35996. particlesEnabled: boolean;
  35997. /**
  35998. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35999. */
  36000. spritesEnabled: boolean;
  36001. private _skeletonsEnabled;
  36002. /**
  36003. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36004. */
  36005. set skeletonsEnabled(value: boolean);
  36006. get skeletonsEnabled(): boolean;
  36007. /**
  36008. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36009. */
  36010. lensFlaresEnabled: boolean;
  36011. /**
  36012. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36013. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36014. */
  36015. collisionsEnabled: boolean;
  36016. private _collisionCoordinator;
  36017. /** @hidden */
  36018. get collisionCoordinator(): ICollisionCoordinator;
  36019. /**
  36020. * Defines the gravity applied to this scene (used only for collisions)
  36021. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36022. */
  36023. gravity: Vector3;
  36024. /**
  36025. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36026. */
  36027. postProcessesEnabled: boolean;
  36028. /**
  36029. * The list of postprocesses added to the scene
  36030. */
  36031. postProcesses: PostProcess[];
  36032. /**
  36033. * Gets the current postprocess manager
  36034. */
  36035. postProcessManager: PostProcessManager;
  36036. /**
  36037. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36038. */
  36039. renderTargetsEnabled: boolean;
  36040. /**
  36041. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36042. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36043. */
  36044. dumpNextRenderTargets: boolean;
  36045. /**
  36046. * The list of user defined render targets added to the scene
  36047. */
  36048. customRenderTargets: RenderTargetTexture[];
  36049. /**
  36050. * Defines if texture loading must be delayed
  36051. * If true, textures will only be loaded when they need to be rendered
  36052. */
  36053. useDelayedTextureLoading: boolean;
  36054. /**
  36055. * Gets the list of meshes imported to the scene through SceneLoader
  36056. */
  36057. importedMeshesFiles: String[];
  36058. /**
  36059. * Gets or sets a boolean indicating if probes are enabled on this scene
  36060. */
  36061. probesEnabled: boolean;
  36062. /**
  36063. * Gets or sets the current offline provider to use to store scene data
  36064. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36065. */
  36066. offlineProvider: IOfflineProvider;
  36067. /**
  36068. * Gets or sets the action manager associated with the scene
  36069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36070. */
  36071. actionManager: AbstractActionManager;
  36072. private _meshesForIntersections;
  36073. /**
  36074. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36075. */
  36076. proceduralTexturesEnabled: boolean;
  36077. private _engine;
  36078. private _totalVertices;
  36079. /** @hidden */
  36080. _activeIndices: PerfCounter;
  36081. /** @hidden */
  36082. _activeParticles: PerfCounter;
  36083. /** @hidden */
  36084. _activeBones: PerfCounter;
  36085. private _animationRatio;
  36086. /** @hidden */
  36087. _animationTimeLast: number;
  36088. /** @hidden */
  36089. _animationTime: number;
  36090. /**
  36091. * Gets or sets a general scale for animation speed
  36092. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36093. */
  36094. animationTimeScale: number;
  36095. /** @hidden */
  36096. _cachedMaterial: Nullable<Material>;
  36097. /** @hidden */
  36098. _cachedEffect: Nullable<Effect>;
  36099. /** @hidden */
  36100. _cachedVisibility: Nullable<number>;
  36101. private _renderId;
  36102. private _frameId;
  36103. private _executeWhenReadyTimeoutId;
  36104. private _intermediateRendering;
  36105. private _viewUpdateFlag;
  36106. private _projectionUpdateFlag;
  36107. /** @hidden */
  36108. _toBeDisposed: Nullable<IDisposable>[];
  36109. private _activeRequests;
  36110. /** @hidden */
  36111. _pendingData: any[];
  36112. private _isDisposed;
  36113. /**
  36114. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36115. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36116. */
  36117. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36118. private _activeMeshes;
  36119. private _processedMaterials;
  36120. private _renderTargets;
  36121. /** @hidden */
  36122. _activeParticleSystems: SmartArray<IParticleSystem>;
  36123. private _activeSkeletons;
  36124. private _softwareSkinnedMeshes;
  36125. private _renderingManager;
  36126. /** @hidden */
  36127. _activeAnimatables: Animatable[];
  36128. private _transformMatrix;
  36129. private _sceneUbo;
  36130. /** @hidden */
  36131. _viewMatrix: Matrix;
  36132. private _projectionMatrix;
  36133. /** @hidden */
  36134. _forcedViewPosition: Nullable<Vector3>;
  36135. /** @hidden */
  36136. _frustumPlanes: Plane[];
  36137. /**
  36138. * Gets the list of frustum planes (built from the active camera)
  36139. */
  36140. get frustumPlanes(): Plane[];
  36141. /**
  36142. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36143. * This is useful if there are more lights that the maximum simulteanous authorized
  36144. */
  36145. requireLightSorting: boolean;
  36146. /** @hidden */
  36147. readonly useMaterialMeshMap: boolean;
  36148. /** @hidden */
  36149. readonly useClonedMeshMap: boolean;
  36150. private _externalData;
  36151. private _uid;
  36152. /**
  36153. * @hidden
  36154. * Backing store of defined scene components.
  36155. */
  36156. _components: ISceneComponent[];
  36157. /**
  36158. * @hidden
  36159. * Backing store of defined scene components.
  36160. */
  36161. _serializableComponents: ISceneSerializableComponent[];
  36162. /**
  36163. * List of components to register on the next registration step.
  36164. */
  36165. private _transientComponents;
  36166. /**
  36167. * Registers the transient components if needed.
  36168. */
  36169. private _registerTransientComponents;
  36170. /**
  36171. * @hidden
  36172. * Add a component to the scene.
  36173. * Note that the ccomponent could be registered on th next frame if this is called after
  36174. * the register component stage.
  36175. * @param component Defines the component to add to the scene
  36176. */
  36177. _addComponent(component: ISceneComponent): void;
  36178. /**
  36179. * @hidden
  36180. * Gets a component from the scene.
  36181. * @param name defines the name of the component to retrieve
  36182. * @returns the component or null if not present
  36183. */
  36184. _getComponent(name: string): Nullable<ISceneComponent>;
  36185. /**
  36186. * @hidden
  36187. * Defines the actions happening before camera updates.
  36188. */
  36189. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36190. /**
  36191. * @hidden
  36192. * Defines the actions happening before clear the canvas.
  36193. */
  36194. _beforeClearStage: Stage<SimpleStageAction>;
  36195. /**
  36196. * @hidden
  36197. * Defines the actions when collecting render targets for the frame.
  36198. */
  36199. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36200. /**
  36201. * @hidden
  36202. * Defines the actions happening for one camera in the frame.
  36203. */
  36204. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36205. /**
  36206. * @hidden
  36207. * Defines the actions happening during the per mesh ready checks.
  36208. */
  36209. _isReadyForMeshStage: Stage<MeshStageAction>;
  36210. /**
  36211. * @hidden
  36212. * Defines the actions happening before evaluate active mesh checks.
  36213. */
  36214. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36215. /**
  36216. * @hidden
  36217. * Defines the actions happening during the evaluate sub mesh checks.
  36218. */
  36219. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36220. /**
  36221. * @hidden
  36222. * Defines the actions happening during the active mesh stage.
  36223. */
  36224. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36225. /**
  36226. * @hidden
  36227. * Defines the actions happening during the per camera render target step.
  36228. */
  36229. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36230. /**
  36231. * @hidden
  36232. * Defines the actions happening just before the active camera is drawing.
  36233. */
  36234. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36235. /**
  36236. * @hidden
  36237. * Defines the actions happening just before a render target is drawing.
  36238. */
  36239. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36240. /**
  36241. * @hidden
  36242. * Defines the actions happening just before a rendering group is drawing.
  36243. */
  36244. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36245. /**
  36246. * @hidden
  36247. * Defines the actions happening just before a mesh is drawing.
  36248. */
  36249. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36250. /**
  36251. * @hidden
  36252. * Defines the actions happening just after a mesh has been drawn.
  36253. */
  36254. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36255. /**
  36256. * @hidden
  36257. * Defines the actions happening just after a rendering group has been drawn.
  36258. */
  36259. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36260. /**
  36261. * @hidden
  36262. * Defines the actions happening just after the active camera has been drawn.
  36263. */
  36264. _afterCameraDrawStage: Stage<CameraStageAction>;
  36265. /**
  36266. * @hidden
  36267. * Defines the actions happening just after a render target has been drawn.
  36268. */
  36269. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36270. /**
  36271. * @hidden
  36272. * Defines the actions happening just after rendering all cameras and computing intersections.
  36273. */
  36274. _afterRenderStage: Stage<SimpleStageAction>;
  36275. /**
  36276. * @hidden
  36277. * Defines the actions happening when a pointer move event happens.
  36278. */
  36279. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36280. /**
  36281. * @hidden
  36282. * Defines the actions happening when a pointer down event happens.
  36283. */
  36284. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36285. /**
  36286. * @hidden
  36287. * Defines the actions happening when a pointer up event happens.
  36288. */
  36289. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36290. /**
  36291. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36292. */
  36293. private geometriesByUniqueId;
  36294. /**
  36295. * Creates a new Scene
  36296. * @param engine defines the engine to use to render this scene
  36297. * @param options defines the scene options
  36298. */
  36299. constructor(engine: Engine, options?: SceneOptions);
  36300. /**
  36301. * Gets a string idenfifying the name of the class
  36302. * @returns "Scene" string
  36303. */
  36304. getClassName(): string;
  36305. private _defaultMeshCandidates;
  36306. /**
  36307. * @hidden
  36308. */
  36309. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36310. private _defaultSubMeshCandidates;
  36311. /**
  36312. * @hidden
  36313. */
  36314. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36315. /**
  36316. * Sets the default candidate providers for the scene.
  36317. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36318. * and getCollidingSubMeshCandidates to their default function
  36319. */
  36320. setDefaultCandidateProviders(): void;
  36321. /**
  36322. * Gets the mesh that is currently under the pointer
  36323. */
  36324. get meshUnderPointer(): Nullable<AbstractMesh>;
  36325. /**
  36326. * Gets or sets the current on-screen X position of the pointer
  36327. */
  36328. get pointerX(): number;
  36329. set pointerX(value: number);
  36330. /**
  36331. * Gets or sets the current on-screen Y position of the pointer
  36332. */
  36333. get pointerY(): number;
  36334. set pointerY(value: number);
  36335. /**
  36336. * Gets the cached material (ie. the latest rendered one)
  36337. * @returns the cached material
  36338. */
  36339. getCachedMaterial(): Nullable<Material>;
  36340. /**
  36341. * Gets the cached effect (ie. the latest rendered one)
  36342. * @returns the cached effect
  36343. */
  36344. getCachedEffect(): Nullable<Effect>;
  36345. /**
  36346. * Gets the cached visibility state (ie. the latest rendered one)
  36347. * @returns the cached visibility state
  36348. */
  36349. getCachedVisibility(): Nullable<number>;
  36350. /**
  36351. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36352. * @param material defines the current material
  36353. * @param effect defines the current effect
  36354. * @param visibility defines the current visibility state
  36355. * @returns true if one parameter is not cached
  36356. */
  36357. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36358. /**
  36359. * Gets the engine associated with the scene
  36360. * @returns an Engine
  36361. */
  36362. getEngine(): Engine;
  36363. /**
  36364. * Gets the total number of vertices rendered per frame
  36365. * @returns the total number of vertices rendered per frame
  36366. */
  36367. getTotalVertices(): number;
  36368. /**
  36369. * Gets the performance counter for total vertices
  36370. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36371. */
  36372. get totalVerticesPerfCounter(): PerfCounter;
  36373. /**
  36374. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36375. * @returns the total number of active indices rendered per frame
  36376. */
  36377. getActiveIndices(): number;
  36378. /**
  36379. * Gets the performance counter for active indices
  36380. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36381. */
  36382. get totalActiveIndicesPerfCounter(): PerfCounter;
  36383. /**
  36384. * Gets the total number of active particles rendered per frame
  36385. * @returns the total number of active particles rendered per frame
  36386. */
  36387. getActiveParticles(): number;
  36388. /**
  36389. * Gets the performance counter for active particles
  36390. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36391. */
  36392. get activeParticlesPerfCounter(): PerfCounter;
  36393. /**
  36394. * Gets the total number of active bones rendered per frame
  36395. * @returns the total number of active bones rendered per frame
  36396. */
  36397. getActiveBones(): number;
  36398. /**
  36399. * Gets the performance counter for active bones
  36400. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36401. */
  36402. get activeBonesPerfCounter(): PerfCounter;
  36403. /**
  36404. * Gets the array of active meshes
  36405. * @returns an array of AbstractMesh
  36406. */
  36407. getActiveMeshes(): SmartArray<AbstractMesh>;
  36408. /**
  36409. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36410. * @returns a number
  36411. */
  36412. getAnimationRatio(): number;
  36413. /**
  36414. * Gets an unique Id for the current render phase
  36415. * @returns a number
  36416. */
  36417. getRenderId(): number;
  36418. /**
  36419. * Gets an unique Id for the current frame
  36420. * @returns a number
  36421. */
  36422. getFrameId(): number;
  36423. /** Call this function if you want to manually increment the render Id*/
  36424. incrementRenderId(): void;
  36425. private _createUbo;
  36426. /**
  36427. * Use this method to simulate a pointer move on a mesh
  36428. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36429. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36430. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36431. * @returns the current scene
  36432. */
  36433. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36434. /**
  36435. * Use this method to simulate a pointer down on a mesh
  36436. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36437. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36438. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36439. * @returns the current scene
  36440. */
  36441. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36442. /**
  36443. * Use this method to simulate a pointer up on a mesh
  36444. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36445. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36446. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36447. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36448. * @returns the current scene
  36449. */
  36450. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36451. /**
  36452. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36453. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36454. * @returns true if the pointer was captured
  36455. */
  36456. isPointerCaptured(pointerId?: number): boolean;
  36457. /**
  36458. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36459. * @param attachUp defines if you want to attach events to pointerup
  36460. * @param attachDown defines if you want to attach events to pointerdown
  36461. * @param attachMove defines if you want to attach events to pointermove
  36462. */
  36463. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36464. /** Detaches all event handlers*/
  36465. detachControl(): void;
  36466. /**
  36467. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36468. * Delay loaded resources are not taking in account
  36469. * @return true if all required resources are ready
  36470. */
  36471. isReady(): boolean;
  36472. /** Resets all cached information relative to material (including effect and visibility) */
  36473. resetCachedMaterial(): void;
  36474. /**
  36475. * Registers a function to be called before every frame render
  36476. * @param func defines the function to register
  36477. */
  36478. registerBeforeRender(func: () => void): void;
  36479. /**
  36480. * Unregisters a function called before every frame render
  36481. * @param func defines the function to unregister
  36482. */
  36483. unregisterBeforeRender(func: () => void): void;
  36484. /**
  36485. * Registers a function to be called after every frame render
  36486. * @param func defines the function to register
  36487. */
  36488. registerAfterRender(func: () => void): void;
  36489. /**
  36490. * Unregisters a function called after every frame render
  36491. * @param func defines the function to unregister
  36492. */
  36493. unregisterAfterRender(func: () => void): void;
  36494. private _executeOnceBeforeRender;
  36495. /**
  36496. * The provided function will run before render once and will be disposed afterwards.
  36497. * A timeout delay can be provided so that the function will be executed in N ms.
  36498. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36499. * @param func The function to be executed.
  36500. * @param timeout optional delay in ms
  36501. */
  36502. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36503. /** @hidden */
  36504. _addPendingData(data: any): void;
  36505. /** @hidden */
  36506. _removePendingData(data: any): void;
  36507. /**
  36508. * Returns the number of items waiting to be loaded
  36509. * @returns the number of items waiting to be loaded
  36510. */
  36511. getWaitingItemsCount(): number;
  36512. /**
  36513. * Returns a boolean indicating if the scene is still loading data
  36514. */
  36515. get isLoading(): boolean;
  36516. /**
  36517. * Registers a function to be executed when the scene is ready
  36518. * @param {Function} func - the function to be executed
  36519. */
  36520. executeWhenReady(func: () => void): void;
  36521. /**
  36522. * Returns a promise that resolves when the scene is ready
  36523. * @returns A promise that resolves when the scene is ready
  36524. */
  36525. whenReadyAsync(): Promise<void>;
  36526. /** @hidden */
  36527. _checkIsReady(): void;
  36528. /**
  36529. * Gets all animatable attached to the scene
  36530. */
  36531. get animatables(): Animatable[];
  36532. /**
  36533. * Resets the last animation time frame.
  36534. * Useful to override when animations start running when loading a scene for the first time.
  36535. */
  36536. resetLastAnimationTimeFrame(): void;
  36537. /**
  36538. * Gets the current view matrix
  36539. * @returns a Matrix
  36540. */
  36541. getViewMatrix(): Matrix;
  36542. /**
  36543. * Gets the current projection matrix
  36544. * @returns a Matrix
  36545. */
  36546. getProjectionMatrix(): Matrix;
  36547. /**
  36548. * Gets the current transform matrix
  36549. * @returns a Matrix made of View * Projection
  36550. */
  36551. getTransformMatrix(): Matrix;
  36552. /**
  36553. * Sets the current transform matrix
  36554. * @param viewL defines the View matrix to use
  36555. * @param projectionL defines the Projection matrix to use
  36556. * @param viewR defines the right View matrix to use (if provided)
  36557. * @param projectionR defines the right Projection matrix to use (if provided)
  36558. */
  36559. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36560. /**
  36561. * Gets the uniform buffer used to store scene data
  36562. * @returns a UniformBuffer
  36563. */
  36564. getSceneUniformBuffer(): UniformBuffer;
  36565. /**
  36566. * Gets an unique (relatively to the current scene) Id
  36567. * @returns an unique number for the scene
  36568. */
  36569. getUniqueId(): number;
  36570. /**
  36571. * Add a mesh to the list of scene's meshes
  36572. * @param newMesh defines the mesh to add
  36573. * @param recursive if all child meshes should also be added to the scene
  36574. */
  36575. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36576. /**
  36577. * Remove a mesh for the list of scene's meshes
  36578. * @param toRemove defines the mesh to remove
  36579. * @param recursive if all child meshes should also be removed from the scene
  36580. * @returns the index where the mesh was in the mesh list
  36581. */
  36582. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36583. /**
  36584. * Add a transform node to the list of scene's transform nodes
  36585. * @param newTransformNode defines the transform node to add
  36586. */
  36587. addTransformNode(newTransformNode: TransformNode): void;
  36588. /**
  36589. * Remove a transform node for the list of scene's transform nodes
  36590. * @param toRemove defines the transform node to remove
  36591. * @returns the index where the transform node was in the transform node list
  36592. */
  36593. removeTransformNode(toRemove: TransformNode): number;
  36594. /**
  36595. * Remove a skeleton for the list of scene's skeletons
  36596. * @param toRemove defines the skeleton to remove
  36597. * @returns the index where the skeleton was in the skeleton list
  36598. */
  36599. removeSkeleton(toRemove: Skeleton): number;
  36600. /**
  36601. * Remove a morph target for the list of scene's morph targets
  36602. * @param toRemove defines the morph target to remove
  36603. * @returns the index where the morph target was in the morph target list
  36604. */
  36605. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36606. /**
  36607. * Remove a light for the list of scene's lights
  36608. * @param toRemove defines the light to remove
  36609. * @returns the index where the light was in the light list
  36610. */
  36611. removeLight(toRemove: Light): number;
  36612. /**
  36613. * Remove a camera for the list of scene's cameras
  36614. * @param toRemove defines the camera to remove
  36615. * @returns the index where the camera was in the camera list
  36616. */
  36617. removeCamera(toRemove: Camera): number;
  36618. /**
  36619. * Remove a particle system for the list of scene's particle systems
  36620. * @param toRemove defines the particle system to remove
  36621. * @returns the index where the particle system was in the particle system list
  36622. */
  36623. removeParticleSystem(toRemove: IParticleSystem): number;
  36624. /**
  36625. * Remove a animation for the list of scene's animations
  36626. * @param toRemove defines the animation to remove
  36627. * @returns the index where the animation was in the animation list
  36628. */
  36629. removeAnimation(toRemove: Animation): number;
  36630. /**
  36631. * Will stop the animation of the given target
  36632. * @param target - the target
  36633. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36634. * @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)
  36635. */
  36636. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36637. /**
  36638. * Removes the given animation group from this scene.
  36639. * @param toRemove The animation group to remove
  36640. * @returns The index of the removed animation group
  36641. */
  36642. removeAnimationGroup(toRemove: AnimationGroup): number;
  36643. /**
  36644. * Removes the given multi-material from this scene.
  36645. * @param toRemove The multi-material to remove
  36646. * @returns The index of the removed multi-material
  36647. */
  36648. removeMultiMaterial(toRemove: MultiMaterial): number;
  36649. /**
  36650. * Removes the given material from this scene.
  36651. * @param toRemove The material to remove
  36652. * @returns The index of the removed material
  36653. */
  36654. removeMaterial(toRemove: Material): number;
  36655. /**
  36656. * Removes the given action manager from this scene.
  36657. * @param toRemove The action manager to remove
  36658. * @returns The index of the removed action manager
  36659. */
  36660. removeActionManager(toRemove: AbstractActionManager): number;
  36661. /**
  36662. * Removes the given texture from this scene.
  36663. * @param toRemove The texture to remove
  36664. * @returns The index of the removed texture
  36665. */
  36666. removeTexture(toRemove: BaseTexture): number;
  36667. /**
  36668. * Adds the given light to this scene
  36669. * @param newLight The light to add
  36670. */
  36671. addLight(newLight: Light): void;
  36672. /**
  36673. * Sorts the list list based on light priorities
  36674. */
  36675. sortLightsByPriority(): void;
  36676. /**
  36677. * Adds the given camera to this scene
  36678. * @param newCamera The camera to add
  36679. */
  36680. addCamera(newCamera: Camera): void;
  36681. /**
  36682. * Adds the given skeleton to this scene
  36683. * @param newSkeleton The skeleton to add
  36684. */
  36685. addSkeleton(newSkeleton: Skeleton): void;
  36686. /**
  36687. * Adds the given particle system to this scene
  36688. * @param newParticleSystem The particle system to add
  36689. */
  36690. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36691. /**
  36692. * Adds the given animation to this scene
  36693. * @param newAnimation The animation to add
  36694. */
  36695. addAnimation(newAnimation: Animation): void;
  36696. /**
  36697. * Adds the given animation group to this scene.
  36698. * @param newAnimationGroup The animation group to add
  36699. */
  36700. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36701. /**
  36702. * Adds the given multi-material to this scene
  36703. * @param newMultiMaterial The multi-material to add
  36704. */
  36705. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36706. /**
  36707. * Adds the given material to this scene
  36708. * @param newMaterial The material to add
  36709. */
  36710. addMaterial(newMaterial: Material): void;
  36711. /**
  36712. * Adds the given morph target to this scene
  36713. * @param newMorphTargetManager The morph target to add
  36714. */
  36715. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36716. /**
  36717. * Adds the given geometry to this scene
  36718. * @param newGeometry The geometry to add
  36719. */
  36720. addGeometry(newGeometry: Geometry): void;
  36721. /**
  36722. * Adds the given action manager to this scene
  36723. * @param newActionManager The action manager to add
  36724. */
  36725. addActionManager(newActionManager: AbstractActionManager): void;
  36726. /**
  36727. * Adds the given texture to this scene.
  36728. * @param newTexture The texture to add
  36729. */
  36730. addTexture(newTexture: BaseTexture): void;
  36731. /**
  36732. * Switch active camera
  36733. * @param newCamera defines the new active camera
  36734. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36735. */
  36736. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36737. /**
  36738. * sets the active camera of the scene using its ID
  36739. * @param id defines the camera's ID
  36740. * @return the new active camera or null if none found.
  36741. */
  36742. setActiveCameraByID(id: string): Nullable<Camera>;
  36743. /**
  36744. * sets the active camera of the scene using its name
  36745. * @param name defines the camera's name
  36746. * @returns the new active camera or null if none found.
  36747. */
  36748. setActiveCameraByName(name: string): Nullable<Camera>;
  36749. /**
  36750. * get an animation group using its name
  36751. * @param name defines the material's name
  36752. * @return the animation group or null if none found.
  36753. */
  36754. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36755. /**
  36756. * Get a material using its unique id
  36757. * @param uniqueId defines the material's unique id
  36758. * @return the material or null if none found.
  36759. */
  36760. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36761. /**
  36762. * get a material using its id
  36763. * @param id defines the material's ID
  36764. * @return the material or null if none found.
  36765. */
  36766. getMaterialByID(id: string): Nullable<Material>;
  36767. /**
  36768. * Gets a the last added material using a given id
  36769. * @param id defines the material's ID
  36770. * @return the last material with the given id or null if none found.
  36771. */
  36772. getLastMaterialByID(id: string): Nullable<Material>;
  36773. /**
  36774. * Gets a material using its name
  36775. * @param name defines the material's name
  36776. * @return the material or null if none found.
  36777. */
  36778. getMaterialByName(name: string): Nullable<Material>;
  36779. /**
  36780. * Get a texture using its unique id
  36781. * @param uniqueId defines the texture's unique id
  36782. * @return the texture or null if none found.
  36783. */
  36784. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36785. /**
  36786. * Gets a camera using its id
  36787. * @param id defines the id to look for
  36788. * @returns the camera or null if not found
  36789. */
  36790. getCameraByID(id: string): Nullable<Camera>;
  36791. /**
  36792. * Gets a camera using its unique id
  36793. * @param uniqueId defines the unique id to look for
  36794. * @returns the camera or null if not found
  36795. */
  36796. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36797. /**
  36798. * Gets a camera using its name
  36799. * @param name defines the camera's name
  36800. * @return the camera or null if none found.
  36801. */
  36802. getCameraByName(name: string): Nullable<Camera>;
  36803. /**
  36804. * Gets a bone using its id
  36805. * @param id defines the bone's id
  36806. * @return the bone or null if not found
  36807. */
  36808. getBoneByID(id: string): Nullable<Bone>;
  36809. /**
  36810. * Gets a bone using its id
  36811. * @param name defines the bone's name
  36812. * @return the bone or null if not found
  36813. */
  36814. getBoneByName(name: string): Nullable<Bone>;
  36815. /**
  36816. * Gets a light node using its name
  36817. * @param name defines the the light's name
  36818. * @return the light or null if none found.
  36819. */
  36820. getLightByName(name: string): Nullable<Light>;
  36821. /**
  36822. * Gets a light node using its id
  36823. * @param id defines the light's id
  36824. * @return the light or null if none found.
  36825. */
  36826. getLightByID(id: string): Nullable<Light>;
  36827. /**
  36828. * Gets a light node using its scene-generated unique ID
  36829. * @param uniqueId defines the light's unique id
  36830. * @return the light or null if none found.
  36831. */
  36832. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36833. /**
  36834. * Gets a particle system by id
  36835. * @param id defines the particle system id
  36836. * @return the corresponding system or null if none found
  36837. */
  36838. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36839. /**
  36840. * Gets a geometry using its ID
  36841. * @param id defines the geometry's id
  36842. * @return the geometry or null if none found.
  36843. */
  36844. getGeometryByID(id: string): Nullable<Geometry>;
  36845. private _getGeometryByUniqueID;
  36846. /**
  36847. * Add a new geometry to this scene
  36848. * @param geometry defines the geometry to be added to the scene.
  36849. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36850. * @return a boolean defining if the geometry was added or not
  36851. */
  36852. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36853. /**
  36854. * Removes an existing geometry
  36855. * @param geometry defines the geometry to be removed from the scene
  36856. * @return a boolean defining if the geometry was removed or not
  36857. */
  36858. removeGeometry(geometry: Geometry): boolean;
  36859. /**
  36860. * Gets the list of geometries attached to the scene
  36861. * @returns an array of Geometry
  36862. */
  36863. getGeometries(): Geometry[];
  36864. /**
  36865. * Gets the first added mesh found of a given ID
  36866. * @param id defines the id to search for
  36867. * @return the mesh found or null if not found at all
  36868. */
  36869. getMeshByID(id: string): Nullable<AbstractMesh>;
  36870. /**
  36871. * Gets a list of meshes using their id
  36872. * @param id defines the id to search for
  36873. * @returns a list of meshes
  36874. */
  36875. getMeshesByID(id: string): Array<AbstractMesh>;
  36876. /**
  36877. * Gets the first added transform node found of a given ID
  36878. * @param id defines the id to search for
  36879. * @return the found transform node or null if not found at all.
  36880. */
  36881. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36882. /**
  36883. * Gets a transform node with its auto-generated unique id
  36884. * @param uniqueId efines the unique id to search for
  36885. * @return the found transform node or null if not found at all.
  36886. */
  36887. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36888. /**
  36889. * Gets a list of transform nodes using their id
  36890. * @param id defines the id to search for
  36891. * @returns a list of transform nodes
  36892. */
  36893. getTransformNodesByID(id: string): Array<TransformNode>;
  36894. /**
  36895. * Gets a mesh with its auto-generated unique id
  36896. * @param uniqueId defines the unique id to search for
  36897. * @return the found mesh or null if not found at all.
  36898. */
  36899. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36900. /**
  36901. * Gets a the last added mesh using a given id
  36902. * @param id defines the id to search for
  36903. * @return the found mesh or null if not found at all.
  36904. */
  36905. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36906. /**
  36907. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36908. * @param id defines the id to search for
  36909. * @return the found node or null if not found at all
  36910. */
  36911. getLastEntryByID(id: string): Nullable<Node>;
  36912. /**
  36913. * Gets a node (Mesh, Camera, Light) using a given id
  36914. * @param id defines the id to search for
  36915. * @return the found node or null if not found at all
  36916. */
  36917. getNodeByID(id: string): Nullable<Node>;
  36918. /**
  36919. * Gets a node (Mesh, Camera, Light) using a given name
  36920. * @param name defines the name to search for
  36921. * @return the found node or null if not found at all.
  36922. */
  36923. getNodeByName(name: string): Nullable<Node>;
  36924. /**
  36925. * Gets a mesh using a given name
  36926. * @param name defines the name to search for
  36927. * @return the found mesh or null if not found at all.
  36928. */
  36929. getMeshByName(name: string): Nullable<AbstractMesh>;
  36930. /**
  36931. * Gets a transform node using a given name
  36932. * @param name defines the name to search for
  36933. * @return the found transform node or null if not found at all.
  36934. */
  36935. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36936. /**
  36937. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36938. * @param id defines the id to search for
  36939. * @return the found skeleton or null if not found at all.
  36940. */
  36941. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36942. /**
  36943. * Gets a skeleton using a given auto generated unique id
  36944. * @param uniqueId defines the unique id to search for
  36945. * @return the found skeleton or null if not found at all.
  36946. */
  36947. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36948. /**
  36949. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36950. * @param id defines the id to search for
  36951. * @return the found skeleton or null if not found at all.
  36952. */
  36953. getSkeletonById(id: string): Nullable<Skeleton>;
  36954. /**
  36955. * Gets a skeleton using a given name
  36956. * @param name defines the name to search for
  36957. * @return the found skeleton or null if not found at all.
  36958. */
  36959. getSkeletonByName(name: string): Nullable<Skeleton>;
  36960. /**
  36961. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36962. * @param id defines the id to search for
  36963. * @return the found morph target manager or null if not found at all.
  36964. */
  36965. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36966. /**
  36967. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36968. * @param id defines the id to search for
  36969. * @return the found morph target or null if not found at all.
  36970. */
  36971. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36972. /**
  36973. * Gets a boolean indicating if the given mesh is active
  36974. * @param mesh defines the mesh to look for
  36975. * @returns true if the mesh is in the active list
  36976. */
  36977. isActiveMesh(mesh: AbstractMesh): boolean;
  36978. /**
  36979. * Return a unique id as a string which can serve as an identifier for the scene
  36980. */
  36981. get uid(): string;
  36982. /**
  36983. * Add an externaly attached data from its key.
  36984. * This method call will fail and return false, if such key already exists.
  36985. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36986. * @param key the unique key that identifies the data
  36987. * @param data the data object to associate to the key for this Engine instance
  36988. * @return true if no such key were already present and the data was added successfully, false otherwise
  36989. */
  36990. addExternalData<T>(key: string, data: T): boolean;
  36991. /**
  36992. * Get an externaly attached data from its key
  36993. * @param key the unique key that identifies the data
  36994. * @return the associated data, if present (can be null), or undefined if not present
  36995. */
  36996. getExternalData<T>(key: string): Nullable<T>;
  36997. /**
  36998. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36999. * @param key the unique key that identifies the data
  37000. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37001. * @return the associated data, can be null if the factory returned null.
  37002. */
  37003. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37004. /**
  37005. * Remove an externaly attached data from the Engine instance
  37006. * @param key the unique key that identifies the data
  37007. * @return true if the data was successfully removed, false if it doesn't exist
  37008. */
  37009. removeExternalData(key: string): boolean;
  37010. private _evaluateSubMesh;
  37011. /**
  37012. * Clear the processed materials smart array preventing retention point in material dispose.
  37013. */
  37014. freeProcessedMaterials(): void;
  37015. private _preventFreeActiveMeshesAndRenderingGroups;
  37016. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37017. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37018. * when disposing several meshes in a row or a hierarchy of meshes.
  37019. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37020. */
  37021. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37022. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37023. /**
  37024. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37025. */
  37026. freeActiveMeshes(): void;
  37027. /**
  37028. * Clear the info related to rendering groups preventing retention points during dispose.
  37029. */
  37030. freeRenderingGroups(): void;
  37031. /** @hidden */
  37032. _isInIntermediateRendering(): boolean;
  37033. /**
  37034. * Lambda returning the list of potentially active meshes.
  37035. */
  37036. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37037. /**
  37038. * Lambda returning the list of potentially active sub meshes.
  37039. */
  37040. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37041. /**
  37042. * Lambda returning the list of potentially intersecting sub meshes.
  37043. */
  37044. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37045. /**
  37046. * Lambda returning the list of potentially colliding sub meshes.
  37047. */
  37048. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37049. private _activeMeshesFrozen;
  37050. private _skipEvaluateActiveMeshesCompletely;
  37051. /**
  37052. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37053. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37054. * @returns the current scene
  37055. */
  37056. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37057. /**
  37058. * Use this function to restart evaluating active meshes on every frame
  37059. * @returns the current scene
  37060. */
  37061. unfreezeActiveMeshes(): Scene;
  37062. private _evaluateActiveMeshes;
  37063. private _activeMesh;
  37064. /**
  37065. * Update the transform matrix to update from the current active camera
  37066. * @param force defines a boolean used to force the update even if cache is up to date
  37067. */
  37068. updateTransformMatrix(force?: boolean): void;
  37069. private _bindFrameBuffer;
  37070. /** @hidden */
  37071. _allowPostProcessClearColor: boolean;
  37072. /** @hidden */
  37073. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37074. private _processSubCameras;
  37075. private _checkIntersections;
  37076. /** @hidden */
  37077. _advancePhysicsEngineStep(step: number): void;
  37078. /**
  37079. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37080. */
  37081. getDeterministicFrameTime: () => number;
  37082. /** @hidden */
  37083. _animate(): void;
  37084. /** Execute all animations (for a frame) */
  37085. animate(): void;
  37086. /**
  37087. * Render the scene
  37088. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37089. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37090. */
  37091. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37092. /**
  37093. * Freeze all materials
  37094. * A frozen material will not be updatable but should be faster to render
  37095. */
  37096. freezeMaterials(): void;
  37097. /**
  37098. * Unfreeze all materials
  37099. * A frozen material will not be updatable but should be faster to render
  37100. */
  37101. unfreezeMaterials(): void;
  37102. /**
  37103. * Releases all held ressources
  37104. */
  37105. dispose(): void;
  37106. /**
  37107. * Gets if the scene is already disposed
  37108. */
  37109. get isDisposed(): boolean;
  37110. /**
  37111. * Call this function to reduce memory footprint of the scene.
  37112. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37113. */
  37114. clearCachedVertexData(): void;
  37115. /**
  37116. * This function will remove the local cached buffer data from texture.
  37117. * It will save memory but will prevent the texture from being rebuilt
  37118. */
  37119. cleanCachedTextureBuffer(): void;
  37120. /**
  37121. * Get the world extend vectors with an optional filter
  37122. *
  37123. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37124. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37125. */
  37126. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37127. min: Vector3;
  37128. max: Vector3;
  37129. };
  37130. /**
  37131. * Creates a ray that can be used to pick in the scene
  37132. * @param x defines the x coordinate of the origin (on-screen)
  37133. * @param y defines the y coordinate of the origin (on-screen)
  37134. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37135. * @param camera defines the camera to use for the picking
  37136. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37137. * @returns a Ray
  37138. */
  37139. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37140. /**
  37141. * Creates a ray that can be used to pick in the scene
  37142. * @param x defines the x coordinate of the origin (on-screen)
  37143. * @param y defines the y coordinate of the origin (on-screen)
  37144. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37145. * @param result defines the ray where to store the picking ray
  37146. * @param camera defines the camera to use for the picking
  37147. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37148. * @returns the current scene
  37149. */
  37150. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37151. /**
  37152. * Creates a ray that can be used to pick in the scene
  37153. * @param x defines the x coordinate of the origin (on-screen)
  37154. * @param y defines the y coordinate of the origin (on-screen)
  37155. * @param camera defines the camera to use for the picking
  37156. * @returns a Ray
  37157. */
  37158. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37159. /**
  37160. * Creates a ray that can be used to pick in the scene
  37161. * @param x defines the x coordinate of the origin (on-screen)
  37162. * @param y defines the y coordinate of the origin (on-screen)
  37163. * @param result defines the ray where to store the picking ray
  37164. * @param camera defines the camera to use for the picking
  37165. * @returns the current scene
  37166. */
  37167. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37168. /** Launch a ray to try to pick a mesh in the scene
  37169. * @param x position on screen
  37170. * @param y position on screen
  37171. * @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
  37172. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37173. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37174. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37175. * @returns a PickingInfo
  37176. */
  37177. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37178. /** Use the given ray to pick a mesh in the scene
  37179. * @param ray The ray to use to pick meshes
  37180. * @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
  37181. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37182. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37183. * @returns a PickingInfo
  37184. */
  37185. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37186. /**
  37187. * Launch a ray to try to pick a mesh in the scene
  37188. * @param x X position on screen
  37189. * @param y Y position on screen
  37190. * @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
  37191. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37192. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37193. * @returns an array of PickingInfo
  37194. */
  37195. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37196. /**
  37197. * Launch a ray to try to pick a mesh in the scene
  37198. * @param ray Ray to use
  37199. * @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
  37200. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37201. * @returns an array of PickingInfo
  37202. */
  37203. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37204. /**
  37205. * Force the value of meshUnderPointer
  37206. * @param mesh defines the mesh to use
  37207. */
  37208. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37209. /**
  37210. * Gets the mesh under the pointer
  37211. * @returns a Mesh or null if no mesh is under the pointer
  37212. */
  37213. getPointerOverMesh(): Nullable<AbstractMesh>;
  37214. /** @hidden */
  37215. _rebuildGeometries(): void;
  37216. /** @hidden */
  37217. _rebuildTextures(): void;
  37218. private _getByTags;
  37219. /**
  37220. * Get a list of meshes by tags
  37221. * @param tagsQuery defines the tags query to use
  37222. * @param forEach defines a predicate used to filter results
  37223. * @returns an array of Mesh
  37224. */
  37225. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37226. /**
  37227. * Get a list of cameras by tags
  37228. * @param tagsQuery defines the tags query to use
  37229. * @param forEach defines a predicate used to filter results
  37230. * @returns an array of Camera
  37231. */
  37232. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37233. /**
  37234. * Get a list of lights by tags
  37235. * @param tagsQuery defines the tags query to use
  37236. * @param forEach defines a predicate used to filter results
  37237. * @returns an array of Light
  37238. */
  37239. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37240. /**
  37241. * Get a list of materials by tags
  37242. * @param tagsQuery defines the tags query to use
  37243. * @param forEach defines a predicate used to filter results
  37244. * @returns an array of Material
  37245. */
  37246. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37247. /**
  37248. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37249. * This allowed control for front to back rendering or reversly depending of the special needs.
  37250. *
  37251. * @param renderingGroupId The rendering group id corresponding to its index
  37252. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37253. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37254. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37255. */
  37256. 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;
  37257. /**
  37258. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37259. *
  37260. * @param renderingGroupId The rendering group id corresponding to its index
  37261. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37262. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37263. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37264. */
  37265. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37266. /**
  37267. * Gets the current auto clear configuration for one rendering group of the rendering
  37268. * manager.
  37269. * @param index the rendering group index to get the information for
  37270. * @returns The auto clear setup for the requested rendering group
  37271. */
  37272. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37273. private _blockMaterialDirtyMechanism;
  37274. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37275. get blockMaterialDirtyMechanism(): boolean;
  37276. set blockMaterialDirtyMechanism(value: boolean);
  37277. /**
  37278. * Will flag all materials as dirty to trigger new shader compilation
  37279. * @param flag defines the flag used to specify which material part must be marked as dirty
  37280. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37281. */
  37282. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37283. /** @hidden */
  37284. _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;
  37285. /** @hidden */
  37286. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37287. /** @hidden */
  37288. _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;
  37289. /** @hidden */
  37290. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37291. /** @hidden */
  37292. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37293. /** @hidden */
  37294. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37295. }
  37296. }
  37297. declare module BABYLON {
  37298. /**
  37299. * Set of assets to keep when moving a scene into an asset container.
  37300. */
  37301. export class KeepAssets extends AbstractScene {
  37302. }
  37303. /**
  37304. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37305. */
  37306. export class InstantiatedEntries {
  37307. /**
  37308. * List of new root nodes (eg. nodes with no parent)
  37309. */
  37310. rootNodes: TransformNode[];
  37311. /**
  37312. * List of new skeletons
  37313. */
  37314. skeletons: Skeleton[];
  37315. /**
  37316. * List of new animation groups
  37317. */
  37318. animationGroups: AnimationGroup[];
  37319. }
  37320. /**
  37321. * Container with a set of assets that can be added or removed from a scene.
  37322. */
  37323. export class AssetContainer extends AbstractScene {
  37324. private _wasAddedToScene;
  37325. /**
  37326. * The scene the AssetContainer belongs to.
  37327. */
  37328. scene: Scene;
  37329. /**
  37330. * Instantiates an AssetContainer.
  37331. * @param scene The scene the AssetContainer belongs to.
  37332. */
  37333. constructor(scene: Scene);
  37334. /**
  37335. * Instantiate or clone all meshes and add the new ones to the scene.
  37336. * Skeletons and animation groups will all be cloned
  37337. * @param nameFunction defines an optional function used to get new names for clones
  37338. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37339. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37340. */
  37341. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37342. /**
  37343. * Adds all the assets from the container to the scene.
  37344. */
  37345. addAllToScene(): void;
  37346. /**
  37347. * Removes all the assets in the container from the scene
  37348. */
  37349. removeAllFromScene(): void;
  37350. /**
  37351. * Disposes all the assets in the container
  37352. */
  37353. dispose(): void;
  37354. private _moveAssets;
  37355. /**
  37356. * Removes all the assets contained in the scene and adds them to the container.
  37357. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37358. */
  37359. moveAllFromScene(keepAssets?: KeepAssets): void;
  37360. /**
  37361. * 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.
  37362. * @returns the root mesh
  37363. */
  37364. createRootMesh(): Mesh;
  37365. /**
  37366. * Merge animations from this asset container into a scene
  37367. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37368. * @param animatables set of animatables to retarget to a node from the scene
  37369. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37370. */
  37371. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37372. }
  37373. }
  37374. declare module BABYLON {
  37375. /**
  37376. * Defines how the parser contract is defined.
  37377. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37378. */
  37379. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37380. /**
  37381. * Defines how the individual parser contract is defined.
  37382. * These parser can parse an individual asset
  37383. */
  37384. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37385. /**
  37386. * Base class of the scene acting as a container for the different elements composing a scene.
  37387. * This class is dynamically extended by the different components of the scene increasing
  37388. * flexibility and reducing coupling
  37389. */
  37390. export abstract class AbstractScene {
  37391. /**
  37392. * Stores the list of available parsers in the application.
  37393. */
  37394. private static _BabylonFileParsers;
  37395. /**
  37396. * Stores the list of available individual parsers in the application.
  37397. */
  37398. private static _IndividualBabylonFileParsers;
  37399. /**
  37400. * Adds a parser in the list of available ones
  37401. * @param name Defines the name of the parser
  37402. * @param parser Defines the parser to add
  37403. */
  37404. static AddParser(name: string, parser: BabylonFileParser): void;
  37405. /**
  37406. * Gets a general parser from the list of avaialble ones
  37407. * @param name Defines the name of the parser
  37408. * @returns the requested parser or null
  37409. */
  37410. static GetParser(name: string): Nullable<BabylonFileParser>;
  37411. /**
  37412. * Adds n individual parser in the list of available ones
  37413. * @param name Defines the name of the parser
  37414. * @param parser Defines the parser to add
  37415. */
  37416. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37417. /**
  37418. * Gets an individual parser from the list of avaialble ones
  37419. * @param name Defines the name of the parser
  37420. * @returns the requested parser or null
  37421. */
  37422. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37423. /**
  37424. * Parser json data and populate both a scene and its associated container object
  37425. * @param jsonData Defines the data to parse
  37426. * @param scene Defines the scene to parse the data for
  37427. * @param container Defines the container attached to the parsing sequence
  37428. * @param rootUrl Defines the root url of the data
  37429. */
  37430. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37431. /**
  37432. * Gets the list of root nodes (ie. nodes with no parent)
  37433. */
  37434. rootNodes: Node[];
  37435. /** All of the cameras added to this scene
  37436. * @see http://doc.babylonjs.com/babylon101/cameras
  37437. */
  37438. cameras: Camera[];
  37439. /**
  37440. * All of the lights added to this scene
  37441. * @see http://doc.babylonjs.com/babylon101/lights
  37442. */
  37443. lights: Light[];
  37444. /**
  37445. * All of the (abstract) meshes added to this scene
  37446. */
  37447. meshes: AbstractMesh[];
  37448. /**
  37449. * The list of skeletons added to the scene
  37450. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37451. */
  37452. skeletons: Skeleton[];
  37453. /**
  37454. * All of the particle systems added to this scene
  37455. * @see http://doc.babylonjs.com/babylon101/particles
  37456. */
  37457. particleSystems: IParticleSystem[];
  37458. /**
  37459. * Gets a list of Animations associated with the scene
  37460. */
  37461. animations: Animation[];
  37462. /**
  37463. * All of the animation groups added to this scene
  37464. * @see http://doc.babylonjs.com/how_to/group
  37465. */
  37466. animationGroups: AnimationGroup[];
  37467. /**
  37468. * All of the multi-materials added to this scene
  37469. * @see http://doc.babylonjs.com/how_to/multi_materials
  37470. */
  37471. multiMaterials: MultiMaterial[];
  37472. /**
  37473. * All of the materials added to this scene
  37474. * In the context of a Scene, it is not supposed to be modified manually.
  37475. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37476. * Note also that the order of the Material within the array is not significant and might change.
  37477. * @see http://doc.babylonjs.com/babylon101/materials
  37478. */
  37479. materials: Material[];
  37480. /**
  37481. * The list of morph target managers added to the scene
  37482. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37483. */
  37484. morphTargetManagers: MorphTargetManager[];
  37485. /**
  37486. * The list of geometries used in the scene.
  37487. */
  37488. geometries: Geometry[];
  37489. /**
  37490. * All of the tranform nodes added to this scene
  37491. * In the context of a Scene, it is not supposed to be modified manually.
  37492. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37493. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37494. * @see http://doc.babylonjs.com/how_to/transformnode
  37495. */
  37496. transformNodes: TransformNode[];
  37497. /**
  37498. * ActionManagers available on the scene.
  37499. */
  37500. actionManagers: AbstractActionManager[];
  37501. /**
  37502. * Textures to keep.
  37503. */
  37504. textures: BaseTexture[];
  37505. /**
  37506. * Environment texture for the scene
  37507. */
  37508. environmentTexture: Nullable<BaseTexture>;
  37509. /**
  37510. * @returns all meshes, lights, cameras, transformNodes and bones
  37511. */
  37512. getNodes(): Array<Node>;
  37513. }
  37514. }
  37515. declare module BABYLON {
  37516. /**
  37517. * Interface used to define options for Sound class
  37518. */
  37519. export interface ISoundOptions {
  37520. /**
  37521. * Does the sound autoplay once loaded.
  37522. */
  37523. autoplay?: boolean;
  37524. /**
  37525. * Does the sound loop after it finishes playing once.
  37526. */
  37527. loop?: boolean;
  37528. /**
  37529. * Sound's volume
  37530. */
  37531. volume?: number;
  37532. /**
  37533. * Is it a spatial sound?
  37534. */
  37535. spatialSound?: boolean;
  37536. /**
  37537. * Maximum distance to hear that sound
  37538. */
  37539. maxDistance?: number;
  37540. /**
  37541. * Uses user defined attenuation function
  37542. */
  37543. useCustomAttenuation?: boolean;
  37544. /**
  37545. * Define the roll off factor of spatial sounds.
  37546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37547. */
  37548. rolloffFactor?: number;
  37549. /**
  37550. * Define the reference distance the sound should be heard perfectly.
  37551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37552. */
  37553. refDistance?: number;
  37554. /**
  37555. * Define the distance attenuation model the sound will follow.
  37556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37557. */
  37558. distanceModel?: string;
  37559. /**
  37560. * Defines the playback speed (1 by default)
  37561. */
  37562. playbackRate?: number;
  37563. /**
  37564. * Defines if the sound is from a streaming source
  37565. */
  37566. streaming?: boolean;
  37567. /**
  37568. * Defines an optional length (in seconds) inside the sound file
  37569. */
  37570. length?: number;
  37571. /**
  37572. * Defines an optional offset (in seconds) inside the sound file
  37573. */
  37574. offset?: number;
  37575. /**
  37576. * If true, URLs will not be required to state the audio file codec to use.
  37577. */
  37578. skipCodecCheck?: boolean;
  37579. }
  37580. /**
  37581. * Defines a sound that can be played in the application.
  37582. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37584. */
  37585. export class Sound {
  37586. /**
  37587. * The name of the sound in the scene.
  37588. */
  37589. name: string;
  37590. /**
  37591. * Does the sound autoplay once loaded.
  37592. */
  37593. autoplay: boolean;
  37594. /**
  37595. * Does the sound loop after it finishes playing once.
  37596. */
  37597. loop: boolean;
  37598. /**
  37599. * Does the sound use a custom attenuation curve to simulate the falloff
  37600. * happening when the source gets further away from the camera.
  37601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37602. */
  37603. useCustomAttenuation: boolean;
  37604. /**
  37605. * The sound track id this sound belongs to.
  37606. */
  37607. soundTrackId: number;
  37608. /**
  37609. * Is this sound currently played.
  37610. */
  37611. isPlaying: boolean;
  37612. /**
  37613. * Is this sound currently paused.
  37614. */
  37615. isPaused: boolean;
  37616. /**
  37617. * Does this sound enables spatial sound.
  37618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37619. */
  37620. spatialSound: boolean;
  37621. /**
  37622. * Define the reference distance the sound should be heard perfectly.
  37623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37624. */
  37625. refDistance: number;
  37626. /**
  37627. * Define the roll off factor of spatial sounds.
  37628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37629. */
  37630. rolloffFactor: number;
  37631. /**
  37632. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37634. */
  37635. maxDistance: number;
  37636. /**
  37637. * Define the distance attenuation model the sound will follow.
  37638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37639. */
  37640. distanceModel: string;
  37641. /**
  37642. * @hidden
  37643. * Back Compat
  37644. **/
  37645. onended: () => any;
  37646. /**
  37647. * Observable event when the current playing sound finishes.
  37648. */
  37649. onEndedObservable: Observable<Sound>;
  37650. private _panningModel;
  37651. private _playbackRate;
  37652. private _streaming;
  37653. private _startTime;
  37654. private _startOffset;
  37655. private _position;
  37656. /** @hidden */
  37657. _positionInEmitterSpace: boolean;
  37658. private _localDirection;
  37659. private _volume;
  37660. private _isReadyToPlay;
  37661. private _isDirectional;
  37662. private _readyToPlayCallback;
  37663. private _audioBuffer;
  37664. private _soundSource;
  37665. private _streamingSource;
  37666. private _soundPanner;
  37667. private _soundGain;
  37668. private _inputAudioNode;
  37669. private _outputAudioNode;
  37670. private _coneInnerAngle;
  37671. private _coneOuterAngle;
  37672. private _coneOuterGain;
  37673. private _scene;
  37674. private _connectedTransformNode;
  37675. private _customAttenuationFunction;
  37676. private _registerFunc;
  37677. private _isOutputConnected;
  37678. private _htmlAudioElement;
  37679. private _urlType;
  37680. private _length?;
  37681. private _offset?;
  37682. /** @hidden */
  37683. static _SceneComponentInitialization: (scene: Scene) => void;
  37684. /**
  37685. * Create a sound and attach it to a scene
  37686. * @param name Name of your sound
  37687. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37688. * @param scene defines the scene the sound belongs to
  37689. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37690. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37691. */
  37692. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37693. /**
  37694. * Release the sound and its associated resources
  37695. */
  37696. dispose(): void;
  37697. /**
  37698. * Gets if the sounds is ready to be played or not.
  37699. * @returns true if ready, otherwise false
  37700. */
  37701. isReady(): boolean;
  37702. private _soundLoaded;
  37703. /**
  37704. * Sets the data of the sound from an audiobuffer
  37705. * @param audioBuffer The audioBuffer containing the data
  37706. */
  37707. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37708. /**
  37709. * Updates the current sounds options such as maxdistance, loop...
  37710. * @param options A JSON object containing values named as the object properties
  37711. */
  37712. updateOptions(options: ISoundOptions): void;
  37713. private _createSpatialParameters;
  37714. private _updateSpatialParameters;
  37715. /**
  37716. * Switch the panning model to HRTF:
  37717. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37719. */
  37720. switchPanningModelToHRTF(): void;
  37721. /**
  37722. * Switch the panning model to Equal Power:
  37723. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37725. */
  37726. switchPanningModelToEqualPower(): void;
  37727. private _switchPanningModel;
  37728. /**
  37729. * Connect this sound to a sound track audio node like gain...
  37730. * @param soundTrackAudioNode the sound track audio node to connect to
  37731. */
  37732. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37733. /**
  37734. * Transform this sound into a directional source
  37735. * @param coneInnerAngle Size of the inner cone in degree
  37736. * @param coneOuterAngle Size of the outer cone in degree
  37737. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37738. */
  37739. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37740. /**
  37741. * Gets or sets the inner angle for the directional cone.
  37742. */
  37743. get directionalConeInnerAngle(): number;
  37744. /**
  37745. * Gets or sets the inner angle for the directional cone.
  37746. */
  37747. set directionalConeInnerAngle(value: number);
  37748. /**
  37749. * Gets or sets the outer angle for the directional cone.
  37750. */
  37751. get directionalConeOuterAngle(): number;
  37752. /**
  37753. * Gets or sets the outer angle for the directional cone.
  37754. */
  37755. set directionalConeOuterAngle(value: number);
  37756. /**
  37757. * Sets the position of the emitter if spatial sound is enabled
  37758. * @param newPosition Defines the new posisiton
  37759. */
  37760. setPosition(newPosition: Vector3): void;
  37761. /**
  37762. * Sets the local direction of the emitter if spatial sound is enabled
  37763. * @param newLocalDirection Defines the new local direction
  37764. */
  37765. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37766. private _updateDirection;
  37767. /** @hidden */
  37768. updateDistanceFromListener(): void;
  37769. /**
  37770. * Sets a new custom attenuation function for the sound.
  37771. * @param callback Defines the function used for the attenuation
  37772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37773. */
  37774. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37775. /**
  37776. * Play the sound
  37777. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37778. * @param offset (optional) Start the sound at a specific time in seconds
  37779. * @param length (optional) Sound duration (in seconds)
  37780. */
  37781. play(time?: number, offset?: number, length?: number): void;
  37782. private _onended;
  37783. /**
  37784. * Stop the sound
  37785. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37786. */
  37787. stop(time?: number): void;
  37788. /**
  37789. * Put the sound in pause
  37790. */
  37791. pause(): void;
  37792. /**
  37793. * Sets a dedicated volume for this sounds
  37794. * @param newVolume Define the new volume of the sound
  37795. * @param time Define time for gradual change to new volume
  37796. */
  37797. setVolume(newVolume: number, time?: number): void;
  37798. /**
  37799. * Set the sound play back rate
  37800. * @param newPlaybackRate Define the playback rate the sound should be played at
  37801. */
  37802. setPlaybackRate(newPlaybackRate: number): void;
  37803. /**
  37804. * Gets the volume of the sound.
  37805. * @returns the volume of the sound
  37806. */
  37807. getVolume(): number;
  37808. /**
  37809. * Attach the sound to a dedicated mesh
  37810. * @param transformNode The transform node to connect the sound with
  37811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37812. */
  37813. attachToMesh(transformNode: TransformNode): void;
  37814. /**
  37815. * Detach the sound from the previously attached mesh
  37816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37817. */
  37818. detachFromMesh(): void;
  37819. private _onRegisterAfterWorldMatrixUpdate;
  37820. /**
  37821. * Clone the current sound in the scene.
  37822. * @returns the new sound clone
  37823. */
  37824. clone(): Nullable<Sound>;
  37825. /**
  37826. * Gets the current underlying audio buffer containing the data
  37827. * @returns the audio buffer
  37828. */
  37829. getAudioBuffer(): Nullable<AudioBuffer>;
  37830. /**
  37831. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37832. * @returns the source node
  37833. */
  37834. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37835. /**
  37836. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37837. * @returns the gain node
  37838. */
  37839. getSoundGain(): Nullable<GainNode>;
  37840. /**
  37841. * Serializes the Sound in a JSON representation
  37842. * @returns the JSON representation of the sound
  37843. */
  37844. serialize(): any;
  37845. /**
  37846. * Parse a JSON representation of a sound to innstantiate in a given scene
  37847. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37848. * @param scene Define the scene the new parsed sound should be created in
  37849. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37850. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37851. * @returns the newly parsed sound
  37852. */
  37853. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37854. }
  37855. }
  37856. declare module BABYLON {
  37857. /**
  37858. * This defines an action helpful to play a defined sound on a triggered action.
  37859. */
  37860. export class PlaySoundAction extends Action {
  37861. private _sound;
  37862. /**
  37863. * Instantiate the action
  37864. * @param triggerOptions defines the trigger options
  37865. * @param sound defines the sound to play
  37866. * @param condition defines the trigger related conditions
  37867. */
  37868. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37869. /** @hidden */
  37870. _prepare(): void;
  37871. /**
  37872. * Execute the action and play the sound.
  37873. */
  37874. execute(): void;
  37875. /**
  37876. * Serializes the actions and its related information.
  37877. * @param parent defines the object to serialize in
  37878. * @returns the serialized object
  37879. */
  37880. serialize(parent: any): any;
  37881. }
  37882. /**
  37883. * This defines an action helpful to stop a defined sound on a triggered action.
  37884. */
  37885. export class StopSoundAction extends Action {
  37886. private _sound;
  37887. /**
  37888. * Instantiate the action
  37889. * @param triggerOptions defines the trigger options
  37890. * @param sound defines the sound to stop
  37891. * @param condition defines the trigger related conditions
  37892. */
  37893. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37894. /** @hidden */
  37895. _prepare(): void;
  37896. /**
  37897. * Execute the action and stop the sound.
  37898. */
  37899. execute(): void;
  37900. /**
  37901. * Serializes the actions and its related information.
  37902. * @param parent defines the object to serialize in
  37903. * @returns the serialized object
  37904. */
  37905. serialize(parent: any): any;
  37906. }
  37907. }
  37908. declare module BABYLON {
  37909. /**
  37910. * This defines an action responsible to change the value of a property
  37911. * by interpolating between its current value and the newly set one once triggered.
  37912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37913. */
  37914. export class InterpolateValueAction extends Action {
  37915. /**
  37916. * Defines the path of the property where the value should be interpolated
  37917. */
  37918. propertyPath: string;
  37919. /**
  37920. * Defines the target value at the end of the interpolation.
  37921. */
  37922. value: any;
  37923. /**
  37924. * Defines the time it will take for the property to interpolate to the value.
  37925. */
  37926. duration: number;
  37927. /**
  37928. * Defines if the other scene animations should be stopped when the action has been triggered
  37929. */
  37930. stopOtherAnimations?: boolean;
  37931. /**
  37932. * Defines a callback raised once the interpolation animation has been done.
  37933. */
  37934. onInterpolationDone?: () => void;
  37935. /**
  37936. * Observable triggered once the interpolation animation has been done.
  37937. */
  37938. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37939. private _target;
  37940. private _effectiveTarget;
  37941. private _property;
  37942. /**
  37943. * Instantiate the action
  37944. * @param triggerOptions defines the trigger options
  37945. * @param target defines the object containing the value to interpolate
  37946. * @param propertyPath defines the path to the property in the target object
  37947. * @param value defines the target value at the end of the interpolation
  37948. * @param duration deines the time it will take for the property to interpolate to the value.
  37949. * @param condition defines the trigger related conditions
  37950. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37951. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37952. */
  37953. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37954. /** @hidden */
  37955. _prepare(): void;
  37956. /**
  37957. * Execute the action starts the value interpolation.
  37958. */
  37959. execute(): void;
  37960. /**
  37961. * Serializes the actions and its related information.
  37962. * @param parent defines the object to serialize in
  37963. * @returns the serialized object
  37964. */
  37965. serialize(parent: any): any;
  37966. }
  37967. }
  37968. declare module BABYLON {
  37969. /**
  37970. * Options allowed during the creation of a sound track.
  37971. */
  37972. export interface ISoundTrackOptions {
  37973. /**
  37974. * The volume the sound track should take during creation
  37975. */
  37976. volume?: number;
  37977. /**
  37978. * Define if the sound track is the main sound track of the scene
  37979. */
  37980. mainTrack?: boolean;
  37981. }
  37982. /**
  37983. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37984. * It will be also used in a future release to apply effects on a specific track.
  37985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37986. */
  37987. export class SoundTrack {
  37988. /**
  37989. * The unique identifier of the sound track in the scene.
  37990. */
  37991. id: number;
  37992. /**
  37993. * The list of sounds included in the sound track.
  37994. */
  37995. soundCollection: Array<Sound>;
  37996. private _outputAudioNode;
  37997. private _scene;
  37998. private _connectedAnalyser;
  37999. private _options;
  38000. private _isInitialized;
  38001. /**
  38002. * Creates a new sound track.
  38003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38004. * @param scene Define the scene the sound track belongs to
  38005. * @param options
  38006. */
  38007. constructor(scene: Scene, options?: ISoundTrackOptions);
  38008. private _initializeSoundTrackAudioGraph;
  38009. /**
  38010. * Release the sound track and its associated resources
  38011. */
  38012. dispose(): void;
  38013. /**
  38014. * Adds a sound to this sound track
  38015. * @param sound define the cound to add
  38016. * @ignoreNaming
  38017. */
  38018. AddSound(sound: Sound): void;
  38019. /**
  38020. * Removes a sound to this sound track
  38021. * @param sound define the cound to remove
  38022. * @ignoreNaming
  38023. */
  38024. RemoveSound(sound: Sound): void;
  38025. /**
  38026. * Set a global volume for the full sound track.
  38027. * @param newVolume Define the new volume of the sound track
  38028. */
  38029. setVolume(newVolume: number): void;
  38030. /**
  38031. * Switch the panning model to HRTF:
  38032. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38034. */
  38035. switchPanningModelToHRTF(): void;
  38036. /**
  38037. * Switch the panning model to Equal Power:
  38038. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38040. */
  38041. switchPanningModelToEqualPower(): void;
  38042. /**
  38043. * Connect the sound track to an audio analyser allowing some amazing
  38044. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38045. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38046. * @param analyser The analyser to connect to the engine
  38047. */
  38048. connectToAnalyser(analyser: Analyser): void;
  38049. }
  38050. }
  38051. declare module BABYLON {
  38052. interface AbstractScene {
  38053. /**
  38054. * The list of sounds used in the scene.
  38055. */
  38056. sounds: Nullable<Array<Sound>>;
  38057. }
  38058. interface Scene {
  38059. /**
  38060. * @hidden
  38061. * Backing field
  38062. */
  38063. _mainSoundTrack: SoundTrack;
  38064. /**
  38065. * The main sound track played by the scene.
  38066. * It cotains your primary collection of sounds.
  38067. */
  38068. mainSoundTrack: SoundTrack;
  38069. /**
  38070. * The list of sound tracks added to the scene
  38071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38072. */
  38073. soundTracks: Nullable<Array<SoundTrack>>;
  38074. /**
  38075. * Gets a sound using a given name
  38076. * @param name defines the name to search for
  38077. * @return the found sound or null if not found at all.
  38078. */
  38079. getSoundByName(name: string): Nullable<Sound>;
  38080. /**
  38081. * Gets or sets if audio support is enabled
  38082. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38083. */
  38084. audioEnabled: boolean;
  38085. /**
  38086. * Gets or sets if audio will be output to headphones
  38087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38088. */
  38089. headphone: boolean;
  38090. /**
  38091. * Gets or sets custom audio listener position provider
  38092. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38093. */
  38094. audioListenerPositionProvider: Nullable<() => Vector3>;
  38095. /**
  38096. * Gets or sets a refresh rate when using 3D audio positioning
  38097. */
  38098. audioPositioningRefreshRate: number;
  38099. }
  38100. /**
  38101. * Defines the sound scene component responsible to manage any sounds
  38102. * in a given scene.
  38103. */
  38104. export class AudioSceneComponent implements ISceneSerializableComponent {
  38105. /**
  38106. * The component name helpfull to identify the component in the list of scene components.
  38107. */
  38108. readonly name: string;
  38109. /**
  38110. * The scene the component belongs to.
  38111. */
  38112. scene: Scene;
  38113. private _audioEnabled;
  38114. /**
  38115. * Gets whether audio is enabled or not.
  38116. * Please use related enable/disable method to switch state.
  38117. */
  38118. get audioEnabled(): boolean;
  38119. private _headphone;
  38120. /**
  38121. * Gets whether audio is outputing to headphone or not.
  38122. * Please use the according Switch methods to change output.
  38123. */
  38124. get headphone(): boolean;
  38125. /**
  38126. * Gets or sets a refresh rate when using 3D audio positioning
  38127. */
  38128. audioPositioningRefreshRate: number;
  38129. private _audioListenerPositionProvider;
  38130. /**
  38131. * Gets the current audio listener position provider
  38132. */
  38133. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38134. /**
  38135. * Sets a custom listener position for all sounds in the scene
  38136. * By default, this is the position of the first active camera
  38137. */
  38138. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38139. /**
  38140. * Creates a new instance of the component for the given scene
  38141. * @param scene Defines the scene to register the component in
  38142. */
  38143. constructor(scene: Scene);
  38144. /**
  38145. * Registers the component in a given scene
  38146. */
  38147. register(): void;
  38148. /**
  38149. * Rebuilds the elements related to this component in case of
  38150. * context lost for instance.
  38151. */
  38152. rebuild(): void;
  38153. /**
  38154. * Serializes the component data to the specified json object
  38155. * @param serializationObject The object to serialize to
  38156. */
  38157. serialize(serializationObject: any): void;
  38158. /**
  38159. * Adds all the elements from the container to the scene
  38160. * @param container the container holding the elements
  38161. */
  38162. addFromContainer(container: AbstractScene): void;
  38163. /**
  38164. * Removes all the elements in the container from the scene
  38165. * @param container contains the elements to remove
  38166. * @param dispose if the removed element should be disposed (default: false)
  38167. */
  38168. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38169. /**
  38170. * Disposes the component and the associated ressources.
  38171. */
  38172. dispose(): void;
  38173. /**
  38174. * Disables audio in the associated scene.
  38175. */
  38176. disableAudio(): void;
  38177. /**
  38178. * Enables audio in the associated scene.
  38179. */
  38180. enableAudio(): void;
  38181. /**
  38182. * Switch audio to headphone output.
  38183. */
  38184. switchAudioModeForHeadphones(): void;
  38185. /**
  38186. * Switch audio to normal speakers.
  38187. */
  38188. switchAudioModeForNormalSpeakers(): void;
  38189. private _cachedCameraDirection;
  38190. private _cachedCameraPosition;
  38191. private _lastCheck;
  38192. private _afterRender;
  38193. }
  38194. }
  38195. declare module BABYLON {
  38196. /**
  38197. * Wraps one or more Sound objects and selects one with random weight for playback.
  38198. */
  38199. export class WeightedSound {
  38200. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38201. loop: boolean;
  38202. private _coneInnerAngle;
  38203. private _coneOuterAngle;
  38204. private _volume;
  38205. /** A Sound is currently playing. */
  38206. isPlaying: boolean;
  38207. /** A Sound is currently paused. */
  38208. isPaused: boolean;
  38209. private _sounds;
  38210. private _weights;
  38211. private _currentIndex?;
  38212. /**
  38213. * Creates a new WeightedSound from the list of sounds given.
  38214. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38215. * @param sounds Array of Sounds that will be selected from.
  38216. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38217. */
  38218. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38219. /**
  38220. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38221. */
  38222. get directionalConeInnerAngle(): number;
  38223. /**
  38224. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38225. */
  38226. set directionalConeInnerAngle(value: number);
  38227. /**
  38228. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38229. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38230. */
  38231. get directionalConeOuterAngle(): number;
  38232. /**
  38233. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38234. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38235. */
  38236. set directionalConeOuterAngle(value: number);
  38237. /**
  38238. * Playback volume.
  38239. */
  38240. get volume(): number;
  38241. /**
  38242. * Playback volume.
  38243. */
  38244. set volume(value: number);
  38245. private _onended;
  38246. /**
  38247. * Suspend playback
  38248. */
  38249. pause(): void;
  38250. /**
  38251. * Stop playback
  38252. */
  38253. stop(): void;
  38254. /**
  38255. * Start playback.
  38256. * @param startOffset Position the clip head at a specific time in seconds.
  38257. */
  38258. play(startOffset?: number): void;
  38259. }
  38260. }
  38261. declare module BABYLON {
  38262. /**
  38263. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38264. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38265. */
  38266. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38267. /**
  38268. * Gets the name of the behavior.
  38269. */
  38270. get name(): string;
  38271. /**
  38272. * The easing function used by animations
  38273. */
  38274. static EasingFunction: BackEase;
  38275. /**
  38276. * The easing mode used by animations
  38277. */
  38278. static EasingMode: number;
  38279. /**
  38280. * The duration of the animation, in milliseconds
  38281. */
  38282. transitionDuration: number;
  38283. /**
  38284. * Length of the distance animated by the transition when lower radius is reached
  38285. */
  38286. lowerRadiusTransitionRange: number;
  38287. /**
  38288. * Length of the distance animated by the transition when upper radius is reached
  38289. */
  38290. upperRadiusTransitionRange: number;
  38291. private _autoTransitionRange;
  38292. /**
  38293. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38294. */
  38295. get autoTransitionRange(): boolean;
  38296. /**
  38297. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38298. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38299. */
  38300. set autoTransitionRange(value: boolean);
  38301. private _attachedCamera;
  38302. private _onAfterCheckInputsObserver;
  38303. private _onMeshTargetChangedObserver;
  38304. /**
  38305. * Initializes the behavior.
  38306. */
  38307. init(): void;
  38308. /**
  38309. * Attaches the behavior to its arc rotate camera.
  38310. * @param camera Defines the camera to attach the behavior to
  38311. */
  38312. attach(camera: ArcRotateCamera): void;
  38313. /**
  38314. * Detaches the behavior from its current arc rotate camera.
  38315. */
  38316. detach(): void;
  38317. private _radiusIsAnimating;
  38318. private _radiusBounceTransition;
  38319. private _animatables;
  38320. private _cachedWheelPrecision;
  38321. /**
  38322. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38323. * @param radiusLimit The limit to check against.
  38324. * @return Bool to indicate if at limit.
  38325. */
  38326. private _isRadiusAtLimit;
  38327. /**
  38328. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38329. * @param radiusDelta The delta by which to animate to. Can be negative.
  38330. */
  38331. private _applyBoundRadiusAnimation;
  38332. /**
  38333. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38334. */
  38335. protected _clearAnimationLocks(): void;
  38336. /**
  38337. * Stops and removes all animations that have been applied to the camera
  38338. */
  38339. stopAllAnimations(): void;
  38340. }
  38341. }
  38342. declare module BABYLON {
  38343. /**
  38344. * 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.
  38345. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38346. */
  38347. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38348. /**
  38349. * Gets the name of the behavior.
  38350. */
  38351. get name(): string;
  38352. private _mode;
  38353. private _radiusScale;
  38354. private _positionScale;
  38355. private _defaultElevation;
  38356. private _elevationReturnTime;
  38357. private _elevationReturnWaitTime;
  38358. private _zoomStopsAnimation;
  38359. private _framingTime;
  38360. /**
  38361. * The easing function used by animations
  38362. */
  38363. static EasingFunction: ExponentialEase;
  38364. /**
  38365. * The easing mode used by animations
  38366. */
  38367. static EasingMode: number;
  38368. /**
  38369. * Sets the current mode used by the behavior
  38370. */
  38371. set mode(mode: number);
  38372. /**
  38373. * Gets current mode used by the behavior.
  38374. */
  38375. get mode(): number;
  38376. /**
  38377. * Sets the scale applied to the radius (1 by default)
  38378. */
  38379. set radiusScale(radius: number);
  38380. /**
  38381. * Gets the scale applied to the radius
  38382. */
  38383. get radiusScale(): number;
  38384. /**
  38385. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38386. */
  38387. set positionScale(scale: number);
  38388. /**
  38389. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38390. */
  38391. get positionScale(): number;
  38392. /**
  38393. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38394. * behaviour is triggered, in radians.
  38395. */
  38396. set defaultElevation(elevation: number);
  38397. /**
  38398. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38399. * behaviour is triggered, in radians.
  38400. */
  38401. get defaultElevation(): number;
  38402. /**
  38403. * Sets the time (in milliseconds) taken to return to the default beta position.
  38404. * Negative value indicates camera should not return to default.
  38405. */
  38406. set elevationReturnTime(speed: number);
  38407. /**
  38408. * Gets the time (in milliseconds) taken to return to the default beta position.
  38409. * Negative value indicates camera should not return to default.
  38410. */
  38411. get elevationReturnTime(): number;
  38412. /**
  38413. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38414. */
  38415. set elevationReturnWaitTime(time: number);
  38416. /**
  38417. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38418. */
  38419. get elevationReturnWaitTime(): number;
  38420. /**
  38421. * Sets the flag that indicates if user zooming should stop animation.
  38422. */
  38423. set zoomStopsAnimation(flag: boolean);
  38424. /**
  38425. * Gets the flag that indicates if user zooming should stop animation.
  38426. */
  38427. get zoomStopsAnimation(): boolean;
  38428. /**
  38429. * Sets the transition time when framing the mesh, in milliseconds
  38430. */
  38431. set framingTime(time: number);
  38432. /**
  38433. * Gets the transition time when framing the mesh, in milliseconds
  38434. */
  38435. get framingTime(): number;
  38436. /**
  38437. * Define if the behavior should automatically change the configured
  38438. * camera limits and sensibilities.
  38439. */
  38440. autoCorrectCameraLimitsAndSensibility: boolean;
  38441. private _onPrePointerObservableObserver;
  38442. private _onAfterCheckInputsObserver;
  38443. private _onMeshTargetChangedObserver;
  38444. private _attachedCamera;
  38445. private _isPointerDown;
  38446. private _lastInteractionTime;
  38447. /**
  38448. * Initializes the behavior.
  38449. */
  38450. init(): void;
  38451. /**
  38452. * Attaches the behavior to its arc rotate camera.
  38453. * @param camera Defines the camera to attach the behavior to
  38454. */
  38455. attach(camera: ArcRotateCamera): void;
  38456. /**
  38457. * Detaches the behavior from its current arc rotate camera.
  38458. */
  38459. detach(): void;
  38460. private _animatables;
  38461. private _betaIsAnimating;
  38462. private _betaTransition;
  38463. private _radiusTransition;
  38464. private _vectorTransition;
  38465. /**
  38466. * Targets the given mesh and updates zoom level accordingly.
  38467. * @param mesh The mesh to target.
  38468. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38469. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38470. */
  38471. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38472. /**
  38473. * Targets the given mesh with its children and updates zoom level accordingly.
  38474. * @param mesh The mesh to target.
  38475. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38476. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38477. */
  38478. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38479. /**
  38480. * Targets the given meshes with their children and updates zoom level accordingly.
  38481. * @param meshes The mesh to target.
  38482. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38483. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38484. */
  38485. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38486. /**
  38487. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38488. * @param minimumWorld Determines the smaller position of the bounding box extend
  38489. * @param maximumWorld Determines the bigger position of the bounding box extend
  38490. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38491. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38492. */
  38493. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38494. /**
  38495. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38496. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38497. * frustum width.
  38498. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38499. * to fully enclose the mesh in the viewing frustum.
  38500. */
  38501. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38502. /**
  38503. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38504. * is automatically returned to its default position (expected to be above ground plane).
  38505. */
  38506. private _maintainCameraAboveGround;
  38507. /**
  38508. * Returns the frustum slope based on the canvas ratio and camera FOV
  38509. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38510. */
  38511. private _getFrustumSlope;
  38512. /**
  38513. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38514. */
  38515. private _clearAnimationLocks;
  38516. /**
  38517. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38518. */
  38519. private _applyUserInteraction;
  38520. /**
  38521. * Stops and removes all animations that have been applied to the camera
  38522. */
  38523. stopAllAnimations(): void;
  38524. /**
  38525. * Gets a value indicating if the user is moving the camera
  38526. */
  38527. get isUserIsMoving(): boolean;
  38528. /**
  38529. * The camera can move all the way towards the mesh.
  38530. */
  38531. static IgnoreBoundsSizeMode: number;
  38532. /**
  38533. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38534. */
  38535. static FitFrustumSidesMode: number;
  38536. }
  38537. }
  38538. declare module BABYLON {
  38539. /**
  38540. * Base class for Camera Pointer Inputs.
  38541. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38542. * for example usage.
  38543. */
  38544. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38545. /**
  38546. * Defines the camera the input is attached to.
  38547. */
  38548. abstract camera: Camera;
  38549. /**
  38550. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38551. */
  38552. protected _altKey: boolean;
  38553. protected _ctrlKey: boolean;
  38554. protected _metaKey: boolean;
  38555. protected _shiftKey: boolean;
  38556. /**
  38557. * Which mouse buttons were pressed at time of last mouse event.
  38558. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38559. */
  38560. protected _buttonsPressed: number;
  38561. /**
  38562. * Defines the buttons associated with the input to handle camera move.
  38563. */
  38564. buttons: number[];
  38565. /**
  38566. * Attach the input controls to a specific dom element to get the input from.
  38567. * @param element Defines the element the controls should be listened from
  38568. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38569. */
  38570. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38571. /**
  38572. * Detach the current controls from the specified dom element.
  38573. * @param element Defines the element to stop listening the inputs from
  38574. */
  38575. detachControl(element: Nullable<HTMLElement>): void;
  38576. /**
  38577. * Gets the class name of the current input.
  38578. * @returns the class name
  38579. */
  38580. getClassName(): string;
  38581. /**
  38582. * Get the friendly name associated with the input class.
  38583. * @returns the input friendly name
  38584. */
  38585. getSimpleName(): string;
  38586. /**
  38587. * Called on pointer POINTERDOUBLETAP event.
  38588. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38589. */
  38590. protected onDoubleTap(type: string): void;
  38591. /**
  38592. * Called on pointer POINTERMOVE event if only a single touch is active.
  38593. * Override this method to provide functionality.
  38594. */
  38595. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38596. /**
  38597. * Called on pointer POINTERMOVE event if multiple touches are active.
  38598. * Override this method to provide functionality.
  38599. */
  38600. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38601. /**
  38602. * Called on JS contextmenu event.
  38603. * Override this method to provide functionality.
  38604. */
  38605. protected onContextMenu(evt: PointerEvent): void;
  38606. /**
  38607. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38608. * press.
  38609. * Override this method to provide functionality.
  38610. */
  38611. protected onButtonDown(evt: PointerEvent): void;
  38612. /**
  38613. * Called each time a new POINTERUP event occurs. Ie, for each button
  38614. * release.
  38615. * Override this method to provide functionality.
  38616. */
  38617. protected onButtonUp(evt: PointerEvent): void;
  38618. /**
  38619. * Called when window becomes inactive.
  38620. * Override this method to provide functionality.
  38621. */
  38622. protected onLostFocus(): void;
  38623. private _pointerInput;
  38624. private _observer;
  38625. private _onLostFocus;
  38626. private pointA;
  38627. private pointB;
  38628. }
  38629. }
  38630. declare module BABYLON {
  38631. /**
  38632. * Manage the pointers inputs to control an arc rotate camera.
  38633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38634. */
  38635. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38636. /**
  38637. * Defines the camera the input is attached to.
  38638. */
  38639. camera: ArcRotateCamera;
  38640. /**
  38641. * Gets the class name of the current input.
  38642. * @returns the class name
  38643. */
  38644. getClassName(): string;
  38645. /**
  38646. * Defines the buttons associated with the input to handle camera move.
  38647. */
  38648. buttons: number[];
  38649. /**
  38650. * Defines the pointer angular sensibility along the X axis or how fast is
  38651. * the camera rotating.
  38652. */
  38653. angularSensibilityX: number;
  38654. /**
  38655. * Defines the pointer angular sensibility along the Y axis or how fast is
  38656. * the camera rotating.
  38657. */
  38658. angularSensibilityY: number;
  38659. /**
  38660. * Defines the pointer pinch precision or how fast is the camera zooming.
  38661. */
  38662. pinchPrecision: number;
  38663. /**
  38664. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38665. * from 0.
  38666. * It defines the percentage of current camera.radius to use as delta when
  38667. * pinch zoom is used.
  38668. */
  38669. pinchDeltaPercentage: number;
  38670. /**
  38671. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38672. * that any object in the plane at the camera's target point will scale
  38673. * perfectly with finger motion.
  38674. * Overrides pinchDeltaPercentage and pinchPrecision.
  38675. */
  38676. useNaturalPinchZoom: boolean;
  38677. /**
  38678. * Defines the pointer panning sensibility or how fast is the camera moving.
  38679. */
  38680. panningSensibility: number;
  38681. /**
  38682. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38683. */
  38684. multiTouchPanning: boolean;
  38685. /**
  38686. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38687. * zoom (pinch) through multitouch.
  38688. */
  38689. multiTouchPanAndZoom: boolean;
  38690. /**
  38691. * Revers pinch action direction.
  38692. */
  38693. pinchInwards: boolean;
  38694. private _isPanClick;
  38695. private _twoFingerActivityCount;
  38696. private _isPinching;
  38697. /**
  38698. * Called on pointer POINTERMOVE event if only a single touch is active.
  38699. */
  38700. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38701. /**
  38702. * Called on pointer POINTERDOUBLETAP event.
  38703. */
  38704. protected onDoubleTap(type: string): void;
  38705. /**
  38706. * Called on pointer POINTERMOVE event if multiple touches are active.
  38707. */
  38708. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38709. /**
  38710. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38711. * press.
  38712. */
  38713. protected onButtonDown(evt: PointerEvent): void;
  38714. /**
  38715. * Called each time a new POINTERUP event occurs. Ie, for each button
  38716. * release.
  38717. */
  38718. protected onButtonUp(evt: PointerEvent): void;
  38719. /**
  38720. * Called when window becomes inactive.
  38721. */
  38722. protected onLostFocus(): void;
  38723. }
  38724. }
  38725. declare module BABYLON {
  38726. /**
  38727. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38728. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38729. */
  38730. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38731. /**
  38732. * Defines the camera the input is attached to.
  38733. */
  38734. camera: ArcRotateCamera;
  38735. /**
  38736. * Defines the list of key codes associated with the up action (increase alpha)
  38737. */
  38738. keysUp: number[];
  38739. /**
  38740. * Defines the list of key codes associated with the down action (decrease alpha)
  38741. */
  38742. keysDown: number[];
  38743. /**
  38744. * Defines the list of key codes associated with the left action (increase beta)
  38745. */
  38746. keysLeft: number[];
  38747. /**
  38748. * Defines the list of key codes associated with the right action (decrease beta)
  38749. */
  38750. keysRight: number[];
  38751. /**
  38752. * Defines the list of key codes associated with the reset action.
  38753. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38754. */
  38755. keysReset: number[];
  38756. /**
  38757. * Defines the panning sensibility of the inputs.
  38758. * (How fast is the camera panning)
  38759. */
  38760. panningSensibility: number;
  38761. /**
  38762. * Defines the zooming sensibility of the inputs.
  38763. * (How fast is the camera zooming)
  38764. */
  38765. zoomingSensibility: number;
  38766. /**
  38767. * Defines whether maintaining the alt key down switch the movement mode from
  38768. * orientation to zoom.
  38769. */
  38770. useAltToZoom: boolean;
  38771. /**
  38772. * Rotation speed of the camera
  38773. */
  38774. angularSpeed: number;
  38775. private _keys;
  38776. private _ctrlPressed;
  38777. private _altPressed;
  38778. private _onCanvasBlurObserver;
  38779. private _onKeyboardObserver;
  38780. private _engine;
  38781. private _scene;
  38782. /**
  38783. * Attach the input controls to a specific dom element to get the input from.
  38784. * @param element Defines the element the controls should be listened from
  38785. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38786. */
  38787. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38788. /**
  38789. * Detach the current controls from the specified dom element.
  38790. * @param element Defines the element to stop listening the inputs from
  38791. */
  38792. detachControl(element: Nullable<HTMLElement>): void;
  38793. /**
  38794. * Update the current camera state depending on the inputs that have been used this frame.
  38795. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38796. */
  38797. checkInputs(): void;
  38798. /**
  38799. * Gets the class name of the current intput.
  38800. * @returns the class name
  38801. */
  38802. getClassName(): string;
  38803. /**
  38804. * Get the friendly name associated with the input class.
  38805. * @returns the input friendly name
  38806. */
  38807. getSimpleName(): string;
  38808. }
  38809. }
  38810. declare module BABYLON {
  38811. /**
  38812. * Manage the mouse wheel inputs to control an arc rotate camera.
  38813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38814. */
  38815. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38816. /**
  38817. * Defines the camera the input is attached to.
  38818. */
  38819. camera: ArcRotateCamera;
  38820. /**
  38821. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38822. */
  38823. wheelPrecision: number;
  38824. /**
  38825. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38826. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38827. */
  38828. wheelDeltaPercentage: number;
  38829. private _wheel;
  38830. private _observer;
  38831. private computeDeltaFromMouseWheelLegacyEvent;
  38832. /**
  38833. * Attach the input controls to a specific dom element to get the input from.
  38834. * @param element Defines the element the controls should be listened from
  38835. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38836. */
  38837. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38838. /**
  38839. * Detach the current controls from the specified dom element.
  38840. * @param element Defines the element to stop listening the inputs from
  38841. */
  38842. detachControl(element: Nullable<HTMLElement>): void;
  38843. /**
  38844. * Gets the class name of the current intput.
  38845. * @returns the class name
  38846. */
  38847. getClassName(): string;
  38848. /**
  38849. * Get the friendly name associated with the input class.
  38850. * @returns the input friendly name
  38851. */
  38852. getSimpleName(): string;
  38853. }
  38854. }
  38855. declare module BABYLON {
  38856. /**
  38857. * Default Inputs manager for the ArcRotateCamera.
  38858. * It groups all the default supported inputs for ease of use.
  38859. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38860. */
  38861. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38862. /**
  38863. * Instantiates a new ArcRotateCameraInputsManager.
  38864. * @param camera Defines the camera the inputs belong to
  38865. */
  38866. constructor(camera: ArcRotateCamera);
  38867. /**
  38868. * Add mouse wheel input support to the input manager.
  38869. * @returns the current input manager
  38870. */
  38871. addMouseWheel(): ArcRotateCameraInputsManager;
  38872. /**
  38873. * Add pointers input support to the input manager.
  38874. * @returns the current input manager
  38875. */
  38876. addPointers(): ArcRotateCameraInputsManager;
  38877. /**
  38878. * Add keyboard input support to the input manager.
  38879. * @returns the current input manager
  38880. */
  38881. addKeyboard(): ArcRotateCameraInputsManager;
  38882. }
  38883. }
  38884. declare module BABYLON {
  38885. /**
  38886. * This represents an orbital type of camera.
  38887. *
  38888. * 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.
  38889. * 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.
  38890. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38891. */
  38892. export class ArcRotateCamera extends TargetCamera {
  38893. /**
  38894. * Defines the rotation angle of the camera along the longitudinal axis.
  38895. */
  38896. alpha: number;
  38897. /**
  38898. * Defines the rotation angle of the camera along the latitudinal axis.
  38899. */
  38900. beta: number;
  38901. /**
  38902. * Defines the radius of the camera from it s target point.
  38903. */
  38904. radius: number;
  38905. protected _target: Vector3;
  38906. protected _targetHost: Nullable<AbstractMesh>;
  38907. /**
  38908. * Defines the target point of the camera.
  38909. * The camera looks towards it form the radius distance.
  38910. */
  38911. get target(): Vector3;
  38912. set target(value: Vector3);
  38913. /**
  38914. * Define the current local position of the camera in the scene
  38915. */
  38916. get position(): Vector3;
  38917. set position(newPosition: Vector3);
  38918. protected _upVector: Vector3;
  38919. protected _upToYMatrix: Matrix;
  38920. protected _YToUpMatrix: Matrix;
  38921. /**
  38922. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38923. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38924. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38925. */
  38926. set upVector(vec: Vector3);
  38927. get upVector(): Vector3;
  38928. /**
  38929. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38930. */
  38931. setMatUp(): void;
  38932. /**
  38933. * Current inertia value on the longitudinal axis.
  38934. * The bigger this number the longer it will take for the camera to stop.
  38935. */
  38936. inertialAlphaOffset: number;
  38937. /**
  38938. * Current inertia value on the latitudinal axis.
  38939. * The bigger this number the longer it will take for the camera to stop.
  38940. */
  38941. inertialBetaOffset: number;
  38942. /**
  38943. * Current inertia value on the radius axis.
  38944. * The bigger this number the longer it will take for the camera to stop.
  38945. */
  38946. inertialRadiusOffset: number;
  38947. /**
  38948. * Minimum allowed angle on the longitudinal axis.
  38949. * This can help limiting how the Camera is able to move in the scene.
  38950. */
  38951. lowerAlphaLimit: Nullable<number>;
  38952. /**
  38953. * Maximum allowed angle on the longitudinal axis.
  38954. * This can help limiting how the Camera is able to move in the scene.
  38955. */
  38956. upperAlphaLimit: Nullable<number>;
  38957. /**
  38958. * Minimum allowed angle on the latitudinal axis.
  38959. * This can help limiting how the Camera is able to move in the scene.
  38960. */
  38961. lowerBetaLimit: number;
  38962. /**
  38963. * Maximum allowed angle on the latitudinal axis.
  38964. * This can help limiting how the Camera is able to move in the scene.
  38965. */
  38966. upperBetaLimit: number;
  38967. /**
  38968. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38969. * This can help limiting how the Camera is able to move in the scene.
  38970. */
  38971. lowerRadiusLimit: Nullable<number>;
  38972. /**
  38973. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38974. * This can help limiting how the Camera is able to move in the scene.
  38975. */
  38976. upperRadiusLimit: Nullable<number>;
  38977. /**
  38978. * Defines the current inertia value used during panning of the camera along the X axis.
  38979. */
  38980. inertialPanningX: number;
  38981. /**
  38982. * Defines the current inertia value used during panning of the camera along the Y axis.
  38983. */
  38984. inertialPanningY: number;
  38985. /**
  38986. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38987. * Basically if your fingers moves away from more than this distance you will be considered
  38988. * in pinch mode.
  38989. */
  38990. pinchToPanMaxDistance: number;
  38991. /**
  38992. * Defines the maximum distance the camera can pan.
  38993. * This could help keeping the cammera always in your scene.
  38994. */
  38995. panningDistanceLimit: Nullable<number>;
  38996. /**
  38997. * Defines the target of the camera before paning.
  38998. */
  38999. panningOriginTarget: Vector3;
  39000. /**
  39001. * Defines the value of the inertia used during panning.
  39002. * 0 would mean stop inertia and one would mean no decelleration at all.
  39003. */
  39004. panningInertia: number;
  39005. /**
  39006. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39007. */
  39008. get angularSensibilityX(): number;
  39009. set angularSensibilityX(value: number);
  39010. /**
  39011. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39012. */
  39013. get angularSensibilityY(): number;
  39014. set angularSensibilityY(value: number);
  39015. /**
  39016. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39017. */
  39018. get pinchPrecision(): number;
  39019. set pinchPrecision(value: number);
  39020. /**
  39021. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39022. * It will be used instead of pinchDeltaPrecision if different from 0.
  39023. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39024. */
  39025. get pinchDeltaPercentage(): number;
  39026. set pinchDeltaPercentage(value: number);
  39027. /**
  39028. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39029. * and pinch delta percentage.
  39030. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39031. * that any object in the plane at the camera's target point will scale
  39032. * perfectly with finger motion.
  39033. */
  39034. get useNaturalPinchZoom(): boolean;
  39035. set useNaturalPinchZoom(value: boolean);
  39036. /**
  39037. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39038. */
  39039. get panningSensibility(): number;
  39040. set panningSensibility(value: number);
  39041. /**
  39042. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39043. */
  39044. get keysUp(): number[];
  39045. set keysUp(value: number[]);
  39046. /**
  39047. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39048. */
  39049. get keysDown(): number[];
  39050. set keysDown(value: number[]);
  39051. /**
  39052. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39053. */
  39054. get keysLeft(): number[];
  39055. set keysLeft(value: number[]);
  39056. /**
  39057. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39058. */
  39059. get keysRight(): number[];
  39060. set keysRight(value: number[]);
  39061. /**
  39062. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39063. */
  39064. get wheelPrecision(): number;
  39065. set wheelPrecision(value: number);
  39066. /**
  39067. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39068. * It will be used instead of pinchDeltaPrecision if different from 0.
  39069. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39070. */
  39071. get wheelDeltaPercentage(): number;
  39072. set wheelDeltaPercentage(value: number);
  39073. /**
  39074. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39075. */
  39076. zoomOnFactor: number;
  39077. /**
  39078. * Defines a screen offset for the camera position.
  39079. */
  39080. targetScreenOffset: Vector2;
  39081. /**
  39082. * Allows the camera to be completely reversed.
  39083. * If false the camera can not arrive upside down.
  39084. */
  39085. allowUpsideDown: boolean;
  39086. /**
  39087. * Define if double tap/click is used to restore the previously saved state of the camera.
  39088. */
  39089. useInputToRestoreState: boolean;
  39090. /** @hidden */
  39091. _viewMatrix: Matrix;
  39092. /** @hidden */
  39093. _useCtrlForPanning: boolean;
  39094. /** @hidden */
  39095. _panningMouseButton: number;
  39096. /**
  39097. * Defines the input associated to the camera.
  39098. */
  39099. inputs: ArcRotateCameraInputsManager;
  39100. /** @hidden */
  39101. _reset: () => void;
  39102. /**
  39103. * Defines the allowed panning axis.
  39104. */
  39105. panningAxis: Vector3;
  39106. protected _localDirection: Vector3;
  39107. protected _transformedDirection: Vector3;
  39108. private _bouncingBehavior;
  39109. /**
  39110. * Gets the bouncing behavior of the camera if it has been enabled.
  39111. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39112. */
  39113. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39114. /**
  39115. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39117. */
  39118. get useBouncingBehavior(): boolean;
  39119. set useBouncingBehavior(value: boolean);
  39120. private _framingBehavior;
  39121. /**
  39122. * Gets the framing behavior of the camera if it has been enabled.
  39123. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39124. */
  39125. get framingBehavior(): Nullable<FramingBehavior>;
  39126. /**
  39127. * Defines if the framing behavior of the camera is enabled on the camera.
  39128. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39129. */
  39130. get useFramingBehavior(): boolean;
  39131. set useFramingBehavior(value: boolean);
  39132. private _autoRotationBehavior;
  39133. /**
  39134. * Gets the auto rotation behavior of the camera if it has been enabled.
  39135. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39136. */
  39137. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39138. /**
  39139. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39140. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39141. */
  39142. get useAutoRotationBehavior(): boolean;
  39143. set useAutoRotationBehavior(value: boolean);
  39144. /**
  39145. * Observable triggered when the mesh target has been changed on the camera.
  39146. */
  39147. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39148. /**
  39149. * Event raised when the camera is colliding with a mesh.
  39150. */
  39151. onCollide: (collidedMesh: AbstractMesh) => void;
  39152. /**
  39153. * Defines whether the camera should check collision with the objects oh the scene.
  39154. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39155. */
  39156. checkCollisions: boolean;
  39157. /**
  39158. * Defines the collision radius of the camera.
  39159. * This simulates a sphere around the camera.
  39160. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39161. */
  39162. collisionRadius: Vector3;
  39163. protected _collider: Collider;
  39164. protected _previousPosition: Vector3;
  39165. protected _collisionVelocity: Vector3;
  39166. protected _newPosition: Vector3;
  39167. protected _previousAlpha: number;
  39168. protected _previousBeta: number;
  39169. protected _previousRadius: number;
  39170. protected _collisionTriggered: boolean;
  39171. protected _targetBoundingCenter: Nullable<Vector3>;
  39172. private _computationVector;
  39173. /**
  39174. * Instantiates a new ArcRotateCamera in a given scene
  39175. * @param name Defines the name of the camera
  39176. * @param alpha Defines the camera rotation along the logitudinal axis
  39177. * @param beta Defines the camera rotation along the latitudinal axis
  39178. * @param radius Defines the camera distance from its target
  39179. * @param target Defines the camera target
  39180. * @param scene Defines the scene the camera belongs to
  39181. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39182. */
  39183. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39184. /** @hidden */
  39185. _initCache(): void;
  39186. /** @hidden */
  39187. _updateCache(ignoreParentClass?: boolean): void;
  39188. protected _getTargetPosition(): Vector3;
  39189. private _storedAlpha;
  39190. private _storedBeta;
  39191. private _storedRadius;
  39192. private _storedTarget;
  39193. private _storedTargetScreenOffset;
  39194. /**
  39195. * Stores the current state of the camera (alpha, beta, radius and target)
  39196. * @returns the camera itself
  39197. */
  39198. storeState(): Camera;
  39199. /**
  39200. * @hidden
  39201. * Restored camera state. You must call storeState() first
  39202. */
  39203. _restoreStateValues(): boolean;
  39204. /** @hidden */
  39205. _isSynchronizedViewMatrix(): boolean;
  39206. /**
  39207. * Attached controls to the current camera.
  39208. * @param element Defines the element the controls should be listened from
  39209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39210. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39211. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39212. */
  39213. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39214. /**
  39215. * Detach the current controls from the camera.
  39216. * The camera will stop reacting to inputs.
  39217. * @param element Defines the element to stop listening the inputs from
  39218. */
  39219. detachControl(element: HTMLElement): void;
  39220. /** @hidden */
  39221. _checkInputs(): void;
  39222. protected _checkLimits(): void;
  39223. /**
  39224. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39225. */
  39226. rebuildAnglesAndRadius(): void;
  39227. /**
  39228. * Use a position to define the current camera related information like alpha, beta and radius
  39229. * @param position Defines the position to set the camera at
  39230. */
  39231. setPosition(position: Vector3): void;
  39232. /**
  39233. * Defines the target the camera should look at.
  39234. * This will automatically adapt alpha beta and radius to fit within the new target.
  39235. * @param target Defines the new target as a Vector or a mesh
  39236. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39237. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39238. */
  39239. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39240. /** @hidden */
  39241. _getViewMatrix(): Matrix;
  39242. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39243. /**
  39244. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39245. * @param meshes Defines the mesh to zoom on
  39246. * @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)
  39247. */
  39248. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39249. /**
  39250. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39251. * The target will be changed but the radius
  39252. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39253. * @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)
  39254. */
  39255. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39256. min: Vector3;
  39257. max: Vector3;
  39258. distance: number;
  39259. }, doNotUpdateMaxZ?: boolean): void;
  39260. /**
  39261. * @override
  39262. * Override Camera.createRigCamera
  39263. */
  39264. createRigCamera(name: string, cameraIndex: number): Camera;
  39265. /**
  39266. * @hidden
  39267. * @override
  39268. * Override Camera._updateRigCameras
  39269. */
  39270. _updateRigCameras(): void;
  39271. /**
  39272. * Destroy the camera and release the current resources hold by it.
  39273. */
  39274. dispose(): void;
  39275. /**
  39276. * Gets the current object class name.
  39277. * @return the class name
  39278. */
  39279. getClassName(): string;
  39280. }
  39281. }
  39282. declare module BABYLON {
  39283. /**
  39284. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39285. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39286. */
  39287. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39288. /**
  39289. * Gets the name of the behavior.
  39290. */
  39291. get name(): string;
  39292. private _zoomStopsAnimation;
  39293. private _idleRotationSpeed;
  39294. private _idleRotationWaitTime;
  39295. private _idleRotationSpinupTime;
  39296. /**
  39297. * Sets the flag that indicates if user zooming should stop animation.
  39298. */
  39299. set zoomStopsAnimation(flag: boolean);
  39300. /**
  39301. * Gets the flag that indicates if user zooming should stop animation.
  39302. */
  39303. get zoomStopsAnimation(): boolean;
  39304. /**
  39305. * Sets the default speed at which the camera rotates around the model.
  39306. */
  39307. set idleRotationSpeed(speed: number);
  39308. /**
  39309. * Gets the default speed at which the camera rotates around the model.
  39310. */
  39311. get idleRotationSpeed(): number;
  39312. /**
  39313. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39314. */
  39315. set idleRotationWaitTime(time: number);
  39316. /**
  39317. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39318. */
  39319. get idleRotationWaitTime(): number;
  39320. /**
  39321. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39322. */
  39323. set idleRotationSpinupTime(time: number);
  39324. /**
  39325. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39326. */
  39327. get idleRotationSpinupTime(): number;
  39328. /**
  39329. * Gets a value indicating if the camera is currently rotating because of this behavior
  39330. */
  39331. get rotationInProgress(): boolean;
  39332. private _onPrePointerObservableObserver;
  39333. private _onAfterCheckInputsObserver;
  39334. private _attachedCamera;
  39335. private _isPointerDown;
  39336. private _lastFrameTime;
  39337. private _lastInteractionTime;
  39338. private _cameraRotationSpeed;
  39339. /**
  39340. * Initializes the behavior.
  39341. */
  39342. init(): void;
  39343. /**
  39344. * Attaches the behavior to its arc rotate camera.
  39345. * @param camera Defines the camera to attach the behavior to
  39346. */
  39347. attach(camera: ArcRotateCamera): void;
  39348. /**
  39349. * Detaches the behavior from its current arc rotate camera.
  39350. */
  39351. detach(): void;
  39352. /**
  39353. * Returns true if user is scrolling.
  39354. * @return true if user is scrolling.
  39355. */
  39356. private _userIsZooming;
  39357. private _lastFrameRadius;
  39358. private _shouldAnimationStopForInteraction;
  39359. /**
  39360. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39361. */
  39362. private _applyUserInteraction;
  39363. private _userIsMoving;
  39364. }
  39365. }
  39366. declare module BABYLON {
  39367. /**
  39368. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39369. */
  39370. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39371. private ui;
  39372. /**
  39373. * The name of the behavior
  39374. */
  39375. name: string;
  39376. /**
  39377. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39378. */
  39379. distanceAwayFromFace: number;
  39380. /**
  39381. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39382. */
  39383. distanceAwayFromBottomOfFace: number;
  39384. private _faceVectors;
  39385. private _target;
  39386. private _scene;
  39387. private _onRenderObserver;
  39388. private _tmpMatrix;
  39389. private _tmpVector;
  39390. /**
  39391. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39392. * @param ui The transform node that should be attched to the mesh
  39393. */
  39394. constructor(ui: TransformNode);
  39395. /**
  39396. * Initializes the behavior
  39397. */
  39398. init(): void;
  39399. private _closestFace;
  39400. private _zeroVector;
  39401. private _lookAtTmpMatrix;
  39402. private _lookAtToRef;
  39403. /**
  39404. * Attaches the AttachToBoxBehavior to the passed in mesh
  39405. * @param target The mesh that the specified node will be attached to
  39406. */
  39407. attach(target: Mesh): void;
  39408. /**
  39409. * Detaches the behavior from the mesh
  39410. */
  39411. detach(): void;
  39412. }
  39413. }
  39414. declare module BABYLON {
  39415. /**
  39416. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39417. */
  39418. export class FadeInOutBehavior implements Behavior<Mesh> {
  39419. /**
  39420. * Time in milliseconds to delay before fading in (Default: 0)
  39421. */
  39422. delay: number;
  39423. /**
  39424. * Time in milliseconds for the mesh to fade in (Default: 300)
  39425. */
  39426. fadeInTime: number;
  39427. private _millisecondsPerFrame;
  39428. private _hovered;
  39429. private _hoverValue;
  39430. private _ownerNode;
  39431. /**
  39432. * Instatiates the FadeInOutBehavior
  39433. */
  39434. constructor();
  39435. /**
  39436. * The name of the behavior
  39437. */
  39438. get name(): string;
  39439. /**
  39440. * Initializes the behavior
  39441. */
  39442. init(): void;
  39443. /**
  39444. * Attaches the fade behavior on the passed in mesh
  39445. * @param ownerNode The mesh that will be faded in/out once attached
  39446. */
  39447. attach(ownerNode: Mesh): void;
  39448. /**
  39449. * Detaches the behavior from the mesh
  39450. */
  39451. detach(): void;
  39452. /**
  39453. * Triggers the mesh to begin fading in or out
  39454. * @param value if the object should fade in or out (true to fade in)
  39455. */
  39456. fadeIn(value: boolean): void;
  39457. private _update;
  39458. private _setAllVisibility;
  39459. }
  39460. }
  39461. declare module BABYLON {
  39462. /**
  39463. * Class containing a set of static utilities functions for managing Pivots
  39464. * @hidden
  39465. */
  39466. export class PivotTools {
  39467. private static _PivotCached;
  39468. private static _OldPivotPoint;
  39469. private static _PivotTranslation;
  39470. private static _PivotTmpVector;
  39471. /** @hidden */
  39472. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39473. /** @hidden */
  39474. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39475. }
  39476. }
  39477. declare module BABYLON {
  39478. /**
  39479. * Class containing static functions to help procedurally build meshes
  39480. */
  39481. export class PlaneBuilder {
  39482. /**
  39483. * Creates a plane mesh
  39484. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39485. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39486. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39488. * * 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
  39489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39490. * @param name defines the name of the mesh
  39491. * @param options defines the options used to create the mesh
  39492. * @param scene defines the hosting scene
  39493. * @returns the plane mesh
  39494. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39495. */
  39496. static CreatePlane(name: string, options: {
  39497. size?: number;
  39498. width?: number;
  39499. height?: number;
  39500. sideOrientation?: number;
  39501. frontUVs?: Vector4;
  39502. backUVs?: Vector4;
  39503. updatable?: boolean;
  39504. sourcePlane?: Plane;
  39505. }, scene?: Nullable<Scene>): Mesh;
  39506. }
  39507. }
  39508. declare module BABYLON {
  39509. /**
  39510. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39511. */
  39512. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39513. private static _AnyMouseID;
  39514. /**
  39515. * Abstract mesh the behavior is set on
  39516. */
  39517. attachedNode: AbstractMesh;
  39518. private _dragPlane;
  39519. private _scene;
  39520. private _pointerObserver;
  39521. private _beforeRenderObserver;
  39522. private static _planeScene;
  39523. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39524. /**
  39525. * 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)
  39526. */
  39527. maxDragAngle: number;
  39528. /**
  39529. * @hidden
  39530. */
  39531. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39532. /**
  39533. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39534. */
  39535. currentDraggingPointerID: number;
  39536. /**
  39537. * The last position where the pointer hit the drag plane in world space
  39538. */
  39539. lastDragPosition: Vector3;
  39540. /**
  39541. * If the behavior is currently in a dragging state
  39542. */
  39543. dragging: boolean;
  39544. /**
  39545. * 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)
  39546. */
  39547. dragDeltaRatio: number;
  39548. /**
  39549. * If the drag plane orientation should be updated during the dragging (Default: true)
  39550. */
  39551. updateDragPlane: boolean;
  39552. private _debugMode;
  39553. private _moving;
  39554. /**
  39555. * Fires each time the attached mesh is dragged with the pointer
  39556. * * delta between last drag position and current drag position in world space
  39557. * * dragDistance along the drag axis
  39558. * * dragPlaneNormal normal of the current drag plane used during the drag
  39559. * * dragPlanePoint in world space where the drag intersects the drag plane
  39560. */
  39561. onDragObservable: Observable<{
  39562. delta: Vector3;
  39563. dragPlanePoint: Vector3;
  39564. dragPlaneNormal: Vector3;
  39565. dragDistance: number;
  39566. pointerId: number;
  39567. }>;
  39568. /**
  39569. * Fires each time a drag begins (eg. mouse down on mesh)
  39570. */
  39571. onDragStartObservable: Observable<{
  39572. dragPlanePoint: Vector3;
  39573. pointerId: number;
  39574. }>;
  39575. /**
  39576. * Fires each time a drag ends (eg. mouse release after drag)
  39577. */
  39578. onDragEndObservable: Observable<{
  39579. dragPlanePoint: Vector3;
  39580. pointerId: number;
  39581. }>;
  39582. /**
  39583. * If the attached mesh should be moved when dragged
  39584. */
  39585. moveAttached: boolean;
  39586. /**
  39587. * If the drag behavior will react to drag events (Default: true)
  39588. */
  39589. enabled: boolean;
  39590. /**
  39591. * If pointer events should start and release the drag (Default: true)
  39592. */
  39593. startAndReleaseDragOnPointerEvents: boolean;
  39594. /**
  39595. * If camera controls should be detached during the drag
  39596. */
  39597. detachCameraControls: boolean;
  39598. /**
  39599. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39600. */
  39601. useObjectOrientationForDragging: boolean;
  39602. private _options;
  39603. /**
  39604. * Gets the options used by the behavior
  39605. */
  39606. get options(): {
  39607. dragAxis?: Vector3;
  39608. dragPlaneNormal?: Vector3;
  39609. };
  39610. /**
  39611. * Sets the options used by the behavior
  39612. */
  39613. set options(options: {
  39614. dragAxis?: Vector3;
  39615. dragPlaneNormal?: Vector3;
  39616. });
  39617. /**
  39618. * Creates a pointer drag behavior that can be attached to a mesh
  39619. * @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)
  39620. */
  39621. constructor(options?: {
  39622. dragAxis?: Vector3;
  39623. dragPlaneNormal?: Vector3;
  39624. });
  39625. /**
  39626. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39627. */
  39628. validateDrag: (targetPosition: Vector3) => boolean;
  39629. /**
  39630. * The name of the behavior
  39631. */
  39632. get name(): string;
  39633. /**
  39634. * Initializes the behavior
  39635. */
  39636. init(): void;
  39637. private _tmpVector;
  39638. private _alternatePickedPoint;
  39639. private _worldDragAxis;
  39640. private _targetPosition;
  39641. private _attachedElement;
  39642. /**
  39643. * Attaches the drag behavior the passed in mesh
  39644. * @param ownerNode The mesh that will be dragged around once attached
  39645. * @param predicate Predicate to use for pick filtering
  39646. */
  39647. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39648. /**
  39649. * Force relase the drag action by code.
  39650. */
  39651. releaseDrag(): void;
  39652. private _startDragRay;
  39653. private _lastPointerRay;
  39654. /**
  39655. * Simulates the start of a pointer drag event on the behavior
  39656. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39657. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39658. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39659. */
  39660. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39661. private _startDrag;
  39662. private _dragDelta;
  39663. private _moveDrag;
  39664. private _pickWithRayOnDragPlane;
  39665. private _pointA;
  39666. private _pointB;
  39667. private _pointC;
  39668. private _lineA;
  39669. private _lineB;
  39670. private _localAxis;
  39671. private _lookAt;
  39672. private _updateDragPlanePosition;
  39673. /**
  39674. * Detaches the behavior from the mesh
  39675. */
  39676. detach(): void;
  39677. }
  39678. }
  39679. declare module BABYLON {
  39680. /**
  39681. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39682. */
  39683. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39684. private _dragBehaviorA;
  39685. private _dragBehaviorB;
  39686. private _startDistance;
  39687. private _initialScale;
  39688. private _targetScale;
  39689. private _ownerNode;
  39690. private _sceneRenderObserver;
  39691. /**
  39692. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39693. */
  39694. constructor();
  39695. /**
  39696. * The name of the behavior
  39697. */
  39698. get name(): string;
  39699. /**
  39700. * Initializes the behavior
  39701. */
  39702. init(): void;
  39703. private _getCurrentDistance;
  39704. /**
  39705. * Attaches the scale behavior the passed in mesh
  39706. * @param ownerNode The mesh that will be scaled around once attached
  39707. */
  39708. attach(ownerNode: Mesh): void;
  39709. /**
  39710. * Detaches the behavior from the mesh
  39711. */
  39712. detach(): void;
  39713. }
  39714. }
  39715. declare module BABYLON {
  39716. /**
  39717. * 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
  39718. */
  39719. export class SixDofDragBehavior implements Behavior<Mesh> {
  39720. private static _virtualScene;
  39721. private _ownerNode;
  39722. private _sceneRenderObserver;
  39723. private _scene;
  39724. private _targetPosition;
  39725. private _virtualOriginMesh;
  39726. private _virtualDragMesh;
  39727. private _pointerObserver;
  39728. private _moving;
  39729. private _startingOrientation;
  39730. private _attachedElement;
  39731. /**
  39732. * 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)
  39733. */
  39734. private zDragFactor;
  39735. /**
  39736. * If the object should rotate to face the drag origin
  39737. */
  39738. rotateDraggedObject: boolean;
  39739. /**
  39740. * If the behavior is currently in a dragging state
  39741. */
  39742. dragging: boolean;
  39743. /**
  39744. * 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)
  39745. */
  39746. dragDeltaRatio: number;
  39747. /**
  39748. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39749. */
  39750. currentDraggingPointerID: number;
  39751. /**
  39752. * If camera controls should be detached during the drag
  39753. */
  39754. detachCameraControls: boolean;
  39755. /**
  39756. * Fires each time a drag starts
  39757. */
  39758. onDragStartObservable: Observable<{}>;
  39759. /**
  39760. * Fires each time a drag ends (eg. mouse release after drag)
  39761. */
  39762. onDragEndObservable: Observable<{}>;
  39763. /**
  39764. * 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
  39765. */
  39766. constructor();
  39767. /**
  39768. * The name of the behavior
  39769. */
  39770. get name(): string;
  39771. /**
  39772. * Initializes the behavior
  39773. */
  39774. init(): void;
  39775. /**
  39776. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39777. */
  39778. private get _pointerCamera();
  39779. /**
  39780. * Attaches the scale behavior the passed in mesh
  39781. * @param ownerNode The mesh that will be scaled around once attached
  39782. */
  39783. attach(ownerNode: Mesh): void;
  39784. /**
  39785. * Detaches the behavior from the mesh
  39786. */
  39787. detach(): void;
  39788. }
  39789. }
  39790. declare module BABYLON {
  39791. /**
  39792. * Class used to apply inverse kinematics to bones
  39793. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39794. */
  39795. export class BoneIKController {
  39796. private static _tmpVecs;
  39797. private static _tmpQuat;
  39798. private static _tmpMats;
  39799. /**
  39800. * Gets or sets the target mesh
  39801. */
  39802. targetMesh: AbstractMesh;
  39803. /** Gets or sets the mesh used as pole */
  39804. poleTargetMesh: AbstractMesh;
  39805. /**
  39806. * Gets or sets the bone used as pole
  39807. */
  39808. poleTargetBone: Nullable<Bone>;
  39809. /**
  39810. * Gets or sets the target position
  39811. */
  39812. targetPosition: Vector3;
  39813. /**
  39814. * Gets or sets the pole target position
  39815. */
  39816. poleTargetPosition: Vector3;
  39817. /**
  39818. * Gets or sets the pole target local offset
  39819. */
  39820. poleTargetLocalOffset: Vector3;
  39821. /**
  39822. * Gets or sets the pole angle
  39823. */
  39824. poleAngle: number;
  39825. /**
  39826. * Gets or sets the mesh associated with the controller
  39827. */
  39828. mesh: AbstractMesh;
  39829. /**
  39830. * 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)
  39831. */
  39832. slerpAmount: number;
  39833. private _bone1Quat;
  39834. private _bone1Mat;
  39835. private _bone2Ang;
  39836. private _bone1;
  39837. private _bone2;
  39838. private _bone1Length;
  39839. private _bone2Length;
  39840. private _maxAngle;
  39841. private _maxReach;
  39842. private _rightHandedSystem;
  39843. private _bendAxis;
  39844. private _slerping;
  39845. private _adjustRoll;
  39846. /**
  39847. * Gets or sets maximum allowed angle
  39848. */
  39849. get maxAngle(): number;
  39850. set maxAngle(value: number);
  39851. /**
  39852. * Creates a new BoneIKController
  39853. * @param mesh defines the mesh to control
  39854. * @param bone defines the bone to control
  39855. * @param options defines options to set up the controller
  39856. */
  39857. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39858. targetMesh?: AbstractMesh;
  39859. poleTargetMesh?: AbstractMesh;
  39860. poleTargetBone?: Bone;
  39861. poleTargetLocalOffset?: Vector3;
  39862. poleAngle?: number;
  39863. bendAxis?: Vector3;
  39864. maxAngle?: number;
  39865. slerpAmount?: number;
  39866. });
  39867. private _setMaxAngle;
  39868. /**
  39869. * Force the controller to update the bones
  39870. */
  39871. update(): void;
  39872. }
  39873. }
  39874. declare module BABYLON {
  39875. /**
  39876. * Class used to make a bone look toward a point in space
  39877. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39878. */
  39879. export class BoneLookController {
  39880. private static _tmpVecs;
  39881. private static _tmpQuat;
  39882. private static _tmpMats;
  39883. /**
  39884. * The target Vector3 that the bone will look at
  39885. */
  39886. target: Vector3;
  39887. /**
  39888. * The mesh that the bone is attached to
  39889. */
  39890. mesh: AbstractMesh;
  39891. /**
  39892. * The bone that will be looking to the target
  39893. */
  39894. bone: Bone;
  39895. /**
  39896. * The up axis of the coordinate system that is used when the bone is rotated
  39897. */
  39898. upAxis: Vector3;
  39899. /**
  39900. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39901. */
  39902. upAxisSpace: Space;
  39903. /**
  39904. * Used to make an adjustment to the yaw of the bone
  39905. */
  39906. adjustYaw: number;
  39907. /**
  39908. * Used to make an adjustment to the pitch of the bone
  39909. */
  39910. adjustPitch: number;
  39911. /**
  39912. * Used to make an adjustment to the roll of the bone
  39913. */
  39914. adjustRoll: number;
  39915. /**
  39916. * 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)
  39917. */
  39918. slerpAmount: number;
  39919. private _minYaw;
  39920. private _maxYaw;
  39921. private _minPitch;
  39922. private _maxPitch;
  39923. private _minYawSin;
  39924. private _minYawCos;
  39925. private _maxYawSin;
  39926. private _maxYawCos;
  39927. private _midYawConstraint;
  39928. private _minPitchTan;
  39929. private _maxPitchTan;
  39930. private _boneQuat;
  39931. private _slerping;
  39932. private _transformYawPitch;
  39933. private _transformYawPitchInv;
  39934. private _firstFrameSkipped;
  39935. private _yawRange;
  39936. private _fowardAxis;
  39937. /**
  39938. * Gets or sets the minimum yaw angle that the bone can look to
  39939. */
  39940. get minYaw(): number;
  39941. set minYaw(value: number);
  39942. /**
  39943. * Gets or sets the maximum yaw angle that the bone can look to
  39944. */
  39945. get maxYaw(): number;
  39946. set maxYaw(value: number);
  39947. /**
  39948. * Gets or sets the minimum pitch angle that the bone can look to
  39949. */
  39950. get minPitch(): number;
  39951. set minPitch(value: number);
  39952. /**
  39953. * Gets or sets the maximum pitch angle that the bone can look to
  39954. */
  39955. get maxPitch(): number;
  39956. set maxPitch(value: number);
  39957. /**
  39958. * Create a BoneLookController
  39959. * @param mesh the mesh that the bone belongs to
  39960. * @param bone the bone that will be looking to the target
  39961. * @param target the target Vector3 to look at
  39962. * @param options optional settings:
  39963. * * maxYaw: the maximum angle the bone will yaw to
  39964. * * minYaw: the minimum angle the bone will yaw to
  39965. * * maxPitch: the maximum angle the bone will pitch to
  39966. * * minPitch: the minimum angle the bone will yaw to
  39967. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39968. * * upAxis: the up axis of the coordinate system
  39969. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39970. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39971. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39972. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39973. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39974. * * adjustRoll: used to make an adjustment to the roll of the bone
  39975. **/
  39976. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39977. maxYaw?: number;
  39978. minYaw?: number;
  39979. maxPitch?: number;
  39980. minPitch?: number;
  39981. slerpAmount?: number;
  39982. upAxis?: Vector3;
  39983. upAxisSpace?: Space;
  39984. yawAxis?: Vector3;
  39985. pitchAxis?: Vector3;
  39986. adjustYaw?: number;
  39987. adjustPitch?: number;
  39988. adjustRoll?: number;
  39989. });
  39990. /**
  39991. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39992. */
  39993. update(): void;
  39994. private _getAngleDiff;
  39995. private _getAngleBetween;
  39996. private _isAngleBetween;
  39997. }
  39998. }
  39999. declare module BABYLON {
  40000. /**
  40001. * Manage the gamepad inputs to control an arc rotate camera.
  40002. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40003. */
  40004. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40005. /**
  40006. * Defines the camera the input is attached to.
  40007. */
  40008. camera: ArcRotateCamera;
  40009. /**
  40010. * Defines the gamepad the input is gathering event from.
  40011. */
  40012. gamepad: Nullable<Gamepad>;
  40013. /**
  40014. * Defines the gamepad rotation sensiblity.
  40015. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40016. */
  40017. gamepadRotationSensibility: number;
  40018. /**
  40019. * Defines the gamepad move sensiblity.
  40020. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40021. */
  40022. gamepadMoveSensibility: number;
  40023. private _yAxisScale;
  40024. /**
  40025. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40026. */
  40027. get invertYAxis(): boolean;
  40028. set invertYAxis(value: boolean);
  40029. private _onGamepadConnectedObserver;
  40030. private _onGamepadDisconnectedObserver;
  40031. /**
  40032. * Attach the input controls to a specific dom element to get the input from.
  40033. * @param element Defines the element the controls should be listened from
  40034. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40035. */
  40036. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40037. /**
  40038. * Detach the current controls from the specified dom element.
  40039. * @param element Defines the element to stop listening the inputs from
  40040. */
  40041. detachControl(element: Nullable<HTMLElement>): void;
  40042. /**
  40043. * Update the current camera state depending on the inputs that have been used this frame.
  40044. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40045. */
  40046. checkInputs(): void;
  40047. /**
  40048. * Gets the class name of the current intput.
  40049. * @returns the class name
  40050. */
  40051. getClassName(): string;
  40052. /**
  40053. * Get the friendly name associated with the input class.
  40054. * @returns the input friendly name
  40055. */
  40056. getSimpleName(): string;
  40057. }
  40058. }
  40059. declare module BABYLON {
  40060. interface ArcRotateCameraInputsManager {
  40061. /**
  40062. * Add orientation input support to the input manager.
  40063. * @returns the current input manager
  40064. */
  40065. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40066. }
  40067. /**
  40068. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40070. */
  40071. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40072. /**
  40073. * Defines the camera the input is attached to.
  40074. */
  40075. camera: ArcRotateCamera;
  40076. /**
  40077. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40078. */
  40079. alphaCorrection: number;
  40080. /**
  40081. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40082. */
  40083. gammaCorrection: number;
  40084. private _alpha;
  40085. private _gamma;
  40086. private _dirty;
  40087. private _deviceOrientationHandler;
  40088. /**
  40089. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40090. */
  40091. constructor();
  40092. /**
  40093. * Attach the input controls to a specific dom element to get the input from.
  40094. * @param element Defines the element the controls should be listened from
  40095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40096. */
  40097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40098. /** @hidden */
  40099. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40100. /**
  40101. * Update the current camera state depending on the inputs that have been used this frame.
  40102. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40103. */
  40104. checkInputs(): void;
  40105. /**
  40106. * Detach the current controls from the specified dom element.
  40107. * @param element Defines the element to stop listening the inputs from
  40108. */
  40109. detachControl(element: Nullable<HTMLElement>): void;
  40110. /**
  40111. * Gets the class name of the current intput.
  40112. * @returns the class name
  40113. */
  40114. getClassName(): string;
  40115. /**
  40116. * Get the friendly name associated with the input class.
  40117. * @returns the input friendly name
  40118. */
  40119. getSimpleName(): string;
  40120. }
  40121. }
  40122. declare module BABYLON {
  40123. /**
  40124. * Listen to mouse events to control the camera.
  40125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40126. */
  40127. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40128. /**
  40129. * Defines the camera the input is attached to.
  40130. */
  40131. camera: FlyCamera;
  40132. /**
  40133. * Defines if touch is enabled. (Default is true.)
  40134. */
  40135. touchEnabled: boolean;
  40136. /**
  40137. * Defines the buttons associated with the input to handle camera rotation.
  40138. */
  40139. buttons: number[];
  40140. /**
  40141. * Assign buttons for Yaw control.
  40142. */
  40143. buttonsYaw: number[];
  40144. /**
  40145. * Assign buttons for Pitch control.
  40146. */
  40147. buttonsPitch: number[];
  40148. /**
  40149. * Assign buttons for Roll control.
  40150. */
  40151. buttonsRoll: number[];
  40152. /**
  40153. * Detect if any button is being pressed while mouse is moved.
  40154. * -1 = Mouse locked.
  40155. * 0 = Left button.
  40156. * 1 = Middle Button.
  40157. * 2 = Right Button.
  40158. */
  40159. activeButton: number;
  40160. /**
  40161. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40162. * Higher values reduce its sensitivity.
  40163. */
  40164. angularSensibility: number;
  40165. private _mousemoveCallback;
  40166. private _observer;
  40167. private _rollObserver;
  40168. private previousPosition;
  40169. private noPreventDefault;
  40170. private element;
  40171. /**
  40172. * Listen to mouse events to control the camera.
  40173. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40174. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40175. */
  40176. constructor(touchEnabled?: boolean);
  40177. /**
  40178. * Attach the mouse control to the HTML DOM element.
  40179. * @param element Defines the element that listens to the input events.
  40180. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40181. */
  40182. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40183. /**
  40184. * Detach the current controls from the specified dom element.
  40185. * @param element Defines the element to stop listening the inputs from
  40186. */
  40187. detachControl(element: Nullable<HTMLElement>): void;
  40188. /**
  40189. * Gets the class name of the current input.
  40190. * @returns the class name.
  40191. */
  40192. getClassName(): string;
  40193. /**
  40194. * Get the friendly name associated with the input class.
  40195. * @returns the input's friendly name.
  40196. */
  40197. getSimpleName(): string;
  40198. private _pointerInput;
  40199. private _onMouseMove;
  40200. /**
  40201. * Rotate camera by mouse offset.
  40202. */
  40203. private rotateCamera;
  40204. }
  40205. }
  40206. declare module BABYLON {
  40207. /**
  40208. * Default Inputs manager for the FlyCamera.
  40209. * It groups all the default supported inputs for ease of use.
  40210. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40211. */
  40212. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40213. /**
  40214. * Instantiates a new FlyCameraInputsManager.
  40215. * @param camera Defines the camera the inputs belong to.
  40216. */
  40217. constructor(camera: FlyCamera);
  40218. /**
  40219. * Add keyboard input support to the input manager.
  40220. * @returns the new FlyCameraKeyboardMoveInput().
  40221. */
  40222. addKeyboard(): FlyCameraInputsManager;
  40223. /**
  40224. * Add mouse input support to the input manager.
  40225. * @param touchEnabled Enable touch screen support.
  40226. * @returns the new FlyCameraMouseInput().
  40227. */
  40228. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40229. }
  40230. }
  40231. declare module BABYLON {
  40232. /**
  40233. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40234. * such as in a 3D Space Shooter or a Flight Simulator.
  40235. */
  40236. export class FlyCamera extends TargetCamera {
  40237. /**
  40238. * Define the collision ellipsoid of the camera.
  40239. * This is helpful for simulating a camera body, like a player's body.
  40240. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40241. */
  40242. ellipsoid: Vector3;
  40243. /**
  40244. * Define an offset for the position of the ellipsoid around the camera.
  40245. * This can be helpful if the camera is attached away from the player's body center,
  40246. * such as at its head.
  40247. */
  40248. ellipsoidOffset: Vector3;
  40249. /**
  40250. * Enable or disable collisions of the camera with the rest of the scene objects.
  40251. */
  40252. checkCollisions: boolean;
  40253. /**
  40254. * Enable or disable gravity on the camera.
  40255. */
  40256. applyGravity: boolean;
  40257. /**
  40258. * Define the current direction the camera is moving to.
  40259. */
  40260. cameraDirection: Vector3;
  40261. /**
  40262. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40263. * This overrides and empties cameraRotation.
  40264. */
  40265. rotationQuaternion: Quaternion;
  40266. /**
  40267. * Track Roll to maintain the wanted Rolling when looking around.
  40268. */
  40269. _trackRoll: number;
  40270. /**
  40271. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40272. */
  40273. rollCorrect: number;
  40274. /**
  40275. * Mimic a banked turn, Rolling the camera when Yawing.
  40276. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40277. */
  40278. bankedTurn: boolean;
  40279. /**
  40280. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40281. */
  40282. bankedTurnLimit: number;
  40283. /**
  40284. * Value of 0 disables the banked Roll.
  40285. * Value of 1 is equal to the Yaw angle in radians.
  40286. */
  40287. bankedTurnMultiplier: number;
  40288. /**
  40289. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40290. */
  40291. inputs: FlyCameraInputsManager;
  40292. /**
  40293. * Gets the input sensibility for mouse input.
  40294. * Higher values reduce sensitivity.
  40295. */
  40296. get angularSensibility(): number;
  40297. /**
  40298. * Sets the input sensibility for a mouse input.
  40299. * Higher values reduce sensitivity.
  40300. */
  40301. set angularSensibility(value: number);
  40302. /**
  40303. * Get the keys for camera movement forward.
  40304. */
  40305. get keysForward(): number[];
  40306. /**
  40307. * Set the keys for camera movement forward.
  40308. */
  40309. set keysForward(value: number[]);
  40310. /**
  40311. * Get the keys for camera movement backward.
  40312. */
  40313. get keysBackward(): number[];
  40314. set keysBackward(value: number[]);
  40315. /**
  40316. * Get the keys for camera movement up.
  40317. */
  40318. get keysUp(): number[];
  40319. /**
  40320. * Set the keys for camera movement up.
  40321. */
  40322. set keysUp(value: number[]);
  40323. /**
  40324. * Get the keys for camera movement down.
  40325. */
  40326. get keysDown(): number[];
  40327. /**
  40328. * Set the keys for camera movement down.
  40329. */
  40330. set keysDown(value: number[]);
  40331. /**
  40332. * Get the keys for camera movement left.
  40333. */
  40334. get keysLeft(): number[];
  40335. /**
  40336. * Set the keys for camera movement left.
  40337. */
  40338. set keysLeft(value: number[]);
  40339. /**
  40340. * Set the keys for camera movement right.
  40341. */
  40342. get keysRight(): number[];
  40343. /**
  40344. * Set the keys for camera movement right.
  40345. */
  40346. set keysRight(value: number[]);
  40347. /**
  40348. * Event raised when the camera collides with a mesh in the scene.
  40349. */
  40350. onCollide: (collidedMesh: AbstractMesh) => void;
  40351. private _collider;
  40352. private _needMoveForGravity;
  40353. private _oldPosition;
  40354. private _diffPosition;
  40355. private _newPosition;
  40356. /** @hidden */
  40357. _localDirection: Vector3;
  40358. /** @hidden */
  40359. _transformedDirection: Vector3;
  40360. /**
  40361. * Instantiates a FlyCamera.
  40362. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40363. * such as in a 3D Space Shooter or a Flight Simulator.
  40364. * @param name Define the name of the camera in the scene.
  40365. * @param position Define the starting position of the camera in the scene.
  40366. * @param scene Define the scene the camera belongs to.
  40367. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40368. */
  40369. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40370. /**
  40371. * Attach a control to the HTML DOM element.
  40372. * @param element Defines the element that listens to the input events.
  40373. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40374. */
  40375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40376. /**
  40377. * Detach a control from the HTML DOM element.
  40378. * The camera will stop reacting to that input.
  40379. * @param element Defines the element that listens to the input events.
  40380. */
  40381. detachControl(element: HTMLElement): void;
  40382. private _collisionMask;
  40383. /**
  40384. * Get the mask that the camera ignores in collision events.
  40385. */
  40386. get collisionMask(): number;
  40387. /**
  40388. * Set the mask that the camera ignores in collision events.
  40389. */
  40390. set collisionMask(mask: number);
  40391. /** @hidden */
  40392. _collideWithWorld(displacement: Vector3): void;
  40393. /** @hidden */
  40394. private _onCollisionPositionChange;
  40395. /** @hidden */
  40396. _checkInputs(): void;
  40397. /** @hidden */
  40398. _decideIfNeedsToMove(): boolean;
  40399. /** @hidden */
  40400. _updatePosition(): void;
  40401. /**
  40402. * Restore the Roll to its target value at the rate specified.
  40403. * @param rate - Higher means slower restoring.
  40404. * @hidden
  40405. */
  40406. restoreRoll(rate: number): void;
  40407. /**
  40408. * Destroy the camera and release the current resources held by it.
  40409. */
  40410. dispose(): void;
  40411. /**
  40412. * Get the current object class name.
  40413. * @returns the class name.
  40414. */
  40415. getClassName(): string;
  40416. }
  40417. }
  40418. declare module BABYLON {
  40419. /**
  40420. * Listen to keyboard events to control the camera.
  40421. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40422. */
  40423. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40424. /**
  40425. * Defines the camera the input is attached to.
  40426. */
  40427. camera: FlyCamera;
  40428. /**
  40429. * The list of keyboard keys used to control the forward move of the camera.
  40430. */
  40431. keysForward: number[];
  40432. /**
  40433. * The list of keyboard keys used to control the backward move of the camera.
  40434. */
  40435. keysBackward: number[];
  40436. /**
  40437. * The list of keyboard keys used to control the forward move of the camera.
  40438. */
  40439. keysUp: number[];
  40440. /**
  40441. * The list of keyboard keys used to control the backward move of the camera.
  40442. */
  40443. keysDown: number[];
  40444. /**
  40445. * The list of keyboard keys used to control the right strafe move of the camera.
  40446. */
  40447. keysRight: number[];
  40448. /**
  40449. * The list of keyboard keys used to control the left strafe move of the camera.
  40450. */
  40451. keysLeft: number[];
  40452. private _keys;
  40453. private _onCanvasBlurObserver;
  40454. private _onKeyboardObserver;
  40455. private _engine;
  40456. private _scene;
  40457. /**
  40458. * Attach the input controls to a specific dom element to get the input from.
  40459. * @param element Defines the element the controls should be listened from
  40460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40461. */
  40462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40463. /**
  40464. * Detach the current controls from the specified dom element.
  40465. * @param element Defines the element to stop listening the inputs from
  40466. */
  40467. detachControl(element: Nullable<HTMLElement>): void;
  40468. /**
  40469. * Gets the class name of the current intput.
  40470. * @returns the class name
  40471. */
  40472. getClassName(): string;
  40473. /** @hidden */
  40474. _onLostFocus(e: FocusEvent): void;
  40475. /**
  40476. * Get the friendly name associated with the input class.
  40477. * @returns the input friendly name
  40478. */
  40479. getSimpleName(): string;
  40480. /**
  40481. * Update the current camera state depending on the inputs that have been used this frame.
  40482. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40483. */
  40484. checkInputs(): void;
  40485. }
  40486. }
  40487. declare module BABYLON {
  40488. /**
  40489. * Manage the mouse wheel inputs to control a follow camera.
  40490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40491. */
  40492. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40493. /**
  40494. * Defines the camera the input is attached to.
  40495. */
  40496. camera: FollowCamera;
  40497. /**
  40498. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40499. */
  40500. axisControlRadius: boolean;
  40501. /**
  40502. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40503. */
  40504. axisControlHeight: boolean;
  40505. /**
  40506. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40507. */
  40508. axisControlRotation: boolean;
  40509. /**
  40510. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40511. * relation to mouseWheel events.
  40512. */
  40513. wheelPrecision: number;
  40514. /**
  40515. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40516. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40517. */
  40518. wheelDeltaPercentage: number;
  40519. private _wheel;
  40520. private _observer;
  40521. /**
  40522. * Attach the input controls to a specific dom element to get the input from.
  40523. * @param element Defines the element the controls should be listened from
  40524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40525. */
  40526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40527. /**
  40528. * Detach the current controls from the specified dom element.
  40529. * @param element Defines the element to stop listening the inputs from
  40530. */
  40531. detachControl(element: Nullable<HTMLElement>): void;
  40532. /**
  40533. * Gets the class name of the current intput.
  40534. * @returns the class name
  40535. */
  40536. getClassName(): string;
  40537. /**
  40538. * Get the friendly name associated with the input class.
  40539. * @returns the input friendly name
  40540. */
  40541. getSimpleName(): string;
  40542. }
  40543. }
  40544. declare module BABYLON {
  40545. /**
  40546. * Manage the pointers inputs to control an follow camera.
  40547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40548. */
  40549. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40550. /**
  40551. * Defines the camera the input is attached to.
  40552. */
  40553. camera: FollowCamera;
  40554. /**
  40555. * Gets the class name of the current input.
  40556. * @returns the class name
  40557. */
  40558. getClassName(): string;
  40559. /**
  40560. * Defines the pointer angular sensibility along the X axis or how fast is
  40561. * the camera rotating.
  40562. * A negative number will reverse the axis direction.
  40563. */
  40564. angularSensibilityX: number;
  40565. /**
  40566. * Defines the pointer angular sensibility along the Y axis or how fast is
  40567. * the camera rotating.
  40568. * A negative number will reverse the axis direction.
  40569. */
  40570. angularSensibilityY: number;
  40571. /**
  40572. * Defines the pointer pinch precision or how fast is the camera zooming.
  40573. * A negative number will reverse the axis direction.
  40574. */
  40575. pinchPrecision: number;
  40576. /**
  40577. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40578. * from 0.
  40579. * It defines the percentage of current camera.radius to use as delta when
  40580. * pinch zoom is used.
  40581. */
  40582. pinchDeltaPercentage: number;
  40583. /**
  40584. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40585. */
  40586. axisXControlRadius: boolean;
  40587. /**
  40588. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40589. */
  40590. axisXControlHeight: boolean;
  40591. /**
  40592. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40593. */
  40594. axisXControlRotation: boolean;
  40595. /**
  40596. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40597. */
  40598. axisYControlRadius: boolean;
  40599. /**
  40600. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40601. */
  40602. axisYControlHeight: boolean;
  40603. /**
  40604. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40605. */
  40606. axisYControlRotation: boolean;
  40607. /**
  40608. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40609. */
  40610. axisPinchControlRadius: boolean;
  40611. /**
  40612. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40613. */
  40614. axisPinchControlHeight: boolean;
  40615. /**
  40616. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40617. */
  40618. axisPinchControlRotation: boolean;
  40619. /**
  40620. * Log error messages if basic misconfiguration has occurred.
  40621. */
  40622. warningEnable: boolean;
  40623. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40624. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40625. private _warningCounter;
  40626. private _warning;
  40627. }
  40628. }
  40629. declare module BABYLON {
  40630. /**
  40631. * Default Inputs manager for the FollowCamera.
  40632. * It groups all the default supported inputs for ease of use.
  40633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40634. */
  40635. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40636. /**
  40637. * Instantiates a new FollowCameraInputsManager.
  40638. * @param camera Defines the camera the inputs belong to
  40639. */
  40640. constructor(camera: FollowCamera);
  40641. /**
  40642. * Add keyboard input support to the input manager.
  40643. * @returns the current input manager
  40644. */
  40645. addKeyboard(): FollowCameraInputsManager;
  40646. /**
  40647. * Add mouse wheel input support to the input manager.
  40648. * @returns the current input manager
  40649. */
  40650. addMouseWheel(): FollowCameraInputsManager;
  40651. /**
  40652. * Add pointers input support to the input manager.
  40653. * @returns the current input manager
  40654. */
  40655. addPointers(): FollowCameraInputsManager;
  40656. /**
  40657. * Add orientation input support to the input manager.
  40658. * @returns the current input manager
  40659. */
  40660. addVRDeviceOrientation(): FollowCameraInputsManager;
  40661. }
  40662. }
  40663. declare module BABYLON {
  40664. /**
  40665. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40666. * an arc rotate version arcFollowCamera are available.
  40667. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40668. */
  40669. export class FollowCamera extends TargetCamera {
  40670. /**
  40671. * Distance the follow camera should follow an object at
  40672. */
  40673. radius: number;
  40674. /**
  40675. * Minimum allowed distance of the camera to the axis of rotation
  40676. * (The camera can not get closer).
  40677. * This can help limiting how the Camera is able to move in the scene.
  40678. */
  40679. lowerRadiusLimit: Nullable<number>;
  40680. /**
  40681. * Maximum allowed distance of the camera to the axis of rotation
  40682. * (The camera can not get further).
  40683. * This can help limiting how the Camera is able to move in the scene.
  40684. */
  40685. upperRadiusLimit: Nullable<number>;
  40686. /**
  40687. * Define a rotation offset between the camera and the object it follows
  40688. */
  40689. rotationOffset: number;
  40690. /**
  40691. * Minimum allowed angle to camera position relative to target object.
  40692. * This can help limiting how the Camera is able to move in the scene.
  40693. */
  40694. lowerRotationOffsetLimit: Nullable<number>;
  40695. /**
  40696. * Maximum allowed angle to camera position relative to target object.
  40697. * This can help limiting how the Camera is able to move in the scene.
  40698. */
  40699. upperRotationOffsetLimit: Nullable<number>;
  40700. /**
  40701. * Define a height offset between the camera and the object it follows.
  40702. * It can help following an object from the top (like a car chaing a plane)
  40703. */
  40704. heightOffset: number;
  40705. /**
  40706. * Minimum allowed height of camera position relative to target object.
  40707. * This can help limiting how the Camera is able to move in the scene.
  40708. */
  40709. lowerHeightOffsetLimit: Nullable<number>;
  40710. /**
  40711. * Maximum allowed height of camera position relative to target object.
  40712. * This can help limiting how the Camera is able to move in the scene.
  40713. */
  40714. upperHeightOffsetLimit: Nullable<number>;
  40715. /**
  40716. * Define how fast the camera can accelerate to follow it s target.
  40717. */
  40718. cameraAcceleration: number;
  40719. /**
  40720. * Define the speed limit of the camera following an object.
  40721. */
  40722. maxCameraSpeed: number;
  40723. /**
  40724. * Define the target of the camera.
  40725. */
  40726. lockedTarget: Nullable<AbstractMesh>;
  40727. /**
  40728. * Defines the input associated with the camera.
  40729. */
  40730. inputs: FollowCameraInputsManager;
  40731. /**
  40732. * Instantiates the follow camera.
  40733. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40734. * @param name Define the name of the camera in the scene
  40735. * @param position Define the position of the camera
  40736. * @param scene Define the scene the camera belong to
  40737. * @param lockedTarget Define the target of the camera
  40738. */
  40739. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40740. private _follow;
  40741. /**
  40742. * Attached controls to the current camera.
  40743. * @param element Defines the element the controls should be listened from
  40744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40745. */
  40746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40747. /**
  40748. * Detach the current controls from the camera.
  40749. * The camera will stop reacting to inputs.
  40750. * @param element Defines the element to stop listening the inputs from
  40751. */
  40752. detachControl(element: HTMLElement): void;
  40753. /** @hidden */
  40754. _checkInputs(): void;
  40755. private _checkLimits;
  40756. /**
  40757. * Gets the camera class name.
  40758. * @returns the class name
  40759. */
  40760. getClassName(): string;
  40761. }
  40762. /**
  40763. * Arc Rotate version of the follow camera.
  40764. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40765. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40766. */
  40767. export class ArcFollowCamera extends TargetCamera {
  40768. /** The longitudinal angle of the camera */
  40769. alpha: number;
  40770. /** The latitudinal angle of the camera */
  40771. beta: number;
  40772. /** The radius of the camera from its target */
  40773. radius: number;
  40774. /** Define the camera target (the messh it should follow) */
  40775. target: Nullable<AbstractMesh>;
  40776. private _cartesianCoordinates;
  40777. /**
  40778. * Instantiates a new ArcFollowCamera
  40779. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40780. * @param name Define the name of the camera
  40781. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40782. * @param beta Define the rotation angle of the camera around the elevation axis
  40783. * @param radius Define the radius of the camera from its target point
  40784. * @param target Define the target of the camera
  40785. * @param scene Define the scene the camera belongs to
  40786. */
  40787. constructor(name: string,
  40788. /** The longitudinal angle of the camera */
  40789. alpha: number,
  40790. /** The latitudinal angle of the camera */
  40791. beta: number,
  40792. /** The radius of the camera from its target */
  40793. radius: number,
  40794. /** Define the camera target (the messh it should follow) */
  40795. target: Nullable<AbstractMesh>, scene: Scene);
  40796. private _follow;
  40797. /** @hidden */
  40798. _checkInputs(): void;
  40799. /**
  40800. * Returns the class name of the object.
  40801. * It is mostly used internally for serialization purposes.
  40802. */
  40803. getClassName(): string;
  40804. }
  40805. }
  40806. declare module BABYLON {
  40807. /**
  40808. * Manage the keyboard inputs to control the movement of a follow camera.
  40809. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40810. */
  40811. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40812. /**
  40813. * Defines the camera the input is attached to.
  40814. */
  40815. camera: FollowCamera;
  40816. /**
  40817. * Defines the list of key codes associated with the up action (increase heightOffset)
  40818. */
  40819. keysHeightOffsetIncr: number[];
  40820. /**
  40821. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40822. */
  40823. keysHeightOffsetDecr: number[];
  40824. /**
  40825. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40826. */
  40827. keysHeightOffsetModifierAlt: boolean;
  40828. /**
  40829. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40830. */
  40831. keysHeightOffsetModifierCtrl: boolean;
  40832. /**
  40833. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40834. */
  40835. keysHeightOffsetModifierShift: boolean;
  40836. /**
  40837. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40838. */
  40839. keysRotationOffsetIncr: number[];
  40840. /**
  40841. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40842. */
  40843. keysRotationOffsetDecr: number[];
  40844. /**
  40845. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40846. */
  40847. keysRotationOffsetModifierAlt: boolean;
  40848. /**
  40849. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40850. */
  40851. keysRotationOffsetModifierCtrl: boolean;
  40852. /**
  40853. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40854. */
  40855. keysRotationOffsetModifierShift: boolean;
  40856. /**
  40857. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40858. */
  40859. keysRadiusIncr: number[];
  40860. /**
  40861. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40862. */
  40863. keysRadiusDecr: number[];
  40864. /**
  40865. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40866. */
  40867. keysRadiusModifierAlt: boolean;
  40868. /**
  40869. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40870. */
  40871. keysRadiusModifierCtrl: boolean;
  40872. /**
  40873. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40874. */
  40875. keysRadiusModifierShift: boolean;
  40876. /**
  40877. * Defines the rate of change of heightOffset.
  40878. */
  40879. heightSensibility: number;
  40880. /**
  40881. * Defines the rate of change of rotationOffset.
  40882. */
  40883. rotationSensibility: number;
  40884. /**
  40885. * Defines the rate of change of radius.
  40886. */
  40887. radiusSensibility: number;
  40888. private _keys;
  40889. private _ctrlPressed;
  40890. private _altPressed;
  40891. private _shiftPressed;
  40892. private _onCanvasBlurObserver;
  40893. private _onKeyboardObserver;
  40894. private _engine;
  40895. private _scene;
  40896. /**
  40897. * Attach the input controls to a specific dom element to get the input from.
  40898. * @param element Defines the element the controls should be listened from
  40899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40900. */
  40901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40902. /**
  40903. * Detach the current controls from the specified dom element.
  40904. * @param element Defines the element to stop listening the inputs from
  40905. */
  40906. detachControl(element: Nullable<HTMLElement>): void;
  40907. /**
  40908. * Update the current camera state depending on the inputs that have been used this frame.
  40909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40910. */
  40911. checkInputs(): void;
  40912. /**
  40913. * Gets the class name of the current input.
  40914. * @returns the class name
  40915. */
  40916. getClassName(): string;
  40917. /**
  40918. * Get the friendly name associated with the input class.
  40919. * @returns the input friendly name
  40920. */
  40921. getSimpleName(): string;
  40922. /**
  40923. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40924. * allow modification of the heightOffset value.
  40925. */
  40926. private _modifierHeightOffset;
  40927. /**
  40928. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40929. * allow modification of the rotationOffset value.
  40930. */
  40931. private _modifierRotationOffset;
  40932. /**
  40933. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40934. * allow modification of the radius value.
  40935. */
  40936. private _modifierRadius;
  40937. }
  40938. }
  40939. declare module BABYLON {
  40940. interface FreeCameraInputsManager {
  40941. /**
  40942. * @hidden
  40943. */
  40944. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40945. /**
  40946. * Add orientation input support to the input manager.
  40947. * @returns the current input manager
  40948. */
  40949. addDeviceOrientation(): FreeCameraInputsManager;
  40950. }
  40951. /**
  40952. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40953. * Screen rotation is taken into account.
  40954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40955. */
  40956. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40957. private _camera;
  40958. private _screenOrientationAngle;
  40959. private _constantTranform;
  40960. private _screenQuaternion;
  40961. private _alpha;
  40962. private _beta;
  40963. private _gamma;
  40964. /**
  40965. * Can be used to detect if a device orientation sensor is available on a device
  40966. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40967. * @returns a promise that will resolve on orientation change
  40968. */
  40969. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40970. /**
  40971. * @hidden
  40972. */
  40973. _onDeviceOrientationChangedObservable: Observable<void>;
  40974. /**
  40975. * Instantiates a new input
  40976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40977. */
  40978. constructor();
  40979. /**
  40980. * Define the camera controlled by the input.
  40981. */
  40982. get camera(): FreeCamera;
  40983. set camera(camera: FreeCamera);
  40984. /**
  40985. * Attach the input controls to a specific dom element to get the input from.
  40986. * @param element Defines the element the controls should be listened from
  40987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40988. */
  40989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40990. private _orientationChanged;
  40991. private _deviceOrientation;
  40992. /**
  40993. * Detach the current controls from the specified dom element.
  40994. * @param element Defines the element to stop listening the inputs from
  40995. */
  40996. detachControl(element: Nullable<HTMLElement>): void;
  40997. /**
  40998. * Update the current camera state depending on the inputs that have been used this frame.
  40999. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41000. */
  41001. checkInputs(): void;
  41002. /**
  41003. * Gets the class name of the current intput.
  41004. * @returns the class name
  41005. */
  41006. getClassName(): string;
  41007. /**
  41008. * Get the friendly name associated with the input class.
  41009. * @returns the input friendly name
  41010. */
  41011. getSimpleName(): string;
  41012. }
  41013. }
  41014. declare module BABYLON {
  41015. /**
  41016. * Manage the gamepad inputs to control a free camera.
  41017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41018. */
  41019. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41020. /**
  41021. * Define the camera the input is attached to.
  41022. */
  41023. camera: FreeCamera;
  41024. /**
  41025. * Define the Gamepad controlling the input
  41026. */
  41027. gamepad: Nullable<Gamepad>;
  41028. /**
  41029. * Defines the gamepad rotation sensiblity.
  41030. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41031. */
  41032. gamepadAngularSensibility: number;
  41033. /**
  41034. * Defines the gamepad move sensiblity.
  41035. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41036. */
  41037. gamepadMoveSensibility: number;
  41038. private _yAxisScale;
  41039. /**
  41040. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41041. */
  41042. get invertYAxis(): boolean;
  41043. set invertYAxis(value: boolean);
  41044. private _onGamepadConnectedObserver;
  41045. private _onGamepadDisconnectedObserver;
  41046. private _cameraTransform;
  41047. private _deltaTransform;
  41048. private _vector3;
  41049. private _vector2;
  41050. /**
  41051. * Attach the input controls to a specific dom element to get the input from.
  41052. * @param element Defines the element the controls should be listened from
  41053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41054. */
  41055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41056. /**
  41057. * Detach the current controls from the specified dom element.
  41058. * @param element Defines the element to stop listening the inputs from
  41059. */
  41060. detachControl(element: Nullable<HTMLElement>): void;
  41061. /**
  41062. * Update the current camera state depending on the inputs that have been used this frame.
  41063. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41064. */
  41065. checkInputs(): void;
  41066. /**
  41067. * Gets the class name of the current intput.
  41068. * @returns the class name
  41069. */
  41070. getClassName(): string;
  41071. /**
  41072. * Get the friendly name associated with the input class.
  41073. * @returns the input friendly name
  41074. */
  41075. getSimpleName(): string;
  41076. }
  41077. }
  41078. declare module BABYLON {
  41079. /**
  41080. * Defines the potential axis of a Joystick
  41081. */
  41082. export enum JoystickAxis {
  41083. /** X axis */
  41084. X = 0,
  41085. /** Y axis */
  41086. Y = 1,
  41087. /** Z axis */
  41088. Z = 2
  41089. }
  41090. /**
  41091. * Class used to define virtual joystick (used in touch mode)
  41092. */
  41093. export class VirtualJoystick {
  41094. /**
  41095. * Gets or sets a boolean indicating that left and right values must be inverted
  41096. */
  41097. reverseLeftRight: boolean;
  41098. /**
  41099. * Gets or sets a boolean indicating that up and down values must be inverted
  41100. */
  41101. reverseUpDown: boolean;
  41102. /**
  41103. * Gets the offset value for the position (ie. the change of the position value)
  41104. */
  41105. deltaPosition: Vector3;
  41106. /**
  41107. * Gets a boolean indicating if the virtual joystick was pressed
  41108. */
  41109. pressed: boolean;
  41110. /**
  41111. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41112. */
  41113. static Canvas: Nullable<HTMLCanvasElement>;
  41114. private static _globalJoystickIndex;
  41115. private static vjCanvasContext;
  41116. private static vjCanvasWidth;
  41117. private static vjCanvasHeight;
  41118. private static halfWidth;
  41119. private _action;
  41120. private _axisTargetedByLeftAndRight;
  41121. private _axisTargetedByUpAndDown;
  41122. private _joystickSensibility;
  41123. private _inversedSensibility;
  41124. private _joystickPointerID;
  41125. private _joystickColor;
  41126. private _joystickPointerPos;
  41127. private _joystickPreviousPointerPos;
  41128. private _joystickPointerStartPos;
  41129. private _deltaJoystickVector;
  41130. private _leftJoystick;
  41131. private _touches;
  41132. private _onPointerDownHandlerRef;
  41133. private _onPointerMoveHandlerRef;
  41134. private _onPointerUpHandlerRef;
  41135. private _onResize;
  41136. /**
  41137. * Creates a new virtual joystick
  41138. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41139. */
  41140. constructor(leftJoystick?: boolean);
  41141. /**
  41142. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41143. * @param newJoystickSensibility defines the new sensibility
  41144. */
  41145. setJoystickSensibility(newJoystickSensibility: number): void;
  41146. private _onPointerDown;
  41147. private _onPointerMove;
  41148. private _onPointerUp;
  41149. /**
  41150. * Change the color of the virtual joystick
  41151. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41152. */
  41153. setJoystickColor(newColor: string): void;
  41154. /**
  41155. * Defines a callback to call when the joystick is touched
  41156. * @param action defines the callback
  41157. */
  41158. setActionOnTouch(action: () => any): void;
  41159. /**
  41160. * Defines which axis you'd like to control for left & right
  41161. * @param axis defines the axis to use
  41162. */
  41163. setAxisForLeftRight(axis: JoystickAxis): void;
  41164. /**
  41165. * Defines which axis you'd like to control for up & down
  41166. * @param axis defines the axis to use
  41167. */
  41168. setAxisForUpDown(axis: JoystickAxis): void;
  41169. private _drawVirtualJoystick;
  41170. /**
  41171. * Release internal HTML canvas
  41172. */
  41173. releaseCanvas(): void;
  41174. }
  41175. }
  41176. declare module BABYLON {
  41177. interface FreeCameraInputsManager {
  41178. /**
  41179. * Add virtual joystick input support to the input manager.
  41180. * @returns the current input manager
  41181. */
  41182. addVirtualJoystick(): FreeCameraInputsManager;
  41183. }
  41184. /**
  41185. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41186. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41187. */
  41188. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41189. /**
  41190. * Defines the camera the input is attached to.
  41191. */
  41192. camera: FreeCamera;
  41193. private _leftjoystick;
  41194. private _rightjoystick;
  41195. /**
  41196. * Gets the left stick of the virtual joystick.
  41197. * @returns The virtual Joystick
  41198. */
  41199. getLeftJoystick(): VirtualJoystick;
  41200. /**
  41201. * Gets the right stick of the virtual joystick.
  41202. * @returns The virtual Joystick
  41203. */
  41204. getRightJoystick(): VirtualJoystick;
  41205. /**
  41206. * Update the current camera state depending on the inputs that have been used this frame.
  41207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41208. */
  41209. checkInputs(): void;
  41210. /**
  41211. * Attach the input controls to a specific dom element to get the input from.
  41212. * @param element Defines the element the controls should be listened from
  41213. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41214. */
  41215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41216. /**
  41217. * Detach the current controls from the specified dom element.
  41218. * @param element Defines the element to stop listening the inputs from
  41219. */
  41220. detachControl(element: Nullable<HTMLElement>): void;
  41221. /**
  41222. * Gets the class name of the current intput.
  41223. * @returns the class name
  41224. */
  41225. getClassName(): string;
  41226. /**
  41227. * Get the friendly name associated with the input class.
  41228. * @returns the input friendly name
  41229. */
  41230. getSimpleName(): string;
  41231. }
  41232. }
  41233. declare module BABYLON {
  41234. /**
  41235. * This represents a FPS type of camera controlled by touch.
  41236. * This is like a universal camera minus the Gamepad controls.
  41237. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41238. */
  41239. export class TouchCamera extends FreeCamera {
  41240. /**
  41241. * Defines the touch sensibility for rotation.
  41242. * The higher the faster.
  41243. */
  41244. get touchAngularSensibility(): number;
  41245. set touchAngularSensibility(value: number);
  41246. /**
  41247. * Defines the touch sensibility for move.
  41248. * The higher the faster.
  41249. */
  41250. get touchMoveSensibility(): number;
  41251. set touchMoveSensibility(value: number);
  41252. /**
  41253. * Instantiates a new touch camera.
  41254. * This represents a FPS type of camera controlled by touch.
  41255. * This is like a universal camera minus the Gamepad controls.
  41256. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41257. * @param name Define the name of the camera in the scene
  41258. * @param position Define the start position of the camera in the scene
  41259. * @param scene Define the scene the camera belongs to
  41260. */
  41261. constructor(name: string, position: Vector3, scene: Scene);
  41262. /**
  41263. * Gets the current object class name.
  41264. * @return the class name
  41265. */
  41266. getClassName(): string;
  41267. /** @hidden */
  41268. _setupInputs(): void;
  41269. }
  41270. }
  41271. declare module BABYLON {
  41272. /**
  41273. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41274. * being tilted forward or back and left or right.
  41275. */
  41276. export class DeviceOrientationCamera extends FreeCamera {
  41277. private _initialQuaternion;
  41278. private _quaternionCache;
  41279. private _tmpDragQuaternion;
  41280. private _disablePointerInputWhenUsingDeviceOrientation;
  41281. /**
  41282. * Creates a new device orientation camera
  41283. * @param name The name of the camera
  41284. * @param position The start position camera
  41285. * @param scene The scene the camera belongs to
  41286. */
  41287. constructor(name: string, position: Vector3, scene: Scene);
  41288. /**
  41289. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41290. */
  41291. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41292. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41293. private _dragFactor;
  41294. /**
  41295. * Enabled turning on the y axis when the orientation sensor is active
  41296. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41297. */
  41298. enableHorizontalDragging(dragFactor?: number): void;
  41299. /**
  41300. * Gets the current instance class name ("DeviceOrientationCamera").
  41301. * This helps avoiding instanceof at run time.
  41302. * @returns the class name
  41303. */
  41304. getClassName(): string;
  41305. /**
  41306. * @hidden
  41307. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41308. */
  41309. _checkInputs(): void;
  41310. /**
  41311. * Reset the camera to its default orientation on the specified axis only.
  41312. * @param axis The axis to reset
  41313. */
  41314. resetToCurrentRotation(axis?: Axis): void;
  41315. }
  41316. }
  41317. declare module BABYLON {
  41318. /**
  41319. * Defines supported buttons for XBox360 compatible gamepads
  41320. */
  41321. export enum Xbox360Button {
  41322. /** A */
  41323. A = 0,
  41324. /** B */
  41325. B = 1,
  41326. /** X */
  41327. X = 2,
  41328. /** Y */
  41329. Y = 3,
  41330. /** Left button */
  41331. LB = 4,
  41332. /** Right button */
  41333. RB = 5,
  41334. /** Back */
  41335. Back = 8,
  41336. /** Start */
  41337. Start = 9,
  41338. /** Left stick */
  41339. LeftStick = 10,
  41340. /** Right stick */
  41341. RightStick = 11
  41342. }
  41343. /** Defines values for XBox360 DPad */
  41344. export enum Xbox360Dpad {
  41345. /** Up */
  41346. Up = 12,
  41347. /** Down */
  41348. Down = 13,
  41349. /** Left */
  41350. Left = 14,
  41351. /** Right */
  41352. Right = 15
  41353. }
  41354. /**
  41355. * Defines a XBox360 gamepad
  41356. */
  41357. export class Xbox360Pad extends Gamepad {
  41358. private _leftTrigger;
  41359. private _rightTrigger;
  41360. private _onlefttriggerchanged;
  41361. private _onrighttriggerchanged;
  41362. private _onbuttondown;
  41363. private _onbuttonup;
  41364. private _ondpaddown;
  41365. private _ondpadup;
  41366. /** Observable raised when a button is pressed */
  41367. onButtonDownObservable: Observable<Xbox360Button>;
  41368. /** Observable raised when a button is released */
  41369. onButtonUpObservable: Observable<Xbox360Button>;
  41370. /** Observable raised when a pad is pressed */
  41371. onPadDownObservable: Observable<Xbox360Dpad>;
  41372. /** Observable raised when a pad is released */
  41373. onPadUpObservable: Observable<Xbox360Dpad>;
  41374. private _buttonA;
  41375. private _buttonB;
  41376. private _buttonX;
  41377. private _buttonY;
  41378. private _buttonBack;
  41379. private _buttonStart;
  41380. private _buttonLB;
  41381. private _buttonRB;
  41382. private _buttonLeftStick;
  41383. private _buttonRightStick;
  41384. private _dPadUp;
  41385. private _dPadDown;
  41386. private _dPadLeft;
  41387. private _dPadRight;
  41388. private _isXboxOnePad;
  41389. /**
  41390. * Creates a new XBox360 gamepad object
  41391. * @param id defines the id of this gamepad
  41392. * @param index defines its index
  41393. * @param gamepad defines the internal HTML gamepad object
  41394. * @param xboxOne defines if it is a XBox One gamepad
  41395. */
  41396. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41397. /**
  41398. * Defines the callback to call when left trigger is pressed
  41399. * @param callback defines the callback to use
  41400. */
  41401. onlefttriggerchanged(callback: (value: number) => void): void;
  41402. /**
  41403. * Defines the callback to call when right trigger is pressed
  41404. * @param callback defines the callback to use
  41405. */
  41406. onrighttriggerchanged(callback: (value: number) => void): void;
  41407. /**
  41408. * Gets the left trigger value
  41409. */
  41410. get leftTrigger(): number;
  41411. /**
  41412. * Sets the left trigger value
  41413. */
  41414. set leftTrigger(newValue: number);
  41415. /**
  41416. * Gets the right trigger value
  41417. */
  41418. get rightTrigger(): number;
  41419. /**
  41420. * Sets the right trigger value
  41421. */
  41422. set rightTrigger(newValue: number);
  41423. /**
  41424. * Defines the callback to call when a button is pressed
  41425. * @param callback defines the callback to use
  41426. */
  41427. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41428. /**
  41429. * Defines the callback to call when a button is released
  41430. * @param callback defines the callback to use
  41431. */
  41432. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41433. /**
  41434. * Defines the callback to call when a pad is pressed
  41435. * @param callback defines the callback to use
  41436. */
  41437. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41438. /**
  41439. * Defines the callback to call when a pad is released
  41440. * @param callback defines the callback to use
  41441. */
  41442. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41443. private _setButtonValue;
  41444. private _setDPadValue;
  41445. /**
  41446. * Gets the value of the `A` button
  41447. */
  41448. get buttonA(): number;
  41449. /**
  41450. * Sets the value of the `A` button
  41451. */
  41452. set buttonA(value: number);
  41453. /**
  41454. * Gets the value of the `B` button
  41455. */
  41456. get buttonB(): number;
  41457. /**
  41458. * Sets the value of the `B` button
  41459. */
  41460. set buttonB(value: number);
  41461. /**
  41462. * Gets the value of the `X` button
  41463. */
  41464. get buttonX(): number;
  41465. /**
  41466. * Sets the value of the `X` button
  41467. */
  41468. set buttonX(value: number);
  41469. /**
  41470. * Gets the value of the `Y` button
  41471. */
  41472. get buttonY(): number;
  41473. /**
  41474. * Sets the value of the `Y` button
  41475. */
  41476. set buttonY(value: number);
  41477. /**
  41478. * Gets the value of the `Start` button
  41479. */
  41480. get buttonStart(): number;
  41481. /**
  41482. * Sets the value of the `Start` button
  41483. */
  41484. set buttonStart(value: number);
  41485. /**
  41486. * Gets the value of the `Back` button
  41487. */
  41488. get buttonBack(): number;
  41489. /**
  41490. * Sets the value of the `Back` button
  41491. */
  41492. set buttonBack(value: number);
  41493. /**
  41494. * Gets the value of the `Left` button
  41495. */
  41496. get buttonLB(): number;
  41497. /**
  41498. * Sets the value of the `Left` button
  41499. */
  41500. set buttonLB(value: number);
  41501. /**
  41502. * Gets the value of the `Right` button
  41503. */
  41504. get buttonRB(): number;
  41505. /**
  41506. * Sets the value of the `Right` button
  41507. */
  41508. set buttonRB(value: number);
  41509. /**
  41510. * Gets the value of the Left joystick
  41511. */
  41512. get buttonLeftStick(): number;
  41513. /**
  41514. * Sets the value of the Left joystick
  41515. */
  41516. set buttonLeftStick(value: number);
  41517. /**
  41518. * Gets the value of the Right joystick
  41519. */
  41520. get buttonRightStick(): number;
  41521. /**
  41522. * Sets the value of the Right joystick
  41523. */
  41524. set buttonRightStick(value: number);
  41525. /**
  41526. * Gets the value of D-pad up
  41527. */
  41528. get dPadUp(): number;
  41529. /**
  41530. * Sets the value of D-pad up
  41531. */
  41532. set dPadUp(value: number);
  41533. /**
  41534. * Gets the value of D-pad down
  41535. */
  41536. get dPadDown(): number;
  41537. /**
  41538. * Sets the value of D-pad down
  41539. */
  41540. set dPadDown(value: number);
  41541. /**
  41542. * Gets the value of D-pad left
  41543. */
  41544. get dPadLeft(): number;
  41545. /**
  41546. * Sets the value of D-pad left
  41547. */
  41548. set dPadLeft(value: number);
  41549. /**
  41550. * Gets the value of D-pad right
  41551. */
  41552. get dPadRight(): number;
  41553. /**
  41554. * Sets the value of D-pad right
  41555. */
  41556. set dPadRight(value: number);
  41557. /**
  41558. * Force the gamepad to synchronize with device values
  41559. */
  41560. update(): void;
  41561. /**
  41562. * Disposes the gamepad
  41563. */
  41564. dispose(): void;
  41565. }
  41566. }
  41567. declare module BABYLON {
  41568. /**
  41569. * Defines supported buttons for DualShock compatible gamepads
  41570. */
  41571. export enum DualShockButton {
  41572. /** Cross */
  41573. Cross = 0,
  41574. /** Circle */
  41575. Circle = 1,
  41576. /** Square */
  41577. Square = 2,
  41578. /** Triangle */
  41579. Triangle = 3,
  41580. /** L1 */
  41581. L1 = 4,
  41582. /** R1 */
  41583. R1 = 5,
  41584. /** Share */
  41585. Share = 8,
  41586. /** Options */
  41587. Options = 9,
  41588. /** Left stick */
  41589. LeftStick = 10,
  41590. /** Right stick */
  41591. RightStick = 11
  41592. }
  41593. /** Defines values for DualShock DPad */
  41594. export enum DualShockDpad {
  41595. /** Up */
  41596. Up = 12,
  41597. /** Down */
  41598. Down = 13,
  41599. /** Left */
  41600. Left = 14,
  41601. /** Right */
  41602. Right = 15
  41603. }
  41604. /**
  41605. * Defines a DualShock gamepad
  41606. */
  41607. export class DualShockPad extends Gamepad {
  41608. private _leftTrigger;
  41609. private _rightTrigger;
  41610. private _onlefttriggerchanged;
  41611. private _onrighttriggerchanged;
  41612. private _onbuttondown;
  41613. private _onbuttonup;
  41614. private _ondpaddown;
  41615. private _ondpadup;
  41616. /** Observable raised when a button is pressed */
  41617. onButtonDownObservable: Observable<DualShockButton>;
  41618. /** Observable raised when a button is released */
  41619. onButtonUpObservable: Observable<DualShockButton>;
  41620. /** Observable raised when a pad is pressed */
  41621. onPadDownObservable: Observable<DualShockDpad>;
  41622. /** Observable raised when a pad is released */
  41623. onPadUpObservable: Observable<DualShockDpad>;
  41624. private _buttonCross;
  41625. private _buttonCircle;
  41626. private _buttonSquare;
  41627. private _buttonTriangle;
  41628. private _buttonShare;
  41629. private _buttonOptions;
  41630. private _buttonL1;
  41631. private _buttonR1;
  41632. private _buttonLeftStick;
  41633. private _buttonRightStick;
  41634. private _dPadUp;
  41635. private _dPadDown;
  41636. private _dPadLeft;
  41637. private _dPadRight;
  41638. /**
  41639. * Creates a new DualShock gamepad object
  41640. * @param id defines the id of this gamepad
  41641. * @param index defines its index
  41642. * @param gamepad defines the internal HTML gamepad object
  41643. */
  41644. constructor(id: string, index: number, gamepad: any);
  41645. /**
  41646. * Defines the callback to call when left trigger is pressed
  41647. * @param callback defines the callback to use
  41648. */
  41649. onlefttriggerchanged(callback: (value: number) => void): void;
  41650. /**
  41651. * Defines the callback to call when right trigger is pressed
  41652. * @param callback defines the callback to use
  41653. */
  41654. onrighttriggerchanged(callback: (value: number) => void): void;
  41655. /**
  41656. * Gets the left trigger value
  41657. */
  41658. get leftTrigger(): number;
  41659. /**
  41660. * Sets the left trigger value
  41661. */
  41662. set leftTrigger(newValue: number);
  41663. /**
  41664. * Gets the right trigger value
  41665. */
  41666. get rightTrigger(): number;
  41667. /**
  41668. * Sets the right trigger value
  41669. */
  41670. set rightTrigger(newValue: number);
  41671. /**
  41672. * Defines the callback to call when a button is pressed
  41673. * @param callback defines the callback to use
  41674. */
  41675. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41676. /**
  41677. * Defines the callback to call when a button is released
  41678. * @param callback defines the callback to use
  41679. */
  41680. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41681. /**
  41682. * Defines the callback to call when a pad is pressed
  41683. * @param callback defines the callback to use
  41684. */
  41685. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41686. /**
  41687. * Defines the callback to call when a pad is released
  41688. * @param callback defines the callback to use
  41689. */
  41690. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41691. private _setButtonValue;
  41692. private _setDPadValue;
  41693. /**
  41694. * Gets the value of the `Cross` button
  41695. */
  41696. get buttonCross(): number;
  41697. /**
  41698. * Sets the value of the `Cross` button
  41699. */
  41700. set buttonCross(value: number);
  41701. /**
  41702. * Gets the value of the `Circle` button
  41703. */
  41704. get buttonCircle(): number;
  41705. /**
  41706. * Sets the value of the `Circle` button
  41707. */
  41708. set buttonCircle(value: number);
  41709. /**
  41710. * Gets the value of the `Square` button
  41711. */
  41712. get buttonSquare(): number;
  41713. /**
  41714. * Sets the value of the `Square` button
  41715. */
  41716. set buttonSquare(value: number);
  41717. /**
  41718. * Gets the value of the `Triangle` button
  41719. */
  41720. get buttonTriangle(): number;
  41721. /**
  41722. * Sets the value of the `Triangle` button
  41723. */
  41724. set buttonTriangle(value: number);
  41725. /**
  41726. * Gets the value of the `Options` button
  41727. */
  41728. get buttonOptions(): number;
  41729. /**
  41730. * Sets the value of the `Options` button
  41731. */
  41732. set buttonOptions(value: number);
  41733. /**
  41734. * Gets the value of the `Share` button
  41735. */
  41736. get buttonShare(): number;
  41737. /**
  41738. * Sets the value of the `Share` button
  41739. */
  41740. set buttonShare(value: number);
  41741. /**
  41742. * Gets the value of the `L1` button
  41743. */
  41744. get buttonL1(): number;
  41745. /**
  41746. * Sets the value of the `L1` button
  41747. */
  41748. set buttonL1(value: number);
  41749. /**
  41750. * Gets the value of the `R1` button
  41751. */
  41752. get buttonR1(): number;
  41753. /**
  41754. * Sets the value of the `R1` button
  41755. */
  41756. set buttonR1(value: number);
  41757. /**
  41758. * Gets the value of the Left joystick
  41759. */
  41760. get buttonLeftStick(): number;
  41761. /**
  41762. * Sets the value of the Left joystick
  41763. */
  41764. set buttonLeftStick(value: number);
  41765. /**
  41766. * Gets the value of the Right joystick
  41767. */
  41768. get buttonRightStick(): number;
  41769. /**
  41770. * Sets the value of the Right joystick
  41771. */
  41772. set buttonRightStick(value: number);
  41773. /**
  41774. * Gets the value of D-pad up
  41775. */
  41776. get dPadUp(): number;
  41777. /**
  41778. * Sets the value of D-pad up
  41779. */
  41780. set dPadUp(value: number);
  41781. /**
  41782. * Gets the value of D-pad down
  41783. */
  41784. get dPadDown(): number;
  41785. /**
  41786. * Sets the value of D-pad down
  41787. */
  41788. set dPadDown(value: number);
  41789. /**
  41790. * Gets the value of D-pad left
  41791. */
  41792. get dPadLeft(): number;
  41793. /**
  41794. * Sets the value of D-pad left
  41795. */
  41796. set dPadLeft(value: number);
  41797. /**
  41798. * Gets the value of D-pad right
  41799. */
  41800. get dPadRight(): number;
  41801. /**
  41802. * Sets the value of D-pad right
  41803. */
  41804. set dPadRight(value: number);
  41805. /**
  41806. * Force the gamepad to synchronize with device values
  41807. */
  41808. update(): void;
  41809. /**
  41810. * Disposes the gamepad
  41811. */
  41812. dispose(): void;
  41813. }
  41814. }
  41815. declare module BABYLON {
  41816. /**
  41817. * Manager for handling gamepads
  41818. */
  41819. export class GamepadManager {
  41820. private _scene?;
  41821. private _babylonGamepads;
  41822. private _oneGamepadConnected;
  41823. /** @hidden */
  41824. _isMonitoring: boolean;
  41825. private _gamepadEventSupported;
  41826. private _gamepadSupport?;
  41827. /**
  41828. * observable to be triggered when the gamepad controller has been connected
  41829. */
  41830. onGamepadConnectedObservable: Observable<Gamepad>;
  41831. /**
  41832. * observable to be triggered when the gamepad controller has been disconnected
  41833. */
  41834. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41835. private _onGamepadConnectedEvent;
  41836. private _onGamepadDisconnectedEvent;
  41837. /**
  41838. * Initializes the gamepad manager
  41839. * @param _scene BabylonJS scene
  41840. */
  41841. constructor(_scene?: Scene | undefined);
  41842. /**
  41843. * The gamepads in the game pad manager
  41844. */
  41845. get gamepads(): Gamepad[];
  41846. /**
  41847. * Get the gamepad controllers based on type
  41848. * @param type The type of gamepad controller
  41849. * @returns Nullable gamepad
  41850. */
  41851. getGamepadByType(type?: number): Nullable<Gamepad>;
  41852. /**
  41853. * Disposes the gamepad manager
  41854. */
  41855. dispose(): void;
  41856. private _addNewGamepad;
  41857. private _startMonitoringGamepads;
  41858. private _stopMonitoringGamepads;
  41859. /** @hidden */
  41860. _checkGamepadsStatus(): void;
  41861. private _updateGamepadObjects;
  41862. }
  41863. }
  41864. declare module BABYLON {
  41865. interface Scene {
  41866. /** @hidden */
  41867. _gamepadManager: Nullable<GamepadManager>;
  41868. /**
  41869. * Gets the gamepad manager associated with the scene
  41870. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41871. */
  41872. gamepadManager: GamepadManager;
  41873. }
  41874. /**
  41875. * Interface representing a free camera inputs manager
  41876. */
  41877. interface FreeCameraInputsManager {
  41878. /**
  41879. * Adds gamepad input support to the FreeCameraInputsManager.
  41880. * @returns the FreeCameraInputsManager
  41881. */
  41882. addGamepad(): FreeCameraInputsManager;
  41883. }
  41884. /**
  41885. * Interface representing an arc rotate camera inputs manager
  41886. */
  41887. interface ArcRotateCameraInputsManager {
  41888. /**
  41889. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41890. * @returns the camera inputs manager
  41891. */
  41892. addGamepad(): ArcRotateCameraInputsManager;
  41893. }
  41894. /**
  41895. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41896. */
  41897. export class GamepadSystemSceneComponent implements ISceneComponent {
  41898. /**
  41899. * The component name helpfull to identify the component in the list of scene components.
  41900. */
  41901. readonly name: string;
  41902. /**
  41903. * The scene the component belongs to.
  41904. */
  41905. scene: Scene;
  41906. /**
  41907. * Creates a new instance of the component for the given scene
  41908. * @param scene Defines the scene to register the component in
  41909. */
  41910. constructor(scene: Scene);
  41911. /**
  41912. * Registers the component in a given scene
  41913. */
  41914. register(): void;
  41915. /**
  41916. * Rebuilds the elements related to this component in case of
  41917. * context lost for instance.
  41918. */
  41919. rebuild(): void;
  41920. /**
  41921. * Disposes the component and the associated ressources
  41922. */
  41923. dispose(): void;
  41924. private _beforeCameraUpdate;
  41925. }
  41926. }
  41927. declare module BABYLON {
  41928. /**
  41929. * 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,
  41930. * which still works and will still be found in many Playgrounds.
  41931. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41932. */
  41933. export class UniversalCamera extends TouchCamera {
  41934. /**
  41935. * Defines the gamepad rotation sensiblity.
  41936. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41937. */
  41938. get gamepadAngularSensibility(): number;
  41939. set gamepadAngularSensibility(value: number);
  41940. /**
  41941. * Defines the gamepad move sensiblity.
  41942. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41943. */
  41944. get gamepadMoveSensibility(): number;
  41945. set gamepadMoveSensibility(value: number);
  41946. /**
  41947. * 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,
  41948. * which still works and will still be found in many Playgrounds.
  41949. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41950. * @param name Define the name of the camera in the scene
  41951. * @param position Define the start position of the camera in the scene
  41952. * @param scene Define the scene the camera belongs to
  41953. */
  41954. constructor(name: string, position: Vector3, scene: Scene);
  41955. /**
  41956. * Gets the current object class name.
  41957. * @return the class name
  41958. */
  41959. getClassName(): string;
  41960. }
  41961. }
  41962. declare module BABYLON {
  41963. /**
  41964. * This represents a FPS type of camera. This is only here for back compat purpose.
  41965. * Please use the UniversalCamera instead as both are identical.
  41966. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41967. */
  41968. export class GamepadCamera extends UniversalCamera {
  41969. /**
  41970. * Instantiates a new Gamepad Camera
  41971. * This represents a FPS type of camera. This is only here for back compat purpose.
  41972. * Please use the UniversalCamera instead as both are identical.
  41973. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41974. * @param name Define the name of the camera in the scene
  41975. * @param position Define the start position of the camera in the scene
  41976. * @param scene Define the scene the camera belongs to
  41977. */
  41978. constructor(name: string, position: Vector3, scene: Scene);
  41979. /**
  41980. * Gets the current object class name.
  41981. * @return the class name
  41982. */
  41983. getClassName(): string;
  41984. }
  41985. }
  41986. declare module BABYLON {
  41987. /** @hidden */
  41988. export var passPixelShader: {
  41989. name: string;
  41990. shader: string;
  41991. };
  41992. }
  41993. declare module BABYLON {
  41994. /** @hidden */
  41995. export var passCubePixelShader: {
  41996. name: string;
  41997. shader: string;
  41998. };
  41999. }
  42000. declare module BABYLON {
  42001. /**
  42002. * PassPostProcess which produces an output the same as it's input
  42003. */
  42004. export class PassPostProcess extends PostProcess {
  42005. /**
  42006. * Creates the PassPostProcess
  42007. * @param name The name of the effect.
  42008. * @param options The required width/height ratio to downsize to before computing the render pass.
  42009. * @param camera The camera to apply the render pass to.
  42010. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42011. * @param engine The engine which the post process will be applied. (default: current engine)
  42012. * @param reusable If the post process can be reused on the same frame. (default: false)
  42013. * @param textureType The type of texture to be used when performing the post processing.
  42014. * @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)
  42015. */
  42016. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42017. }
  42018. /**
  42019. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42020. */
  42021. export class PassCubePostProcess extends PostProcess {
  42022. private _face;
  42023. /**
  42024. * Gets or sets the cube face to display.
  42025. * * 0 is +X
  42026. * * 1 is -X
  42027. * * 2 is +Y
  42028. * * 3 is -Y
  42029. * * 4 is +Z
  42030. * * 5 is -Z
  42031. */
  42032. get face(): number;
  42033. set face(value: number);
  42034. /**
  42035. * Creates the PassCubePostProcess
  42036. * @param name The name of the effect.
  42037. * @param options The required width/height ratio to downsize to before computing the render pass.
  42038. * @param camera The camera to apply the render pass to.
  42039. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42040. * @param engine The engine which the post process will be applied. (default: current engine)
  42041. * @param reusable If the post process can be reused on the same frame. (default: false)
  42042. * @param textureType The type of texture to be used when performing the post processing.
  42043. * @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)
  42044. */
  42045. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42046. }
  42047. }
  42048. declare module BABYLON {
  42049. /** @hidden */
  42050. export var anaglyphPixelShader: {
  42051. name: string;
  42052. shader: string;
  42053. };
  42054. }
  42055. declare module BABYLON {
  42056. /**
  42057. * Postprocess used to generate anaglyphic rendering
  42058. */
  42059. export class AnaglyphPostProcess extends PostProcess {
  42060. private _passedProcess;
  42061. /**
  42062. * Creates a new AnaglyphPostProcess
  42063. * @param name defines postprocess name
  42064. * @param options defines creation options or target ratio scale
  42065. * @param rigCameras defines cameras using this postprocess
  42066. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42067. * @param engine defines hosting engine
  42068. * @param reusable defines if the postprocess will be reused multiple times per frame
  42069. */
  42070. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42071. }
  42072. }
  42073. declare module BABYLON {
  42074. /**
  42075. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42076. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42077. */
  42078. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42079. /**
  42080. * Creates a new AnaglyphArcRotateCamera
  42081. * @param name defines camera name
  42082. * @param alpha defines alpha angle (in radians)
  42083. * @param beta defines beta angle (in radians)
  42084. * @param radius defines radius
  42085. * @param target defines camera target
  42086. * @param interaxialDistance defines distance between each color axis
  42087. * @param scene defines the hosting scene
  42088. */
  42089. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42090. /**
  42091. * Gets camera class name
  42092. * @returns AnaglyphArcRotateCamera
  42093. */
  42094. getClassName(): string;
  42095. }
  42096. }
  42097. declare module BABYLON {
  42098. /**
  42099. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42100. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42101. */
  42102. export class AnaglyphFreeCamera extends FreeCamera {
  42103. /**
  42104. * Creates a new AnaglyphFreeCamera
  42105. * @param name defines camera name
  42106. * @param position defines initial position
  42107. * @param interaxialDistance defines distance between each color axis
  42108. * @param scene defines the hosting scene
  42109. */
  42110. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42111. /**
  42112. * Gets camera class name
  42113. * @returns AnaglyphFreeCamera
  42114. */
  42115. getClassName(): string;
  42116. }
  42117. }
  42118. declare module BABYLON {
  42119. /**
  42120. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42121. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42122. */
  42123. export class AnaglyphGamepadCamera extends GamepadCamera {
  42124. /**
  42125. * Creates a new AnaglyphGamepadCamera
  42126. * @param name defines camera name
  42127. * @param position defines initial position
  42128. * @param interaxialDistance defines distance between each color axis
  42129. * @param scene defines the hosting scene
  42130. */
  42131. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42132. /**
  42133. * Gets camera class name
  42134. * @returns AnaglyphGamepadCamera
  42135. */
  42136. getClassName(): string;
  42137. }
  42138. }
  42139. declare module BABYLON {
  42140. /**
  42141. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42142. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42143. */
  42144. export class AnaglyphUniversalCamera extends UniversalCamera {
  42145. /**
  42146. * Creates a new AnaglyphUniversalCamera
  42147. * @param name defines camera name
  42148. * @param position defines initial position
  42149. * @param interaxialDistance defines distance between each color axis
  42150. * @param scene defines the hosting scene
  42151. */
  42152. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42153. /**
  42154. * Gets camera class name
  42155. * @returns AnaglyphUniversalCamera
  42156. */
  42157. getClassName(): string;
  42158. }
  42159. }
  42160. declare module BABYLON {
  42161. /** @hidden */
  42162. export var stereoscopicInterlacePixelShader: {
  42163. name: string;
  42164. shader: string;
  42165. };
  42166. }
  42167. declare module BABYLON {
  42168. /**
  42169. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  42170. */
  42171. export class StereoscopicInterlacePostProcessI extends PostProcess {
  42172. private _stepSize;
  42173. private _passedProcess;
  42174. /**
  42175. * Initializes a StereoscopicInterlacePostProcessI
  42176. * @param name The name of the effect.
  42177. * @param rigCameras The rig cameras to be appled to the post process
  42178. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  42179. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  42180. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42181. * @param engine The engine which the post process will be applied. (default: current engine)
  42182. * @param reusable If the post process can be reused on the same frame. (default: false)
  42183. */
  42184. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42185. }
  42186. /**
  42187. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42188. */
  42189. export class StereoscopicInterlacePostProcess extends PostProcess {
  42190. private _stepSize;
  42191. private _passedProcess;
  42192. /**
  42193. * Initializes a StereoscopicInterlacePostProcess
  42194. * @param name The name of the effect.
  42195. * @param rigCameras The rig cameras to be appled to the post process
  42196. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42198. * @param engine The engine which the post process will be applied. (default: current engine)
  42199. * @param reusable If the post process can be reused on the same frame. (default: false)
  42200. */
  42201. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42202. }
  42203. }
  42204. declare module BABYLON {
  42205. /**
  42206. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42207. * @see http://doc.babylonjs.com/features/cameras
  42208. */
  42209. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42210. /**
  42211. * Creates a new StereoscopicArcRotateCamera
  42212. * @param name defines camera name
  42213. * @param alpha defines alpha angle (in radians)
  42214. * @param beta defines beta angle (in radians)
  42215. * @param radius defines radius
  42216. * @param target defines camera target
  42217. * @param interaxialDistance defines distance between each color axis
  42218. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42219. * @param scene defines the hosting scene
  42220. */
  42221. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42222. /**
  42223. * Gets camera class name
  42224. * @returns StereoscopicArcRotateCamera
  42225. */
  42226. getClassName(): string;
  42227. }
  42228. }
  42229. declare module BABYLON {
  42230. /**
  42231. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42232. * @see http://doc.babylonjs.com/features/cameras
  42233. */
  42234. export class StereoscopicFreeCamera extends FreeCamera {
  42235. /**
  42236. * Creates a new StereoscopicFreeCamera
  42237. * @param name defines camera name
  42238. * @param position defines initial position
  42239. * @param interaxialDistance defines distance between each color axis
  42240. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42241. * @param scene defines the hosting scene
  42242. */
  42243. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42244. /**
  42245. * Gets camera class name
  42246. * @returns StereoscopicFreeCamera
  42247. */
  42248. getClassName(): string;
  42249. }
  42250. }
  42251. declare module BABYLON {
  42252. /**
  42253. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42254. * @see http://doc.babylonjs.com/features/cameras
  42255. */
  42256. export class StereoscopicGamepadCamera extends GamepadCamera {
  42257. /**
  42258. * Creates a new StereoscopicGamepadCamera
  42259. * @param name defines camera name
  42260. * @param position defines initial position
  42261. * @param interaxialDistance defines distance between each color axis
  42262. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42263. * @param scene defines the hosting scene
  42264. */
  42265. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42266. /**
  42267. * Gets camera class name
  42268. * @returns StereoscopicGamepadCamera
  42269. */
  42270. getClassName(): string;
  42271. }
  42272. }
  42273. declare module BABYLON {
  42274. /**
  42275. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42276. * @see http://doc.babylonjs.com/features/cameras
  42277. */
  42278. export class StereoscopicUniversalCamera extends UniversalCamera {
  42279. /**
  42280. * Creates a new StereoscopicUniversalCamera
  42281. * @param name defines camera name
  42282. * @param position defines initial position
  42283. * @param interaxialDistance defines distance between each color axis
  42284. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42285. * @param scene defines the hosting scene
  42286. */
  42287. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42288. /**
  42289. * Gets camera class name
  42290. * @returns StereoscopicUniversalCamera
  42291. */
  42292. getClassName(): string;
  42293. }
  42294. }
  42295. declare module BABYLON {
  42296. /**
  42297. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42298. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42299. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42300. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42301. */
  42302. export class VirtualJoysticksCamera extends FreeCamera {
  42303. /**
  42304. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42305. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42306. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42307. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42308. * @param name Define the name of the camera in the scene
  42309. * @param position Define the start position of the camera in the scene
  42310. * @param scene Define the scene the camera belongs to
  42311. */
  42312. constructor(name: string, position: Vector3, scene: Scene);
  42313. /**
  42314. * Gets the current object class name.
  42315. * @return the class name
  42316. */
  42317. getClassName(): string;
  42318. }
  42319. }
  42320. declare module BABYLON {
  42321. /**
  42322. * This represents all the required metrics to create a VR camera.
  42323. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42324. */
  42325. export class VRCameraMetrics {
  42326. /**
  42327. * Define the horizontal resolution off the screen.
  42328. */
  42329. hResolution: number;
  42330. /**
  42331. * Define the vertical resolution off the screen.
  42332. */
  42333. vResolution: number;
  42334. /**
  42335. * Define the horizontal screen size.
  42336. */
  42337. hScreenSize: number;
  42338. /**
  42339. * Define the vertical screen size.
  42340. */
  42341. vScreenSize: number;
  42342. /**
  42343. * Define the vertical screen center position.
  42344. */
  42345. vScreenCenter: number;
  42346. /**
  42347. * Define the distance of the eyes to the screen.
  42348. */
  42349. eyeToScreenDistance: number;
  42350. /**
  42351. * Define the distance between both lenses
  42352. */
  42353. lensSeparationDistance: number;
  42354. /**
  42355. * Define the distance between both viewer's eyes.
  42356. */
  42357. interpupillaryDistance: number;
  42358. /**
  42359. * Define the distortion factor of the VR postprocess.
  42360. * Please, touch with care.
  42361. */
  42362. distortionK: number[];
  42363. /**
  42364. * Define the chromatic aberration correction factors for the VR post process.
  42365. */
  42366. chromaAbCorrection: number[];
  42367. /**
  42368. * Define the scale factor of the post process.
  42369. * The smaller the better but the slower.
  42370. */
  42371. postProcessScaleFactor: number;
  42372. /**
  42373. * Define an offset for the lens center.
  42374. */
  42375. lensCenterOffset: number;
  42376. /**
  42377. * Define if the current vr camera should compensate the distortion of the lense or not.
  42378. */
  42379. compensateDistortion: boolean;
  42380. /**
  42381. * Defines if multiview should be enabled when rendering (Default: false)
  42382. */
  42383. multiviewEnabled: boolean;
  42384. /**
  42385. * Gets the rendering aspect ratio based on the provided resolutions.
  42386. */
  42387. get aspectRatio(): number;
  42388. /**
  42389. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42390. */
  42391. get aspectRatioFov(): number;
  42392. /**
  42393. * @hidden
  42394. */
  42395. get leftHMatrix(): Matrix;
  42396. /**
  42397. * @hidden
  42398. */
  42399. get rightHMatrix(): Matrix;
  42400. /**
  42401. * @hidden
  42402. */
  42403. get leftPreViewMatrix(): Matrix;
  42404. /**
  42405. * @hidden
  42406. */
  42407. get rightPreViewMatrix(): Matrix;
  42408. /**
  42409. * Get the default VRMetrics based on the most generic setup.
  42410. * @returns the default vr metrics
  42411. */
  42412. static GetDefault(): VRCameraMetrics;
  42413. }
  42414. }
  42415. declare module BABYLON {
  42416. /** @hidden */
  42417. export var vrDistortionCorrectionPixelShader: {
  42418. name: string;
  42419. shader: string;
  42420. };
  42421. }
  42422. declare module BABYLON {
  42423. /**
  42424. * VRDistortionCorrectionPostProcess used for mobile VR
  42425. */
  42426. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42427. private _isRightEye;
  42428. private _distortionFactors;
  42429. private _postProcessScaleFactor;
  42430. private _lensCenterOffset;
  42431. private _scaleIn;
  42432. private _scaleFactor;
  42433. private _lensCenter;
  42434. /**
  42435. * Initializes the VRDistortionCorrectionPostProcess
  42436. * @param name The name of the effect.
  42437. * @param camera The camera to apply the render pass to.
  42438. * @param isRightEye If this is for the right eye distortion
  42439. * @param vrMetrics All the required metrics for the VR camera
  42440. */
  42441. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42442. }
  42443. }
  42444. declare module BABYLON {
  42445. /**
  42446. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42447. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42448. */
  42449. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42450. /**
  42451. * Creates a new VRDeviceOrientationArcRotateCamera
  42452. * @param name defines camera name
  42453. * @param alpha defines the camera rotation along the logitudinal axis
  42454. * @param beta defines the camera rotation along the latitudinal axis
  42455. * @param radius defines the camera distance from its target
  42456. * @param target defines the camera target
  42457. * @param scene defines the scene the camera belongs to
  42458. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42459. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42460. */
  42461. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42462. /**
  42463. * Gets camera class name
  42464. * @returns VRDeviceOrientationArcRotateCamera
  42465. */
  42466. getClassName(): string;
  42467. }
  42468. }
  42469. declare module BABYLON {
  42470. /**
  42471. * Camera used to simulate VR rendering (based on FreeCamera)
  42472. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42473. */
  42474. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42475. /**
  42476. * Creates a new VRDeviceOrientationFreeCamera
  42477. * @param name defines camera name
  42478. * @param position defines the start position of the camera
  42479. * @param scene defines the scene the camera belongs to
  42480. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42481. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42482. */
  42483. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42484. /**
  42485. * Gets camera class name
  42486. * @returns VRDeviceOrientationFreeCamera
  42487. */
  42488. getClassName(): string;
  42489. }
  42490. }
  42491. declare module BABYLON {
  42492. /**
  42493. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42494. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42495. */
  42496. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42497. /**
  42498. * Creates a new VRDeviceOrientationGamepadCamera
  42499. * @param name defines camera name
  42500. * @param position defines the start position of the camera
  42501. * @param scene defines the scene the camera belongs to
  42502. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42503. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42504. */
  42505. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42506. /**
  42507. * Gets camera class name
  42508. * @returns VRDeviceOrientationGamepadCamera
  42509. */
  42510. getClassName(): string;
  42511. }
  42512. }
  42513. declare module BABYLON {
  42514. /** @hidden */
  42515. export var imageProcessingPixelShader: {
  42516. name: string;
  42517. shader: string;
  42518. };
  42519. }
  42520. declare module BABYLON {
  42521. /**
  42522. * ImageProcessingPostProcess
  42523. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42524. */
  42525. export class ImageProcessingPostProcess extends PostProcess {
  42526. /**
  42527. * Default configuration related to image processing available in the PBR Material.
  42528. */
  42529. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42530. /**
  42531. * Gets the image processing configuration used either in this material.
  42532. */
  42533. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42534. /**
  42535. * Sets the Default image processing configuration used either in the this material.
  42536. *
  42537. * If sets to null, the scene one is in use.
  42538. */
  42539. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42540. /**
  42541. * Keep track of the image processing observer to allow dispose and replace.
  42542. */
  42543. private _imageProcessingObserver;
  42544. /**
  42545. * Attaches a new image processing configuration to the PBR Material.
  42546. * @param configuration
  42547. */
  42548. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42549. /**
  42550. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42551. */
  42552. get colorCurves(): Nullable<ColorCurves>;
  42553. /**
  42554. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42555. */
  42556. set colorCurves(value: Nullable<ColorCurves>);
  42557. /**
  42558. * Gets wether the color curves effect is enabled.
  42559. */
  42560. get colorCurvesEnabled(): boolean;
  42561. /**
  42562. * Sets wether the color curves effect is enabled.
  42563. */
  42564. set colorCurvesEnabled(value: boolean);
  42565. /**
  42566. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42567. */
  42568. get colorGradingTexture(): Nullable<BaseTexture>;
  42569. /**
  42570. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42571. */
  42572. set colorGradingTexture(value: Nullable<BaseTexture>);
  42573. /**
  42574. * Gets wether the color grading effect is enabled.
  42575. */
  42576. get colorGradingEnabled(): boolean;
  42577. /**
  42578. * Gets wether the color grading effect is enabled.
  42579. */
  42580. set colorGradingEnabled(value: boolean);
  42581. /**
  42582. * Gets exposure used in the effect.
  42583. */
  42584. get exposure(): number;
  42585. /**
  42586. * Sets exposure used in the effect.
  42587. */
  42588. set exposure(value: number);
  42589. /**
  42590. * Gets wether tonemapping is enabled or not.
  42591. */
  42592. get toneMappingEnabled(): boolean;
  42593. /**
  42594. * Sets wether tonemapping is enabled or not
  42595. */
  42596. set toneMappingEnabled(value: boolean);
  42597. /**
  42598. * Gets the type of tone mapping effect.
  42599. */
  42600. get toneMappingType(): number;
  42601. /**
  42602. * Sets the type of tone mapping effect.
  42603. */
  42604. set toneMappingType(value: number);
  42605. /**
  42606. * Gets contrast used in the effect.
  42607. */
  42608. get contrast(): number;
  42609. /**
  42610. * Sets contrast used in the effect.
  42611. */
  42612. set contrast(value: number);
  42613. /**
  42614. * Gets Vignette stretch size.
  42615. */
  42616. get vignetteStretch(): number;
  42617. /**
  42618. * Sets Vignette stretch size.
  42619. */
  42620. set vignetteStretch(value: number);
  42621. /**
  42622. * Gets Vignette centre X Offset.
  42623. */
  42624. get vignetteCentreX(): number;
  42625. /**
  42626. * Sets Vignette centre X Offset.
  42627. */
  42628. set vignetteCentreX(value: number);
  42629. /**
  42630. * Gets Vignette centre Y Offset.
  42631. */
  42632. get vignetteCentreY(): number;
  42633. /**
  42634. * Sets Vignette centre Y Offset.
  42635. */
  42636. set vignetteCentreY(value: number);
  42637. /**
  42638. * Gets Vignette weight or intensity of the vignette effect.
  42639. */
  42640. get vignetteWeight(): number;
  42641. /**
  42642. * Sets Vignette weight or intensity of the vignette effect.
  42643. */
  42644. set vignetteWeight(value: number);
  42645. /**
  42646. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42647. * if vignetteEnabled is set to true.
  42648. */
  42649. get vignetteColor(): Color4;
  42650. /**
  42651. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42652. * if vignetteEnabled is set to true.
  42653. */
  42654. set vignetteColor(value: Color4);
  42655. /**
  42656. * Gets Camera field of view used by the Vignette effect.
  42657. */
  42658. get vignetteCameraFov(): number;
  42659. /**
  42660. * Sets Camera field of view used by the Vignette effect.
  42661. */
  42662. set vignetteCameraFov(value: number);
  42663. /**
  42664. * Gets the vignette blend mode allowing different kind of effect.
  42665. */
  42666. get vignetteBlendMode(): number;
  42667. /**
  42668. * Sets the vignette blend mode allowing different kind of effect.
  42669. */
  42670. set vignetteBlendMode(value: number);
  42671. /**
  42672. * Gets wether the vignette effect is enabled.
  42673. */
  42674. get vignetteEnabled(): boolean;
  42675. /**
  42676. * Sets wether the vignette effect is enabled.
  42677. */
  42678. set vignetteEnabled(value: boolean);
  42679. private _fromLinearSpace;
  42680. /**
  42681. * Gets wether the input of the processing is in Gamma or Linear Space.
  42682. */
  42683. get fromLinearSpace(): boolean;
  42684. /**
  42685. * Sets wether the input of the processing is in Gamma or Linear Space.
  42686. */
  42687. set fromLinearSpace(value: boolean);
  42688. /**
  42689. * Defines cache preventing GC.
  42690. */
  42691. private _defines;
  42692. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42693. /**
  42694. * "ImageProcessingPostProcess"
  42695. * @returns "ImageProcessingPostProcess"
  42696. */
  42697. getClassName(): string;
  42698. protected _updateParameters(): void;
  42699. dispose(camera?: Camera): void;
  42700. }
  42701. }
  42702. declare module BABYLON {
  42703. /**
  42704. * Class containing static functions to help procedurally build meshes
  42705. */
  42706. export class GroundBuilder {
  42707. /**
  42708. * Creates a ground mesh
  42709. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42710. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42712. * @param name defines the name of the mesh
  42713. * @param options defines the options used to create the mesh
  42714. * @param scene defines the hosting scene
  42715. * @returns the ground mesh
  42716. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42717. */
  42718. static CreateGround(name: string, options: {
  42719. width?: number;
  42720. height?: number;
  42721. subdivisions?: number;
  42722. subdivisionsX?: number;
  42723. subdivisionsY?: number;
  42724. updatable?: boolean;
  42725. }, scene: any): Mesh;
  42726. /**
  42727. * Creates a tiled ground mesh
  42728. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42729. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42730. * * 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
  42731. * * 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
  42732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42733. * @param name defines the name of the mesh
  42734. * @param options defines the options used to create the mesh
  42735. * @param scene defines the hosting scene
  42736. * @returns the tiled ground mesh
  42737. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42738. */
  42739. static CreateTiledGround(name: string, options: {
  42740. xmin: number;
  42741. zmin: number;
  42742. xmax: number;
  42743. zmax: number;
  42744. subdivisions?: {
  42745. w: number;
  42746. h: number;
  42747. };
  42748. precision?: {
  42749. w: number;
  42750. h: number;
  42751. };
  42752. updatable?: boolean;
  42753. }, scene?: Nullable<Scene>): Mesh;
  42754. /**
  42755. * Creates a ground mesh from a height map
  42756. * * The parameter `url` sets the URL of the height map image resource.
  42757. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42758. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42759. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42760. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42761. * * 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.
  42762. * * 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).
  42763. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42765. * @param name defines the name of the mesh
  42766. * @param url defines the url to the height map
  42767. * @param options defines the options used to create the mesh
  42768. * @param scene defines the hosting scene
  42769. * @returns the ground mesh
  42770. * @see https://doc.babylonjs.com/babylon101/height_map
  42771. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42772. */
  42773. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42774. width?: number;
  42775. height?: number;
  42776. subdivisions?: number;
  42777. minHeight?: number;
  42778. maxHeight?: number;
  42779. colorFilter?: Color3;
  42780. alphaFilter?: number;
  42781. updatable?: boolean;
  42782. onReady?: (mesh: GroundMesh) => void;
  42783. }, scene?: Nullable<Scene>): GroundMesh;
  42784. }
  42785. }
  42786. declare module BABYLON {
  42787. /**
  42788. * Class containing static functions to help procedurally build meshes
  42789. */
  42790. export class TorusBuilder {
  42791. /**
  42792. * Creates a torus mesh
  42793. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42794. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42795. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42797. * * 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
  42798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42799. * @param name defines the name of the mesh
  42800. * @param options defines the options used to create the mesh
  42801. * @param scene defines the hosting scene
  42802. * @returns the torus mesh
  42803. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42804. */
  42805. static CreateTorus(name: string, options: {
  42806. diameter?: number;
  42807. thickness?: number;
  42808. tessellation?: number;
  42809. updatable?: boolean;
  42810. sideOrientation?: number;
  42811. frontUVs?: Vector4;
  42812. backUVs?: Vector4;
  42813. }, scene: any): Mesh;
  42814. }
  42815. }
  42816. declare module BABYLON {
  42817. /**
  42818. * Class containing static functions to help procedurally build meshes
  42819. */
  42820. export class CylinderBuilder {
  42821. /**
  42822. * Creates a cylinder or a cone mesh
  42823. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42824. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42825. * * 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.
  42826. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42827. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42828. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42829. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42830. * * 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).
  42831. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42832. * * 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).
  42833. * * 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
  42834. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42835. * * 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
  42836. * * 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.
  42837. * * If `enclose` is false, a ring surface is one element.
  42838. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42839. * * 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
  42840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42841. * * 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
  42842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42843. * @param name defines the name of the mesh
  42844. * @param options defines the options used to create the mesh
  42845. * @param scene defines the hosting scene
  42846. * @returns the cylinder mesh
  42847. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42848. */
  42849. static CreateCylinder(name: string, options: {
  42850. height?: number;
  42851. diameterTop?: number;
  42852. diameterBottom?: number;
  42853. diameter?: number;
  42854. tessellation?: number;
  42855. subdivisions?: number;
  42856. arc?: number;
  42857. faceColors?: Color4[];
  42858. faceUV?: Vector4[];
  42859. updatable?: boolean;
  42860. hasRings?: boolean;
  42861. enclose?: boolean;
  42862. cap?: number;
  42863. sideOrientation?: number;
  42864. frontUVs?: Vector4;
  42865. backUVs?: Vector4;
  42866. }, scene: any): Mesh;
  42867. }
  42868. }
  42869. declare module BABYLON {
  42870. /**
  42871. * States of the webXR experience
  42872. */
  42873. export enum WebXRState {
  42874. /**
  42875. * Transitioning to being in XR mode
  42876. */
  42877. ENTERING_XR = 0,
  42878. /**
  42879. * Transitioning to non XR mode
  42880. */
  42881. EXITING_XR = 1,
  42882. /**
  42883. * In XR mode and presenting
  42884. */
  42885. IN_XR = 2,
  42886. /**
  42887. * Not entered XR mode
  42888. */
  42889. NOT_IN_XR = 3
  42890. }
  42891. /**
  42892. * Abstraction of the XR render target
  42893. */
  42894. export interface WebXRRenderTarget extends IDisposable {
  42895. /**
  42896. * xrpresent context of the canvas which can be used to display/mirror xr content
  42897. */
  42898. canvasContext: WebGLRenderingContext;
  42899. /**
  42900. * xr layer for the canvas
  42901. */
  42902. xrLayer: Nullable<XRWebGLLayer>;
  42903. /**
  42904. * Initializes the xr layer for the session
  42905. * @param xrSession xr session
  42906. * @returns a promise that will resolve once the XR Layer has been created
  42907. */
  42908. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42909. }
  42910. }
  42911. declare module BABYLON {
  42912. /**
  42913. * COnfiguration object for WebXR output canvas
  42914. */
  42915. export class WebXRManagedOutputCanvasOptions {
  42916. /**
  42917. * An optional canvas in case you wish to create it yourself and provide it here.
  42918. * If not provided, a new canvas will be created
  42919. */
  42920. canvasElement?: HTMLCanvasElement;
  42921. /**
  42922. * Options for this XR Layer output
  42923. */
  42924. canvasOptions?: XRWebGLLayerOptions;
  42925. /**
  42926. * CSS styling for a newly created canvas (if not provided)
  42927. */
  42928. newCanvasCssStyle?: string;
  42929. /**
  42930. * Get the default values of the configuration object
  42931. * @returns default values of this configuration object
  42932. */
  42933. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42934. }
  42935. /**
  42936. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42937. */
  42938. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42939. private _options;
  42940. private _canvas;
  42941. private _engine;
  42942. /**
  42943. * Rendering context of the canvas which can be used to display/mirror xr content
  42944. */
  42945. canvasContext: WebGLRenderingContext;
  42946. /**
  42947. * xr layer for the canvas
  42948. */
  42949. xrLayer: Nullable<XRWebGLLayer>;
  42950. /**
  42951. * Initializes the canvas to be added/removed upon entering/exiting xr
  42952. * @param _xrSessionManager The XR Session manager
  42953. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42954. */
  42955. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42956. /**
  42957. * Disposes of the object
  42958. */
  42959. dispose(): void;
  42960. /**
  42961. * Initializes the xr layer for the session
  42962. * @param xrSession xr session
  42963. * @returns a promise that will resolve once the XR Layer has been created
  42964. */
  42965. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42966. private _addCanvas;
  42967. private _removeCanvas;
  42968. private _setManagedOutputCanvas;
  42969. }
  42970. }
  42971. declare module BABYLON {
  42972. /**
  42973. * Manages an XRSession to work with Babylon's engine
  42974. * @see https://doc.babylonjs.com/how_to/webxr
  42975. */
  42976. export class WebXRSessionManager implements IDisposable {
  42977. /** The scene which the session should be created for */
  42978. scene: Scene;
  42979. private _referenceSpace;
  42980. private _rttProvider;
  42981. private _sessionEnded;
  42982. private _xrNavigator;
  42983. private baseLayer;
  42984. /**
  42985. * The base reference space from which the session started. good if you want to reset your
  42986. * reference space
  42987. */
  42988. baseReferenceSpace: XRReferenceSpace;
  42989. /**
  42990. * Current XR frame
  42991. */
  42992. currentFrame: Nullable<XRFrame>;
  42993. /** WebXR timestamp updated every frame */
  42994. currentTimestamp: number;
  42995. /**
  42996. * Used just in case of a failure to initialize an immersive session.
  42997. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42998. */
  42999. defaultHeightCompensation: number;
  43000. /**
  43001. * Fires every time a new xrFrame arrives which can be used to update the camera
  43002. */
  43003. onXRFrameObservable: Observable<XRFrame>;
  43004. /**
  43005. * Fires when the reference space changed
  43006. */
  43007. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43008. /**
  43009. * Fires when the xr session is ended either by the device or manually done
  43010. */
  43011. onXRSessionEnded: Observable<any>;
  43012. /**
  43013. * Fires when the xr session is ended either by the device or manually done
  43014. */
  43015. onXRSessionInit: Observable<XRSession>;
  43016. /**
  43017. * Underlying xr session
  43018. */
  43019. session: XRSession;
  43020. /**
  43021. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43022. * or get the offset the player is currently at.
  43023. */
  43024. viewerReferenceSpace: XRReferenceSpace;
  43025. /**
  43026. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43027. * @param scene The scene which the session should be created for
  43028. */
  43029. constructor(
  43030. /** The scene which the session should be created for */
  43031. scene: Scene);
  43032. /**
  43033. * The current reference space used in this session. This reference space can constantly change!
  43034. * It is mainly used to offset the camera's position.
  43035. */
  43036. get referenceSpace(): XRReferenceSpace;
  43037. /**
  43038. * Set a new reference space and triggers the observable
  43039. */
  43040. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43041. /**
  43042. * Disposes of the session manager
  43043. */
  43044. dispose(): void;
  43045. /**
  43046. * Stops the xrSession and restores the render loop
  43047. * @returns Promise which resolves after it exits XR
  43048. */
  43049. exitXRAsync(): Promise<void>;
  43050. /**
  43051. * Gets the correct render target texture to be rendered this frame for this eye
  43052. * @param eye the eye for which to get the render target
  43053. * @returns the render target for the specified eye
  43054. */
  43055. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43056. /**
  43057. * Creates a WebXRRenderTarget object for the XR session
  43058. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43059. * @param options optional options to provide when creating a new render target
  43060. * @returns a WebXR render target to which the session can render
  43061. */
  43062. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43063. /**
  43064. * Initializes the manager
  43065. * After initialization enterXR can be called to start an XR session
  43066. * @returns Promise which resolves after it is initialized
  43067. */
  43068. initializeAsync(): Promise<void>;
  43069. /**
  43070. * Initializes an xr session
  43071. * @param xrSessionMode mode to initialize
  43072. * @param xrSessionInit defines optional and required values to pass to the session builder
  43073. * @returns a promise which will resolve once the session has been initialized
  43074. */
  43075. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43076. /**
  43077. * Checks if a session would be supported for the creation options specified
  43078. * @param sessionMode session mode to check if supported eg. immersive-vr
  43079. * @returns A Promise that resolves to true if supported and false if not
  43080. */
  43081. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43082. /**
  43083. * Resets the reference space to the one started the session
  43084. */
  43085. resetReferenceSpace(): void;
  43086. /**
  43087. * Starts rendering to the xr layer
  43088. */
  43089. runXRRenderLoop(): void;
  43090. /**
  43091. * Sets the reference space on the xr session
  43092. * @param referenceSpaceType space to set
  43093. * @returns a promise that will resolve once the reference space has been set
  43094. */
  43095. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43096. /**
  43097. * Updates the render state of the session
  43098. * @param state state to set
  43099. * @returns a promise that resolves once the render state has been updated
  43100. */
  43101. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43102. /**
  43103. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43104. * @param sessionMode defines the session to test
  43105. * @returns a promise with boolean as final value
  43106. */
  43107. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43108. private _createRenderTargetTexture;
  43109. }
  43110. }
  43111. declare module BABYLON {
  43112. /**
  43113. * WebXR Camera which holds the views for the xrSession
  43114. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43115. */
  43116. export class WebXRCamera extends FreeCamera {
  43117. private _xrSessionManager;
  43118. private _firstFrame;
  43119. private _referenceQuaternion;
  43120. private _referencedPosition;
  43121. private _xrInvPositionCache;
  43122. private _xrInvQuaternionCache;
  43123. /**
  43124. * Should position compensation execute on first frame.
  43125. * This is used when copying the position from a native (non XR) camera
  43126. */
  43127. compensateOnFirstFrame: boolean;
  43128. /**
  43129. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43130. * @param name the name of the camera
  43131. * @param scene the scene to add the camera to
  43132. * @param _xrSessionManager a constructed xr session manager
  43133. */
  43134. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43135. /**
  43136. * Return the user's height, unrelated to the current ground.
  43137. * This will be the y position of this camera, when ground level is 0.
  43138. */
  43139. get realWorldHeight(): number;
  43140. /** @hidden */
  43141. _updateForDualEyeDebugging(): void;
  43142. /**
  43143. * Sets this camera's transformation based on a non-vr camera
  43144. * @param otherCamera the non-vr camera to copy the transformation from
  43145. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43146. */
  43147. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43148. /**
  43149. * Gets the current instance class name ("WebXRCamera").
  43150. * @returns the class name
  43151. */
  43152. getClassName(): string;
  43153. private _updateFromXRSession;
  43154. private _updateNumberOfRigCameras;
  43155. private _updateReferenceSpace;
  43156. private _updateReferenceSpaceOffset;
  43157. }
  43158. }
  43159. declare module BABYLON {
  43160. /**
  43161. * Defining the interface required for a (webxr) feature
  43162. */
  43163. export interface IWebXRFeature extends IDisposable {
  43164. /**
  43165. * Is this feature attached
  43166. */
  43167. attached: boolean;
  43168. /**
  43169. * Should auto-attach be disabled?
  43170. */
  43171. disableAutoAttach: boolean;
  43172. /**
  43173. * Attach the feature to the session
  43174. * Will usually be called by the features manager
  43175. *
  43176. * @param force should attachment be forced (even when already attached)
  43177. * @returns true if successful.
  43178. */
  43179. attach(force?: boolean): boolean;
  43180. /**
  43181. * Detach the feature from the session
  43182. * Will usually be called by the features manager
  43183. *
  43184. * @returns true if successful.
  43185. */
  43186. detach(): boolean;
  43187. }
  43188. /**
  43189. * A list of the currently available features without referencing them
  43190. */
  43191. export class WebXRFeatureName {
  43192. /**
  43193. * The name of the anchor system feature
  43194. */
  43195. static ANCHOR_SYSTEM: string;
  43196. /**
  43197. * The name of the background remover feature
  43198. */
  43199. static BACKGROUND_REMOVER: string;
  43200. /**
  43201. * The name of the hit test feature
  43202. */
  43203. static HIT_TEST: string;
  43204. /**
  43205. * physics impostors for xr controllers feature
  43206. */
  43207. static PHYSICS_CONTROLLERS: string;
  43208. /**
  43209. * The name of the plane detection feature
  43210. */
  43211. static PLANE_DETECTION: string;
  43212. /**
  43213. * The name of the pointer selection feature
  43214. */
  43215. static POINTER_SELECTION: string;
  43216. /**
  43217. * The name of the teleportation feature
  43218. */
  43219. static TELEPORTATION: string;
  43220. }
  43221. /**
  43222. * Defining the constructor of a feature. Used to register the modules.
  43223. */
  43224. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43225. /**
  43226. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43227. * It is mainly used in AR sessions.
  43228. *
  43229. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43230. */
  43231. export class WebXRFeaturesManager implements IDisposable {
  43232. private _xrSessionManager;
  43233. private static readonly _AvailableFeatures;
  43234. private _features;
  43235. /**
  43236. * constructs a new features manages.
  43237. *
  43238. * @param _xrSessionManager an instance of WebXRSessionManager
  43239. */
  43240. constructor(_xrSessionManager: WebXRSessionManager);
  43241. /**
  43242. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43243. * Mainly used internally.
  43244. *
  43245. * @param featureName the name of the feature to register
  43246. * @param constructorFunction the function used to construct the module
  43247. * @param version the (babylon) version of the module
  43248. * @param stable is that a stable version of this module
  43249. */
  43250. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43251. /**
  43252. * Returns a constructor of a specific feature.
  43253. *
  43254. * @param featureName the name of the feature to construct
  43255. * @param version the version of the feature to load
  43256. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43257. * @param options optional options provided to the module.
  43258. * @returns a function that, when called, will return a new instance of this feature
  43259. */
  43260. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43261. /**
  43262. * Can be used to return the list of features currently registered
  43263. *
  43264. * @returns an Array of available features
  43265. */
  43266. static GetAvailableFeatures(): string[];
  43267. /**
  43268. * Gets the versions available for a specific feature
  43269. * @param featureName the name of the feature
  43270. * @returns an array with the available versions
  43271. */
  43272. static GetAvailableVersions(featureName: string): string[];
  43273. /**
  43274. * Return the latest unstable version of this feature
  43275. * @param featureName the name of the feature to search
  43276. * @returns the version number. if not found will return -1
  43277. */
  43278. static GetLatestVersionOfFeature(featureName: string): number;
  43279. /**
  43280. * Return the latest stable version of this feature
  43281. * @param featureName the name of the feature to search
  43282. * @returns the version number. if not found will return -1
  43283. */
  43284. static GetStableVersionOfFeature(featureName: string): number;
  43285. /**
  43286. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43287. * Can be used during a session to start a feature
  43288. * @param featureName the name of feature to attach
  43289. */
  43290. attachFeature(featureName: string): void;
  43291. /**
  43292. * Can be used inside a session or when the session ends to detach a specific feature
  43293. * @param featureName the name of the feature to detach
  43294. */
  43295. detachFeature(featureName: string): void;
  43296. /**
  43297. * Used to disable an already-enabled feature
  43298. * The feature will be disposed and will be recreated once enabled.
  43299. * @param featureName the feature to disable
  43300. * @returns true if disable was successful
  43301. */
  43302. disableFeature(featureName: string | {
  43303. Name: string;
  43304. }): boolean;
  43305. /**
  43306. * dispose this features manager
  43307. */
  43308. dispose(): void;
  43309. /**
  43310. * 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.
  43311. * 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.
  43312. *
  43313. * @param featureName the name of the feature to load or the class of the feature
  43314. * @param version optional version to load. if not provided the latest version will be enabled
  43315. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43316. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43317. * @returns a new constructed feature or throws an error if feature not found.
  43318. */
  43319. enableFeature(featureName: string | {
  43320. Name: string;
  43321. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43322. /**
  43323. * get the implementation of an enabled feature.
  43324. * @param featureName the name of the feature to load
  43325. * @returns the feature class, if found
  43326. */
  43327. getEnabledFeature(featureName: string): IWebXRFeature;
  43328. /**
  43329. * Get the list of enabled features
  43330. * @returns an array of enabled features
  43331. */
  43332. getEnabledFeatures(): string[];
  43333. }
  43334. }
  43335. declare module BABYLON {
  43336. /**
  43337. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43338. * @see https://doc.babylonjs.com/how_to/webxr
  43339. */
  43340. export class WebXRExperienceHelper implements IDisposable {
  43341. private scene;
  43342. private _nonVRCamera;
  43343. private _originalSceneAutoClear;
  43344. private _supported;
  43345. /**
  43346. * Camera used to render xr content
  43347. */
  43348. camera: WebXRCamera;
  43349. /** A features manager for this xr session */
  43350. featuresManager: WebXRFeaturesManager;
  43351. /**
  43352. * Observers registered here will be triggered after the camera's initial transformation is set
  43353. * This can be used to set a different ground level or an extra rotation.
  43354. *
  43355. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43356. * to the position set after this observable is done executing.
  43357. */
  43358. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43359. /**
  43360. * Fires when the state of the experience helper has changed
  43361. */
  43362. onStateChangedObservable: Observable<WebXRState>;
  43363. /** Session manager used to keep track of xr session */
  43364. sessionManager: WebXRSessionManager;
  43365. /**
  43366. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43367. */
  43368. state: WebXRState;
  43369. /**
  43370. * Creates a WebXRExperienceHelper
  43371. * @param scene The scene the helper should be created in
  43372. */
  43373. private constructor();
  43374. /**
  43375. * Creates the experience helper
  43376. * @param scene the scene to attach the experience helper to
  43377. * @returns a promise for the experience helper
  43378. */
  43379. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43380. /**
  43381. * Disposes of the experience helper
  43382. */
  43383. dispose(): void;
  43384. /**
  43385. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43386. * @param sessionMode options for the XR session
  43387. * @param referenceSpaceType frame of reference of the XR session
  43388. * @param renderTarget the output canvas that will be used to enter XR mode
  43389. * @returns promise that resolves after xr mode has entered
  43390. */
  43391. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43392. /**
  43393. * Exits XR mode and returns the scene to its original state
  43394. * @returns promise that resolves after xr mode has exited
  43395. */
  43396. exitXRAsync(): Promise<void>;
  43397. private _nonXRToXRCamera;
  43398. private _setState;
  43399. }
  43400. }
  43401. declare module BABYLON {
  43402. /**
  43403. * X-Y values for axes in WebXR
  43404. */
  43405. export interface IWebXRMotionControllerAxesValue {
  43406. /**
  43407. * The value of the x axis
  43408. */
  43409. x: number;
  43410. /**
  43411. * The value of the y-axis
  43412. */
  43413. y: number;
  43414. }
  43415. /**
  43416. * changed / previous values for the values of this component
  43417. */
  43418. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43419. /**
  43420. * current (this frame) value
  43421. */
  43422. current: T;
  43423. /**
  43424. * previous (last change) value
  43425. */
  43426. previous: T;
  43427. }
  43428. /**
  43429. * Represents changes in the component between current frame and last values recorded
  43430. */
  43431. export interface IWebXRMotionControllerComponentChanges {
  43432. /**
  43433. * will be populated with previous and current values if axes changed
  43434. */
  43435. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43436. /**
  43437. * will be populated with previous and current values if pressed changed
  43438. */
  43439. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43440. /**
  43441. * will be populated with previous and current values if touched changed
  43442. */
  43443. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43444. /**
  43445. * will be populated with previous and current values if value changed
  43446. */
  43447. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43448. }
  43449. /**
  43450. * This class represents a single component (for example button or thumbstick) of a motion controller
  43451. */
  43452. export class WebXRControllerComponent implements IDisposable {
  43453. /**
  43454. * the id of this component
  43455. */
  43456. id: string;
  43457. /**
  43458. * the type of the component
  43459. */
  43460. type: MotionControllerComponentType;
  43461. private _buttonIndex;
  43462. private _axesIndices;
  43463. private _axes;
  43464. private _changes;
  43465. private _currentValue;
  43466. private _hasChanges;
  43467. private _pressed;
  43468. private _touched;
  43469. /**
  43470. * button component type
  43471. */
  43472. static BUTTON_TYPE: MotionControllerComponentType;
  43473. /**
  43474. * squeeze component type
  43475. */
  43476. static SQUEEZE_TYPE: MotionControllerComponentType;
  43477. /**
  43478. * Thumbstick component type
  43479. */
  43480. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43481. /**
  43482. * Touchpad component type
  43483. */
  43484. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43485. /**
  43486. * trigger component type
  43487. */
  43488. static TRIGGER_TYPE: MotionControllerComponentType;
  43489. /**
  43490. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43491. * the axes data changes
  43492. */
  43493. onAxisValueChangedObservable: Observable<{
  43494. x: number;
  43495. y: number;
  43496. }>;
  43497. /**
  43498. * Observers registered here will be triggered when the state of a button changes
  43499. * State change is either pressed / touched / value
  43500. */
  43501. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43502. /**
  43503. * Creates a new component for a motion controller.
  43504. * It is created by the motion controller itself
  43505. *
  43506. * @param id the id of this component
  43507. * @param type the type of the component
  43508. * @param _buttonIndex index in the buttons array of the gamepad
  43509. * @param _axesIndices indices of the values in the axes array of the gamepad
  43510. */
  43511. constructor(
  43512. /**
  43513. * the id of this component
  43514. */
  43515. id: string,
  43516. /**
  43517. * the type of the component
  43518. */
  43519. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43520. /**
  43521. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43522. */
  43523. get axes(): IWebXRMotionControllerAxesValue;
  43524. /**
  43525. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43526. */
  43527. get changes(): IWebXRMotionControllerComponentChanges;
  43528. /**
  43529. * Return whether or not the component changed the last frame
  43530. */
  43531. get hasChanges(): boolean;
  43532. /**
  43533. * is the button currently pressed
  43534. */
  43535. get pressed(): boolean;
  43536. /**
  43537. * is the button currently touched
  43538. */
  43539. get touched(): boolean;
  43540. /**
  43541. * Get the current value of this component
  43542. */
  43543. get value(): number;
  43544. /**
  43545. * Dispose this component
  43546. */
  43547. dispose(): void;
  43548. /**
  43549. * Are there axes correlating to this component
  43550. * @return true is axes data is available
  43551. */
  43552. isAxes(): boolean;
  43553. /**
  43554. * Is this component a button (hence - pressable)
  43555. * @returns true if can be pressed
  43556. */
  43557. isButton(): boolean;
  43558. /**
  43559. * update this component using the gamepad object it is in. Called on every frame
  43560. * @param nativeController the native gamepad controller object
  43561. */
  43562. update(nativeController: IMinimalMotionControllerObject): void;
  43563. }
  43564. }
  43565. declare module BABYLON {
  43566. /**
  43567. * Class used to represent data loading progression
  43568. */
  43569. export class SceneLoaderProgressEvent {
  43570. /** defines if data length to load can be evaluated */
  43571. readonly lengthComputable: boolean;
  43572. /** defines the loaded data length */
  43573. readonly loaded: number;
  43574. /** defines the data length to load */
  43575. readonly total: number;
  43576. /**
  43577. * Create a new progress event
  43578. * @param lengthComputable defines if data length to load can be evaluated
  43579. * @param loaded defines the loaded data length
  43580. * @param total defines the data length to load
  43581. */
  43582. constructor(
  43583. /** defines if data length to load can be evaluated */
  43584. lengthComputable: boolean,
  43585. /** defines the loaded data length */
  43586. loaded: number,
  43587. /** defines the data length to load */
  43588. total: number);
  43589. /**
  43590. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43591. * @param event defines the source event
  43592. * @returns a new SceneLoaderProgressEvent
  43593. */
  43594. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43595. }
  43596. /**
  43597. * Interface used by SceneLoader plugins to define supported file extensions
  43598. */
  43599. export interface ISceneLoaderPluginExtensions {
  43600. /**
  43601. * Defines the list of supported extensions
  43602. */
  43603. [extension: string]: {
  43604. isBinary: boolean;
  43605. };
  43606. }
  43607. /**
  43608. * Interface used by SceneLoader plugin factory
  43609. */
  43610. export interface ISceneLoaderPluginFactory {
  43611. /**
  43612. * Defines the name of the factory
  43613. */
  43614. name: string;
  43615. /**
  43616. * Function called to create a new plugin
  43617. * @return the new plugin
  43618. */
  43619. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43620. /**
  43621. * The callback that returns true if the data can be directly loaded.
  43622. * @param data string containing the file data
  43623. * @returns if the data can be loaded directly
  43624. */
  43625. canDirectLoad?(data: string): boolean;
  43626. }
  43627. /**
  43628. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43629. */
  43630. export interface ISceneLoaderPluginBase {
  43631. /**
  43632. * The friendly name of this plugin.
  43633. */
  43634. name: string;
  43635. /**
  43636. * The file extensions supported by this plugin.
  43637. */
  43638. extensions: string | ISceneLoaderPluginExtensions;
  43639. /**
  43640. * The callback called when loading from a url.
  43641. * @param scene scene loading this url
  43642. * @param url url to load
  43643. * @param onSuccess callback called when the file successfully loads
  43644. * @param onProgress callback called while file is loading (if the server supports this mode)
  43645. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43646. * @param onError callback called when the file fails to load
  43647. * @returns a file request object
  43648. */
  43649. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43650. /**
  43651. * The callback called when loading from a file object.
  43652. * @param scene scene loading this file
  43653. * @param file defines the file to load
  43654. * @param onSuccess defines the callback to call when data is loaded
  43655. * @param onProgress defines the callback to call during loading process
  43656. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43657. * @param onError defines the callback to call when an error occurs
  43658. * @returns a file request object
  43659. */
  43660. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43661. /**
  43662. * The callback that returns true if the data can be directly loaded.
  43663. * @param data string containing the file data
  43664. * @returns if the data can be loaded directly
  43665. */
  43666. canDirectLoad?(data: string): boolean;
  43667. /**
  43668. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43669. * @param scene scene loading this data
  43670. * @param data string containing the data
  43671. * @returns data to pass to the plugin
  43672. */
  43673. directLoad?(scene: Scene, data: string): any;
  43674. /**
  43675. * The callback that allows custom handling of the root url based on the response url.
  43676. * @param rootUrl the original root url
  43677. * @param responseURL the response url if available
  43678. * @returns the new root url
  43679. */
  43680. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43681. }
  43682. /**
  43683. * Interface used to define a SceneLoader plugin
  43684. */
  43685. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43686. /**
  43687. * Import meshes into a scene.
  43688. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43689. * @param scene The scene to import into
  43690. * @param data The data to import
  43691. * @param rootUrl The root url for scene and resources
  43692. * @param meshes The meshes array to import into
  43693. * @param particleSystems The particle systems array to import into
  43694. * @param skeletons The skeletons array to import into
  43695. * @param onError The callback when import fails
  43696. * @returns True if successful or false otherwise
  43697. */
  43698. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43699. /**
  43700. * Load into a scene.
  43701. * @param scene The scene to load into
  43702. * @param data The data to import
  43703. * @param rootUrl The root url for scene and resources
  43704. * @param onError The callback when import fails
  43705. * @returns True if successful or false otherwise
  43706. */
  43707. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43708. /**
  43709. * Load into an asset container.
  43710. * @param scene The scene to load into
  43711. * @param data The data to import
  43712. * @param rootUrl The root url for scene and resources
  43713. * @param onError The callback when import fails
  43714. * @returns The loaded asset container
  43715. */
  43716. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43717. }
  43718. /**
  43719. * Interface used to define an async SceneLoader plugin
  43720. */
  43721. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43722. /**
  43723. * Import meshes into a scene.
  43724. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43725. * @param scene The scene to import into
  43726. * @param data The data to import
  43727. * @param rootUrl The root url for scene and resources
  43728. * @param onProgress The callback when the load progresses
  43729. * @param fileName Defines the name of the file to load
  43730. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43731. */
  43732. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43733. meshes: AbstractMesh[];
  43734. particleSystems: IParticleSystem[];
  43735. skeletons: Skeleton[];
  43736. animationGroups: AnimationGroup[];
  43737. }>;
  43738. /**
  43739. * Load into a scene.
  43740. * @param scene The scene to load into
  43741. * @param data The data to import
  43742. * @param rootUrl The root url for scene and resources
  43743. * @param onProgress The callback when the load progresses
  43744. * @param fileName Defines the name of the file to load
  43745. * @returns Nothing
  43746. */
  43747. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43748. /**
  43749. * Load into an asset container.
  43750. * @param scene The scene to load into
  43751. * @param data The data to import
  43752. * @param rootUrl The root url for scene and resources
  43753. * @param onProgress The callback when the load progresses
  43754. * @param fileName Defines the name of the file to load
  43755. * @returns The loaded asset container
  43756. */
  43757. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43758. }
  43759. /**
  43760. * Mode that determines how to handle old animation groups before loading new ones.
  43761. */
  43762. export enum SceneLoaderAnimationGroupLoadingMode {
  43763. /**
  43764. * Reset all old animations to initial state then dispose them.
  43765. */
  43766. Clean = 0,
  43767. /**
  43768. * Stop all old animations.
  43769. */
  43770. Stop = 1,
  43771. /**
  43772. * Restart old animations from first frame.
  43773. */
  43774. Sync = 2,
  43775. /**
  43776. * Old animations remains untouched.
  43777. */
  43778. NoSync = 3
  43779. }
  43780. /**
  43781. * Class used to load scene from various file formats using registered plugins
  43782. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43783. */
  43784. export class SceneLoader {
  43785. /**
  43786. * No logging while loading
  43787. */
  43788. static readonly NO_LOGGING: number;
  43789. /**
  43790. * Minimal logging while loading
  43791. */
  43792. static readonly MINIMAL_LOGGING: number;
  43793. /**
  43794. * Summary logging while loading
  43795. */
  43796. static readonly SUMMARY_LOGGING: number;
  43797. /**
  43798. * Detailled logging while loading
  43799. */
  43800. static readonly DETAILED_LOGGING: number;
  43801. /**
  43802. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43803. */
  43804. static get ForceFullSceneLoadingForIncremental(): boolean;
  43805. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43806. /**
  43807. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43808. */
  43809. static get ShowLoadingScreen(): boolean;
  43810. static set ShowLoadingScreen(value: boolean);
  43811. /**
  43812. * Defines the current logging level (while loading the scene)
  43813. * @ignorenaming
  43814. */
  43815. static get loggingLevel(): number;
  43816. static set loggingLevel(value: number);
  43817. /**
  43818. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43819. */
  43820. static get CleanBoneMatrixWeights(): boolean;
  43821. static set CleanBoneMatrixWeights(value: boolean);
  43822. /**
  43823. * Event raised when a plugin is used to load a scene
  43824. */
  43825. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43826. private static _registeredPlugins;
  43827. private static _getDefaultPlugin;
  43828. private static _getPluginForExtension;
  43829. private static _getPluginForDirectLoad;
  43830. private static _getPluginForFilename;
  43831. private static _getDirectLoad;
  43832. private static _loadData;
  43833. private static _getFileInfo;
  43834. /**
  43835. * Gets a plugin that can load the given extension
  43836. * @param extension defines the extension to load
  43837. * @returns a plugin or null if none works
  43838. */
  43839. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43840. /**
  43841. * Gets a boolean indicating that the given extension can be loaded
  43842. * @param extension defines the extension to load
  43843. * @returns true if the extension is supported
  43844. */
  43845. static IsPluginForExtensionAvailable(extension: string): boolean;
  43846. /**
  43847. * Adds a new plugin to the list of registered plugins
  43848. * @param plugin defines the plugin to add
  43849. */
  43850. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43851. /**
  43852. * Import meshes into a scene
  43853. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43854. * @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)
  43855. * @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)
  43856. * @param scene the instance of BABYLON.Scene to append to
  43857. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43858. * @param onProgress a callback with a progress event for each file being loaded
  43859. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43860. * @param pluginExtension the extension used to determine the plugin
  43861. * @returns The loaded plugin
  43862. */
  43863. 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>;
  43864. /**
  43865. * Import meshes into a scene
  43866. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43867. * @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)
  43868. * @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)
  43869. * @param scene the instance of BABYLON.Scene to append to
  43870. * @param onProgress a callback with a progress event for each file being loaded
  43871. * @param pluginExtension the extension used to determine the plugin
  43872. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43873. */
  43874. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43875. meshes: AbstractMesh[];
  43876. particleSystems: IParticleSystem[];
  43877. skeletons: Skeleton[];
  43878. animationGroups: AnimationGroup[];
  43879. }>;
  43880. /**
  43881. * Load a scene
  43882. * @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)
  43883. * @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)
  43884. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43885. * @param onSuccess a callback with the scene when import succeeds
  43886. * @param onProgress a callback with a progress event for each file being loaded
  43887. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43888. * @param pluginExtension the extension used to determine the plugin
  43889. * @returns The loaded plugin
  43890. */
  43891. 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>;
  43892. /**
  43893. * Load a scene
  43894. * @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)
  43895. * @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)
  43896. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43897. * @param onProgress a callback with a progress event for each file being loaded
  43898. * @param pluginExtension the extension used to determine the plugin
  43899. * @returns The loaded scene
  43900. */
  43901. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43902. /**
  43903. * Append a scene
  43904. * @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)
  43905. * @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)
  43906. * @param scene is the instance of BABYLON.Scene to append to
  43907. * @param onSuccess a callback with the scene when import succeeds
  43908. * @param onProgress a callback with a progress event for each file being loaded
  43909. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43910. * @param pluginExtension the extension used to determine the plugin
  43911. * @returns The loaded plugin
  43912. */
  43913. 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>;
  43914. /**
  43915. * Append a scene
  43916. * @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)
  43917. * @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)
  43918. * @param scene is the instance of BABYLON.Scene to append to
  43919. * @param onProgress a callback with a progress event for each file being loaded
  43920. * @param pluginExtension the extension used to determine the plugin
  43921. * @returns The given scene
  43922. */
  43923. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43924. /**
  43925. * Load a scene into an asset container
  43926. * @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)
  43927. * @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)
  43928. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43929. * @param onSuccess a callback with the scene when import succeeds
  43930. * @param onProgress a callback with a progress event for each file being loaded
  43931. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43932. * @param pluginExtension the extension used to determine the plugin
  43933. * @returns The loaded plugin
  43934. */
  43935. 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>;
  43936. /**
  43937. * Load a scene into an asset container
  43938. * @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)
  43939. * @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)
  43940. * @param scene is the instance of Scene to append to
  43941. * @param onProgress a callback with a progress event for each file being loaded
  43942. * @param pluginExtension the extension used to determine the plugin
  43943. * @returns The loaded asset container
  43944. */
  43945. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43946. /**
  43947. * Import animations from a file into a scene
  43948. * @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)
  43949. * @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)
  43950. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43951. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43952. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43953. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43954. * @param onSuccess a callback with the scene when import succeeds
  43955. * @param onProgress a callback with a progress event for each file being loaded
  43956. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43957. */
  43958. 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;
  43959. /**
  43960. * Import animations from a file into a scene
  43961. * @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)
  43962. * @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)
  43963. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43964. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43965. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43966. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43967. * @param onSuccess a callback with the scene when import succeeds
  43968. * @param onProgress a callback with a progress event for each file being loaded
  43969. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43970. * @returns the updated scene with imported animations
  43971. */
  43972. 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>;
  43973. }
  43974. }
  43975. declare module BABYLON {
  43976. /**
  43977. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43978. */
  43979. export type MotionControllerHandness = "none" | "left" | "right";
  43980. /**
  43981. * The type of components available in motion controllers.
  43982. * This is not the name of the component.
  43983. */
  43984. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43985. /**
  43986. * The state of a controller component
  43987. */
  43988. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43989. /**
  43990. * The schema of motion controller layout.
  43991. * No object will be initialized using this interface
  43992. * This is used just to define the profile.
  43993. */
  43994. export interface IMotionControllerLayout {
  43995. /**
  43996. * Path to load the assets. Usually relative to the base path
  43997. */
  43998. assetPath: string;
  43999. /**
  44000. * Available components (unsorted)
  44001. */
  44002. components: {
  44003. /**
  44004. * A map of component Ids
  44005. */
  44006. [componentId: string]: {
  44007. /**
  44008. * The type of input the component outputs
  44009. */
  44010. type: MotionControllerComponentType;
  44011. /**
  44012. * The indices of this component in the gamepad object
  44013. */
  44014. gamepadIndices: {
  44015. /**
  44016. * Index of button
  44017. */
  44018. button?: number;
  44019. /**
  44020. * If available, index of x-axis
  44021. */
  44022. xAxis?: number;
  44023. /**
  44024. * If available, index of y-axis
  44025. */
  44026. yAxis?: number;
  44027. };
  44028. /**
  44029. * The mesh's root node name
  44030. */
  44031. rootNodeName: string;
  44032. /**
  44033. * Animation definitions for this model
  44034. */
  44035. visualResponses: {
  44036. [stateKey: string]: {
  44037. /**
  44038. * What property will be animated
  44039. */
  44040. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44041. /**
  44042. * What states influence this visual response
  44043. */
  44044. states: MotionControllerComponentStateType[];
  44045. /**
  44046. * Type of animation - movement or visibility
  44047. */
  44048. valueNodeProperty: "transform" | "visibility";
  44049. /**
  44050. * Base node name to move. Its position will be calculated according to the min and max nodes
  44051. */
  44052. valueNodeName?: string;
  44053. /**
  44054. * Minimum movement node
  44055. */
  44056. minNodeName?: string;
  44057. /**
  44058. * Max movement node
  44059. */
  44060. maxNodeName?: string;
  44061. };
  44062. };
  44063. /**
  44064. * If touch enabled, what is the name of node to display user feedback
  44065. */
  44066. touchPointNodeName?: string;
  44067. };
  44068. };
  44069. /**
  44070. * Is it xr standard mapping or not
  44071. */
  44072. gamepadMapping: "" | "xr-standard";
  44073. /**
  44074. * Base root node of this entire model
  44075. */
  44076. rootNodeName: string;
  44077. /**
  44078. * Defines the main button component id
  44079. */
  44080. selectComponentId: string;
  44081. }
  44082. /**
  44083. * A definition for the layout map in the input profile
  44084. */
  44085. export interface IMotionControllerLayoutMap {
  44086. /**
  44087. * Layouts with handness type as a key
  44088. */
  44089. [handness: string]: IMotionControllerLayout;
  44090. }
  44091. /**
  44092. * The XR Input profile schema
  44093. * Profiles can be found here:
  44094. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44095. */
  44096. export interface IMotionControllerProfile {
  44097. /**
  44098. * fallback profiles for this profileId
  44099. */
  44100. fallbackProfileIds: string[];
  44101. /**
  44102. * The layout map, with handness as key
  44103. */
  44104. layouts: IMotionControllerLayoutMap;
  44105. /**
  44106. * The id of this profile
  44107. * correlates to the profile(s) in the xrInput.profiles array
  44108. */
  44109. profileId: string;
  44110. }
  44111. /**
  44112. * A helper-interface for the 3 meshes needed for controller button animation
  44113. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44114. */
  44115. export interface IMotionControllerButtonMeshMap {
  44116. /**
  44117. * the mesh that defines the pressed value mesh position.
  44118. * This is used to find the max-position of this button
  44119. */
  44120. pressedMesh: AbstractMesh;
  44121. /**
  44122. * the mesh that defines the unpressed value mesh position.
  44123. * This is used to find the min (or initial) position of this button
  44124. */
  44125. unpressedMesh: AbstractMesh;
  44126. /**
  44127. * The mesh that will be changed when value changes
  44128. */
  44129. valueMesh: AbstractMesh;
  44130. }
  44131. /**
  44132. * A helper-interface for the 3 meshes needed for controller axis animation.
  44133. * This will be expanded when touchpad animations are fully supported
  44134. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44135. */
  44136. export interface IMotionControllerMeshMap {
  44137. /**
  44138. * the mesh that defines the maximum value mesh position.
  44139. */
  44140. maxMesh?: AbstractMesh;
  44141. /**
  44142. * the mesh that defines the minimum value mesh position.
  44143. */
  44144. minMesh?: AbstractMesh;
  44145. /**
  44146. * The mesh that will be changed when axis value changes
  44147. */
  44148. valueMesh: AbstractMesh;
  44149. }
  44150. /**
  44151. * The elements needed for change-detection of the gamepad objects in motion controllers
  44152. */
  44153. export interface IMinimalMotionControllerObject {
  44154. /**
  44155. * Available axes of this controller
  44156. */
  44157. axes: number[];
  44158. /**
  44159. * An array of available buttons
  44160. */
  44161. buttons: Array<{
  44162. /**
  44163. * Value of the button/trigger
  44164. */
  44165. value: number;
  44166. /**
  44167. * If the button/trigger is currently touched
  44168. */
  44169. touched: boolean;
  44170. /**
  44171. * If the button/trigger is currently pressed
  44172. */
  44173. pressed: boolean;
  44174. }>;
  44175. }
  44176. /**
  44177. * An Abstract Motion controller
  44178. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44179. * Each component has an observable to check for changes in value and state
  44180. */
  44181. export abstract class WebXRAbstractMotionController implements IDisposable {
  44182. protected scene: Scene;
  44183. protected layout: IMotionControllerLayout;
  44184. /**
  44185. * The gamepad object correlating to this controller
  44186. */
  44187. gamepadObject: IMinimalMotionControllerObject;
  44188. /**
  44189. * handness (left/right/none) of this controller
  44190. */
  44191. handness: MotionControllerHandness;
  44192. private _initComponent;
  44193. private _modelReady;
  44194. /**
  44195. * A map of components (WebXRControllerComponent) in this motion controller
  44196. * Components have a ComponentType and can also have both button and axis definitions
  44197. */
  44198. readonly components: {
  44199. [id: string]: WebXRControllerComponent;
  44200. };
  44201. /**
  44202. * Disable the model's animation. Can be set at any time.
  44203. */
  44204. disableAnimation: boolean;
  44205. /**
  44206. * Observers registered here will be triggered when the model of this controller is done loading
  44207. */
  44208. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44209. /**
  44210. * The profile id of this motion controller
  44211. */
  44212. abstract profileId: string;
  44213. /**
  44214. * The root mesh of the model. It is null if the model was not yet initialized
  44215. */
  44216. rootMesh: Nullable<AbstractMesh>;
  44217. /**
  44218. * constructs a new abstract motion controller
  44219. * @param scene the scene to which the model of the controller will be added
  44220. * @param layout The profile layout to load
  44221. * @param gamepadObject The gamepad object correlating to this controller
  44222. * @param handness handness (left/right/none) of this controller
  44223. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44224. */
  44225. constructor(scene: Scene, layout: IMotionControllerLayout,
  44226. /**
  44227. * The gamepad object correlating to this controller
  44228. */
  44229. gamepadObject: IMinimalMotionControllerObject,
  44230. /**
  44231. * handness (left/right/none) of this controller
  44232. */
  44233. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44234. /**
  44235. * Dispose this controller, the model mesh and all its components
  44236. */
  44237. dispose(): void;
  44238. /**
  44239. * Returns all components of specific type
  44240. * @param type the type to search for
  44241. * @return an array of components with this type
  44242. */
  44243. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44244. /**
  44245. * get a component based an its component id as defined in layout.components
  44246. * @param id the id of the component
  44247. * @returns the component correlates to the id or undefined if not found
  44248. */
  44249. getComponent(id: string): WebXRControllerComponent;
  44250. /**
  44251. * Get the list of components available in this motion controller
  44252. * @returns an array of strings correlating to available components
  44253. */
  44254. getComponentIds(): string[];
  44255. /**
  44256. * Get the first component of specific type
  44257. * @param type type of component to find
  44258. * @return a controller component or null if not found
  44259. */
  44260. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44261. /**
  44262. * Get the main (Select) component of this controller as defined in the layout
  44263. * @returns the main component of this controller
  44264. */
  44265. getMainComponent(): WebXRControllerComponent;
  44266. /**
  44267. * Loads the model correlating to this controller
  44268. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44269. * @returns A promise fulfilled with the result of the model loading
  44270. */
  44271. loadModel(): Promise<boolean>;
  44272. /**
  44273. * Update this model using the current XRFrame
  44274. * @param xrFrame the current xr frame to use and update the model
  44275. */
  44276. updateFromXRFrame(xrFrame: XRFrame): void;
  44277. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44278. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44279. /**
  44280. * Moves the axis on the controller mesh based on its current state
  44281. * @param axis the index of the axis
  44282. * @param axisValue the value of the axis which determines the meshes new position
  44283. * @hidden
  44284. */
  44285. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44286. /**
  44287. * Update the model itself with the current frame data
  44288. * @param xrFrame the frame to use for updating the model mesh
  44289. */
  44290. protected updateModel(xrFrame: XRFrame): void;
  44291. /**
  44292. * Get the filename and path for this controller's model
  44293. * @returns a map of filename and path
  44294. */
  44295. protected abstract _getFilenameAndPath(): {
  44296. filename: string;
  44297. path: string;
  44298. };
  44299. /**
  44300. * This function is called before the mesh is loaded. It checks for loading constraints.
  44301. * For example, this function can check if the GLB loader is available
  44302. * If this function returns false, the generic controller will be loaded instead
  44303. * @returns Is the client ready to load the mesh
  44304. */
  44305. protected abstract _getModelLoadingConstraints(): boolean;
  44306. /**
  44307. * This function will be called after the model was successfully loaded and can be used
  44308. * for mesh transformations before it is available for the user
  44309. * @param meshes the loaded meshes
  44310. */
  44311. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44312. /**
  44313. * Set the root mesh for this controller. Important for the WebXR controller class
  44314. * @param meshes the loaded meshes
  44315. */
  44316. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44317. /**
  44318. * A function executed each frame that updates the mesh (if needed)
  44319. * @param xrFrame the current xrFrame
  44320. */
  44321. protected abstract _updateModel(xrFrame: XRFrame): void;
  44322. private _getGenericFilenameAndPath;
  44323. private _getGenericParentMesh;
  44324. }
  44325. }
  44326. declare module BABYLON {
  44327. /**
  44328. * A generic trigger-only motion controller for WebXR
  44329. */
  44330. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44331. /**
  44332. * Static version of the profile id of this controller
  44333. */
  44334. static ProfileId: string;
  44335. profileId: string;
  44336. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44337. protected _getFilenameAndPath(): {
  44338. filename: string;
  44339. path: string;
  44340. };
  44341. protected _getModelLoadingConstraints(): boolean;
  44342. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44343. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44344. protected _updateModel(): void;
  44345. }
  44346. }
  44347. declare module BABYLON {
  44348. /**
  44349. * Class containing static functions to help procedurally build meshes
  44350. */
  44351. export class SphereBuilder {
  44352. /**
  44353. * Creates a sphere mesh
  44354. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44355. * * 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`)
  44356. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44357. * * 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
  44358. * * 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)
  44359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44360. * * 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
  44361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44362. * @param name defines the name of the mesh
  44363. * @param options defines the options used to create the mesh
  44364. * @param scene defines the hosting scene
  44365. * @returns the sphere mesh
  44366. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44367. */
  44368. static CreateSphere(name: string, options: {
  44369. segments?: number;
  44370. diameter?: number;
  44371. diameterX?: number;
  44372. diameterY?: number;
  44373. diameterZ?: number;
  44374. arc?: number;
  44375. slice?: number;
  44376. sideOrientation?: number;
  44377. frontUVs?: Vector4;
  44378. backUVs?: Vector4;
  44379. updatable?: boolean;
  44380. }, scene?: Nullable<Scene>): Mesh;
  44381. }
  44382. }
  44383. declare module BABYLON {
  44384. /**
  44385. * A profiled motion controller has its profile loaded from an online repository.
  44386. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44387. */
  44388. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44389. private _repositoryUrl;
  44390. private _buttonMeshMapping;
  44391. private _touchDots;
  44392. /**
  44393. * The profile ID of this controller. Will be populated when the controller initializes.
  44394. */
  44395. profileId: string;
  44396. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44397. dispose(): void;
  44398. protected _getFilenameAndPath(): {
  44399. filename: string;
  44400. path: string;
  44401. };
  44402. protected _getModelLoadingConstraints(): boolean;
  44403. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44404. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44405. protected _updateModel(_xrFrame: XRFrame): void;
  44406. }
  44407. }
  44408. declare module BABYLON {
  44409. /**
  44410. * A construction function type to create a new controller based on an xrInput object
  44411. */
  44412. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44413. /**
  44414. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44415. *
  44416. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44417. * it should be replaced with auto-loaded controllers.
  44418. *
  44419. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44420. */
  44421. export class WebXRMotionControllerManager {
  44422. private static _AvailableControllers;
  44423. private static _Fallbacks;
  44424. private static _ProfileLoadingPromises;
  44425. private static _ProfilesList;
  44426. /**
  44427. * The base URL of the online controller repository. Can be changed at any time.
  44428. */
  44429. static BaseRepositoryUrl: string;
  44430. /**
  44431. * Which repository gets priority - local or online
  44432. */
  44433. static PrioritizeOnlineRepository: boolean;
  44434. /**
  44435. * Use the online repository, or use only locally-defined controllers
  44436. */
  44437. static UseOnlineRepository: boolean;
  44438. /**
  44439. * Clear the cache used for profile loading and reload when requested again
  44440. */
  44441. static ClearProfilesCache(): void;
  44442. /**
  44443. * Register the default fallbacks.
  44444. * This function is called automatically when this file is imported.
  44445. */
  44446. static DefaultFallbacks(): void;
  44447. /**
  44448. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44449. * @param profileId the profile to which a fallback needs to be found
  44450. * @return an array with corresponding fallback profiles
  44451. */
  44452. static FindFallbackWithProfileId(profileId: string): string[];
  44453. /**
  44454. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44455. * The order of search:
  44456. *
  44457. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44458. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44459. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44460. * 4) return the generic trigger controller if none were found
  44461. *
  44462. * @param xrInput the xrInput to which a new controller is initialized
  44463. * @param scene the scene to which the model will be added
  44464. * @param forceProfile force a certain profile for this controller
  44465. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44466. */
  44467. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44468. /**
  44469. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44470. *
  44471. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44472. *
  44473. * @param type the profile type to register
  44474. * @param constructFunction the function to be called when loading this profile
  44475. */
  44476. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44477. /**
  44478. * Register a fallback to a specific profile.
  44479. * @param profileId the profileId that will receive the fallbacks
  44480. * @param fallbacks A list of fallback profiles
  44481. */
  44482. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44483. /**
  44484. * Will update the list of profiles available in the repository
  44485. * @return a promise that resolves to a map of profiles available online
  44486. */
  44487. static UpdateProfilesList(): Promise<{
  44488. [profile: string]: string;
  44489. }>;
  44490. private static _LoadProfileFromRepository;
  44491. private static _LoadProfilesFromAvailableControllers;
  44492. }
  44493. }
  44494. declare module BABYLON {
  44495. /**
  44496. * Configuration options for the WebXR controller creation
  44497. */
  44498. export interface IWebXRControllerOptions {
  44499. /**
  44500. * Should the controller mesh be animated when a user interacts with it
  44501. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44502. */
  44503. disableMotionControllerAnimation?: boolean;
  44504. /**
  44505. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44506. */
  44507. doNotLoadControllerMesh?: boolean;
  44508. /**
  44509. * Force a specific controller type for this controller.
  44510. * This can be used when creating your own profile or when testing different controllers
  44511. */
  44512. forceControllerProfile?: string;
  44513. }
  44514. /**
  44515. * Represents an XR controller
  44516. */
  44517. export class WebXRInputSource {
  44518. private _scene;
  44519. /** The underlying input source for the controller */
  44520. inputSource: XRInputSource;
  44521. private _options;
  44522. private _tmpQuaternion;
  44523. private _tmpVector;
  44524. private _uniqueId;
  44525. /**
  44526. * 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
  44527. */
  44528. grip?: AbstractMesh;
  44529. /**
  44530. * If available, this is the gamepad object related to this controller.
  44531. * Using this object it is possible to get click events and trackpad changes of the
  44532. * webxr controller that is currently being used.
  44533. */
  44534. motionController?: WebXRAbstractMotionController;
  44535. /**
  44536. * Event that fires when the controller is removed/disposed.
  44537. * The object provided as event data is this controller, after associated assets were disposed.
  44538. * uniqueId is still available.
  44539. */
  44540. onDisposeObservable: Observable<WebXRInputSource>;
  44541. /**
  44542. * Will be triggered when the mesh associated with the motion controller is done loading.
  44543. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44544. * A shortened version of controller -> motion controller -> on mesh loaded.
  44545. */
  44546. onMeshLoadedObservable: Observable<AbstractMesh>;
  44547. /**
  44548. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44549. */
  44550. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44551. /**
  44552. * Pointer which can be used to select objects or attach a visible laser to
  44553. */
  44554. pointer: AbstractMesh;
  44555. /**
  44556. * Creates the controller
  44557. * @see https://doc.babylonjs.com/how_to/webxr
  44558. * @param _scene the scene which the controller should be associated to
  44559. * @param inputSource the underlying input source for the controller
  44560. * @param _options options for this controller creation
  44561. */
  44562. constructor(_scene: Scene,
  44563. /** The underlying input source for the controller */
  44564. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44565. /**
  44566. * Get this controllers unique id
  44567. */
  44568. get uniqueId(): string;
  44569. /**
  44570. * Disposes of the object
  44571. */
  44572. dispose(): void;
  44573. /**
  44574. * Gets a world space ray coming from the pointer or grip
  44575. * @param result the resulting ray
  44576. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44577. */
  44578. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44579. /**
  44580. * Updates the controller pose based on the given XRFrame
  44581. * @param xrFrame xr frame to update the pose with
  44582. * @param referenceSpace reference space to use
  44583. */
  44584. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44585. }
  44586. }
  44587. declare module BABYLON {
  44588. /**
  44589. * The schema for initialization options of the XR Input class
  44590. */
  44591. export interface IWebXRInputOptions {
  44592. /**
  44593. * If set to true no model will be automatically loaded
  44594. */
  44595. doNotLoadControllerMeshes?: boolean;
  44596. /**
  44597. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44598. * If not found, the xr input profile data will be used.
  44599. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44600. */
  44601. forceInputProfile?: string;
  44602. /**
  44603. * Do not send a request to the controller repository to load the profile.
  44604. *
  44605. * Instead, use the controllers available in babylon itself.
  44606. */
  44607. disableOnlineControllerRepository?: boolean;
  44608. /**
  44609. * A custom URL for the controllers repository
  44610. */
  44611. customControllersRepositoryURL?: string;
  44612. /**
  44613. * Should the controller model's components not move according to the user input
  44614. */
  44615. disableControllerAnimation?: boolean;
  44616. }
  44617. /**
  44618. * XR input used to track XR inputs such as controllers/rays
  44619. */
  44620. export class WebXRInput implements IDisposable {
  44621. /**
  44622. * the xr session manager for this session
  44623. */
  44624. xrSessionManager: WebXRSessionManager;
  44625. /**
  44626. * the WebXR camera for this session. Mainly used for teleportation
  44627. */
  44628. xrCamera: WebXRCamera;
  44629. private readonly options;
  44630. /**
  44631. * XR controllers being tracked
  44632. */
  44633. controllers: Array<WebXRInputSource>;
  44634. private _frameObserver;
  44635. private _sessionEndedObserver;
  44636. private _sessionInitObserver;
  44637. /**
  44638. * Event when a controller has been connected/added
  44639. */
  44640. onControllerAddedObservable: Observable<WebXRInputSource>;
  44641. /**
  44642. * Event when a controller has been removed/disconnected
  44643. */
  44644. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44645. /**
  44646. * Initializes the WebXRInput
  44647. * @param xrSessionManager the xr session manager for this session
  44648. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44649. * @param options = initialization options for this xr input
  44650. */
  44651. constructor(
  44652. /**
  44653. * the xr session manager for this session
  44654. */
  44655. xrSessionManager: WebXRSessionManager,
  44656. /**
  44657. * the WebXR camera for this session. Mainly used for teleportation
  44658. */
  44659. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44660. private _onInputSourcesChange;
  44661. private _addAndRemoveControllers;
  44662. /**
  44663. * Disposes of the object
  44664. */
  44665. dispose(): void;
  44666. }
  44667. }
  44668. declare module BABYLON {
  44669. /**
  44670. * This is the base class for all WebXR features.
  44671. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44672. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44673. */
  44674. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44675. protected _xrSessionManager: WebXRSessionManager;
  44676. private _attached;
  44677. private _removeOnDetach;
  44678. /**
  44679. * Should auto-attach be disabled?
  44680. */
  44681. disableAutoAttach: boolean;
  44682. /**
  44683. * Construct a new (abstract) WebXR feature
  44684. * @param _xrSessionManager the xr session manager for this feature
  44685. */
  44686. constructor(_xrSessionManager: WebXRSessionManager);
  44687. /**
  44688. * Is this feature attached
  44689. */
  44690. get attached(): boolean;
  44691. /**
  44692. * attach this feature
  44693. *
  44694. * @param force should attachment be forced (even when already attached)
  44695. * @returns true if successful, false is failed or already attached
  44696. */
  44697. attach(force?: boolean): boolean;
  44698. /**
  44699. * detach this feature.
  44700. *
  44701. * @returns true if successful, false if failed or already detached
  44702. */
  44703. detach(): boolean;
  44704. /**
  44705. * Dispose this feature and all of the resources attached
  44706. */
  44707. dispose(): void;
  44708. /**
  44709. * This is used to register callbacks that will automatically be removed when detach is called.
  44710. * @param observable the observable to which the observer will be attached
  44711. * @param callback the callback to register
  44712. */
  44713. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44714. /**
  44715. * Code in this function will be executed on each xrFrame received from the browser.
  44716. * This function will not execute after the feature is detached.
  44717. * @param _xrFrame the current frame
  44718. */
  44719. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44720. }
  44721. }
  44722. declare module BABYLON {
  44723. /**
  44724. * Renders a layer on top of an existing scene
  44725. */
  44726. export class UtilityLayerRenderer implements IDisposable {
  44727. /** the original scene that will be rendered on top of */
  44728. originalScene: Scene;
  44729. private _pointerCaptures;
  44730. private _lastPointerEvents;
  44731. private static _DefaultUtilityLayer;
  44732. private static _DefaultKeepDepthUtilityLayer;
  44733. private _sharedGizmoLight;
  44734. private _renderCamera;
  44735. /**
  44736. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44737. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44738. * @returns the camera that is used when rendering the utility layer
  44739. */
  44740. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44741. /**
  44742. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44743. * @param cam the camera that should be used when rendering the utility layer
  44744. */
  44745. setRenderCamera(cam: Nullable<Camera>): void;
  44746. /**
  44747. * @hidden
  44748. * Light which used by gizmos to get light shading
  44749. */
  44750. _getSharedGizmoLight(): HemisphericLight;
  44751. /**
  44752. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44753. */
  44754. pickUtilitySceneFirst: boolean;
  44755. /**
  44756. * 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)
  44757. */
  44758. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44759. /**
  44760. * 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)
  44761. */
  44762. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44763. /**
  44764. * The scene that is rendered on top of the original scene
  44765. */
  44766. utilityLayerScene: Scene;
  44767. /**
  44768. * If the utility layer should automatically be rendered on top of existing scene
  44769. */
  44770. shouldRender: boolean;
  44771. /**
  44772. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44773. */
  44774. onlyCheckPointerDownEvents: boolean;
  44775. /**
  44776. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44777. */
  44778. processAllEvents: boolean;
  44779. /**
  44780. * Observable raised when the pointer move from the utility layer scene to the main scene
  44781. */
  44782. onPointerOutObservable: Observable<number>;
  44783. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44784. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44785. private _afterRenderObserver;
  44786. private _sceneDisposeObserver;
  44787. private _originalPointerObserver;
  44788. /**
  44789. * Instantiates a UtilityLayerRenderer
  44790. * @param originalScene the original scene that will be rendered on top of
  44791. * @param handleEvents boolean indicating if the utility layer should handle events
  44792. */
  44793. constructor(
  44794. /** the original scene that will be rendered on top of */
  44795. originalScene: Scene, handleEvents?: boolean);
  44796. private _notifyObservers;
  44797. /**
  44798. * Renders the utility layers scene on top of the original scene
  44799. */
  44800. render(): void;
  44801. /**
  44802. * Disposes of the renderer
  44803. */
  44804. dispose(): void;
  44805. private _updateCamera;
  44806. }
  44807. }
  44808. declare module BABYLON {
  44809. /**
  44810. * Options interface for the pointer selection module
  44811. */
  44812. export interface IWebXRControllerPointerSelectionOptions {
  44813. /**
  44814. * if provided, this scene will be used to render meshes.
  44815. */
  44816. customUtilityLayerScene?: Scene;
  44817. /**
  44818. * 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)
  44819. * If not disabled, the last picked point will be used to execute a pointer up event
  44820. * If disabled, pointer up event will be triggered right after the pointer down event.
  44821. * Used in screen and gaze target ray mode only
  44822. */
  44823. disablePointerUpOnTouchOut: boolean;
  44824. /**
  44825. * For gaze mode (time to select instead of press)
  44826. */
  44827. forceGazeMode: boolean;
  44828. /**
  44829. * 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
  44830. * to start a new countdown to the pointer down event.
  44831. * Defaults to 1.
  44832. */
  44833. gazeModePointerMovedFactor?: number;
  44834. /**
  44835. * Different button type to use instead of the main component
  44836. */
  44837. overrideButtonId?: string;
  44838. /**
  44839. * use this rendering group id for the meshes (optional)
  44840. */
  44841. renderingGroupId?: number;
  44842. /**
  44843. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44844. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44845. * 3000 means 3 seconds between pointing at something and selecting it
  44846. */
  44847. timeToSelect?: number;
  44848. /**
  44849. * Should meshes created here be added to a utility layer or the main scene
  44850. */
  44851. useUtilityLayer?: boolean;
  44852. /**
  44853. * the xr input to use with this pointer selection
  44854. */
  44855. xrInput: WebXRInput;
  44856. }
  44857. /**
  44858. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44859. */
  44860. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44861. private readonly _options;
  44862. private static _idCounter;
  44863. private _attachController;
  44864. private _controllers;
  44865. private _scene;
  44866. private _tmpVectorForPickCompare;
  44867. /**
  44868. * The module's name
  44869. */
  44870. static readonly Name: string;
  44871. /**
  44872. * The (Babylon) version of this module.
  44873. * This is an integer representing the implementation version.
  44874. * This number does not correspond to the WebXR specs version
  44875. */
  44876. static readonly Version: number;
  44877. /**
  44878. * Disable lighting on the laser pointer (so it will always be visible)
  44879. */
  44880. disablePointerLighting: boolean;
  44881. /**
  44882. * Disable lighting on the selection mesh (so it will always be visible)
  44883. */
  44884. disableSelectionMeshLighting: boolean;
  44885. /**
  44886. * Should the laser pointer be displayed
  44887. */
  44888. displayLaserPointer: boolean;
  44889. /**
  44890. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44891. */
  44892. displaySelectionMesh: boolean;
  44893. /**
  44894. * This color will be set to the laser pointer when selection is triggered
  44895. */
  44896. laserPointerPickedColor: Color3;
  44897. /**
  44898. * Default color of the laser pointer
  44899. */
  44900. lasterPointerDefaultColor: Color3;
  44901. /**
  44902. * default color of the selection ring
  44903. */
  44904. selectionMeshDefaultColor: Color3;
  44905. /**
  44906. * This color will be applied to the selection ring when selection is triggered
  44907. */
  44908. selectionMeshPickedColor: Color3;
  44909. /**
  44910. * Optional filter to be used for ray selection. This predicate shares behavior with
  44911. * scene.pointerMovePredicate which takes priority if it is also assigned.
  44912. */
  44913. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44914. /**
  44915. * constructs a new background remover module
  44916. * @param _xrSessionManager the session manager for this module
  44917. * @param _options read-only options to be used in this module
  44918. */
  44919. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44920. /**
  44921. * attach this feature
  44922. * Will usually be called by the features manager
  44923. *
  44924. * @returns true if successful.
  44925. */
  44926. attach(): boolean;
  44927. /**
  44928. * detach this feature.
  44929. * Will usually be called by the features manager
  44930. *
  44931. * @returns true if successful.
  44932. */
  44933. detach(): boolean;
  44934. /**
  44935. * Will get the mesh under a specific pointer.
  44936. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44937. * @param controllerId the controllerId to check
  44938. * @returns The mesh under pointer or null if no mesh is under the pointer
  44939. */
  44940. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44941. /**
  44942. * Get the xr controller that correlates to the pointer id in the pointer event
  44943. *
  44944. * @param id the pointer id to search for
  44945. * @returns the controller that correlates to this id or null if not found
  44946. */
  44947. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44948. protected _onXRFrame(_xrFrame: XRFrame): void;
  44949. private _attachGazeMode;
  44950. private _attachScreenRayMode;
  44951. private _attachTrackedPointerRayMode;
  44952. private _convertNormalToDirectionOfRay;
  44953. private _detachController;
  44954. private _generateNewMeshPair;
  44955. private _pickingMoved;
  44956. private _updatePointerDistance;
  44957. }
  44958. }
  44959. declare module BABYLON {
  44960. /**
  44961. * Button which can be used to enter a different mode of XR
  44962. */
  44963. export class WebXREnterExitUIButton {
  44964. /** button element */
  44965. element: HTMLElement;
  44966. /** XR initialization options for the button */
  44967. sessionMode: XRSessionMode;
  44968. /** Reference space type */
  44969. referenceSpaceType: XRReferenceSpaceType;
  44970. /**
  44971. * Creates a WebXREnterExitUIButton
  44972. * @param element button element
  44973. * @param sessionMode XR initialization session mode
  44974. * @param referenceSpaceType the type of reference space to be used
  44975. */
  44976. constructor(
  44977. /** button element */
  44978. element: HTMLElement,
  44979. /** XR initialization options for the button */
  44980. sessionMode: XRSessionMode,
  44981. /** Reference space type */
  44982. referenceSpaceType: XRReferenceSpaceType);
  44983. /**
  44984. * Extendable function which can be used to update the button's visuals when the state changes
  44985. * @param activeButton the current active button in the UI
  44986. */
  44987. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44988. }
  44989. /**
  44990. * Options to create the webXR UI
  44991. */
  44992. export class WebXREnterExitUIOptions {
  44993. /**
  44994. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44995. */
  44996. customButtons?: Array<WebXREnterExitUIButton>;
  44997. /**
  44998. * A reference space type to use when creating the default button.
  44999. * Default is local-floor
  45000. */
  45001. referenceSpaceType?: XRReferenceSpaceType;
  45002. /**
  45003. * Context to enter xr with
  45004. */
  45005. renderTarget?: Nullable<WebXRRenderTarget>;
  45006. /**
  45007. * A session mode to use when creating the default button.
  45008. * Default is immersive-vr
  45009. */
  45010. sessionMode?: XRSessionMode;
  45011. }
  45012. /**
  45013. * UI to allow the user to enter/exit XR mode
  45014. */
  45015. export class WebXREnterExitUI implements IDisposable {
  45016. private scene;
  45017. /** version of the options passed to this UI */
  45018. options: WebXREnterExitUIOptions;
  45019. private _activeButton;
  45020. private _buttons;
  45021. private _overlay;
  45022. /**
  45023. * Fired every time the active button is changed.
  45024. *
  45025. * When xr is entered via a button that launches xr that button will be the callback parameter
  45026. *
  45027. * When exiting xr the callback parameter will be null)
  45028. */
  45029. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45030. /**
  45031. *
  45032. * @param scene babylon scene object to use
  45033. * @param options (read-only) version of the options passed to this UI
  45034. */
  45035. private constructor();
  45036. /**
  45037. * Creates UI to allow the user to enter/exit XR mode
  45038. * @param scene the scene to add the ui to
  45039. * @param helper the xr experience helper to enter/exit xr with
  45040. * @param options options to configure the UI
  45041. * @returns the created ui
  45042. */
  45043. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45044. /**
  45045. * Disposes of the XR UI component
  45046. */
  45047. dispose(): void;
  45048. private _updateButtons;
  45049. }
  45050. }
  45051. declare module BABYLON {
  45052. /**
  45053. * Class containing static functions to help procedurally build meshes
  45054. */
  45055. export class LinesBuilder {
  45056. /**
  45057. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45058. * * 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
  45059. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45060. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45061. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45062. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45063. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45064. * * 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
  45065. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45067. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45068. * @param name defines the name of the new line system
  45069. * @param options defines the options used to create the line system
  45070. * @param scene defines the hosting scene
  45071. * @returns a new line system mesh
  45072. */
  45073. static CreateLineSystem(name: string, options: {
  45074. lines: Vector3[][];
  45075. updatable?: boolean;
  45076. instance?: Nullable<LinesMesh>;
  45077. colors?: Nullable<Color4[][]>;
  45078. useVertexAlpha?: boolean;
  45079. }, scene: Nullable<Scene>): LinesMesh;
  45080. /**
  45081. * Creates a line mesh
  45082. * 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
  45083. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45084. * * The parameter `points` is an array successive Vector3
  45085. * * 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
  45086. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45087. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45088. * * When updating an instance, remember that only point positions can change, not the number of points
  45089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45090. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45091. * @param name defines the name of the new line system
  45092. * @param options defines the options used to create the line system
  45093. * @param scene defines the hosting scene
  45094. * @returns a new line mesh
  45095. */
  45096. static CreateLines(name: string, options: {
  45097. points: Vector3[];
  45098. updatable?: boolean;
  45099. instance?: Nullable<LinesMesh>;
  45100. colors?: Color4[];
  45101. useVertexAlpha?: boolean;
  45102. }, scene?: Nullable<Scene>): LinesMesh;
  45103. /**
  45104. * Creates a dashed line mesh
  45105. * * 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
  45106. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45107. * * The parameter `points` is an array successive Vector3
  45108. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45109. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45110. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45111. * * 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
  45112. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45113. * * When updating an instance, remember that only point positions can change, not the number of points
  45114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45115. * @param name defines the name of the mesh
  45116. * @param options defines the options used to create the mesh
  45117. * @param scene defines the hosting scene
  45118. * @returns the dashed line mesh
  45119. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45120. */
  45121. static CreateDashedLines(name: string, options: {
  45122. points: Vector3[];
  45123. dashSize?: number;
  45124. gapSize?: number;
  45125. dashNb?: number;
  45126. updatable?: boolean;
  45127. instance?: LinesMesh;
  45128. useVertexAlpha?: boolean;
  45129. }, scene?: Nullable<Scene>): LinesMesh;
  45130. }
  45131. }
  45132. declare module BABYLON {
  45133. /**
  45134. * The options container for the teleportation module
  45135. */
  45136. export interface IWebXRTeleportationOptions {
  45137. /**
  45138. * if provided, this scene will be used to render meshes.
  45139. */
  45140. customUtilityLayerScene?: Scene;
  45141. /**
  45142. * Values to configure the default target mesh
  45143. */
  45144. defaultTargetMeshOptions?: {
  45145. /**
  45146. * Fill color of the teleportation area
  45147. */
  45148. teleportationFillColor?: string;
  45149. /**
  45150. * Border color for the teleportation area
  45151. */
  45152. teleportationBorderColor?: string;
  45153. /**
  45154. * Disable the mesh's animation sequence
  45155. */
  45156. disableAnimation?: boolean;
  45157. /**
  45158. * Disable lighting on the material or the ring and arrow
  45159. */
  45160. disableLighting?: boolean;
  45161. /**
  45162. * Override the default material of the torus and arrow
  45163. */
  45164. torusArrowMaterial?: Material;
  45165. };
  45166. /**
  45167. * A list of meshes to use as floor meshes.
  45168. * Meshes can be added and removed after initializing the feature using the
  45169. * addFloorMesh and removeFloorMesh functions
  45170. * If empty, rotation will still work
  45171. */
  45172. floorMeshes?: AbstractMesh[];
  45173. /**
  45174. * use this rendering group id for the meshes (optional)
  45175. */
  45176. renderingGroupId?: number;
  45177. /**
  45178. * Should teleportation move only to snap points
  45179. */
  45180. snapPointsOnly?: boolean;
  45181. /**
  45182. * An array of points to which the teleportation will snap to.
  45183. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45184. */
  45185. snapPositions?: Vector3[];
  45186. /**
  45187. * How close should the teleportation ray be in order to snap to position.
  45188. * Default to 0.8 units (meters)
  45189. */
  45190. snapToPositionRadius?: number;
  45191. /**
  45192. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45193. * If you want to support rotation, make sure your mesh has a direction indicator.
  45194. *
  45195. * When left untouched, the default mesh will be initialized.
  45196. */
  45197. teleportationTargetMesh?: AbstractMesh;
  45198. /**
  45199. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45200. */
  45201. timeToTeleport?: number;
  45202. /**
  45203. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45204. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45205. */
  45206. useMainComponentOnly?: boolean;
  45207. /**
  45208. * Should meshes created here be added to a utility layer or the main scene
  45209. */
  45210. useUtilityLayer?: boolean;
  45211. /**
  45212. * Babylon XR Input class for controller
  45213. */
  45214. xrInput: WebXRInput;
  45215. }
  45216. /**
  45217. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45218. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45219. * the input of the attached controllers.
  45220. */
  45221. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45222. private _options;
  45223. private _controllers;
  45224. private _currentTeleportationControllerId;
  45225. private _floorMeshes;
  45226. private _quadraticBezierCurve;
  45227. private _selectionFeature;
  45228. private _snapToPositions;
  45229. private _snappedToPoint;
  45230. private _teleportationRingMaterial?;
  45231. private _tmpRay;
  45232. private _tmpVector;
  45233. /**
  45234. * The module's name
  45235. */
  45236. static readonly Name: string;
  45237. /**
  45238. * The (Babylon) version of this module.
  45239. * This is an integer representing the implementation version.
  45240. * This number does not correspond to the webxr specs version
  45241. */
  45242. static readonly Version: number;
  45243. /**
  45244. * Is movement backwards enabled
  45245. */
  45246. backwardsMovementEnabled: boolean;
  45247. /**
  45248. * Distance to travel when moving backwards
  45249. */
  45250. backwardsTeleportationDistance: number;
  45251. /**
  45252. * The distance from the user to the inspection point in the direction of the controller
  45253. * A higher number will allow the user to move further
  45254. * defaults to 5 (meters, in xr units)
  45255. */
  45256. parabolicCheckRadius: number;
  45257. /**
  45258. * Should the module support parabolic ray on top of direct ray
  45259. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45260. * Very helpful when moving between floors / different heights
  45261. */
  45262. parabolicRayEnabled: boolean;
  45263. /**
  45264. * How much rotation should be applied when rotating right and left
  45265. */
  45266. rotationAngle: number;
  45267. /**
  45268. * Is rotation enabled when moving forward?
  45269. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45270. */
  45271. rotationEnabled: boolean;
  45272. /**
  45273. * constructs a new anchor system
  45274. * @param _xrSessionManager an instance of WebXRSessionManager
  45275. * @param _options configuration object for this feature
  45276. */
  45277. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45278. /**
  45279. * Get the snapPointsOnly flag
  45280. */
  45281. get snapPointsOnly(): boolean;
  45282. /**
  45283. * Sets the snapPointsOnly flag
  45284. * @param snapToPoints should teleportation be exclusively to snap points
  45285. */
  45286. set snapPointsOnly(snapToPoints: boolean);
  45287. /**
  45288. * Add a new mesh to the floor meshes array
  45289. * @param mesh the mesh to use as floor mesh
  45290. */
  45291. addFloorMesh(mesh: AbstractMesh): void;
  45292. /**
  45293. * Add a new snap-to point to fix teleportation to this position
  45294. * @param newSnapPoint The new Snap-To point
  45295. */
  45296. addSnapPoint(newSnapPoint: Vector3): void;
  45297. attach(): boolean;
  45298. detach(): boolean;
  45299. dispose(): void;
  45300. /**
  45301. * Remove a mesh from the floor meshes array
  45302. * @param mesh the mesh to remove
  45303. */
  45304. removeFloorMesh(mesh: AbstractMesh): void;
  45305. /**
  45306. * Remove a mesh from the floor meshes array using its name
  45307. * @param name the mesh name to remove
  45308. */
  45309. removeFloorMeshByName(name: string): void;
  45310. /**
  45311. * 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
  45312. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45313. * @returns was the point found and removed or not
  45314. */
  45315. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45316. /**
  45317. * This function sets a selection feature that will be disabled when
  45318. * the forward ray is shown and will be reattached when hidden.
  45319. * This is used to remove the selection rays when moving.
  45320. * @param selectionFeature the feature to disable when forward movement is enabled
  45321. */
  45322. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45323. protected _onXRFrame(_xrFrame: XRFrame): void;
  45324. private _attachController;
  45325. private _createDefaultTargetMesh;
  45326. private _detachController;
  45327. private _findClosestSnapPointWithRadius;
  45328. private _setTargetMeshPosition;
  45329. private _setTargetMeshVisibility;
  45330. private _showParabolicPath;
  45331. private _teleportForward;
  45332. }
  45333. }
  45334. declare module BABYLON {
  45335. /**
  45336. * Options for the default xr helper
  45337. */
  45338. export class WebXRDefaultExperienceOptions {
  45339. /**
  45340. * Enable or disable default UI to enter XR
  45341. */
  45342. disableDefaultUI?: boolean;
  45343. /**
  45344. * Should teleportation not initialize. defaults to false.
  45345. */
  45346. disableTeleportation?: boolean;
  45347. /**
  45348. * Floor meshes that will be used for teleport
  45349. */
  45350. floorMeshes?: Array<AbstractMesh>;
  45351. /**
  45352. * If set to true, the first frame will not be used to reset position
  45353. * The first frame is mainly used when copying transformation from the old camera
  45354. * Mainly used in AR
  45355. */
  45356. ignoreNativeCameraTransformation?: boolean;
  45357. /**
  45358. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45359. */
  45360. inputOptions?: IWebXRInputOptions;
  45361. /**
  45362. * optional configuration for the output canvas
  45363. */
  45364. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45365. /**
  45366. * optional UI options. This can be used among other to change session mode and reference space type
  45367. */
  45368. uiOptions?: WebXREnterExitUIOptions;
  45369. /**
  45370. * When loading teleportation and pointer select, use stable versions instead of latest.
  45371. */
  45372. useStablePlugins?: boolean;
  45373. }
  45374. /**
  45375. * Default experience which provides a similar setup to the previous webVRExperience
  45376. */
  45377. export class WebXRDefaultExperience {
  45378. /**
  45379. * Base experience
  45380. */
  45381. baseExperience: WebXRExperienceHelper;
  45382. /**
  45383. * Enables ui for entering/exiting xr
  45384. */
  45385. enterExitUI: WebXREnterExitUI;
  45386. /**
  45387. * Input experience extension
  45388. */
  45389. input: WebXRInput;
  45390. /**
  45391. * Enables laser pointer and selection
  45392. */
  45393. pointerSelection: WebXRControllerPointerSelection;
  45394. /**
  45395. * Default target xr should render to
  45396. */
  45397. renderTarget: WebXRRenderTarget;
  45398. /**
  45399. * Enables teleportation
  45400. */
  45401. teleportation: WebXRMotionControllerTeleportation;
  45402. private constructor();
  45403. /**
  45404. * Creates the default xr experience
  45405. * @param scene scene
  45406. * @param options options for basic configuration
  45407. * @returns resulting WebXRDefaultExperience
  45408. */
  45409. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45410. /**
  45411. * DIsposes of the experience helper
  45412. */
  45413. dispose(): void;
  45414. }
  45415. }
  45416. declare module BABYLON {
  45417. /**
  45418. * Options to modify the vr teleportation behavior.
  45419. */
  45420. export interface VRTeleportationOptions {
  45421. /**
  45422. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45423. */
  45424. floorMeshName?: string;
  45425. /**
  45426. * A list of meshes to be used as the teleportation floor. (default: empty)
  45427. */
  45428. floorMeshes?: Mesh[];
  45429. /**
  45430. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45431. */
  45432. teleportationMode?: number;
  45433. /**
  45434. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45435. */
  45436. teleportationTime?: number;
  45437. /**
  45438. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45439. */
  45440. teleportationSpeed?: number;
  45441. /**
  45442. * The easing function used in the animation or null for Linear. (default CircleEase)
  45443. */
  45444. easingFunction?: EasingFunction;
  45445. }
  45446. /**
  45447. * Options to modify the vr experience helper's behavior.
  45448. */
  45449. export interface VRExperienceHelperOptions extends WebVROptions {
  45450. /**
  45451. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45452. */
  45453. createDeviceOrientationCamera?: boolean;
  45454. /**
  45455. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45456. */
  45457. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45458. /**
  45459. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45460. */
  45461. laserToggle?: boolean;
  45462. /**
  45463. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45464. */
  45465. floorMeshes?: Mesh[];
  45466. /**
  45467. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45468. */
  45469. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45470. /**
  45471. * Defines if WebXR should be used instead of WebVR (if available)
  45472. */
  45473. useXR?: boolean;
  45474. }
  45475. /**
  45476. * Event containing information after VR has been entered
  45477. */
  45478. export class OnAfterEnteringVRObservableEvent {
  45479. /**
  45480. * If entering vr was successful
  45481. */
  45482. success: boolean;
  45483. }
  45484. /**
  45485. * Helps to quickly add VR support to an existing scene.
  45486. * See http://doc.babylonjs.com/how_to/webvr_helper
  45487. */
  45488. export class VRExperienceHelper {
  45489. /** Options to modify the vr experience helper's behavior. */
  45490. webVROptions: VRExperienceHelperOptions;
  45491. private _scene;
  45492. private _position;
  45493. private _btnVR;
  45494. private _btnVRDisplayed;
  45495. private _webVRsupported;
  45496. private _webVRready;
  45497. private _webVRrequesting;
  45498. private _webVRpresenting;
  45499. private _hasEnteredVR;
  45500. private _fullscreenVRpresenting;
  45501. private _inputElement;
  45502. private _webVRCamera;
  45503. private _vrDeviceOrientationCamera;
  45504. private _deviceOrientationCamera;
  45505. private _existingCamera;
  45506. private _onKeyDown;
  45507. private _onVrDisplayPresentChange;
  45508. private _onVRDisplayChanged;
  45509. private _onVRRequestPresentStart;
  45510. private _onVRRequestPresentComplete;
  45511. /**
  45512. * 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)
  45513. */
  45514. enableGazeEvenWhenNoPointerLock: boolean;
  45515. /**
  45516. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45517. */
  45518. exitVROnDoubleTap: boolean;
  45519. /**
  45520. * Observable raised right before entering VR.
  45521. */
  45522. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45523. /**
  45524. * Observable raised when entering VR has completed.
  45525. */
  45526. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45527. /**
  45528. * Observable raised when exiting VR.
  45529. */
  45530. onExitingVRObservable: Observable<VRExperienceHelper>;
  45531. /**
  45532. * Observable raised when controller mesh is loaded.
  45533. */
  45534. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45535. /** Return this.onEnteringVRObservable
  45536. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45537. */
  45538. get onEnteringVR(): Observable<VRExperienceHelper>;
  45539. /** Return this.onExitingVRObservable
  45540. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45541. */
  45542. get onExitingVR(): Observable<VRExperienceHelper>;
  45543. /** Return this.onControllerMeshLoadedObservable
  45544. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45545. */
  45546. get onControllerMeshLoaded(): Observable<WebVRController>;
  45547. private _rayLength;
  45548. private _useCustomVRButton;
  45549. private _teleportationRequested;
  45550. private _teleportActive;
  45551. private _floorMeshName;
  45552. private _floorMeshesCollection;
  45553. private _teleportationMode;
  45554. private _teleportationTime;
  45555. private _teleportationSpeed;
  45556. private _teleportationEasing;
  45557. private _rotationAllowed;
  45558. private _teleportBackwardsVector;
  45559. private _teleportationTarget;
  45560. private _isDefaultTeleportationTarget;
  45561. private _postProcessMove;
  45562. private _teleportationFillColor;
  45563. private _teleportationBorderColor;
  45564. private _rotationAngle;
  45565. private _haloCenter;
  45566. private _cameraGazer;
  45567. private _padSensibilityUp;
  45568. private _padSensibilityDown;
  45569. private _leftController;
  45570. private _rightController;
  45571. private _gazeColor;
  45572. private _laserColor;
  45573. private _pickedLaserColor;
  45574. private _pickedGazeColor;
  45575. /**
  45576. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45577. */
  45578. onNewMeshSelected: Observable<AbstractMesh>;
  45579. /**
  45580. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45581. * This observable will provide the mesh and the controller used to select the mesh
  45582. */
  45583. onMeshSelectedWithController: Observable<{
  45584. mesh: AbstractMesh;
  45585. controller: WebVRController;
  45586. }>;
  45587. /**
  45588. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45589. */
  45590. onNewMeshPicked: Observable<PickingInfo>;
  45591. private _circleEase;
  45592. /**
  45593. * Observable raised before camera teleportation
  45594. */
  45595. onBeforeCameraTeleport: Observable<Vector3>;
  45596. /**
  45597. * Observable raised after camera teleportation
  45598. */
  45599. onAfterCameraTeleport: Observable<Vector3>;
  45600. /**
  45601. * Observable raised when current selected mesh gets unselected
  45602. */
  45603. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45604. private _raySelectionPredicate;
  45605. /**
  45606. * To be optionaly changed by user to define custom ray selection
  45607. */
  45608. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45609. /**
  45610. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45611. */
  45612. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45613. /**
  45614. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45615. */
  45616. teleportationEnabled: boolean;
  45617. private _defaultHeight;
  45618. private _teleportationInitialized;
  45619. private _interactionsEnabled;
  45620. private _interactionsRequested;
  45621. private _displayGaze;
  45622. private _displayLaserPointer;
  45623. /**
  45624. * The mesh used to display where the user is going to teleport.
  45625. */
  45626. get teleportationTarget(): Mesh;
  45627. /**
  45628. * Sets the mesh to be used to display where the user is going to teleport.
  45629. */
  45630. set teleportationTarget(value: Mesh);
  45631. /**
  45632. * 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
  45633. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45634. * See http://doc.babylonjs.com/resources/baking_transformations
  45635. */
  45636. get gazeTrackerMesh(): Mesh;
  45637. set gazeTrackerMesh(value: Mesh);
  45638. /**
  45639. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45640. */
  45641. updateGazeTrackerScale: boolean;
  45642. /**
  45643. * If the gaze trackers color should be updated when selecting meshes
  45644. */
  45645. updateGazeTrackerColor: boolean;
  45646. /**
  45647. * If the controller laser color should be updated when selecting meshes
  45648. */
  45649. updateControllerLaserColor: boolean;
  45650. /**
  45651. * The gaze tracking mesh corresponding to the left controller
  45652. */
  45653. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45654. /**
  45655. * The gaze tracking mesh corresponding to the right controller
  45656. */
  45657. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45658. /**
  45659. * If the ray of the gaze should be displayed.
  45660. */
  45661. get displayGaze(): boolean;
  45662. /**
  45663. * Sets if the ray of the gaze should be displayed.
  45664. */
  45665. set displayGaze(value: boolean);
  45666. /**
  45667. * If the ray of the LaserPointer should be displayed.
  45668. */
  45669. get displayLaserPointer(): boolean;
  45670. /**
  45671. * Sets if the ray of the LaserPointer should be displayed.
  45672. */
  45673. set displayLaserPointer(value: boolean);
  45674. /**
  45675. * The deviceOrientationCamera used as the camera when not in VR.
  45676. */
  45677. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45678. /**
  45679. * Based on the current WebVR support, returns the current VR camera used.
  45680. */
  45681. get currentVRCamera(): Nullable<Camera>;
  45682. /**
  45683. * The webVRCamera which is used when in VR.
  45684. */
  45685. get webVRCamera(): WebVRFreeCamera;
  45686. /**
  45687. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45688. */
  45689. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45690. /**
  45691. * The html button that is used to trigger entering into VR.
  45692. */
  45693. get vrButton(): Nullable<HTMLButtonElement>;
  45694. private get _teleportationRequestInitiated();
  45695. /**
  45696. * Defines whether or not Pointer lock should be requested when switching to
  45697. * full screen.
  45698. */
  45699. requestPointerLockOnFullScreen: boolean;
  45700. /**
  45701. * If asking to force XR, this will be populated with the default xr experience
  45702. */
  45703. xr: WebXRDefaultExperience;
  45704. /**
  45705. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45706. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45707. */
  45708. xrTestDone: boolean;
  45709. /**
  45710. * Instantiates a VRExperienceHelper.
  45711. * Helps to quickly add VR support to an existing scene.
  45712. * @param scene The scene the VRExperienceHelper belongs to.
  45713. * @param webVROptions Options to modify the vr experience helper's behavior.
  45714. */
  45715. constructor(scene: Scene,
  45716. /** Options to modify the vr experience helper's behavior. */
  45717. webVROptions?: VRExperienceHelperOptions);
  45718. private completeVRInit;
  45719. private _onDefaultMeshLoaded;
  45720. private _onResize;
  45721. private _onFullscreenChange;
  45722. /**
  45723. * Gets a value indicating if we are currently in VR mode.
  45724. */
  45725. get isInVRMode(): boolean;
  45726. private onVrDisplayPresentChange;
  45727. private onVRDisplayChanged;
  45728. private moveButtonToBottomRight;
  45729. private displayVRButton;
  45730. private updateButtonVisibility;
  45731. private _cachedAngularSensibility;
  45732. /**
  45733. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45734. * Otherwise, will use the fullscreen API.
  45735. */
  45736. enterVR(): void;
  45737. /**
  45738. * Attempt to exit VR, or fullscreen.
  45739. */
  45740. exitVR(): void;
  45741. /**
  45742. * The position of the vr experience helper.
  45743. */
  45744. get position(): Vector3;
  45745. /**
  45746. * Sets the position of the vr experience helper.
  45747. */
  45748. set position(value: Vector3);
  45749. /**
  45750. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45751. */
  45752. enableInteractions(): void;
  45753. private get _noControllerIsActive();
  45754. private beforeRender;
  45755. private _isTeleportationFloor;
  45756. /**
  45757. * Adds a floor mesh to be used for teleportation.
  45758. * @param floorMesh the mesh to be used for teleportation.
  45759. */
  45760. addFloorMesh(floorMesh: Mesh): void;
  45761. /**
  45762. * Removes a floor mesh from being used for teleportation.
  45763. * @param floorMesh the mesh to be removed.
  45764. */
  45765. removeFloorMesh(floorMesh: Mesh): void;
  45766. /**
  45767. * Enables interactions and teleportation using the VR controllers and gaze.
  45768. * @param vrTeleportationOptions options to modify teleportation behavior.
  45769. */
  45770. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45771. private _onNewGamepadConnected;
  45772. private _tryEnableInteractionOnController;
  45773. private _onNewGamepadDisconnected;
  45774. private _enableInteractionOnController;
  45775. private _checkTeleportWithRay;
  45776. private _checkRotate;
  45777. private _checkTeleportBackwards;
  45778. private _enableTeleportationOnController;
  45779. private _createTeleportationCircles;
  45780. private _displayTeleportationTarget;
  45781. private _hideTeleportationTarget;
  45782. private _rotateCamera;
  45783. private _moveTeleportationSelectorTo;
  45784. private _workingVector;
  45785. private _workingQuaternion;
  45786. private _workingMatrix;
  45787. /**
  45788. * Time Constant Teleportation Mode
  45789. */
  45790. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45791. /**
  45792. * Speed Constant Teleportation Mode
  45793. */
  45794. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45795. /**
  45796. * Teleports the users feet to the desired location
  45797. * @param location The location where the user's feet should be placed
  45798. */
  45799. teleportCamera(location: Vector3): void;
  45800. private _convertNormalToDirectionOfRay;
  45801. private _castRayAndSelectObject;
  45802. private _notifySelectedMeshUnselected;
  45803. /**
  45804. * Permanently set new colors for the laser pointer
  45805. * @param color the new laser color
  45806. * @param pickedColor the new laser color when picked mesh detected
  45807. */
  45808. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45809. /**
  45810. * Set lighting enabled / disabled on the laser pointer of both controllers
  45811. * @param enabled should the lighting be enabled on the laser pointer
  45812. */
  45813. setLaserLightingState(enabled?: boolean): void;
  45814. /**
  45815. * Permanently set new colors for the gaze pointer
  45816. * @param color the new gaze color
  45817. * @param pickedColor the new gaze color when picked mesh detected
  45818. */
  45819. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45820. /**
  45821. * Sets the color of the laser ray from the vr controllers.
  45822. * @param color new color for the ray.
  45823. */
  45824. changeLaserColor(color: Color3): void;
  45825. /**
  45826. * Sets the color of the ray from the vr headsets gaze.
  45827. * @param color new color for the ray.
  45828. */
  45829. changeGazeColor(color: Color3): void;
  45830. /**
  45831. * Exits VR and disposes of the vr experience helper
  45832. */
  45833. dispose(): void;
  45834. /**
  45835. * Gets the name of the VRExperienceHelper class
  45836. * @returns "VRExperienceHelper"
  45837. */
  45838. getClassName(): string;
  45839. }
  45840. }
  45841. declare module BABYLON {
  45842. /**
  45843. * Contains an array of blocks representing the octree
  45844. */
  45845. export interface IOctreeContainer<T> {
  45846. /**
  45847. * Blocks within the octree
  45848. */
  45849. blocks: Array<OctreeBlock<T>>;
  45850. }
  45851. /**
  45852. * Class used to store a cell in an octree
  45853. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45854. */
  45855. export class OctreeBlock<T> {
  45856. /**
  45857. * Gets the content of the current block
  45858. */
  45859. entries: T[];
  45860. /**
  45861. * Gets the list of block children
  45862. */
  45863. blocks: Array<OctreeBlock<T>>;
  45864. private _depth;
  45865. private _maxDepth;
  45866. private _capacity;
  45867. private _minPoint;
  45868. private _maxPoint;
  45869. private _boundingVectors;
  45870. private _creationFunc;
  45871. /**
  45872. * Creates a new block
  45873. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45874. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45875. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45876. * @param depth defines the current depth of this block in the octree
  45877. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45878. * @param creationFunc defines a callback to call when an element is added to the block
  45879. */
  45880. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45881. /**
  45882. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45883. */
  45884. get capacity(): number;
  45885. /**
  45886. * Gets the minimum vector (in world space) of the block's bounding box
  45887. */
  45888. get minPoint(): Vector3;
  45889. /**
  45890. * Gets the maximum vector (in world space) of the block's bounding box
  45891. */
  45892. get maxPoint(): Vector3;
  45893. /**
  45894. * Add a new element to this block
  45895. * @param entry defines the element to add
  45896. */
  45897. addEntry(entry: T): void;
  45898. /**
  45899. * Remove an element from this block
  45900. * @param entry defines the element to remove
  45901. */
  45902. removeEntry(entry: T): void;
  45903. /**
  45904. * Add an array of elements to this block
  45905. * @param entries defines the array of elements to add
  45906. */
  45907. addEntries(entries: T[]): void;
  45908. /**
  45909. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45910. * @param frustumPlanes defines the frustum planes to test
  45911. * @param selection defines the array to store current content if selection is positive
  45912. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45913. */
  45914. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45915. /**
  45916. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45917. * @param sphereCenter defines the bounding sphere center
  45918. * @param sphereRadius defines the bounding sphere radius
  45919. * @param selection defines the array to store current content if selection is positive
  45920. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45921. */
  45922. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45923. /**
  45924. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45925. * @param ray defines the ray to test with
  45926. * @param selection defines the array to store current content if selection is positive
  45927. */
  45928. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45929. /**
  45930. * Subdivide the content into child blocks (this block will then be empty)
  45931. */
  45932. createInnerBlocks(): void;
  45933. /**
  45934. * @hidden
  45935. */
  45936. 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;
  45937. }
  45938. }
  45939. declare module BABYLON {
  45940. /**
  45941. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45942. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45943. */
  45944. export class Octree<T> {
  45945. /** 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.) */
  45946. maxDepth: number;
  45947. /**
  45948. * Blocks within the octree containing objects
  45949. */
  45950. blocks: Array<OctreeBlock<T>>;
  45951. /**
  45952. * Content stored in the octree
  45953. */
  45954. dynamicContent: T[];
  45955. private _maxBlockCapacity;
  45956. private _selectionContent;
  45957. private _creationFunc;
  45958. /**
  45959. * Creates a octree
  45960. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45961. * @param creationFunc function to be used to instatiate the octree
  45962. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45963. * @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.)
  45964. */
  45965. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45966. /** 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.) */
  45967. maxDepth?: number);
  45968. /**
  45969. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45970. * @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);
  45971. * @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);
  45972. * @param entries meshes to be added to the octree blocks
  45973. */
  45974. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45975. /**
  45976. * Adds a mesh to the octree
  45977. * @param entry Mesh to add to the octree
  45978. */
  45979. addMesh(entry: T): void;
  45980. /**
  45981. * Remove an element from the octree
  45982. * @param entry defines the element to remove
  45983. */
  45984. removeMesh(entry: T): void;
  45985. /**
  45986. * Selects an array of meshes within the frustum
  45987. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45988. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45989. * @returns array of meshes within the frustum
  45990. */
  45991. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45992. /**
  45993. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45994. * @param sphereCenter defines the bounding sphere center
  45995. * @param sphereRadius defines the bounding sphere radius
  45996. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45997. * @returns an array of objects that intersect the sphere
  45998. */
  45999. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46000. /**
  46001. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46002. * @param ray defines the ray to test with
  46003. * @returns array of intersected objects
  46004. */
  46005. intersectsRay(ray: Ray): SmartArray<T>;
  46006. /**
  46007. * Adds a mesh into the octree block if it intersects the block
  46008. */
  46009. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46010. /**
  46011. * Adds a submesh into the octree block if it intersects the block
  46012. */
  46013. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46014. }
  46015. }
  46016. declare module BABYLON {
  46017. interface Scene {
  46018. /**
  46019. * @hidden
  46020. * Backing Filed
  46021. */
  46022. _selectionOctree: Octree<AbstractMesh>;
  46023. /**
  46024. * Gets the octree used to boost mesh selection (picking)
  46025. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46026. */
  46027. selectionOctree: Octree<AbstractMesh>;
  46028. /**
  46029. * Creates or updates the octree used to boost selection (picking)
  46030. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46031. * @param maxCapacity defines the maximum capacity per leaf
  46032. * @param maxDepth defines the maximum depth of the octree
  46033. * @returns an octree of AbstractMesh
  46034. */
  46035. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46036. }
  46037. interface AbstractMesh {
  46038. /**
  46039. * @hidden
  46040. * Backing Field
  46041. */
  46042. _submeshesOctree: Octree<SubMesh>;
  46043. /**
  46044. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46045. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46046. * @param maxCapacity defines the maximum size of each block (64 by default)
  46047. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46048. * @returns the new octree
  46049. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46050. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46051. */
  46052. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46053. }
  46054. /**
  46055. * Defines the octree scene component responsible to manage any octrees
  46056. * in a given scene.
  46057. */
  46058. export class OctreeSceneComponent {
  46059. /**
  46060. * The component name help to identify the component in the list of scene components.
  46061. */
  46062. readonly name: string;
  46063. /**
  46064. * The scene the component belongs to.
  46065. */
  46066. scene: Scene;
  46067. /**
  46068. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46069. */
  46070. readonly checksIsEnabled: boolean;
  46071. /**
  46072. * Creates a new instance of the component for the given scene
  46073. * @param scene Defines the scene to register the component in
  46074. */
  46075. constructor(scene: Scene);
  46076. /**
  46077. * Registers the component in a given scene
  46078. */
  46079. register(): void;
  46080. /**
  46081. * Return the list of active meshes
  46082. * @returns the list of active meshes
  46083. */
  46084. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46085. /**
  46086. * Return the list of active sub meshes
  46087. * @param mesh The mesh to get the candidates sub meshes from
  46088. * @returns the list of active sub meshes
  46089. */
  46090. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46091. private _tempRay;
  46092. /**
  46093. * Return the list of sub meshes intersecting with a given local ray
  46094. * @param mesh defines the mesh to find the submesh for
  46095. * @param localRay defines the ray in local space
  46096. * @returns the list of intersecting sub meshes
  46097. */
  46098. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46099. /**
  46100. * Return the list of sub meshes colliding with a collider
  46101. * @param mesh defines the mesh to find the submesh for
  46102. * @param collider defines the collider to evaluate the collision against
  46103. * @returns the list of colliding sub meshes
  46104. */
  46105. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46106. /**
  46107. * Rebuilds the elements related to this component in case of
  46108. * context lost for instance.
  46109. */
  46110. rebuild(): void;
  46111. /**
  46112. * Disposes the component and the associated ressources.
  46113. */
  46114. dispose(): void;
  46115. }
  46116. }
  46117. declare module BABYLON {
  46118. /**
  46119. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46120. */
  46121. export class Gizmo implements IDisposable {
  46122. /** The utility layer the gizmo will be added to */
  46123. gizmoLayer: UtilityLayerRenderer;
  46124. /**
  46125. * The root mesh of the gizmo
  46126. */
  46127. _rootMesh: Mesh;
  46128. private _attachedMesh;
  46129. /**
  46130. * Ratio for the scale of the gizmo (Default: 1)
  46131. */
  46132. scaleRatio: number;
  46133. /**
  46134. * If a custom mesh has been set (Default: false)
  46135. */
  46136. protected _customMeshSet: boolean;
  46137. /**
  46138. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46139. * * When set, interactions will be enabled
  46140. */
  46141. get attachedMesh(): Nullable<AbstractMesh>;
  46142. set attachedMesh(value: Nullable<AbstractMesh>);
  46143. /**
  46144. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46145. * @param mesh The mesh to replace the default mesh of the gizmo
  46146. */
  46147. setCustomMesh(mesh: Mesh): void;
  46148. /**
  46149. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46150. */
  46151. updateGizmoRotationToMatchAttachedMesh: boolean;
  46152. /**
  46153. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46154. */
  46155. updateGizmoPositionToMatchAttachedMesh: boolean;
  46156. /**
  46157. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46158. */
  46159. updateScale: boolean;
  46160. protected _interactionsEnabled: boolean;
  46161. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46162. private _beforeRenderObserver;
  46163. private _tempVector;
  46164. /**
  46165. * Creates a gizmo
  46166. * @param gizmoLayer The utility layer the gizmo will be added to
  46167. */
  46168. constructor(
  46169. /** The utility layer the gizmo will be added to */
  46170. gizmoLayer?: UtilityLayerRenderer);
  46171. /**
  46172. * Updates the gizmo to match the attached mesh's position/rotation
  46173. */
  46174. protected _update(): void;
  46175. /**
  46176. * Disposes of the gizmo
  46177. */
  46178. dispose(): void;
  46179. }
  46180. }
  46181. declare module BABYLON {
  46182. /**
  46183. * Single plane drag gizmo
  46184. */
  46185. export class PlaneDragGizmo extends Gizmo {
  46186. /**
  46187. * Drag behavior responsible for the gizmos dragging interactions
  46188. */
  46189. dragBehavior: PointerDragBehavior;
  46190. private _pointerObserver;
  46191. /**
  46192. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46193. */
  46194. snapDistance: number;
  46195. /**
  46196. * Event that fires each time the gizmo snaps to a new location.
  46197. * * snapDistance is the the change in distance
  46198. */
  46199. onSnapObservable: Observable<{
  46200. snapDistance: number;
  46201. }>;
  46202. private _plane;
  46203. private _coloredMaterial;
  46204. private _hoverMaterial;
  46205. private _isEnabled;
  46206. private _parent;
  46207. /** @hidden */
  46208. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46209. /** @hidden */
  46210. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46211. /**
  46212. * Creates a PlaneDragGizmo
  46213. * @param gizmoLayer The utility layer the gizmo will be added to
  46214. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46215. * @param color The color of the gizmo
  46216. */
  46217. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46218. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46219. /**
  46220. * If the gizmo is enabled
  46221. */
  46222. set isEnabled(value: boolean);
  46223. get isEnabled(): boolean;
  46224. /**
  46225. * Disposes of the gizmo
  46226. */
  46227. dispose(): void;
  46228. }
  46229. }
  46230. declare module BABYLON {
  46231. /**
  46232. * Gizmo that enables dragging a mesh along 3 axis
  46233. */
  46234. export class PositionGizmo extends Gizmo {
  46235. /**
  46236. * Internal gizmo used for interactions on the x axis
  46237. */
  46238. xGizmo: AxisDragGizmo;
  46239. /**
  46240. * Internal gizmo used for interactions on the y axis
  46241. */
  46242. yGizmo: AxisDragGizmo;
  46243. /**
  46244. * Internal gizmo used for interactions on the z axis
  46245. */
  46246. zGizmo: AxisDragGizmo;
  46247. /**
  46248. * Internal gizmo used for interactions on the yz plane
  46249. */
  46250. xPlaneGizmo: PlaneDragGizmo;
  46251. /**
  46252. * Internal gizmo used for interactions on the xz plane
  46253. */
  46254. yPlaneGizmo: PlaneDragGizmo;
  46255. /**
  46256. * Internal gizmo used for interactions on the xy plane
  46257. */
  46258. zPlaneGizmo: PlaneDragGizmo;
  46259. /**
  46260. * private variables
  46261. */
  46262. private _meshAttached;
  46263. private _updateGizmoRotationToMatchAttachedMesh;
  46264. private _snapDistance;
  46265. private _scaleRatio;
  46266. /** Fires an event when any of it's sub gizmos are dragged */
  46267. onDragStartObservable: Observable<unknown>;
  46268. /** Fires an event when any of it's sub gizmos are released from dragging */
  46269. onDragEndObservable: Observable<unknown>;
  46270. /**
  46271. * If set to true, planar drag is enabled
  46272. */
  46273. private _planarGizmoEnabled;
  46274. get attachedMesh(): Nullable<AbstractMesh>;
  46275. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46276. /**
  46277. * Creates a PositionGizmo
  46278. * @param gizmoLayer The utility layer the gizmo will be added to
  46279. */
  46280. constructor(gizmoLayer?: UtilityLayerRenderer);
  46281. /**
  46282. * If the planar drag gizmo is enabled
  46283. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46284. */
  46285. set planarGizmoEnabled(value: boolean);
  46286. get planarGizmoEnabled(): boolean;
  46287. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46288. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46289. /**
  46290. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46291. */
  46292. set snapDistance(value: number);
  46293. get snapDistance(): number;
  46294. /**
  46295. * Ratio for the scale of the gizmo (Default: 1)
  46296. */
  46297. set scaleRatio(value: number);
  46298. get scaleRatio(): number;
  46299. /**
  46300. * Disposes of the gizmo
  46301. */
  46302. dispose(): void;
  46303. /**
  46304. * CustomMeshes are not supported by this gizmo
  46305. * @param mesh The mesh to replace the default mesh of the gizmo
  46306. */
  46307. setCustomMesh(mesh: Mesh): void;
  46308. }
  46309. }
  46310. declare module BABYLON {
  46311. /**
  46312. * Single axis drag gizmo
  46313. */
  46314. export class AxisDragGizmo extends Gizmo {
  46315. /**
  46316. * Drag behavior responsible for the gizmos dragging interactions
  46317. */
  46318. dragBehavior: PointerDragBehavior;
  46319. private _pointerObserver;
  46320. /**
  46321. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46322. */
  46323. snapDistance: number;
  46324. /**
  46325. * Event that fires each time the gizmo snaps to a new location.
  46326. * * snapDistance is the the change in distance
  46327. */
  46328. onSnapObservable: Observable<{
  46329. snapDistance: number;
  46330. }>;
  46331. private _isEnabled;
  46332. private _parent;
  46333. private _arrow;
  46334. private _coloredMaterial;
  46335. private _hoverMaterial;
  46336. /** @hidden */
  46337. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46338. /** @hidden */
  46339. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46340. /**
  46341. * Creates an AxisDragGizmo
  46342. * @param gizmoLayer The utility layer the gizmo will be added to
  46343. * @param dragAxis The axis which the gizmo will be able to drag on
  46344. * @param color The color of the gizmo
  46345. */
  46346. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46347. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46348. /**
  46349. * If the gizmo is enabled
  46350. */
  46351. set isEnabled(value: boolean);
  46352. get isEnabled(): boolean;
  46353. /**
  46354. * Disposes of the gizmo
  46355. */
  46356. dispose(): void;
  46357. }
  46358. }
  46359. declare module BABYLON.Debug {
  46360. /**
  46361. * The Axes viewer will show 3 axes in a specific point in space
  46362. */
  46363. export class AxesViewer {
  46364. private _xAxis;
  46365. private _yAxis;
  46366. private _zAxis;
  46367. private _scaleLinesFactor;
  46368. private _instanced;
  46369. /**
  46370. * Gets the hosting scene
  46371. */
  46372. scene: Scene;
  46373. /**
  46374. * Gets or sets a number used to scale line length
  46375. */
  46376. scaleLines: number;
  46377. /** Gets the node hierarchy used to render x-axis */
  46378. get xAxis(): TransformNode;
  46379. /** Gets the node hierarchy used to render y-axis */
  46380. get yAxis(): TransformNode;
  46381. /** Gets the node hierarchy used to render z-axis */
  46382. get zAxis(): TransformNode;
  46383. /**
  46384. * Creates a new AxesViewer
  46385. * @param scene defines the hosting scene
  46386. * @param scaleLines defines a number used to scale line length (1 by default)
  46387. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46388. * @param xAxis defines the node hierarchy used to render the x-axis
  46389. * @param yAxis defines the node hierarchy used to render the y-axis
  46390. * @param zAxis defines the node hierarchy used to render the z-axis
  46391. */
  46392. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46393. /**
  46394. * Force the viewer to update
  46395. * @param position defines the position of the viewer
  46396. * @param xaxis defines the x axis of the viewer
  46397. * @param yaxis defines the y axis of the viewer
  46398. * @param zaxis defines the z axis of the viewer
  46399. */
  46400. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46401. /**
  46402. * Creates an instance of this axes viewer.
  46403. * @returns a new axes viewer with instanced meshes
  46404. */
  46405. createInstance(): AxesViewer;
  46406. /** Releases resources */
  46407. dispose(): void;
  46408. private static _SetRenderingGroupId;
  46409. }
  46410. }
  46411. declare module BABYLON.Debug {
  46412. /**
  46413. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46414. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46415. */
  46416. export class BoneAxesViewer extends AxesViewer {
  46417. /**
  46418. * Gets or sets the target mesh where to display the axes viewer
  46419. */
  46420. mesh: Nullable<Mesh>;
  46421. /**
  46422. * Gets or sets the target bone where to display the axes viewer
  46423. */
  46424. bone: Nullable<Bone>;
  46425. /** Gets current position */
  46426. pos: Vector3;
  46427. /** Gets direction of X axis */
  46428. xaxis: Vector3;
  46429. /** Gets direction of Y axis */
  46430. yaxis: Vector3;
  46431. /** Gets direction of Z axis */
  46432. zaxis: Vector3;
  46433. /**
  46434. * Creates a new BoneAxesViewer
  46435. * @param scene defines the hosting scene
  46436. * @param bone defines the target bone
  46437. * @param mesh defines the target mesh
  46438. * @param scaleLines defines a scaling factor for line length (1 by default)
  46439. */
  46440. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46441. /**
  46442. * Force the viewer to update
  46443. */
  46444. update(): void;
  46445. /** Releases resources */
  46446. dispose(): void;
  46447. }
  46448. }
  46449. declare module BABYLON {
  46450. /**
  46451. * Interface used to define scene explorer extensibility option
  46452. */
  46453. export interface IExplorerExtensibilityOption {
  46454. /**
  46455. * Define the option label
  46456. */
  46457. label: string;
  46458. /**
  46459. * Defines the action to execute on click
  46460. */
  46461. action: (entity: any) => void;
  46462. }
  46463. /**
  46464. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46465. */
  46466. export interface IExplorerExtensibilityGroup {
  46467. /**
  46468. * Defines a predicate to test if a given type mut be extended
  46469. */
  46470. predicate: (entity: any) => boolean;
  46471. /**
  46472. * Gets the list of options added to a type
  46473. */
  46474. entries: IExplorerExtensibilityOption[];
  46475. }
  46476. /**
  46477. * Interface used to define the options to use to create the Inspector
  46478. */
  46479. export interface IInspectorOptions {
  46480. /**
  46481. * Display in overlay mode (default: false)
  46482. */
  46483. overlay?: boolean;
  46484. /**
  46485. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46486. */
  46487. globalRoot?: HTMLElement;
  46488. /**
  46489. * Display the Scene explorer
  46490. */
  46491. showExplorer?: boolean;
  46492. /**
  46493. * Display the property inspector
  46494. */
  46495. showInspector?: boolean;
  46496. /**
  46497. * Display in embed mode (both panes on the right)
  46498. */
  46499. embedMode?: boolean;
  46500. /**
  46501. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46502. */
  46503. handleResize?: boolean;
  46504. /**
  46505. * Allow the panes to popup (default: true)
  46506. */
  46507. enablePopup?: boolean;
  46508. /**
  46509. * Allow the panes to be closed by users (default: true)
  46510. */
  46511. enableClose?: boolean;
  46512. /**
  46513. * Optional list of extensibility entries
  46514. */
  46515. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46516. /**
  46517. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46518. */
  46519. inspectorURL?: string;
  46520. /**
  46521. * Optional initial tab (default to DebugLayerTab.Properties)
  46522. */
  46523. initialTab?: DebugLayerTab;
  46524. }
  46525. interface Scene {
  46526. /**
  46527. * @hidden
  46528. * Backing field
  46529. */
  46530. _debugLayer: DebugLayer;
  46531. /**
  46532. * Gets the debug layer (aka Inspector) associated with the scene
  46533. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46534. */
  46535. debugLayer: DebugLayer;
  46536. }
  46537. /**
  46538. * Enum of inspector action tab
  46539. */
  46540. export enum DebugLayerTab {
  46541. /**
  46542. * Properties tag (default)
  46543. */
  46544. Properties = 0,
  46545. /**
  46546. * Debug tab
  46547. */
  46548. Debug = 1,
  46549. /**
  46550. * Statistics tab
  46551. */
  46552. Statistics = 2,
  46553. /**
  46554. * Tools tab
  46555. */
  46556. Tools = 3,
  46557. /**
  46558. * Settings tab
  46559. */
  46560. Settings = 4
  46561. }
  46562. /**
  46563. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46564. * what is happening in your scene
  46565. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46566. */
  46567. export class DebugLayer {
  46568. /**
  46569. * Define the url to get the inspector script from.
  46570. * By default it uses the babylonjs CDN.
  46571. * @ignoreNaming
  46572. */
  46573. static InspectorURL: string;
  46574. private _scene;
  46575. private BJSINSPECTOR;
  46576. private _onPropertyChangedObservable?;
  46577. /**
  46578. * Observable triggered when a property is changed through the inspector.
  46579. */
  46580. get onPropertyChangedObservable(): any;
  46581. /**
  46582. * Instantiates a new debug layer.
  46583. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46584. * what is happening in your scene
  46585. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46586. * @param scene Defines the scene to inspect
  46587. */
  46588. constructor(scene: Scene);
  46589. /** Creates the inspector window. */
  46590. private _createInspector;
  46591. /**
  46592. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46593. * @param entity defines the entity to select
  46594. * @param lineContainerTitle defines the specific block to highlight
  46595. */
  46596. select(entity: any, lineContainerTitle?: string): void;
  46597. /** Get the inspector from bundle or global */
  46598. private _getGlobalInspector;
  46599. /**
  46600. * Get if the inspector is visible or not.
  46601. * @returns true if visible otherwise, false
  46602. */
  46603. isVisible(): boolean;
  46604. /**
  46605. * Hide the inspector and close its window.
  46606. */
  46607. hide(): void;
  46608. /**
  46609. * Launch the debugLayer.
  46610. * @param config Define the configuration of the inspector
  46611. * @return a promise fulfilled when the debug layer is visible
  46612. */
  46613. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46614. }
  46615. }
  46616. declare module BABYLON {
  46617. /**
  46618. * Class containing static functions to help procedurally build meshes
  46619. */
  46620. export class BoxBuilder {
  46621. /**
  46622. * Creates a box mesh
  46623. * * The parameter `size` sets the size (float) of each box side (default 1)
  46624. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46625. * * 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)
  46626. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46628. * * 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
  46629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46630. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46631. * @param name defines the name of the mesh
  46632. * @param options defines the options used to create the mesh
  46633. * @param scene defines the hosting scene
  46634. * @returns the box mesh
  46635. */
  46636. static CreateBox(name: string, options: {
  46637. size?: number;
  46638. width?: number;
  46639. height?: number;
  46640. depth?: number;
  46641. faceUV?: Vector4[];
  46642. faceColors?: Color4[];
  46643. sideOrientation?: number;
  46644. frontUVs?: Vector4;
  46645. backUVs?: Vector4;
  46646. wrap?: boolean;
  46647. topBaseAt?: number;
  46648. bottomBaseAt?: number;
  46649. updatable?: boolean;
  46650. }, scene?: Nullable<Scene>): Mesh;
  46651. }
  46652. }
  46653. declare module BABYLON.Debug {
  46654. /**
  46655. * Used to show the physics impostor around the specific mesh
  46656. */
  46657. export class PhysicsViewer {
  46658. /** @hidden */
  46659. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46660. /** @hidden */
  46661. protected _meshes: Array<Nullable<AbstractMesh>>;
  46662. /** @hidden */
  46663. protected _scene: Nullable<Scene>;
  46664. /** @hidden */
  46665. protected _numMeshes: number;
  46666. /** @hidden */
  46667. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46668. private _renderFunction;
  46669. private _utilityLayer;
  46670. private _debugBoxMesh;
  46671. private _debugSphereMesh;
  46672. private _debugCylinderMesh;
  46673. private _debugMaterial;
  46674. private _debugMeshMeshes;
  46675. /**
  46676. * Creates a new PhysicsViewer
  46677. * @param scene defines the hosting scene
  46678. */
  46679. constructor(scene: Scene);
  46680. /** @hidden */
  46681. protected _updateDebugMeshes(): void;
  46682. /**
  46683. * Renders a specified physic impostor
  46684. * @param impostor defines the impostor to render
  46685. * @param targetMesh defines the mesh represented by the impostor
  46686. * @returns the new debug mesh used to render the impostor
  46687. */
  46688. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46689. /**
  46690. * Hides a specified physic impostor
  46691. * @param impostor defines the impostor to hide
  46692. */
  46693. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46694. private _getDebugMaterial;
  46695. private _getDebugBoxMesh;
  46696. private _getDebugSphereMesh;
  46697. private _getDebugCylinderMesh;
  46698. private _getDebugMeshMesh;
  46699. private _getDebugMesh;
  46700. /** Releases all resources */
  46701. dispose(): void;
  46702. }
  46703. }
  46704. declare module BABYLON {
  46705. /**
  46706. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46707. * in order to better appreciate the issue one might have.
  46708. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46709. */
  46710. export class RayHelper {
  46711. /**
  46712. * Defines the ray we are currently tryin to visualize.
  46713. */
  46714. ray: Nullable<Ray>;
  46715. private _renderPoints;
  46716. private _renderLine;
  46717. private _renderFunction;
  46718. private _scene;
  46719. private _updateToMeshFunction;
  46720. private _attachedToMesh;
  46721. private _meshSpaceDirection;
  46722. private _meshSpaceOrigin;
  46723. /**
  46724. * Helper function to create a colored helper in a scene in one line.
  46725. * @param ray Defines the ray we are currently tryin to visualize
  46726. * @param scene Defines the scene the ray is used in
  46727. * @param color Defines the color we want to see the ray in
  46728. * @returns The newly created ray helper.
  46729. */
  46730. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46731. /**
  46732. * Instantiate a new ray helper.
  46733. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46734. * in order to better appreciate the issue one might have.
  46735. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46736. * @param ray Defines the ray we are currently tryin to visualize
  46737. */
  46738. constructor(ray: Ray);
  46739. /**
  46740. * Shows the ray we are willing to debug.
  46741. * @param scene Defines the scene the ray needs to be rendered in
  46742. * @param color Defines the color the ray needs to be rendered in
  46743. */
  46744. show(scene: Scene, color?: Color3): void;
  46745. /**
  46746. * Hides the ray we are debugging.
  46747. */
  46748. hide(): void;
  46749. private _render;
  46750. /**
  46751. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46752. * @param mesh Defines the mesh we want the helper attached to
  46753. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46754. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46755. * @param length Defines the length of the ray
  46756. */
  46757. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46758. /**
  46759. * Detach the ray helper from the mesh it has previously been attached to.
  46760. */
  46761. detachFromMesh(): void;
  46762. private _updateToMesh;
  46763. /**
  46764. * Dispose the helper and release its associated resources.
  46765. */
  46766. dispose(): void;
  46767. }
  46768. }
  46769. declare module BABYLON.Debug {
  46770. /**
  46771. * Class used to render a debug view of a given skeleton
  46772. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46773. */
  46774. export class SkeletonViewer {
  46775. /** defines the skeleton to render */
  46776. skeleton: Skeleton;
  46777. /** defines the mesh attached to the skeleton */
  46778. mesh: AbstractMesh;
  46779. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46780. autoUpdateBonesMatrices: boolean;
  46781. /** defines the rendering group id to use with the viewer */
  46782. renderingGroupId: number;
  46783. /** Gets or sets the color used to render the skeleton */
  46784. color: Color3;
  46785. private _scene;
  46786. private _debugLines;
  46787. private _debugMesh;
  46788. private _isEnabled;
  46789. private _renderFunction;
  46790. private _utilityLayer;
  46791. /**
  46792. * Returns the mesh used to render the bones
  46793. */
  46794. get debugMesh(): Nullable<LinesMesh>;
  46795. /**
  46796. * Creates a new SkeletonViewer
  46797. * @param skeleton defines the skeleton to render
  46798. * @param mesh defines the mesh attached to the skeleton
  46799. * @param scene defines the hosting scene
  46800. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46801. * @param renderingGroupId defines the rendering group id to use with the viewer
  46802. */
  46803. constructor(
  46804. /** defines the skeleton to render */
  46805. skeleton: Skeleton,
  46806. /** defines the mesh attached to the skeleton */
  46807. mesh: AbstractMesh, scene: Scene,
  46808. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46809. autoUpdateBonesMatrices?: boolean,
  46810. /** defines the rendering group id to use with the viewer */
  46811. renderingGroupId?: number);
  46812. /** Gets or sets a boolean indicating if the viewer is enabled */
  46813. set isEnabled(value: boolean);
  46814. get isEnabled(): boolean;
  46815. private _getBonePosition;
  46816. private _getLinesForBonesWithLength;
  46817. private _getLinesForBonesNoLength;
  46818. /** Update the viewer to sync with current skeleton state */
  46819. update(): void;
  46820. /** Release associated resources */
  46821. dispose(): void;
  46822. }
  46823. }
  46824. declare module BABYLON {
  46825. /**
  46826. * Options to create the null engine
  46827. */
  46828. export class NullEngineOptions {
  46829. /**
  46830. * Render width (Default: 512)
  46831. */
  46832. renderWidth: number;
  46833. /**
  46834. * Render height (Default: 256)
  46835. */
  46836. renderHeight: number;
  46837. /**
  46838. * Texture size (Default: 512)
  46839. */
  46840. textureSize: number;
  46841. /**
  46842. * If delta time between frames should be constant
  46843. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46844. */
  46845. deterministicLockstep: boolean;
  46846. /**
  46847. * Maximum about of steps between frames (Default: 4)
  46848. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46849. */
  46850. lockstepMaxSteps: number;
  46851. }
  46852. /**
  46853. * The null engine class provides support for headless version of babylon.js.
  46854. * This can be used in server side scenario or for testing purposes
  46855. */
  46856. export class NullEngine extends Engine {
  46857. private _options;
  46858. /**
  46859. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46860. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46861. * @returns true if engine is in deterministic lock step mode
  46862. */
  46863. isDeterministicLockStep(): boolean;
  46864. /**
  46865. * Gets the max steps when engine is running in deterministic lock step
  46866. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46867. * @returns the max steps
  46868. */
  46869. getLockstepMaxSteps(): number;
  46870. /**
  46871. * Gets the current hardware scaling level.
  46872. * By default the hardware scaling level is computed from the window device ratio.
  46873. * 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.
  46874. * @returns a number indicating the current hardware scaling level
  46875. */
  46876. getHardwareScalingLevel(): number;
  46877. constructor(options?: NullEngineOptions);
  46878. /**
  46879. * Creates a vertex buffer
  46880. * @param vertices the data for the vertex buffer
  46881. * @returns the new WebGL static buffer
  46882. */
  46883. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46884. /**
  46885. * Creates a new index buffer
  46886. * @param indices defines the content of the index buffer
  46887. * @param updatable defines if the index buffer must be updatable
  46888. * @returns a new webGL buffer
  46889. */
  46890. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46891. /**
  46892. * Clear the current render buffer or the current render target (if any is set up)
  46893. * @param color defines the color to use
  46894. * @param backBuffer defines if the back buffer must be cleared
  46895. * @param depth defines if the depth buffer must be cleared
  46896. * @param stencil defines if the stencil buffer must be cleared
  46897. */
  46898. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46899. /**
  46900. * Gets the current render width
  46901. * @param useScreen defines if screen size must be used (or the current render target if any)
  46902. * @returns a number defining the current render width
  46903. */
  46904. getRenderWidth(useScreen?: boolean): number;
  46905. /**
  46906. * Gets the current render height
  46907. * @param useScreen defines if screen size must be used (or the current render target if any)
  46908. * @returns a number defining the current render height
  46909. */
  46910. getRenderHeight(useScreen?: boolean): number;
  46911. /**
  46912. * Set the WebGL's viewport
  46913. * @param viewport defines the viewport element to be used
  46914. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46915. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46916. */
  46917. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46918. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46919. /**
  46920. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46921. * @param pipelineContext defines the pipeline context to use
  46922. * @param uniformsNames defines the list of uniform names
  46923. * @returns an array of webGL uniform locations
  46924. */
  46925. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46926. /**
  46927. * Gets the lsit of active attributes for a given webGL program
  46928. * @param pipelineContext defines the pipeline context to use
  46929. * @param attributesNames defines the list of attribute names to get
  46930. * @returns an array of indices indicating the offset of each attribute
  46931. */
  46932. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46933. /**
  46934. * Binds an effect to the webGL context
  46935. * @param effect defines the effect to bind
  46936. */
  46937. bindSamplers(effect: Effect): void;
  46938. /**
  46939. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46940. * @param effect defines the effect to activate
  46941. */
  46942. enableEffect(effect: Effect): void;
  46943. /**
  46944. * Set various states to the webGL context
  46945. * @param culling defines backface culling state
  46946. * @param zOffset defines the value to apply to zOffset (0 by default)
  46947. * @param force defines if states must be applied even if cache is up to date
  46948. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46949. */
  46950. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46951. /**
  46952. * Set the value of an uniform to an array of int32
  46953. * @param uniform defines the webGL uniform location where to store the value
  46954. * @param array defines the array of int32 to store
  46955. */
  46956. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46957. /**
  46958. * Set the value of an uniform to an array of int32 (stored as vec2)
  46959. * @param uniform defines the webGL uniform location where to store the value
  46960. * @param array defines the array of int32 to store
  46961. */
  46962. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46963. /**
  46964. * Set the value of an uniform to an array of int32 (stored as vec3)
  46965. * @param uniform defines the webGL uniform location where to store the value
  46966. * @param array defines the array of int32 to store
  46967. */
  46968. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46969. /**
  46970. * Set the value of an uniform to an array of int32 (stored as vec4)
  46971. * @param uniform defines the webGL uniform location where to store the value
  46972. * @param array defines the array of int32 to store
  46973. */
  46974. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46975. /**
  46976. * Set the value of an uniform to an array of float32
  46977. * @param uniform defines the webGL uniform location where to store the value
  46978. * @param array defines the array of float32 to store
  46979. */
  46980. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46981. /**
  46982. * Set the value of an uniform to an array of float32 (stored as vec2)
  46983. * @param uniform defines the webGL uniform location where to store the value
  46984. * @param array defines the array of float32 to store
  46985. */
  46986. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46987. /**
  46988. * Set the value of an uniform to an array of float32 (stored as vec3)
  46989. * @param uniform defines the webGL uniform location where to store the value
  46990. * @param array defines the array of float32 to store
  46991. */
  46992. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46993. /**
  46994. * Set the value of an uniform to an array of float32 (stored as vec4)
  46995. * @param uniform defines the webGL uniform location where to store the value
  46996. * @param array defines the array of float32 to store
  46997. */
  46998. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46999. /**
  47000. * Set the value of an uniform to an array of number
  47001. * @param uniform defines the webGL uniform location where to store the value
  47002. * @param array defines the array of number to store
  47003. */
  47004. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47005. /**
  47006. * Set the value of an uniform to an array of number (stored as vec2)
  47007. * @param uniform defines the webGL uniform location where to store the value
  47008. * @param array defines the array of number to store
  47009. */
  47010. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47011. /**
  47012. * Set the value of an uniform to an array of number (stored as vec3)
  47013. * @param uniform defines the webGL uniform location where to store the value
  47014. * @param array defines the array of number to store
  47015. */
  47016. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47017. /**
  47018. * Set the value of an uniform to an array of number (stored as vec4)
  47019. * @param uniform defines the webGL uniform location where to store the value
  47020. * @param array defines the array of number to store
  47021. */
  47022. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47023. /**
  47024. * Set the value of an uniform to an array of float32 (stored as matrices)
  47025. * @param uniform defines the webGL uniform location where to store the value
  47026. * @param matrices defines the array of float32 to store
  47027. */
  47028. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47029. /**
  47030. * Set the value of an uniform to a matrix (3x3)
  47031. * @param uniform defines the webGL uniform location where to store the value
  47032. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47033. */
  47034. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47035. /**
  47036. * Set the value of an uniform to a matrix (2x2)
  47037. * @param uniform defines the webGL uniform location where to store the value
  47038. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47039. */
  47040. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47041. /**
  47042. * Set the value of an uniform to a number (float)
  47043. * @param uniform defines the webGL uniform location where to store the value
  47044. * @param value defines the float number to store
  47045. */
  47046. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47047. /**
  47048. * Set the value of an uniform to a vec2
  47049. * @param uniform defines the webGL uniform location where to store the value
  47050. * @param x defines the 1st component of the value
  47051. * @param y defines the 2nd component of the value
  47052. */
  47053. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47054. /**
  47055. * Set the value of an uniform to a vec3
  47056. * @param uniform defines the webGL uniform location where to store the value
  47057. * @param x defines the 1st component of the value
  47058. * @param y defines the 2nd component of the value
  47059. * @param z defines the 3rd component of the value
  47060. */
  47061. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47062. /**
  47063. * Set the value of an uniform to a boolean
  47064. * @param uniform defines the webGL uniform location where to store the value
  47065. * @param bool defines the boolean to store
  47066. */
  47067. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47068. /**
  47069. * Set the value of an uniform to a vec4
  47070. * @param uniform defines the webGL uniform location where to store the value
  47071. * @param x defines the 1st component of the value
  47072. * @param y defines the 2nd component of the value
  47073. * @param z defines the 3rd component of the value
  47074. * @param w defines the 4th component of the value
  47075. */
  47076. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47077. /**
  47078. * Sets the current alpha mode
  47079. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47080. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47081. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47082. */
  47083. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47084. /**
  47085. * Bind webGl buffers directly to the webGL context
  47086. * @param vertexBuffers defines the vertex buffer to bind
  47087. * @param indexBuffer defines the index buffer to bind
  47088. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47089. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47090. * @param effect defines the effect associated with the vertex buffer
  47091. */
  47092. bindBuffers(vertexBuffers: {
  47093. [key: string]: VertexBuffer;
  47094. }, indexBuffer: DataBuffer, effect: Effect): void;
  47095. /**
  47096. * Force the entire cache to be cleared
  47097. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47098. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47099. */
  47100. wipeCaches(bruteForce?: boolean): void;
  47101. /**
  47102. * Send a draw order
  47103. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47104. * @param indexStart defines the starting index
  47105. * @param indexCount defines the number of index to draw
  47106. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47107. */
  47108. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47109. /**
  47110. * Draw a list of indexed primitives
  47111. * @param fillMode defines the primitive to use
  47112. * @param indexStart defines the starting index
  47113. * @param indexCount defines the number of index to draw
  47114. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47115. */
  47116. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47117. /**
  47118. * Draw a list of unindexed primitives
  47119. * @param fillMode defines the primitive to use
  47120. * @param verticesStart defines the index of first vertex to draw
  47121. * @param verticesCount defines the count of vertices to draw
  47122. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47123. */
  47124. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47125. /** @hidden */
  47126. _createTexture(): WebGLTexture;
  47127. /** @hidden */
  47128. _releaseTexture(texture: InternalTexture): void;
  47129. /**
  47130. * Usually called from Texture.ts.
  47131. * Passed information to create a WebGLTexture
  47132. * @param urlArg defines a value which contains one of the following:
  47133. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47134. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47135. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47136. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47137. * @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)
  47138. * @param scene needed for loading to the correct scene
  47139. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47140. * @param onLoad optional callback to be called upon successful completion
  47141. * @param onError optional callback to be called upon failure
  47142. * @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
  47143. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47144. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47145. * @param forcedExtension defines the extension to use to pick the right loader
  47146. * @param mimeType defines an optional mime type
  47147. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47148. */
  47149. 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;
  47150. /**
  47151. * Creates a new render target texture
  47152. * @param size defines the size of the texture
  47153. * @param options defines the options used to create the texture
  47154. * @returns a new render target texture stored in an InternalTexture
  47155. */
  47156. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47157. /**
  47158. * Update the sampling mode of a given texture
  47159. * @param samplingMode defines the required sampling mode
  47160. * @param texture defines the texture to update
  47161. */
  47162. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47163. /**
  47164. * Binds the frame buffer to the specified texture.
  47165. * @param texture The texture to render to or null for the default canvas
  47166. * @param faceIndex The face of the texture to render to in case of cube texture
  47167. * @param requiredWidth The width of the target to render to
  47168. * @param requiredHeight The height of the target to render to
  47169. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47170. * @param lodLevel defines le lod level to bind to the frame buffer
  47171. */
  47172. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47173. /**
  47174. * Unbind the current render target texture from the webGL context
  47175. * @param texture defines the render target texture to unbind
  47176. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47177. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47178. */
  47179. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47180. /**
  47181. * Creates a dynamic vertex buffer
  47182. * @param vertices the data for the dynamic vertex buffer
  47183. * @returns the new WebGL dynamic buffer
  47184. */
  47185. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47186. /**
  47187. * Update the content of a dynamic texture
  47188. * @param texture defines the texture to update
  47189. * @param canvas defines the canvas containing the source
  47190. * @param invertY defines if data must be stored with Y axis inverted
  47191. * @param premulAlpha defines if alpha is stored as premultiplied
  47192. * @param format defines the format of the data
  47193. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47194. */
  47195. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47196. /**
  47197. * Gets a boolean indicating if all created effects are ready
  47198. * @returns true if all effects are ready
  47199. */
  47200. areAllEffectsReady(): boolean;
  47201. /**
  47202. * @hidden
  47203. * Get the current error code of the webGL context
  47204. * @returns the error code
  47205. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47206. */
  47207. getError(): number;
  47208. /** @hidden */
  47209. _getUnpackAlignement(): number;
  47210. /** @hidden */
  47211. _unpackFlipY(value: boolean): void;
  47212. /**
  47213. * Update a dynamic index buffer
  47214. * @param indexBuffer defines the target index buffer
  47215. * @param indices defines the data to update
  47216. * @param offset defines the offset in the target index buffer where update should start
  47217. */
  47218. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47219. /**
  47220. * Updates a dynamic vertex buffer.
  47221. * @param vertexBuffer the vertex buffer to update
  47222. * @param vertices the data used to update the vertex buffer
  47223. * @param byteOffset the byte offset of the data (optional)
  47224. * @param byteLength the byte length of the data (optional)
  47225. */
  47226. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47227. /** @hidden */
  47228. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47229. /** @hidden */
  47230. _bindTexture(channel: number, texture: InternalTexture): void;
  47231. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47232. /**
  47233. * 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
  47234. */
  47235. releaseEffects(): void;
  47236. displayLoadingUI(): void;
  47237. hideLoadingUI(): void;
  47238. /** @hidden */
  47239. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47240. /** @hidden */
  47241. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47242. /** @hidden */
  47243. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47244. /** @hidden */
  47245. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47246. }
  47247. }
  47248. declare module BABYLON {
  47249. /**
  47250. * @hidden
  47251. **/
  47252. export class _TimeToken {
  47253. _startTimeQuery: Nullable<WebGLQuery>;
  47254. _endTimeQuery: Nullable<WebGLQuery>;
  47255. _timeElapsedQuery: Nullable<WebGLQuery>;
  47256. _timeElapsedQueryEnded: boolean;
  47257. }
  47258. }
  47259. declare module BABYLON {
  47260. /** @hidden */
  47261. export class _OcclusionDataStorage {
  47262. /** @hidden */
  47263. occlusionInternalRetryCounter: number;
  47264. /** @hidden */
  47265. isOcclusionQueryInProgress: boolean;
  47266. /** @hidden */
  47267. isOccluded: boolean;
  47268. /** @hidden */
  47269. occlusionRetryCount: number;
  47270. /** @hidden */
  47271. occlusionType: number;
  47272. /** @hidden */
  47273. occlusionQueryAlgorithmType: number;
  47274. }
  47275. interface Engine {
  47276. /**
  47277. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47278. * @return the new query
  47279. */
  47280. createQuery(): WebGLQuery;
  47281. /**
  47282. * Delete and release a webGL query
  47283. * @param query defines the query to delete
  47284. * @return the current engine
  47285. */
  47286. deleteQuery(query: WebGLQuery): Engine;
  47287. /**
  47288. * Check if a given query has resolved and got its value
  47289. * @param query defines the query to check
  47290. * @returns true if the query got its value
  47291. */
  47292. isQueryResultAvailable(query: WebGLQuery): boolean;
  47293. /**
  47294. * Gets the value of a given query
  47295. * @param query defines the query to check
  47296. * @returns the value of the query
  47297. */
  47298. getQueryResult(query: WebGLQuery): number;
  47299. /**
  47300. * Initiates an occlusion query
  47301. * @param algorithmType defines the algorithm to use
  47302. * @param query defines the query to use
  47303. * @returns the current engine
  47304. * @see http://doc.babylonjs.com/features/occlusionquery
  47305. */
  47306. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47307. /**
  47308. * Ends an occlusion query
  47309. * @see http://doc.babylonjs.com/features/occlusionquery
  47310. * @param algorithmType defines the algorithm to use
  47311. * @returns the current engine
  47312. */
  47313. endOcclusionQuery(algorithmType: number): Engine;
  47314. /**
  47315. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47316. * Please note that only one query can be issued at a time
  47317. * @returns a time token used to track the time span
  47318. */
  47319. startTimeQuery(): Nullable<_TimeToken>;
  47320. /**
  47321. * Ends a time query
  47322. * @param token defines the token used to measure the time span
  47323. * @returns the time spent (in ns)
  47324. */
  47325. endTimeQuery(token: _TimeToken): int;
  47326. /** @hidden */
  47327. _currentNonTimestampToken: Nullable<_TimeToken>;
  47328. /** @hidden */
  47329. _createTimeQuery(): WebGLQuery;
  47330. /** @hidden */
  47331. _deleteTimeQuery(query: WebGLQuery): void;
  47332. /** @hidden */
  47333. _getGlAlgorithmType(algorithmType: number): number;
  47334. /** @hidden */
  47335. _getTimeQueryResult(query: WebGLQuery): any;
  47336. /** @hidden */
  47337. _getTimeQueryAvailability(query: WebGLQuery): any;
  47338. }
  47339. interface AbstractMesh {
  47340. /**
  47341. * Backing filed
  47342. * @hidden
  47343. */
  47344. __occlusionDataStorage: _OcclusionDataStorage;
  47345. /**
  47346. * Access property
  47347. * @hidden
  47348. */
  47349. _occlusionDataStorage: _OcclusionDataStorage;
  47350. /**
  47351. * 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.
  47352. * The default value is -1 which means don't break the query and wait till the result
  47353. * @see http://doc.babylonjs.com/features/occlusionquery
  47354. */
  47355. occlusionRetryCount: number;
  47356. /**
  47357. * 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:
  47358. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47359. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47360. * * 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.
  47361. * @see http://doc.babylonjs.com/features/occlusionquery
  47362. */
  47363. occlusionType: number;
  47364. /**
  47365. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47366. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47367. * * 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.
  47368. * @see http://doc.babylonjs.com/features/occlusionquery
  47369. */
  47370. occlusionQueryAlgorithmType: number;
  47371. /**
  47372. * 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
  47373. * @see http://doc.babylonjs.com/features/occlusionquery
  47374. */
  47375. isOccluded: boolean;
  47376. /**
  47377. * Flag to check the progress status of the query
  47378. * @see http://doc.babylonjs.com/features/occlusionquery
  47379. */
  47380. isOcclusionQueryInProgress: boolean;
  47381. }
  47382. }
  47383. declare module BABYLON {
  47384. /** @hidden */
  47385. export var _forceTransformFeedbackToBundle: boolean;
  47386. interface Engine {
  47387. /**
  47388. * Creates a webGL transform feedback object
  47389. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47390. * @returns the webGL transform feedback object
  47391. */
  47392. createTransformFeedback(): WebGLTransformFeedback;
  47393. /**
  47394. * Delete a webGL transform feedback object
  47395. * @param value defines the webGL transform feedback object to delete
  47396. */
  47397. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47398. /**
  47399. * Bind a webGL transform feedback object to the webgl context
  47400. * @param value defines the webGL transform feedback object to bind
  47401. */
  47402. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47403. /**
  47404. * Begins a transform feedback operation
  47405. * @param usePoints defines if points or triangles must be used
  47406. */
  47407. beginTransformFeedback(usePoints: boolean): void;
  47408. /**
  47409. * Ends a transform feedback operation
  47410. */
  47411. endTransformFeedback(): void;
  47412. /**
  47413. * Specify the varyings to use with transform feedback
  47414. * @param program defines the associated webGL program
  47415. * @param value defines the list of strings representing the varying names
  47416. */
  47417. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47418. /**
  47419. * Bind a webGL buffer for a transform feedback operation
  47420. * @param value defines the webGL buffer to bind
  47421. */
  47422. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47423. }
  47424. }
  47425. declare module BABYLON {
  47426. /**
  47427. * Creation options of the multi render target texture.
  47428. */
  47429. export interface IMultiRenderTargetOptions {
  47430. /**
  47431. * Define if the texture needs to create mip maps after render.
  47432. */
  47433. generateMipMaps?: boolean;
  47434. /**
  47435. * Define the types of all the draw buffers we want to create
  47436. */
  47437. types?: number[];
  47438. /**
  47439. * Define the sampling modes of all the draw buffers we want to create
  47440. */
  47441. samplingModes?: number[];
  47442. /**
  47443. * Define if a depth buffer is required
  47444. */
  47445. generateDepthBuffer?: boolean;
  47446. /**
  47447. * Define if a stencil buffer is required
  47448. */
  47449. generateStencilBuffer?: boolean;
  47450. /**
  47451. * Define if a depth texture is required instead of a depth buffer
  47452. */
  47453. generateDepthTexture?: boolean;
  47454. /**
  47455. * Define the number of desired draw buffers
  47456. */
  47457. textureCount?: number;
  47458. /**
  47459. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47460. */
  47461. doNotChangeAspectRatio?: boolean;
  47462. /**
  47463. * Define the default type of the buffers we are creating
  47464. */
  47465. defaultType?: number;
  47466. }
  47467. /**
  47468. * A multi render target, like a render target provides the ability to render to a texture.
  47469. * Unlike the render target, it can render to several draw buffers in one draw.
  47470. * This is specially interesting in deferred rendering or for any effects requiring more than
  47471. * just one color from a single pass.
  47472. */
  47473. export class MultiRenderTarget extends RenderTargetTexture {
  47474. private _internalTextures;
  47475. private _textures;
  47476. private _multiRenderTargetOptions;
  47477. /**
  47478. * Get if draw buffers are currently supported by the used hardware and browser.
  47479. */
  47480. get isSupported(): boolean;
  47481. /**
  47482. * Get the list of textures generated by the multi render target.
  47483. */
  47484. get textures(): Texture[];
  47485. /**
  47486. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47487. */
  47488. get depthTexture(): Texture;
  47489. /**
  47490. * Set the wrapping mode on U of all the textures we are rendering to.
  47491. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47492. */
  47493. set wrapU(wrap: number);
  47494. /**
  47495. * Set the wrapping mode on V of all the textures we are rendering to.
  47496. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47497. */
  47498. set wrapV(wrap: number);
  47499. /**
  47500. * Instantiate a new multi render target texture.
  47501. * A multi render target, like a render target provides the ability to render to a texture.
  47502. * Unlike the render target, it can render to several draw buffers in one draw.
  47503. * This is specially interesting in deferred rendering or for any effects requiring more than
  47504. * just one color from a single pass.
  47505. * @param name Define the name of the texture
  47506. * @param size Define the size of the buffers to render to
  47507. * @param count Define the number of target we are rendering into
  47508. * @param scene Define the scene the texture belongs to
  47509. * @param options Define the options used to create the multi render target
  47510. */
  47511. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47512. /** @hidden */
  47513. _rebuild(): void;
  47514. private _createInternalTextures;
  47515. private _createTextures;
  47516. /**
  47517. * Define the number of samples used if MSAA is enabled.
  47518. */
  47519. get samples(): number;
  47520. set samples(value: number);
  47521. /**
  47522. * Resize all the textures in the multi render target.
  47523. * Be carrefull as it will recreate all the data in the new texture.
  47524. * @param size Define the new size
  47525. */
  47526. resize(size: any): void;
  47527. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47528. /**
  47529. * Dispose the render targets and their associated resources
  47530. */
  47531. dispose(): void;
  47532. /**
  47533. * Release all the underlying texture used as draw buffers.
  47534. */
  47535. releaseInternalTextures(): void;
  47536. }
  47537. }
  47538. declare module BABYLON {
  47539. interface ThinEngine {
  47540. /**
  47541. * Unbind a list of render target textures from the webGL context
  47542. * This is used only when drawBuffer extension or webGL2 are active
  47543. * @param textures defines the render target textures to unbind
  47544. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47545. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47546. */
  47547. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47548. /**
  47549. * Create a multi render target texture
  47550. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47551. * @param size defines the size of the texture
  47552. * @param options defines the creation options
  47553. * @returns the cube texture as an InternalTexture
  47554. */
  47555. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47556. /**
  47557. * Update the sample count for a given multiple render target texture
  47558. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47559. * @param textures defines the textures to update
  47560. * @param samples defines the sample count to set
  47561. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47562. */
  47563. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47564. }
  47565. }
  47566. declare module BABYLON {
  47567. /**
  47568. * Class used to define an additional view for the engine
  47569. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47570. */
  47571. export class EngineView {
  47572. /** Defines the canvas where to render the view */
  47573. target: HTMLCanvasElement;
  47574. /** Defines an optional camera used to render the view (will use active camera else) */
  47575. camera?: Camera;
  47576. }
  47577. interface Engine {
  47578. /**
  47579. * Gets or sets the HTML element to use for attaching events
  47580. */
  47581. inputElement: Nullable<HTMLElement>;
  47582. /**
  47583. * Gets the current engine view
  47584. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47585. */
  47586. activeView: Nullable<EngineView>;
  47587. /** Gets or sets the list of views */
  47588. views: EngineView[];
  47589. /**
  47590. * Register a new child canvas
  47591. * @param canvas defines the canvas to register
  47592. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47593. * @returns the associated view
  47594. */
  47595. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47596. /**
  47597. * Remove a registered child canvas
  47598. * @param canvas defines the canvas to remove
  47599. * @returns the current engine
  47600. */
  47601. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47602. }
  47603. }
  47604. declare module BABYLON {
  47605. interface Engine {
  47606. /** @hidden */
  47607. _excludedCompressedTextures: string[];
  47608. /** @hidden */
  47609. _textureFormatInUse: string;
  47610. /**
  47611. * Gets the list of texture formats supported
  47612. */
  47613. readonly texturesSupported: Array<string>;
  47614. /**
  47615. * Gets the texture format in use
  47616. */
  47617. readonly textureFormatInUse: Nullable<string>;
  47618. /**
  47619. * Set the compressed texture extensions or file names to skip.
  47620. *
  47621. * @param skippedFiles defines the list of those texture files you want to skip
  47622. * Example: [".dds", ".env", "myfile.png"]
  47623. */
  47624. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47625. /**
  47626. * Set the compressed texture format to use, based on the formats you have, and the formats
  47627. * supported by the hardware / browser.
  47628. *
  47629. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47630. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47631. * to API arguments needed to compressed textures. This puts the burden on the container
  47632. * generator to house the arcane code for determining these for current & future formats.
  47633. *
  47634. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47635. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47636. *
  47637. * Note: The result of this call is not taken into account when a texture is base64.
  47638. *
  47639. * @param formatsAvailable defines the list of those format families you have created
  47640. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47641. *
  47642. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47643. * @returns The extension selected.
  47644. */
  47645. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47646. }
  47647. }
  47648. declare module BABYLON {
  47649. /**
  47650. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47651. */
  47652. export interface CubeMapInfo {
  47653. /**
  47654. * The pixel array for the front face.
  47655. * This is stored in format, left to right, up to down format.
  47656. */
  47657. front: Nullable<ArrayBufferView>;
  47658. /**
  47659. * The pixel array for the back face.
  47660. * This is stored in format, left to right, up to down format.
  47661. */
  47662. back: Nullable<ArrayBufferView>;
  47663. /**
  47664. * The pixel array for the left face.
  47665. * This is stored in format, left to right, up to down format.
  47666. */
  47667. left: Nullable<ArrayBufferView>;
  47668. /**
  47669. * The pixel array for the right face.
  47670. * This is stored in format, left to right, up to down format.
  47671. */
  47672. right: Nullable<ArrayBufferView>;
  47673. /**
  47674. * The pixel array for the up face.
  47675. * This is stored in format, left to right, up to down format.
  47676. */
  47677. up: Nullable<ArrayBufferView>;
  47678. /**
  47679. * The pixel array for the down face.
  47680. * This is stored in format, left to right, up to down format.
  47681. */
  47682. down: Nullable<ArrayBufferView>;
  47683. /**
  47684. * The size of the cubemap stored.
  47685. *
  47686. * Each faces will be size * size pixels.
  47687. */
  47688. size: number;
  47689. /**
  47690. * The format of the texture.
  47691. *
  47692. * RGBA, RGB.
  47693. */
  47694. format: number;
  47695. /**
  47696. * The type of the texture data.
  47697. *
  47698. * UNSIGNED_INT, FLOAT.
  47699. */
  47700. type: number;
  47701. /**
  47702. * Specifies whether the texture is in gamma space.
  47703. */
  47704. gammaSpace: boolean;
  47705. }
  47706. /**
  47707. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47708. */
  47709. export class PanoramaToCubeMapTools {
  47710. private static FACE_FRONT;
  47711. private static FACE_BACK;
  47712. private static FACE_RIGHT;
  47713. private static FACE_LEFT;
  47714. private static FACE_DOWN;
  47715. private static FACE_UP;
  47716. /**
  47717. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47718. *
  47719. * @param float32Array The source data.
  47720. * @param inputWidth The width of the input panorama.
  47721. * @param inputHeight The height of the input panorama.
  47722. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47723. * @return The cubemap data
  47724. */
  47725. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47726. private static CreateCubemapTexture;
  47727. private static CalcProjectionSpherical;
  47728. }
  47729. }
  47730. declare module BABYLON {
  47731. /**
  47732. * Helper class dealing with the extraction of spherical polynomial dataArray
  47733. * from a cube map.
  47734. */
  47735. export class CubeMapToSphericalPolynomialTools {
  47736. private static FileFaces;
  47737. /**
  47738. * Converts a texture to the according Spherical Polynomial data.
  47739. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47740. *
  47741. * @param texture The texture to extract the information from.
  47742. * @return The Spherical Polynomial data.
  47743. */
  47744. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47745. /**
  47746. * Converts a cubemap to the according Spherical Polynomial data.
  47747. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47748. *
  47749. * @param cubeInfo The Cube map to extract the information from.
  47750. * @return The Spherical Polynomial data.
  47751. */
  47752. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47753. }
  47754. }
  47755. declare module BABYLON {
  47756. interface BaseTexture {
  47757. /**
  47758. * Get the polynomial representation of the texture data.
  47759. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47760. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47761. */
  47762. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47763. }
  47764. }
  47765. declare module BABYLON {
  47766. /** @hidden */
  47767. export var rgbdEncodePixelShader: {
  47768. name: string;
  47769. shader: string;
  47770. };
  47771. }
  47772. declare module BABYLON {
  47773. /** @hidden */
  47774. export var rgbdDecodePixelShader: {
  47775. name: string;
  47776. shader: string;
  47777. };
  47778. }
  47779. declare module BABYLON {
  47780. /**
  47781. * Raw texture data and descriptor sufficient for WebGL texture upload
  47782. */
  47783. export interface EnvironmentTextureInfo {
  47784. /**
  47785. * Version of the environment map
  47786. */
  47787. version: number;
  47788. /**
  47789. * Width of image
  47790. */
  47791. width: number;
  47792. /**
  47793. * Irradiance information stored in the file.
  47794. */
  47795. irradiance: any;
  47796. /**
  47797. * Specular information stored in the file.
  47798. */
  47799. specular: any;
  47800. }
  47801. /**
  47802. * Defines One Image in the file. It requires only the position in the file
  47803. * as well as the length.
  47804. */
  47805. interface BufferImageData {
  47806. /**
  47807. * Length of the image data.
  47808. */
  47809. length: number;
  47810. /**
  47811. * Position of the data from the null terminator delimiting the end of the JSON.
  47812. */
  47813. position: number;
  47814. }
  47815. /**
  47816. * Defines the specular data enclosed in the file.
  47817. * This corresponds to the version 1 of the data.
  47818. */
  47819. export interface EnvironmentTextureSpecularInfoV1 {
  47820. /**
  47821. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47822. */
  47823. specularDataPosition?: number;
  47824. /**
  47825. * This contains all the images data needed to reconstruct the cubemap.
  47826. */
  47827. mipmaps: Array<BufferImageData>;
  47828. /**
  47829. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47830. */
  47831. lodGenerationScale: number;
  47832. }
  47833. /**
  47834. * Sets of helpers addressing the serialization and deserialization of environment texture
  47835. * stored in a BabylonJS env file.
  47836. * Those files are usually stored as .env files.
  47837. */
  47838. export class EnvironmentTextureTools {
  47839. /**
  47840. * Magic number identifying the env file.
  47841. */
  47842. private static _MagicBytes;
  47843. /**
  47844. * Gets the environment info from an env file.
  47845. * @param data The array buffer containing the .env bytes.
  47846. * @returns the environment file info (the json header) if successfully parsed.
  47847. */
  47848. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47849. /**
  47850. * Creates an environment texture from a loaded cube texture.
  47851. * @param texture defines the cube texture to convert in env file
  47852. * @return a promise containing the environment data if succesfull.
  47853. */
  47854. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47855. /**
  47856. * Creates a JSON representation of the spherical data.
  47857. * @param texture defines the texture containing the polynomials
  47858. * @return the JSON representation of the spherical info
  47859. */
  47860. private static _CreateEnvTextureIrradiance;
  47861. /**
  47862. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47863. * @param data the image data
  47864. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47865. * @return the views described by info providing access to the underlying buffer
  47866. */
  47867. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47868. /**
  47869. * Uploads the texture info contained in the env file to the GPU.
  47870. * @param texture defines the internal texture to upload to
  47871. * @param data defines the data to load
  47872. * @param info defines the texture info retrieved through the GetEnvInfo method
  47873. * @returns a promise
  47874. */
  47875. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47876. private static _OnImageReadyAsync;
  47877. /**
  47878. * Uploads the levels of image data to the GPU.
  47879. * @param texture defines the internal texture to upload to
  47880. * @param imageData defines the array buffer views of image data [mipmap][face]
  47881. * @returns a promise
  47882. */
  47883. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47884. /**
  47885. * Uploads spherical polynomials information to the texture.
  47886. * @param texture defines the texture we are trying to upload the information to
  47887. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47888. */
  47889. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47890. /** @hidden */
  47891. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47892. }
  47893. }
  47894. declare module BABYLON {
  47895. /**
  47896. * Contains position and normal vectors for a vertex
  47897. */
  47898. export class PositionNormalVertex {
  47899. /** the position of the vertex (defaut: 0,0,0) */
  47900. position: Vector3;
  47901. /** the normal of the vertex (defaut: 0,1,0) */
  47902. normal: Vector3;
  47903. /**
  47904. * Creates a PositionNormalVertex
  47905. * @param position the position of the vertex (defaut: 0,0,0)
  47906. * @param normal the normal of the vertex (defaut: 0,1,0)
  47907. */
  47908. constructor(
  47909. /** the position of the vertex (defaut: 0,0,0) */
  47910. position?: Vector3,
  47911. /** the normal of the vertex (defaut: 0,1,0) */
  47912. normal?: Vector3);
  47913. /**
  47914. * Clones the PositionNormalVertex
  47915. * @returns the cloned PositionNormalVertex
  47916. */
  47917. clone(): PositionNormalVertex;
  47918. }
  47919. /**
  47920. * Contains position, normal and uv vectors for a vertex
  47921. */
  47922. export class PositionNormalTextureVertex {
  47923. /** the position of the vertex (defaut: 0,0,0) */
  47924. position: Vector3;
  47925. /** the normal of the vertex (defaut: 0,1,0) */
  47926. normal: Vector3;
  47927. /** the uv of the vertex (default: 0,0) */
  47928. uv: Vector2;
  47929. /**
  47930. * Creates a PositionNormalTextureVertex
  47931. * @param position the position of the vertex (defaut: 0,0,0)
  47932. * @param normal the normal of the vertex (defaut: 0,1,0)
  47933. * @param uv the uv of the vertex (default: 0,0)
  47934. */
  47935. constructor(
  47936. /** the position of the vertex (defaut: 0,0,0) */
  47937. position?: Vector3,
  47938. /** the normal of the vertex (defaut: 0,1,0) */
  47939. normal?: Vector3,
  47940. /** the uv of the vertex (default: 0,0) */
  47941. uv?: Vector2);
  47942. /**
  47943. * Clones the PositionNormalTextureVertex
  47944. * @returns the cloned PositionNormalTextureVertex
  47945. */
  47946. clone(): PositionNormalTextureVertex;
  47947. }
  47948. }
  47949. declare module BABYLON {
  47950. /** @hidden */
  47951. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47952. private _genericAttributeLocation;
  47953. private _varyingLocationCount;
  47954. private _varyingLocationMap;
  47955. private _replacements;
  47956. private _textureCount;
  47957. private _uniforms;
  47958. lineProcessor(line: string): string;
  47959. attributeProcessor(attribute: string): string;
  47960. varyingProcessor(varying: string, isFragment: boolean): string;
  47961. uniformProcessor(uniform: string): string;
  47962. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47963. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47964. }
  47965. }
  47966. declare module BABYLON {
  47967. /**
  47968. * Container for accessors for natively-stored mesh data buffers.
  47969. */
  47970. class NativeDataBuffer extends DataBuffer {
  47971. /**
  47972. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47973. */
  47974. nativeIndexBuffer?: any;
  47975. /**
  47976. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47977. */
  47978. nativeVertexBuffer?: any;
  47979. }
  47980. /** @hidden */
  47981. class NativeTexture extends InternalTexture {
  47982. getInternalTexture(): InternalTexture;
  47983. getViewCount(): number;
  47984. }
  47985. /** @hidden */
  47986. export class NativeEngine extends Engine {
  47987. private readonly _native;
  47988. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47989. private readonly INVALID_HANDLE;
  47990. getHardwareScalingLevel(): number;
  47991. constructor();
  47992. /**
  47993. * Can be used to override the current requestAnimationFrame requester.
  47994. * @hidden
  47995. */
  47996. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47997. /**
  47998. * Override default engine behavior.
  47999. * @param color
  48000. * @param backBuffer
  48001. * @param depth
  48002. * @param stencil
  48003. */
  48004. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48005. /**
  48006. * Gets host document
  48007. * @returns the host document object
  48008. */
  48009. getHostDocument(): Nullable<Document>;
  48010. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48011. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48012. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48013. recordVertexArrayObject(vertexBuffers: {
  48014. [key: string]: VertexBuffer;
  48015. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48016. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48017. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48018. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48019. /**
  48020. * Draw a list of indexed primitives
  48021. * @param fillMode defines the primitive to use
  48022. * @param indexStart defines the starting index
  48023. * @param indexCount defines the number of index to draw
  48024. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48025. */
  48026. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48027. /**
  48028. * Draw a list of unindexed primitives
  48029. * @param fillMode defines the primitive to use
  48030. * @param verticesStart defines the index of first vertex to draw
  48031. * @param verticesCount defines the count of vertices to draw
  48032. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48033. */
  48034. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48035. createPipelineContext(): IPipelineContext;
  48036. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48037. /** @hidden */
  48038. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48039. /** @hidden */
  48040. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48041. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48042. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48043. protected _setProgram(program: WebGLProgram): void;
  48044. _releaseEffect(effect: Effect): void;
  48045. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48046. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48047. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48048. bindSamplers(effect: Effect): void;
  48049. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48050. getRenderWidth(useScreen?: boolean): number;
  48051. getRenderHeight(useScreen?: boolean): number;
  48052. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48053. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48054. /**
  48055. * Set the z offset to apply to current rendering
  48056. * @param value defines the offset to apply
  48057. */
  48058. setZOffset(value: number): void;
  48059. /**
  48060. * Gets the current value of the zOffset
  48061. * @returns the current zOffset state
  48062. */
  48063. getZOffset(): number;
  48064. /**
  48065. * Enable or disable depth buffering
  48066. * @param enable defines the state to set
  48067. */
  48068. setDepthBuffer(enable: boolean): void;
  48069. /**
  48070. * Gets a boolean indicating if depth writing is enabled
  48071. * @returns the current depth writing state
  48072. */
  48073. getDepthWrite(): boolean;
  48074. /**
  48075. * Enable or disable depth writing
  48076. * @param enable defines the state to set
  48077. */
  48078. setDepthWrite(enable: boolean): void;
  48079. /**
  48080. * Enable or disable color writing
  48081. * @param enable defines the state to set
  48082. */
  48083. setColorWrite(enable: boolean): void;
  48084. /**
  48085. * Gets a boolean indicating if color writing is enabled
  48086. * @returns the current color writing state
  48087. */
  48088. getColorWrite(): boolean;
  48089. /**
  48090. * Sets alpha constants used by some alpha blending modes
  48091. * @param r defines the red component
  48092. * @param g defines the green component
  48093. * @param b defines the blue component
  48094. * @param a defines the alpha component
  48095. */
  48096. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48097. /**
  48098. * Sets the current alpha mode
  48099. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48100. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48101. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48102. */
  48103. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48104. /**
  48105. * Gets the current alpha mode
  48106. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48107. * @returns the current alpha mode
  48108. */
  48109. getAlphaMode(): number;
  48110. setInt(uniform: WebGLUniformLocation, int: number): void;
  48111. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48112. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48113. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48114. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48115. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48116. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48117. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48118. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48119. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48120. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48121. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48122. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48123. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48124. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48125. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48126. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48127. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48128. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48129. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48130. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48131. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48132. wipeCaches(bruteForce?: boolean): void;
  48133. _createTexture(): WebGLTexture;
  48134. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48135. /**
  48136. * Usually called from Texture.ts.
  48137. * Passed information to create a WebGLTexture
  48138. * @param urlArg defines a value which contains one of the following:
  48139. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48140. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48141. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48142. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48143. * @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)
  48144. * @param scene needed for loading to the correct scene
  48145. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48146. * @param onLoad optional callback to be called upon successful completion
  48147. * @param onError optional callback to be called upon failure
  48148. * @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
  48149. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48150. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48151. * @param forcedExtension defines the extension to use to pick the right loader
  48152. * @param mimeType defines an optional mime type
  48153. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48154. */
  48155. 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;
  48156. /**
  48157. * Creates a cube texture
  48158. * @param rootUrl defines the url where the files to load is located
  48159. * @param scene defines the current scene
  48160. * @param files defines the list of files to load (1 per face)
  48161. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48162. * @param onLoad defines an optional callback raised when the texture is loaded
  48163. * @param onError defines an optional callback raised if there is an issue to load the texture
  48164. * @param format defines the format of the data
  48165. * @param forcedExtension defines the extension to use to pick the right loader
  48166. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48167. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48168. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48169. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48170. * @returns the cube texture as an InternalTexture
  48171. */
  48172. 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;
  48173. private _getSamplingFilter;
  48174. private static _GetNativeTextureFormat;
  48175. createRenderTargetTexture(size: number | {
  48176. width: number;
  48177. height: number;
  48178. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48179. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48180. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48181. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48182. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48183. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48184. /**
  48185. * Updates a dynamic vertex buffer.
  48186. * @param vertexBuffer the vertex buffer to update
  48187. * @param data the data used to update the vertex buffer
  48188. * @param byteOffset the byte offset of the data (optional)
  48189. * @param byteLength the byte length of the data (optional)
  48190. */
  48191. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48192. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48193. private _updateAnisotropicLevel;
  48194. private _getAddressMode;
  48195. /** @hidden */
  48196. _bindTexture(channel: number, texture: InternalTexture): void;
  48197. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48198. releaseEffects(): void;
  48199. /** @hidden */
  48200. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48201. /** @hidden */
  48202. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48203. /** @hidden */
  48204. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48205. /** @hidden */
  48206. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48207. }
  48208. }
  48209. declare module BABYLON {
  48210. /**
  48211. * Gather the list of clipboard event types as constants.
  48212. */
  48213. export class ClipboardEventTypes {
  48214. /**
  48215. * The clipboard event is fired when a copy command is active (pressed).
  48216. */
  48217. static readonly COPY: number;
  48218. /**
  48219. * The clipboard event is fired when a cut command is active (pressed).
  48220. */
  48221. static readonly CUT: number;
  48222. /**
  48223. * The clipboard event is fired when a paste command is active (pressed).
  48224. */
  48225. static readonly PASTE: number;
  48226. }
  48227. /**
  48228. * This class is used to store clipboard related info for the onClipboardObservable event.
  48229. */
  48230. export class ClipboardInfo {
  48231. /**
  48232. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48233. */
  48234. type: number;
  48235. /**
  48236. * Defines the related dom event
  48237. */
  48238. event: ClipboardEvent;
  48239. /**
  48240. *Creates an instance of ClipboardInfo.
  48241. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48242. * @param event Defines the related dom event
  48243. */
  48244. constructor(
  48245. /**
  48246. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48247. */
  48248. type: number,
  48249. /**
  48250. * Defines the related dom event
  48251. */
  48252. event: ClipboardEvent);
  48253. /**
  48254. * Get the clipboard event's type from the keycode.
  48255. * @param keyCode Defines the keyCode for the current keyboard event.
  48256. * @return {number}
  48257. */
  48258. static GetTypeFromCharacter(keyCode: number): number;
  48259. }
  48260. }
  48261. declare module BABYLON {
  48262. /**
  48263. * Google Daydream controller
  48264. */
  48265. export class DaydreamController extends WebVRController {
  48266. /**
  48267. * Base Url for the controller model.
  48268. */
  48269. static MODEL_BASE_URL: string;
  48270. /**
  48271. * File name for the controller model.
  48272. */
  48273. static MODEL_FILENAME: string;
  48274. /**
  48275. * Gamepad Id prefix used to identify Daydream Controller.
  48276. */
  48277. static readonly GAMEPAD_ID_PREFIX: string;
  48278. /**
  48279. * Creates a new DaydreamController from a gamepad
  48280. * @param vrGamepad the gamepad that the controller should be created from
  48281. */
  48282. constructor(vrGamepad: any);
  48283. /**
  48284. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48285. * @param scene scene in which to add meshes
  48286. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48287. */
  48288. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48289. /**
  48290. * Called once for each button that changed state since the last frame
  48291. * @param buttonIdx Which button index changed
  48292. * @param state New state of the button
  48293. * @param changes Which properties on the state changed since last frame
  48294. */
  48295. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48296. }
  48297. }
  48298. declare module BABYLON {
  48299. /**
  48300. * Gear VR Controller
  48301. */
  48302. export class GearVRController extends WebVRController {
  48303. /**
  48304. * Base Url for the controller model.
  48305. */
  48306. static MODEL_BASE_URL: string;
  48307. /**
  48308. * File name for the controller model.
  48309. */
  48310. static MODEL_FILENAME: string;
  48311. /**
  48312. * Gamepad Id prefix used to identify this controller.
  48313. */
  48314. static readonly GAMEPAD_ID_PREFIX: string;
  48315. private readonly _buttonIndexToObservableNameMap;
  48316. /**
  48317. * Creates a new GearVRController from a gamepad
  48318. * @param vrGamepad the gamepad that the controller should be created from
  48319. */
  48320. constructor(vrGamepad: any);
  48321. /**
  48322. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48323. * @param scene scene in which to add meshes
  48324. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48325. */
  48326. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48327. /**
  48328. * Called once for each button that changed state since the last frame
  48329. * @param buttonIdx Which button index changed
  48330. * @param state New state of the button
  48331. * @param changes Which properties on the state changed since last frame
  48332. */
  48333. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48334. }
  48335. }
  48336. declare module BABYLON {
  48337. /**
  48338. * Generic Controller
  48339. */
  48340. export class GenericController extends WebVRController {
  48341. /**
  48342. * Base Url for the controller model.
  48343. */
  48344. static readonly MODEL_BASE_URL: string;
  48345. /**
  48346. * File name for the controller model.
  48347. */
  48348. static readonly MODEL_FILENAME: string;
  48349. /**
  48350. * Creates a new GenericController from a gamepad
  48351. * @param vrGamepad the gamepad that the controller should be created from
  48352. */
  48353. constructor(vrGamepad: any);
  48354. /**
  48355. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48356. * @param scene scene in which to add meshes
  48357. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48358. */
  48359. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48360. /**
  48361. * Called once for each button that changed state since the last frame
  48362. * @param buttonIdx Which button index changed
  48363. * @param state New state of the button
  48364. * @param changes Which properties on the state changed since last frame
  48365. */
  48366. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48367. }
  48368. }
  48369. declare module BABYLON {
  48370. /**
  48371. * Oculus Touch Controller
  48372. */
  48373. export class OculusTouchController extends WebVRController {
  48374. /**
  48375. * Base Url for the controller model.
  48376. */
  48377. static MODEL_BASE_URL: string;
  48378. /**
  48379. * File name for the left controller model.
  48380. */
  48381. static MODEL_LEFT_FILENAME: string;
  48382. /**
  48383. * File name for the right controller model.
  48384. */
  48385. static MODEL_RIGHT_FILENAME: string;
  48386. /**
  48387. * Base Url for the Quest controller model.
  48388. */
  48389. static QUEST_MODEL_BASE_URL: string;
  48390. /**
  48391. * @hidden
  48392. * If the controllers are running on a device that needs the updated Quest controller models
  48393. */
  48394. static _IsQuest: boolean;
  48395. /**
  48396. * Fired when the secondary trigger on this controller is modified
  48397. */
  48398. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48399. /**
  48400. * Fired when the thumb rest on this controller is modified
  48401. */
  48402. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48403. /**
  48404. * Creates a new OculusTouchController from a gamepad
  48405. * @param vrGamepad the gamepad that the controller should be created from
  48406. */
  48407. constructor(vrGamepad: any);
  48408. /**
  48409. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48410. * @param scene scene in which to add meshes
  48411. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48412. */
  48413. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48414. /**
  48415. * Fired when the A button on this controller is modified
  48416. */
  48417. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48418. /**
  48419. * Fired when the B button on this controller is modified
  48420. */
  48421. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48422. /**
  48423. * Fired when the X button on this controller is modified
  48424. */
  48425. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48426. /**
  48427. * Fired when the Y button on this controller is modified
  48428. */
  48429. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48430. /**
  48431. * Called once for each button that changed state since the last frame
  48432. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48433. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48434. * 2) secondary trigger (same)
  48435. * 3) A (right) X (left), touch, pressed = value
  48436. * 4) B / Y
  48437. * 5) thumb rest
  48438. * @param buttonIdx Which button index changed
  48439. * @param state New state of the button
  48440. * @param changes Which properties on the state changed since last frame
  48441. */
  48442. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48443. }
  48444. }
  48445. declare module BABYLON {
  48446. /**
  48447. * Vive Controller
  48448. */
  48449. export class ViveController extends WebVRController {
  48450. /**
  48451. * Base Url for the controller model.
  48452. */
  48453. static MODEL_BASE_URL: string;
  48454. /**
  48455. * File name for the controller model.
  48456. */
  48457. static MODEL_FILENAME: string;
  48458. /**
  48459. * Creates a new ViveController from a gamepad
  48460. * @param vrGamepad the gamepad that the controller should be created from
  48461. */
  48462. constructor(vrGamepad: any);
  48463. /**
  48464. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48465. * @param scene scene in which to add meshes
  48466. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48467. */
  48468. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48469. /**
  48470. * Fired when the left button on this controller is modified
  48471. */
  48472. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48473. /**
  48474. * Fired when the right button on this controller is modified
  48475. */
  48476. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48477. /**
  48478. * Fired when the menu button on this controller is modified
  48479. */
  48480. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48481. /**
  48482. * Called once for each button that changed state since the last frame
  48483. * Vive mapping:
  48484. * 0: touchpad
  48485. * 1: trigger
  48486. * 2: left AND right buttons
  48487. * 3: menu button
  48488. * @param buttonIdx Which button index changed
  48489. * @param state New state of the button
  48490. * @param changes Which properties on the state changed since last frame
  48491. */
  48492. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48493. }
  48494. }
  48495. declare module BABYLON {
  48496. /**
  48497. * Defines the WindowsMotionController object that the state of the windows motion controller
  48498. */
  48499. export class WindowsMotionController extends WebVRController {
  48500. /**
  48501. * The base url used to load the left and right controller models
  48502. */
  48503. static MODEL_BASE_URL: string;
  48504. /**
  48505. * The name of the left controller model file
  48506. */
  48507. static MODEL_LEFT_FILENAME: string;
  48508. /**
  48509. * The name of the right controller model file
  48510. */
  48511. static MODEL_RIGHT_FILENAME: string;
  48512. /**
  48513. * The controller name prefix for this controller type
  48514. */
  48515. static readonly GAMEPAD_ID_PREFIX: string;
  48516. /**
  48517. * The controller id pattern for this controller type
  48518. */
  48519. private static readonly GAMEPAD_ID_PATTERN;
  48520. private _loadedMeshInfo;
  48521. protected readonly _mapping: {
  48522. buttons: string[];
  48523. buttonMeshNames: {
  48524. trigger: string;
  48525. menu: string;
  48526. grip: string;
  48527. thumbstick: string;
  48528. trackpad: string;
  48529. };
  48530. buttonObservableNames: {
  48531. trigger: string;
  48532. menu: string;
  48533. grip: string;
  48534. thumbstick: string;
  48535. trackpad: string;
  48536. };
  48537. axisMeshNames: string[];
  48538. pointingPoseMeshName: string;
  48539. };
  48540. /**
  48541. * Fired when the trackpad on this controller is clicked
  48542. */
  48543. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48544. /**
  48545. * Fired when the trackpad on this controller is modified
  48546. */
  48547. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48548. /**
  48549. * The current x and y values of this controller's trackpad
  48550. */
  48551. trackpad: StickValues;
  48552. /**
  48553. * Creates a new WindowsMotionController from a gamepad
  48554. * @param vrGamepad the gamepad that the controller should be created from
  48555. */
  48556. constructor(vrGamepad: any);
  48557. /**
  48558. * Fired when the trigger on this controller is modified
  48559. */
  48560. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48561. /**
  48562. * Fired when the menu button on this controller is modified
  48563. */
  48564. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48565. /**
  48566. * Fired when the grip button on this controller is modified
  48567. */
  48568. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48569. /**
  48570. * Fired when the thumbstick button on this controller is modified
  48571. */
  48572. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48573. /**
  48574. * Fired when the touchpad button on this controller is modified
  48575. */
  48576. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48577. /**
  48578. * Fired when the touchpad values on this controller are modified
  48579. */
  48580. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48581. protected _updateTrackpad(): void;
  48582. /**
  48583. * Called once per frame by the engine.
  48584. */
  48585. update(): void;
  48586. /**
  48587. * Called once for each button that changed state since the last frame
  48588. * @param buttonIdx Which button index changed
  48589. * @param state New state of the button
  48590. * @param changes Which properties on the state changed since last frame
  48591. */
  48592. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48593. /**
  48594. * Moves the buttons on the controller mesh based on their current state
  48595. * @param buttonName the name of the button to move
  48596. * @param buttonValue the value of the button which determines the buttons new position
  48597. */
  48598. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48599. /**
  48600. * Moves the axis on the controller mesh based on its current state
  48601. * @param axis the index of the axis
  48602. * @param axisValue the value of the axis which determines the meshes new position
  48603. * @hidden
  48604. */
  48605. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48606. /**
  48607. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48608. * @param scene scene in which to add meshes
  48609. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48610. */
  48611. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48612. /**
  48613. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48614. * can be transformed by button presses and axes values, based on this._mapping.
  48615. *
  48616. * @param scene scene in which the meshes exist
  48617. * @param meshes list of meshes that make up the controller model to process
  48618. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48619. */
  48620. private processModel;
  48621. private createMeshInfo;
  48622. /**
  48623. * Gets the ray of the controller in the direction the controller is pointing
  48624. * @param length the length the resulting ray should be
  48625. * @returns a ray in the direction the controller is pointing
  48626. */
  48627. getForwardRay(length?: number): Ray;
  48628. /**
  48629. * Disposes of the controller
  48630. */
  48631. dispose(): void;
  48632. }
  48633. /**
  48634. * This class represents a new windows motion controller in XR.
  48635. */
  48636. export class XRWindowsMotionController extends WindowsMotionController {
  48637. /**
  48638. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48639. */
  48640. protected readonly _mapping: {
  48641. buttons: string[];
  48642. buttonMeshNames: {
  48643. trigger: string;
  48644. menu: string;
  48645. grip: string;
  48646. thumbstick: string;
  48647. trackpad: string;
  48648. };
  48649. buttonObservableNames: {
  48650. trigger: string;
  48651. menu: string;
  48652. grip: string;
  48653. thumbstick: string;
  48654. trackpad: string;
  48655. };
  48656. axisMeshNames: string[];
  48657. pointingPoseMeshName: string;
  48658. };
  48659. /**
  48660. * Construct a new XR-Based windows motion controller
  48661. *
  48662. * @param gamepadInfo the gamepad object from the browser
  48663. */
  48664. constructor(gamepadInfo: any);
  48665. /**
  48666. * holds the thumbstick values (X,Y)
  48667. */
  48668. thumbstickValues: StickValues;
  48669. /**
  48670. * Fired when the thumbstick on this controller is clicked
  48671. */
  48672. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48673. /**
  48674. * Fired when the thumbstick on this controller is modified
  48675. */
  48676. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48677. /**
  48678. * Fired when the touchpad button on this controller is modified
  48679. */
  48680. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48681. /**
  48682. * Fired when the touchpad values on this controller are modified
  48683. */
  48684. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48685. /**
  48686. * Fired when the thumbstick button on this controller is modified
  48687. * here to prevent breaking changes
  48688. */
  48689. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48690. /**
  48691. * updating the thumbstick(!) and not the trackpad.
  48692. * This is named this way due to the difference between WebVR and XR and to avoid
  48693. * changing the parent class.
  48694. */
  48695. protected _updateTrackpad(): void;
  48696. /**
  48697. * Disposes the class with joy
  48698. */
  48699. dispose(): void;
  48700. }
  48701. }
  48702. declare module BABYLON {
  48703. /**
  48704. * Class containing static functions to help procedurally build meshes
  48705. */
  48706. export class PolyhedronBuilder {
  48707. /**
  48708. * Creates a polyhedron mesh
  48709. * * 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
  48710. * * The parameter `size` (positive float, default 1) sets the polygon size
  48711. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48712. * * 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`
  48713. * * 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
  48714. * * 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)`)
  48715. * * 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
  48716. * * 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
  48717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48718. * * 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
  48719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48720. * @param name defines the name of the mesh
  48721. * @param options defines the options used to create the mesh
  48722. * @param scene defines the hosting scene
  48723. * @returns the polyhedron mesh
  48724. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48725. */
  48726. static CreatePolyhedron(name: string, options: {
  48727. type?: number;
  48728. size?: number;
  48729. sizeX?: number;
  48730. sizeY?: number;
  48731. sizeZ?: number;
  48732. custom?: any;
  48733. faceUV?: Vector4[];
  48734. faceColors?: Color4[];
  48735. flat?: boolean;
  48736. updatable?: boolean;
  48737. sideOrientation?: number;
  48738. frontUVs?: Vector4;
  48739. backUVs?: Vector4;
  48740. }, scene?: Nullable<Scene>): Mesh;
  48741. }
  48742. }
  48743. declare module BABYLON {
  48744. /**
  48745. * Gizmo that enables scaling a mesh along 3 axis
  48746. */
  48747. export class ScaleGizmo extends Gizmo {
  48748. /**
  48749. * Internal gizmo used for interactions on the x axis
  48750. */
  48751. xGizmo: AxisScaleGizmo;
  48752. /**
  48753. * Internal gizmo used for interactions on the y axis
  48754. */
  48755. yGizmo: AxisScaleGizmo;
  48756. /**
  48757. * Internal gizmo used for interactions on the z axis
  48758. */
  48759. zGizmo: AxisScaleGizmo;
  48760. /**
  48761. * Internal gizmo used to scale all axis equally
  48762. */
  48763. uniformScaleGizmo: AxisScaleGizmo;
  48764. private _meshAttached;
  48765. private _updateGizmoRotationToMatchAttachedMesh;
  48766. private _snapDistance;
  48767. private _scaleRatio;
  48768. private _uniformScalingMesh;
  48769. private _octahedron;
  48770. private _sensitivity;
  48771. /** Fires an event when any of it's sub gizmos are dragged */
  48772. onDragStartObservable: Observable<unknown>;
  48773. /** Fires an event when any of it's sub gizmos are released from dragging */
  48774. onDragEndObservable: Observable<unknown>;
  48775. get attachedMesh(): Nullable<AbstractMesh>;
  48776. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48777. /**
  48778. * Creates a ScaleGizmo
  48779. * @param gizmoLayer The utility layer the gizmo will be added to
  48780. */
  48781. constructor(gizmoLayer?: UtilityLayerRenderer);
  48782. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48783. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48784. /**
  48785. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48786. */
  48787. set snapDistance(value: number);
  48788. get snapDistance(): number;
  48789. /**
  48790. * Ratio for the scale of the gizmo (Default: 1)
  48791. */
  48792. set scaleRatio(value: number);
  48793. get scaleRatio(): number;
  48794. /**
  48795. * Sensitivity factor for dragging (Default: 1)
  48796. */
  48797. set sensitivity(value: number);
  48798. get sensitivity(): number;
  48799. /**
  48800. * Disposes of the gizmo
  48801. */
  48802. dispose(): void;
  48803. }
  48804. }
  48805. declare module BABYLON {
  48806. /**
  48807. * Single axis scale gizmo
  48808. */
  48809. export class AxisScaleGizmo extends Gizmo {
  48810. /**
  48811. * Drag behavior responsible for the gizmos dragging interactions
  48812. */
  48813. dragBehavior: PointerDragBehavior;
  48814. private _pointerObserver;
  48815. /**
  48816. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48817. */
  48818. snapDistance: number;
  48819. /**
  48820. * Event that fires each time the gizmo snaps to a new location.
  48821. * * snapDistance is the the change in distance
  48822. */
  48823. onSnapObservable: Observable<{
  48824. snapDistance: number;
  48825. }>;
  48826. /**
  48827. * If the scaling operation should be done on all axis (default: false)
  48828. */
  48829. uniformScaling: boolean;
  48830. /**
  48831. * Custom sensitivity value for the drag strength
  48832. */
  48833. sensitivity: number;
  48834. private _isEnabled;
  48835. private _parent;
  48836. private _arrow;
  48837. private _coloredMaterial;
  48838. private _hoverMaterial;
  48839. /**
  48840. * Creates an AxisScaleGizmo
  48841. * @param gizmoLayer The utility layer the gizmo will be added to
  48842. * @param dragAxis The axis which the gizmo will be able to scale on
  48843. * @param color The color of the gizmo
  48844. */
  48845. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48846. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48847. /**
  48848. * If the gizmo is enabled
  48849. */
  48850. set isEnabled(value: boolean);
  48851. get isEnabled(): boolean;
  48852. /**
  48853. * Disposes of the gizmo
  48854. */
  48855. dispose(): void;
  48856. /**
  48857. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48858. * @param mesh The mesh to replace the default mesh of the gizmo
  48859. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48860. */
  48861. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48862. }
  48863. }
  48864. declare module BABYLON {
  48865. /**
  48866. * Bounding box gizmo
  48867. */
  48868. export class BoundingBoxGizmo extends Gizmo {
  48869. private _lineBoundingBox;
  48870. private _rotateSpheresParent;
  48871. private _scaleBoxesParent;
  48872. private _boundingDimensions;
  48873. private _renderObserver;
  48874. private _pointerObserver;
  48875. private _scaleDragSpeed;
  48876. private _tmpQuaternion;
  48877. private _tmpVector;
  48878. private _tmpRotationMatrix;
  48879. /**
  48880. * 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)
  48881. */
  48882. ignoreChildren: boolean;
  48883. /**
  48884. * 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)
  48885. */
  48886. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48887. /**
  48888. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48889. */
  48890. rotationSphereSize: number;
  48891. /**
  48892. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48893. */
  48894. scaleBoxSize: number;
  48895. /**
  48896. * 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)
  48897. */
  48898. fixedDragMeshScreenSize: boolean;
  48899. /**
  48900. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48901. */
  48902. fixedDragMeshScreenSizeDistanceFactor: number;
  48903. /**
  48904. * Fired when a rotation sphere or scale box is dragged
  48905. */
  48906. onDragStartObservable: Observable<{}>;
  48907. /**
  48908. * Fired when a scale box is dragged
  48909. */
  48910. onScaleBoxDragObservable: Observable<{}>;
  48911. /**
  48912. * Fired when a scale box drag is ended
  48913. */
  48914. onScaleBoxDragEndObservable: Observable<{}>;
  48915. /**
  48916. * Fired when a rotation sphere is dragged
  48917. */
  48918. onRotationSphereDragObservable: Observable<{}>;
  48919. /**
  48920. * Fired when a rotation sphere drag is ended
  48921. */
  48922. onRotationSphereDragEndObservable: Observable<{}>;
  48923. /**
  48924. * 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)
  48925. */
  48926. scalePivot: Nullable<Vector3>;
  48927. /**
  48928. * Mesh used as a pivot to rotate the attached mesh
  48929. */
  48930. private _anchorMesh;
  48931. private _existingMeshScale;
  48932. private _dragMesh;
  48933. private pointerDragBehavior;
  48934. private coloredMaterial;
  48935. private hoverColoredMaterial;
  48936. /**
  48937. * Sets the color of the bounding box gizmo
  48938. * @param color the color to set
  48939. */
  48940. setColor(color: Color3): void;
  48941. /**
  48942. * Creates an BoundingBoxGizmo
  48943. * @param gizmoLayer The utility layer the gizmo will be added to
  48944. * @param color The color of the gizmo
  48945. */
  48946. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48947. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48948. private _selectNode;
  48949. /**
  48950. * Updates the bounding box information for the Gizmo
  48951. */
  48952. updateBoundingBox(): void;
  48953. private _updateRotationSpheres;
  48954. private _updateScaleBoxes;
  48955. /**
  48956. * Enables rotation on the specified axis and disables rotation on the others
  48957. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48958. */
  48959. setEnabledRotationAxis(axis: string): void;
  48960. /**
  48961. * Enables/disables scaling
  48962. * @param enable if scaling should be enabled
  48963. * @param homogeneousScaling defines if scaling should only be homogeneous
  48964. */
  48965. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  48966. private _updateDummy;
  48967. /**
  48968. * Enables a pointer drag behavior on the bounding box of the gizmo
  48969. */
  48970. enableDragBehavior(): void;
  48971. /**
  48972. * Disposes of the gizmo
  48973. */
  48974. dispose(): void;
  48975. /**
  48976. * 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)
  48977. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48978. * @returns the bounding box mesh with the passed in mesh as a child
  48979. */
  48980. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48981. /**
  48982. * CustomMeshes are not supported by this gizmo
  48983. * @param mesh The mesh to replace the default mesh of the gizmo
  48984. */
  48985. setCustomMesh(mesh: Mesh): void;
  48986. }
  48987. }
  48988. declare module BABYLON {
  48989. /**
  48990. * Single plane rotation gizmo
  48991. */
  48992. export class PlaneRotationGizmo extends Gizmo {
  48993. /**
  48994. * Drag behavior responsible for the gizmos dragging interactions
  48995. */
  48996. dragBehavior: PointerDragBehavior;
  48997. private _pointerObserver;
  48998. /**
  48999. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49000. */
  49001. snapDistance: number;
  49002. /**
  49003. * Event that fires each time the gizmo snaps to a new location.
  49004. * * snapDistance is the the change in distance
  49005. */
  49006. onSnapObservable: Observable<{
  49007. snapDistance: number;
  49008. }>;
  49009. private _isEnabled;
  49010. private _parent;
  49011. /**
  49012. * Creates a PlaneRotationGizmo
  49013. * @param gizmoLayer The utility layer the gizmo will be added to
  49014. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49015. * @param color The color of the gizmo
  49016. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49017. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49018. */
  49019. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49020. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49021. /**
  49022. * If the gizmo is enabled
  49023. */
  49024. set isEnabled(value: boolean);
  49025. get isEnabled(): boolean;
  49026. /**
  49027. * Disposes of the gizmo
  49028. */
  49029. dispose(): void;
  49030. }
  49031. }
  49032. declare module BABYLON {
  49033. /**
  49034. * Gizmo that enables rotating a mesh along 3 axis
  49035. */
  49036. export class RotationGizmo extends Gizmo {
  49037. /**
  49038. * Internal gizmo used for interactions on the x axis
  49039. */
  49040. xGizmo: PlaneRotationGizmo;
  49041. /**
  49042. * Internal gizmo used for interactions on the y axis
  49043. */
  49044. yGizmo: PlaneRotationGizmo;
  49045. /**
  49046. * Internal gizmo used for interactions on the z axis
  49047. */
  49048. zGizmo: PlaneRotationGizmo;
  49049. /** Fires an event when any of it's sub gizmos are dragged */
  49050. onDragStartObservable: Observable<unknown>;
  49051. /** Fires an event when any of it's sub gizmos are released from dragging */
  49052. onDragEndObservable: Observable<unknown>;
  49053. private _meshAttached;
  49054. get attachedMesh(): Nullable<AbstractMesh>;
  49055. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49056. /**
  49057. * Creates a RotationGizmo
  49058. * @param gizmoLayer The utility layer the gizmo will be added to
  49059. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49060. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49061. */
  49062. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49063. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49064. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49065. /**
  49066. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49067. */
  49068. set snapDistance(value: number);
  49069. get snapDistance(): number;
  49070. /**
  49071. * Ratio for the scale of the gizmo (Default: 1)
  49072. */
  49073. set scaleRatio(value: number);
  49074. get scaleRatio(): number;
  49075. /**
  49076. * Disposes of the gizmo
  49077. */
  49078. dispose(): void;
  49079. /**
  49080. * CustomMeshes are not supported by this gizmo
  49081. * @param mesh The mesh to replace the default mesh of the gizmo
  49082. */
  49083. setCustomMesh(mesh: Mesh): void;
  49084. }
  49085. }
  49086. declare module BABYLON {
  49087. /**
  49088. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49089. */
  49090. export class GizmoManager implements IDisposable {
  49091. private scene;
  49092. /**
  49093. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49094. */
  49095. gizmos: {
  49096. positionGizmo: Nullable<PositionGizmo>;
  49097. rotationGizmo: Nullable<RotationGizmo>;
  49098. scaleGizmo: Nullable<ScaleGizmo>;
  49099. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49100. };
  49101. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49102. clearGizmoOnEmptyPointerEvent: boolean;
  49103. /** Fires an event when the manager is attached to a mesh */
  49104. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49105. private _gizmosEnabled;
  49106. private _pointerObserver;
  49107. private _attachedMesh;
  49108. private _boundingBoxColor;
  49109. private _defaultUtilityLayer;
  49110. private _defaultKeepDepthUtilityLayer;
  49111. /**
  49112. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49113. */
  49114. boundingBoxDragBehavior: SixDofDragBehavior;
  49115. /**
  49116. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49117. */
  49118. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49119. /**
  49120. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49121. */
  49122. usePointerToAttachGizmos: boolean;
  49123. /**
  49124. * Utility layer that the bounding box gizmo belongs to
  49125. */
  49126. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49127. /**
  49128. * Utility layer that all gizmos besides bounding box belong to
  49129. */
  49130. get utilityLayer(): UtilityLayerRenderer;
  49131. /**
  49132. * Instatiates a gizmo manager
  49133. * @param scene the scene to overlay the gizmos on top of
  49134. */
  49135. constructor(scene: Scene);
  49136. /**
  49137. * Attaches a set of gizmos to the specified mesh
  49138. * @param mesh The mesh the gizmo's should be attached to
  49139. */
  49140. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49141. /**
  49142. * If the position gizmo is enabled
  49143. */
  49144. set positionGizmoEnabled(value: boolean);
  49145. get positionGizmoEnabled(): boolean;
  49146. /**
  49147. * If the rotation gizmo is enabled
  49148. */
  49149. set rotationGizmoEnabled(value: boolean);
  49150. get rotationGizmoEnabled(): boolean;
  49151. /**
  49152. * If the scale gizmo is enabled
  49153. */
  49154. set scaleGizmoEnabled(value: boolean);
  49155. get scaleGizmoEnabled(): boolean;
  49156. /**
  49157. * If the boundingBox gizmo is enabled
  49158. */
  49159. set boundingBoxGizmoEnabled(value: boolean);
  49160. get boundingBoxGizmoEnabled(): boolean;
  49161. /**
  49162. * Disposes of the gizmo manager
  49163. */
  49164. dispose(): void;
  49165. }
  49166. }
  49167. declare module BABYLON {
  49168. /**
  49169. * A directional light is defined by a direction (what a surprise!).
  49170. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49171. * 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.
  49172. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49173. */
  49174. export class DirectionalLight extends ShadowLight {
  49175. private _shadowFrustumSize;
  49176. /**
  49177. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49178. */
  49179. get shadowFrustumSize(): number;
  49180. /**
  49181. * Specifies a fix frustum size for the shadow generation.
  49182. */
  49183. set shadowFrustumSize(value: number);
  49184. private _shadowOrthoScale;
  49185. /**
  49186. * Gets the shadow projection scale against the optimal computed one.
  49187. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49188. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49189. */
  49190. get shadowOrthoScale(): number;
  49191. /**
  49192. * Sets the shadow projection scale against the optimal computed one.
  49193. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49194. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49195. */
  49196. set shadowOrthoScale(value: number);
  49197. /**
  49198. * Automatically compute the projection matrix to best fit (including all the casters)
  49199. * on each frame.
  49200. */
  49201. autoUpdateExtends: boolean;
  49202. /**
  49203. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49204. * on each frame. autoUpdateExtends must be set to true for this to work
  49205. */
  49206. autoCalcShadowZBounds: boolean;
  49207. private _orthoLeft;
  49208. private _orthoRight;
  49209. private _orthoTop;
  49210. private _orthoBottom;
  49211. /**
  49212. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49213. * The directional light is emitted from everywhere in the given direction.
  49214. * It can cast shadows.
  49215. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49216. * @param name The friendly name of the light
  49217. * @param direction The direction of the light
  49218. * @param scene The scene the light belongs to
  49219. */
  49220. constructor(name: string, direction: Vector3, scene: Scene);
  49221. /**
  49222. * Returns the string "DirectionalLight".
  49223. * @return The class name
  49224. */
  49225. getClassName(): string;
  49226. /**
  49227. * Returns the integer 1.
  49228. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49229. */
  49230. getTypeID(): number;
  49231. /**
  49232. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49233. * Returns the DirectionalLight Shadow projection matrix.
  49234. */
  49235. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49236. /**
  49237. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49238. * Returns the DirectionalLight Shadow projection matrix.
  49239. */
  49240. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49241. /**
  49242. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49243. * Returns the DirectionalLight Shadow projection matrix.
  49244. */
  49245. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49246. protected _buildUniformLayout(): void;
  49247. /**
  49248. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49249. * @param effect The effect to update
  49250. * @param lightIndex The index of the light in the effect to update
  49251. * @returns The directional light
  49252. */
  49253. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49254. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49255. /**
  49256. * Gets the minZ used for shadow according to both the scene and the light.
  49257. *
  49258. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49259. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49260. * @param activeCamera The camera we are returning the min for
  49261. * @returns the depth min z
  49262. */
  49263. getDepthMinZ(activeCamera: Camera): number;
  49264. /**
  49265. * Gets the maxZ used for shadow according to both the scene and the light.
  49266. *
  49267. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49268. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49269. * @param activeCamera The camera we are returning the max for
  49270. * @returns the depth max z
  49271. */
  49272. getDepthMaxZ(activeCamera: Camera): number;
  49273. /**
  49274. * Prepares the list of defines specific to the light type.
  49275. * @param defines the list of defines
  49276. * @param lightIndex defines the index of the light for the effect
  49277. */
  49278. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49279. }
  49280. }
  49281. declare module BABYLON {
  49282. /**
  49283. * Class containing static functions to help procedurally build meshes
  49284. */
  49285. export class HemisphereBuilder {
  49286. /**
  49287. * Creates a hemisphere mesh
  49288. * @param name defines the name of the mesh
  49289. * @param options defines the options used to create the mesh
  49290. * @param scene defines the hosting scene
  49291. * @returns the hemisphere mesh
  49292. */
  49293. static CreateHemisphere(name: string, options: {
  49294. segments?: number;
  49295. diameter?: number;
  49296. sideOrientation?: number;
  49297. }, scene: any): Mesh;
  49298. }
  49299. }
  49300. declare module BABYLON {
  49301. /**
  49302. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49303. * These values define a cone of light starting from the position, emitting toward the direction.
  49304. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49305. * and the exponent defines the speed of the decay of the light with distance (reach).
  49306. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49307. */
  49308. export class SpotLight extends ShadowLight {
  49309. private _angle;
  49310. private _innerAngle;
  49311. private _cosHalfAngle;
  49312. private _lightAngleScale;
  49313. private _lightAngleOffset;
  49314. /**
  49315. * Gets the cone angle of the spot light in Radians.
  49316. */
  49317. get angle(): number;
  49318. /**
  49319. * Sets the cone angle of the spot light in Radians.
  49320. */
  49321. set angle(value: number);
  49322. /**
  49323. * Only used in gltf falloff mode, this defines the angle where
  49324. * the directional falloff will start before cutting at angle which could be seen
  49325. * as outer angle.
  49326. */
  49327. get innerAngle(): number;
  49328. /**
  49329. * Only used in gltf falloff mode, this defines the angle where
  49330. * the directional falloff will start before cutting at angle which could be seen
  49331. * as outer angle.
  49332. */
  49333. set innerAngle(value: number);
  49334. private _shadowAngleScale;
  49335. /**
  49336. * Allows scaling the angle of the light for shadow generation only.
  49337. */
  49338. get shadowAngleScale(): number;
  49339. /**
  49340. * Allows scaling the angle of the light for shadow generation only.
  49341. */
  49342. set shadowAngleScale(value: number);
  49343. /**
  49344. * The light decay speed with the distance from the emission spot.
  49345. */
  49346. exponent: number;
  49347. private _projectionTextureMatrix;
  49348. /**
  49349. * Allows reading the projecton texture
  49350. */
  49351. get projectionTextureMatrix(): Matrix;
  49352. protected _projectionTextureLightNear: number;
  49353. /**
  49354. * Gets the near clip of the Spotlight for texture projection.
  49355. */
  49356. get projectionTextureLightNear(): number;
  49357. /**
  49358. * Sets the near clip of the Spotlight for texture projection.
  49359. */
  49360. set projectionTextureLightNear(value: number);
  49361. protected _projectionTextureLightFar: number;
  49362. /**
  49363. * Gets the far clip of the Spotlight for texture projection.
  49364. */
  49365. get projectionTextureLightFar(): number;
  49366. /**
  49367. * Sets the far clip of the Spotlight for texture projection.
  49368. */
  49369. set projectionTextureLightFar(value: number);
  49370. protected _projectionTextureUpDirection: Vector3;
  49371. /**
  49372. * Gets the Up vector of the Spotlight for texture projection.
  49373. */
  49374. get projectionTextureUpDirection(): Vector3;
  49375. /**
  49376. * Sets the Up vector of the Spotlight for texture projection.
  49377. */
  49378. set projectionTextureUpDirection(value: Vector3);
  49379. private _projectionTexture;
  49380. /**
  49381. * Gets the projection texture of the light.
  49382. */
  49383. get projectionTexture(): Nullable<BaseTexture>;
  49384. /**
  49385. * Sets the projection texture of the light.
  49386. */
  49387. set projectionTexture(value: Nullable<BaseTexture>);
  49388. private _projectionTextureViewLightDirty;
  49389. private _projectionTextureProjectionLightDirty;
  49390. private _projectionTextureDirty;
  49391. private _projectionTextureViewTargetVector;
  49392. private _projectionTextureViewLightMatrix;
  49393. private _projectionTextureProjectionLightMatrix;
  49394. private _projectionTextureScalingMatrix;
  49395. /**
  49396. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49397. * It can cast shadows.
  49398. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49399. * @param name The light friendly name
  49400. * @param position The position of the spot light in the scene
  49401. * @param direction The direction of the light in the scene
  49402. * @param angle The cone angle of the light in Radians
  49403. * @param exponent The light decay speed with the distance from the emission spot
  49404. * @param scene The scene the lights belongs to
  49405. */
  49406. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49407. /**
  49408. * Returns the string "SpotLight".
  49409. * @returns the class name
  49410. */
  49411. getClassName(): string;
  49412. /**
  49413. * Returns the integer 2.
  49414. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49415. */
  49416. getTypeID(): number;
  49417. /**
  49418. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49419. */
  49420. protected _setDirection(value: Vector3): void;
  49421. /**
  49422. * Overrides the position setter to recompute the projection texture view light Matrix.
  49423. */
  49424. protected _setPosition(value: Vector3): void;
  49425. /**
  49426. * 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.
  49427. * Returns the SpotLight.
  49428. */
  49429. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49430. protected _computeProjectionTextureViewLightMatrix(): void;
  49431. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49432. /**
  49433. * Main function for light texture projection matrix computing.
  49434. */
  49435. protected _computeProjectionTextureMatrix(): void;
  49436. protected _buildUniformLayout(): void;
  49437. private _computeAngleValues;
  49438. /**
  49439. * Sets the passed Effect "effect" with the Light textures.
  49440. * @param effect The effect to update
  49441. * @param lightIndex The index of the light in the effect to update
  49442. * @returns The light
  49443. */
  49444. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49445. /**
  49446. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49447. * @param effect The effect to update
  49448. * @param lightIndex The index of the light in the effect to update
  49449. * @returns The spot light
  49450. */
  49451. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49452. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49453. /**
  49454. * Disposes the light and the associated resources.
  49455. */
  49456. dispose(): void;
  49457. /**
  49458. * Prepares the list of defines specific to the light type.
  49459. * @param defines the list of defines
  49460. * @param lightIndex defines the index of the light for the effect
  49461. */
  49462. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49463. }
  49464. }
  49465. declare module BABYLON {
  49466. /**
  49467. * Gizmo that enables viewing a light
  49468. */
  49469. export class LightGizmo extends Gizmo {
  49470. private _lightMesh;
  49471. private _material;
  49472. private _cachedPosition;
  49473. private _cachedForward;
  49474. private _attachedMeshParent;
  49475. /**
  49476. * Creates a LightGizmo
  49477. * @param gizmoLayer The utility layer the gizmo will be added to
  49478. */
  49479. constructor(gizmoLayer?: UtilityLayerRenderer);
  49480. private _light;
  49481. /**
  49482. * The light that the gizmo is attached to
  49483. */
  49484. set light(light: Nullable<Light>);
  49485. get light(): Nullable<Light>;
  49486. /**
  49487. * Gets the material used to render the light gizmo
  49488. */
  49489. get material(): StandardMaterial;
  49490. /**
  49491. * @hidden
  49492. * Updates the gizmo to match the attached mesh's position/rotation
  49493. */
  49494. protected _update(): void;
  49495. private static _Scale;
  49496. /**
  49497. * Creates the lines for a light mesh
  49498. */
  49499. private static _CreateLightLines;
  49500. /**
  49501. * Disposes of the light gizmo
  49502. */
  49503. dispose(): void;
  49504. private static _CreateHemisphericLightMesh;
  49505. private static _CreatePointLightMesh;
  49506. private static _CreateSpotLightMesh;
  49507. private static _CreateDirectionalLightMesh;
  49508. }
  49509. }
  49510. declare module BABYLON {
  49511. /** @hidden */
  49512. export var backgroundFragmentDeclaration: {
  49513. name: string;
  49514. shader: string;
  49515. };
  49516. }
  49517. declare module BABYLON {
  49518. /** @hidden */
  49519. export var backgroundUboDeclaration: {
  49520. name: string;
  49521. shader: string;
  49522. };
  49523. }
  49524. declare module BABYLON {
  49525. /** @hidden */
  49526. export var backgroundPixelShader: {
  49527. name: string;
  49528. shader: string;
  49529. };
  49530. }
  49531. declare module BABYLON {
  49532. /** @hidden */
  49533. export var backgroundVertexDeclaration: {
  49534. name: string;
  49535. shader: string;
  49536. };
  49537. }
  49538. declare module BABYLON {
  49539. /** @hidden */
  49540. export var backgroundVertexShader: {
  49541. name: string;
  49542. shader: string;
  49543. };
  49544. }
  49545. declare module BABYLON {
  49546. /**
  49547. * Background material used to create an efficient environement around your scene.
  49548. */
  49549. export class BackgroundMaterial extends PushMaterial {
  49550. /**
  49551. * Standard reflectance value at parallel view angle.
  49552. */
  49553. static StandardReflectance0: number;
  49554. /**
  49555. * Standard reflectance value at grazing angle.
  49556. */
  49557. static StandardReflectance90: number;
  49558. protected _primaryColor: Color3;
  49559. /**
  49560. * Key light Color (multiply against the environement texture)
  49561. */
  49562. primaryColor: Color3;
  49563. protected __perceptualColor: Nullable<Color3>;
  49564. /**
  49565. * Experimental Internal Use Only.
  49566. *
  49567. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49568. * This acts as a helper to set the primary color to a more "human friendly" value.
  49569. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49570. * output color as close as possible from the chosen value.
  49571. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49572. * part of lighting setup.)
  49573. */
  49574. get _perceptualColor(): Nullable<Color3>;
  49575. set _perceptualColor(value: Nullable<Color3>);
  49576. protected _primaryColorShadowLevel: float;
  49577. /**
  49578. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49579. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49580. */
  49581. get primaryColorShadowLevel(): float;
  49582. set primaryColorShadowLevel(value: float);
  49583. protected _primaryColorHighlightLevel: float;
  49584. /**
  49585. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49586. * The primary color is used at the level chosen to define what the white area would look.
  49587. */
  49588. get primaryColorHighlightLevel(): float;
  49589. set primaryColorHighlightLevel(value: float);
  49590. protected _reflectionTexture: Nullable<BaseTexture>;
  49591. /**
  49592. * Reflection Texture used in the material.
  49593. * Should be author in a specific way for the best result (refer to the documentation).
  49594. */
  49595. reflectionTexture: Nullable<BaseTexture>;
  49596. protected _reflectionBlur: float;
  49597. /**
  49598. * Reflection Texture level of blur.
  49599. *
  49600. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49601. * texture twice.
  49602. */
  49603. reflectionBlur: float;
  49604. protected _diffuseTexture: Nullable<BaseTexture>;
  49605. /**
  49606. * Diffuse Texture used in the material.
  49607. * Should be author in a specific way for the best result (refer to the documentation).
  49608. */
  49609. diffuseTexture: Nullable<BaseTexture>;
  49610. protected _shadowLights: Nullable<IShadowLight[]>;
  49611. /**
  49612. * Specify the list of lights casting shadow on the material.
  49613. * All scene shadow lights will be included if null.
  49614. */
  49615. shadowLights: Nullable<IShadowLight[]>;
  49616. protected _shadowLevel: float;
  49617. /**
  49618. * Helps adjusting the shadow to a softer level if required.
  49619. * 0 means black shadows and 1 means no shadows.
  49620. */
  49621. shadowLevel: float;
  49622. protected _sceneCenter: Vector3;
  49623. /**
  49624. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49625. * It is usually zero but might be interesting to modify according to your setup.
  49626. */
  49627. sceneCenter: Vector3;
  49628. protected _opacityFresnel: boolean;
  49629. /**
  49630. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49631. * This helps ensuring a nice transition when the camera goes under the ground.
  49632. */
  49633. opacityFresnel: boolean;
  49634. protected _reflectionFresnel: boolean;
  49635. /**
  49636. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49637. * This helps adding a mirror texture on the ground.
  49638. */
  49639. reflectionFresnel: boolean;
  49640. protected _reflectionFalloffDistance: number;
  49641. /**
  49642. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49643. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49644. */
  49645. reflectionFalloffDistance: number;
  49646. protected _reflectionAmount: number;
  49647. /**
  49648. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49649. */
  49650. reflectionAmount: number;
  49651. protected _reflectionReflectance0: number;
  49652. /**
  49653. * This specifies the weight of the reflection at grazing angle.
  49654. */
  49655. reflectionReflectance0: number;
  49656. protected _reflectionReflectance90: number;
  49657. /**
  49658. * This specifies the weight of the reflection at a perpendicular point of view.
  49659. */
  49660. reflectionReflectance90: number;
  49661. /**
  49662. * Sets the reflection reflectance fresnel values according to the default standard
  49663. * empirically know to work well :-)
  49664. */
  49665. set reflectionStandardFresnelWeight(value: number);
  49666. protected _useRGBColor: boolean;
  49667. /**
  49668. * Helps to directly use the maps channels instead of their level.
  49669. */
  49670. useRGBColor: boolean;
  49671. protected _enableNoise: boolean;
  49672. /**
  49673. * This helps reducing the banding effect that could occur on the background.
  49674. */
  49675. enableNoise: boolean;
  49676. /**
  49677. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49678. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49679. * Recommended to be keep at 1.0 except for special cases.
  49680. */
  49681. get fovMultiplier(): number;
  49682. set fovMultiplier(value: number);
  49683. private _fovMultiplier;
  49684. /**
  49685. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49686. */
  49687. useEquirectangularFOV: boolean;
  49688. private _maxSimultaneousLights;
  49689. /**
  49690. * Number of Simultaneous lights allowed on the material.
  49691. */
  49692. maxSimultaneousLights: int;
  49693. /**
  49694. * Default configuration related to image processing available in the Background Material.
  49695. */
  49696. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49697. /**
  49698. * Keep track of the image processing observer to allow dispose and replace.
  49699. */
  49700. private _imageProcessingObserver;
  49701. /**
  49702. * Attaches a new image processing configuration to the PBR Material.
  49703. * @param configuration (if null the scene configuration will be use)
  49704. */
  49705. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49706. /**
  49707. * Gets the image processing configuration used either in this material.
  49708. */
  49709. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49710. /**
  49711. * Sets the Default image processing configuration used either in the this material.
  49712. *
  49713. * If sets to null, the scene one is in use.
  49714. */
  49715. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49716. /**
  49717. * Gets wether the color curves effect is enabled.
  49718. */
  49719. get cameraColorCurvesEnabled(): boolean;
  49720. /**
  49721. * Sets wether the color curves effect is enabled.
  49722. */
  49723. set cameraColorCurvesEnabled(value: boolean);
  49724. /**
  49725. * Gets wether the color grading effect is enabled.
  49726. */
  49727. get cameraColorGradingEnabled(): boolean;
  49728. /**
  49729. * Gets wether the color grading effect is enabled.
  49730. */
  49731. set cameraColorGradingEnabled(value: boolean);
  49732. /**
  49733. * Gets wether tonemapping is enabled or not.
  49734. */
  49735. get cameraToneMappingEnabled(): boolean;
  49736. /**
  49737. * Sets wether tonemapping is enabled or not
  49738. */
  49739. set cameraToneMappingEnabled(value: boolean);
  49740. /**
  49741. * The camera exposure used on this material.
  49742. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49743. * This corresponds to a photographic exposure.
  49744. */
  49745. get cameraExposure(): float;
  49746. /**
  49747. * The camera exposure used on this material.
  49748. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49749. * This corresponds to a photographic exposure.
  49750. */
  49751. set cameraExposure(value: float);
  49752. /**
  49753. * Gets The camera contrast used on this material.
  49754. */
  49755. get cameraContrast(): float;
  49756. /**
  49757. * Sets The camera contrast used on this material.
  49758. */
  49759. set cameraContrast(value: float);
  49760. /**
  49761. * Gets the Color Grading 2D Lookup Texture.
  49762. */
  49763. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49764. /**
  49765. * Sets the Color Grading 2D Lookup Texture.
  49766. */
  49767. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49768. /**
  49769. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49770. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49771. * 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;
  49772. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49773. */
  49774. get cameraColorCurves(): Nullable<ColorCurves>;
  49775. /**
  49776. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49777. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49778. * 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;
  49779. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49780. */
  49781. set cameraColorCurves(value: Nullable<ColorCurves>);
  49782. /**
  49783. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49784. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49785. */
  49786. switchToBGR: boolean;
  49787. private _renderTargets;
  49788. private _reflectionControls;
  49789. private _white;
  49790. private _primaryShadowColor;
  49791. private _primaryHighlightColor;
  49792. /**
  49793. * Instantiates a Background Material in the given scene
  49794. * @param name The friendly name of the material
  49795. * @param scene The scene to add the material to
  49796. */
  49797. constructor(name: string, scene: Scene);
  49798. /**
  49799. * Gets a boolean indicating that current material needs to register RTT
  49800. */
  49801. get hasRenderTargetTextures(): boolean;
  49802. /**
  49803. * The entire material has been created in order to prevent overdraw.
  49804. * @returns false
  49805. */
  49806. needAlphaTesting(): boolean;
  49807. /**
  49808. * The entire material has been created in order to prevent overdraw.
  49809. * @returns true if blending is enable
  49810. */
  49811. needAlphaBlending(): boolean;
  49812. /**
  49813. * Checks wether the material is ready to be rendered for a given mesh.
  49814. * @param mesh The mesh to render
  49815. * @param subMesh The submesh to check against
  49816. * @param useInstances Specify wether or not the material is used with instances
  49817. * @returns true if all the dependencies are ready (Textures, Effects...)
  49818. */
  49819. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49820. /**
  49821. * Compute the primary color according to the chosen perceptual color.
  49822. */
  49823. private _computePrimaryColorFromPerceptualColor;
  49824. /**
  49825. * Compute the highlights and shadow colors according to their chosen levels.
  49826. */
  49827. private _computePrimaryColors;
  49828. /**
  49829. * Build the uniform buffer used in the material.
  49830. */
  49831. buildUniformLayout(): void;
  49832. /**
  49833. * Unbind the material.
  49834. */
  49835. unbind(): void;
  49836. /**
  49837. * Bind only the world matrix to the material.
  49838. * @param world The world matrix to bind.
  49839. */
  49840. bindOnlyWorldMatrix(world: Matrix): void;
  49841. /**
  49842. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49843. * @param world The world matrix to bind.
  49844. * @param subMesh The submesh to bind for.
  49845. */
  49846. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49847. /**
  49848. * Checks to see if a texture is used in the material.
  49849. * @param texture - Base texture to use.
  49850. * @returns - Boolean specifying if a texture is used in the material.
  49851. */
  49852. hasTexture(texture: BaseTexture): boolean;
  49853. /**
  49854. * Dispose the material.
  49855. * @param forceDisposeEffect Force disposal of the associated effect.
  49856. * @param forceDisposeTextures Force disposal of the associated textures.
  49857. */
  49858. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49859. /**
  49860. * Clones the material.
  49861. * @param name The cloned name.
  49862. * @returns The cloned material.
  49863. */
  49864. clone(name: string): BackgroundMaterial;
  49865. /**
  49866. * Serializes the current material to its JSON representation.
  49867. * @returns The JSON representation.
  49868. */
  49869. serialize(): any;
  49870. /**
  49871. * Gets the class name of the material
  49872. * @returns "BackgroundMaterial"
  49873. */
  49874. getClassName(): string;
  49875. /**
  49876. * Parse a JSON input to create back a background material.
  49877. * @param source The JSON data to parse
  49878. * @param scene The scene to create the parsed material in
  49879. * @param rootUrl The root url of the assets the material depends upon
  49880. * @returns the instantiated BackgroundMaterial.
  49881. */
  49882. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49883. }
  49884. }
  49885. declare module BABYLON {
  49886. /**
  49887. * Represents the different options available during the creation of
  49888. * a Environment helper.
  49889. *
  49890. * This can control the default ground, skybox and image processing setup of your scene.
  49891. */
  49892. export interface IEnvironmentHelperOptions {
  49893. /**
  49894. * Specifies whether or not to create a ground.
  49895. * True by default.
  49896. */
  49897. createGround: boolean;
  49898. /**
  49899. * Specifies the ground size.
  49900. * 15 by default.
  49901. */
  49902. groundSize: number;
  49903. /**
  49904. * The texture used on the ground for the main color.
  49905. * Comes from the BabylonJS CDN by default.
  49906. *
  49907. * Remarks: Can be either a texture or a url.
  49908. */
  49909. groundTexture: string | BaseTexture;
  49910. /**
  49911. * The color mixed in the ground texture by default.
  49912. * BabylonJS clearColor by default.
  49913. */
  49914. groundColor: Color3;
  49915. /**
  49916. * Specifies the ground opacity.
  49917. * 1 by default.
  49918. */
  49919. groundOpacity: number;
  49920. /**
  49921. * Enables the ground to receive shadows.
  49922. * True by default.
  49923. */
  49924. enableGroundShadow: boolean;
  49925. /**
  49926. * Helps preventing the shadow to be fully black on the ground.
  49927. * 0.5 by default.
  49928. */
  49929. groundShadowLevel: number;
  49930. /**
  49931. * Creates a mirror texture attach to the ground.
  49932. * false by default.
  49933. */
  49934. enableGroundMirror: boolean;
  49935. /**
  49936. * Specifies the ground mirror size ratio.
  49937. * 0.3 by default as the default kernel is 64.
  49938. */
  49939. groundMirrorSizeRatio: number;
  49940. /**
  49941. * Specifies the ground mirror blur kernel size.
  49942. * 64 by default.
  49943. */
  49944. groundMirrorBlurKernel: number;
  49945. /**
  49946. * Specifies the ground mirror visibility amount.
  49947. * 1 by default
  49948. */
  49949. groundMirrorAmount: number;
  49950. /**
  49951. * Specifies the ground mirror reflectance weight.
  49952. * This uses the standard weight of the background material to setup the fresnel effect
  49953. * of the mirror.
  49954. * 1 by default.
  49955. */
  49956. groundMirrorFresnelWeight: number;
  49957. /**
  49958. * Specifies the ground mirror Falloff distance.
  49959. * This can helps reducing the size of the reflection.
  49960. * 0 by Default.
  49961. */
  49962. groundMirrorFallOffDistance: number;
  49963. /**
  49964. * Specifies the ground mirror texture type.
  49965. * Unsigned Int by Default.
  49966. */
  49967. groundMirrorTextureType: number;
  49968. /**
  49969. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49970. * the shown objects.
  49971. */
  49972. groundYBias: number;
  49973. /**
  49974. * Specifies whether or not to create a skybox.
  49975. * True by default.
  49976. */
  49977. createSkybox: boolean;
  49978. /**
  49979. * Specifies the skybox size.
  49980. * 20 by default.
  49981. */
  49982. skyboxSize: number;
  49983. /**
  49984. * The texture used on the skybox for the main color.
  49985. * Comes from the BabylonJS CDN by default.
  49986. *
  49987. * Remarks: Can be either a texture or a url.
  49988. */
  49989. skyboxTexture: string | BaseTexture;
  49990. /**
  49991. * The color mixed in the skybox texture by default.
  49992. * BabylonJS clearColor by default.
  49993. */
  49994. skyboxColor: Color3;
  49995. /**
  49996. * The background rotation around the Y axis of the scene.
  49997. * This helps aligning the key lights of your scene with the background.
  49998. * 0 by default.
  49999. */
  50000. backgroundYRotation: number;
  50001. /**
  50002. * Compute automatically the size of the elements to best fit with the scene.
  50003. */
  50004. sizeAuto: boolean;
  50005. /**
  50006. * Default position of the rootMesh if autoSize is not true.
  50007. */
  50008. rootPosition: Vector3;
  50009. /**
  50010. * Sets up the image processing in the scene.
  50011. * true by default.
  50012. */
  50013. setupImageProcessing: boolean;
  50014. /**
  50015. * The texture used as your environment texture in the scene.
  50016. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50017. *
  50018. * Remarks: Can be either a texture or a url.
  50019. */
  50020. environmentTexture: string | BaseTexture;
  50021. /**
  50022. * The value of the exposure to apply to the scene.
  50023. * 0.6 by default if setupImageProcessing is true.
  50024. */
  50025. cameraExposure: number;
  50026. /**
  50027. * The value of the contrast to apply to the scene.
  50028. * 1.6 by default if setupImageProcessing is true.
  50029. */
  50030. cameraContrast: number;
  50031. /**
  50032. * Specifies whether or not tonemapping should be enabled in the scene.
  50033. * true by default if setupImageProcessing is true.
  50034. */
  50035. toneMappingEnabled: boolean;
  50036. }
  50037. /**
  50038. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50039. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50040. * It also helps with the default setup of your imageProcessing configuration.
  50041. */
  50042. export class EnvironmentHelper {
  50043. /**
  50044. * Default ground texture URL.
  50045. */
  50046. private static _groundTextureCDNUrl;
  50047. /**
  50048. * Default skybox texture URL.
  50049. */
  50050. private static _skyboxTextureCDNUrl;
  50051. /**
  50052. * Default environment texture URL.
  50053. */
  50054. private static _environmentTextureCDNUrl;
  50055. /**
  50056. * Creates the default options for the helper.
  50057. */
  50058. private static _getDefaultOptions;
  50059. private _rootMesh;
  50060. /**
  50061. * Gets the root mesh created by the helper.
  50062. */
  50063. get rootMesh(): Mesh;
  50064. private _skybox;
  50065. /**
  50066. * Gets the skybox created by the helper.
  50067. */
  50068. get skybox(): Nullable<Mesh>;
  50069. private _skyboxTexture;
  50070. /**
  50071. * Gets the skybox texture created by the helper.
  50072. */
  50073. get skyboxTexture(): Nullable<BaseTexture>;
  50074. private _skyboxMaterial;
  50075. /**
  50076. * Gets the skybox material created by the helper.
  50077. */
  50078. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50079. private _ground;
  50080. /**
  50081. * Gets the ground mesh created by the helper.
  50082. */
  50083. get ground(): Nullable<Mesh>;
  50084. private _groundTexture;
  50085. /**
  50086. * Gets the ground texture created by the helper.
  50087. */
  50088. get groundTexture(): Nullable<BaseTexture>;
  50089. private _groundMirror;
  50090. /**
  50091. * Gets the ground mirror created by the helper.
  50092. */
  50093. get groundMirror(): Nullable<MirrorTexture>;
  50094. /**
  50095. * Gets the ground mirror render list to helps pushing the meshes
  50096. * you wish in the ground reflection.
  50097. */
  50098. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50099. private _groundMaterial;
  50100. /**
  50101. * Gets the ground material created by the helper.
  50102. */
  50103. get groundMaterial(): Nullable<BackgroundMaterial>;
  50104. /**
  50105. * Stores the creation options.
  50106. */
  50107. private readonly _scene;
  50108. private _options;
  50109. /**
  50110. * This observable will be notified with any error during the creation of the environment,
  50111. * mainly texture creation errors.
  50112. */
  50113. onErrorObservable: Observable<{
  50114. message?: string;
  50115. exception?: any;
  50116. }>;
  50117. /**
  50118. * constructor
  50119. * @param options Defines the options we want to customize the helper
  50120. * @param scene The scene to add the material to
  50121. */
  50122. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50123. /**
  50124. * Updates the background according to the new options
  50125. * @param options
  50126. */
  50127. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50128. /**
  50129. * Sets the primary color of all the available elements.
  50130. * @param color the main color to affect to the ground and the background
  50131. */
  50132. setMainColor(color: Color3): void;
  50133. /**
  50134. * Setup the image processing according to the specified options.
  50135. */
  50136. private _setupImageProcessing;
  50137. /**
  50138. * Setup the environment texture according to the specified options.
  50139. */
  50140. private _setupEnvironmentTexture;
  50141. /**
  50142. * Setup the background according to the specified options.
  50143. */
  50144. private _setupBackground;
  50145. /**
  50146. * Get the scene sizes according to the setup.
  50147. */
  50148. private _getSceneSize;
  50149. /**
  50150. * Setup the ground according to the specified options.
  50151. */
  50152. private _setupGround;
  50153. /**
  50154. * Setup the ground material according to the specified options.
  50155. */
  50156. private _setupGroundMaterial;
  50157. /**
  50158. * Setup the ground diffuse texture according to the specified options.
  50159. */
  50160. private _setupGroundDiffuseTexture;
  50161. /**
  50162. * Setup the ground mirror texture according to the specified options.
  50163. */
  50164. private _setupGroundMirrorTexture;
  50165. /**
  50166. * Setup the ground to receive the mirror texture.
  50167. */
  50168. private _setupMirrorInGroundMaterial;
  50169. /**
  50170. * Setup the skybox according to the specified options.
  50171. */
  50172. private _setupSkybox;
  50173. /**
  50174. * Setup the skybox material according to the specified options.
  50175. */
  50176. private _setupSkyboxMaterial;
  50177. /**
  50178. * Setup the skybox reflection texture according to the specified options.
  50179. */
  50180. private _setupSkyboxReflectionTexture;
  50181. private _errorHandler;
  50182. /**
  50183. * Dispose all the elements created by the Helper.
  50184. */
  50185. dispose(): void;
  50186. }
  50187. }
  50188. declare module BABYLON {
  50189. /**
  50190. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50191. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50192. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50193. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50194. */
  50195. export class PhotoDome extends TransformNode {
  50196. /**
  50197. * Define the image as a Monoscopic panoramic 360 image.
  50198. */
  50199. static readonly MODE_MONOSCOPIC: number;
  50200. /**
  50201. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50202. */
  50203. static readonly MODE_TOPBOTTOM: number;
  50204. /**
  50205. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50206. */
  50207. static readonly MODE_SIDEBYSIDE: number;
  50208. private _useDirectMapping;
  50209. /**
  50210. * The texture being displayed on the sphere
  50211. */
  50212. protected _photoTexture: Texture;
  50213. /**
  50214. * Gets or sets the texture being displayed on the sphere
  50215. */
  50216. get photoTexture(): Texture;
  50217. set photoTexture(value: Texture);
  50218. /**
  50219. * Observable raised when an error occured while loading the 360 image
  50220. */
  50221. onLoadErrorObservable: Observable<string>;
  50222. /**
  50223. * The skybox material
  50224. */
  50225. protected _material: BackgroundMaterial;
  50226. /**
  50227. * The surface used for the skybox
  50228. */
  50229. protected _mesh: Mesh;
  50230. /**
  50231. * Gets the mesh used for the skybox.
  50232. */
  50233. get mesh(): Mesh;
  50234. /**
  50235. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50236. * Also see the options.resolution property.
  50237. */
  50238. get fovMultiplier(): number;
  50239. set fovMultiplier(value: number);
  50240. private _imageMode;
  50241. /**
  50242. * Gets or set the current video mode for the video. It can be:
  50243. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50244. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50245. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50246. */
  50247. get imageMode(): number;
  50248. set imageMode(value: number);
  50249. /**
  50250. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50251. * @param name Element's name, child elements will append suffixes for their own names.
  50252. * @param urlsOfPhoto defines the url of the photo to display
  50253. * @param options defines an object containing optional or exposed sub element properties
  50254. * @param onError defines a callback called when an error occured while loading the texture
  50255. */
  50256. constructor(name: string, urlOfPhoto: string, options: {
  50257. resolution?: number;
  50258. size?: number;
  50259. useDirectMapping?: boolean;
  50260. faceForward?: boolean;
  50261. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50262. private _onBeforeCameraRenderObserver;
  50263. private _changeImageMode;
  50264. /**
  50265. * Releases resources associated with this node.
  50266. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50267. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50268. */
  50269. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50270. }
  50271. }
  50272. declare module BABYLON {
  50273. /**
  50274. * Class used to host RGBD texture specific utilities
  50275. */
  50276. export class RGBDTextureTools {
  50277. /**
  50278. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50279. * @param texture the texture to expand.
  50280. */
  50281. static ExpandRGBDTexture(texture: Texture): void;
  50282. }
  50283. }
  50284. declare module BABYLON {
  50285. /**
  50286. * Class used to host texture specific utilities
  50287. */
  50288. export class BRDFTextureTools {
  50289. /**
  50290. * Prevents texture cache collision
  50291. */
  50292. private static _instanceNumber;
  50293. /**
  50294. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50295. * @param scene defines the hosting scene
  50296. * @returns the environment BRDF texture
  50297. */
  50298. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50299. private static _environmentBRDFBase64Texture;
  50300. }
  50301. }
  50302. declare module BABYLON {
  50303. /**
  50304. * @hidden
  50305. */
  50306. export interface IMaterialClearCoatDefines {
  50307. CLEARCOAT: boolean;
  50308. CLEARCOAT_DEFAULTIOR: boolean;
  50309. CLEARCOAT_TEXTURE: boolean;
  50310. CLEARCOAT_TEXTUREDIRECTUV: number;
  50311. CLEARCOAT_BUMP: boolean;
  50312. CLEARCOAT_BUMPDIRECTUV: number;
  50313. CLEARCOAT_TINT: boolean;
  50314. CLEARCOAT_TINT_TEXTURE: boolean;
  50315. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50316. /** @hidden */
  50317. _areTexturesDirty: boolean;
  50318. }
  50319. /**
  50320. * Define the code related to the clear coat parameters of the pbr material.
  50321. */
  50322. export class PBRClearCoatConfiguration {
  50323. /**
  50324. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50325. * The default fits with a polyurethane material.
  50326. */
  50327. private static readonly _DefaultIndexOfRefraction;
  50328. private _isEnabled;
  50329. /**
  50330. * Defines if the clear coat is enabled in the material.
  50331. */
  50332. isEnabled: boolean;
  50333. /**
  50334. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50335. */
  50336. intensity: number;
  50337. /**
  50338. * Defines the clear coat layer roughness.
  50339. */
  50340. roughness: number;
  50341. private _indexOfRefraction;
  50342. /**
  50343. * Defines the index of refraction of the clear coat.
  50344. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50345. * The default fits with a polyurethane material.
  50346. * Changing the default value is more performance intensive.
  50347. */
  50348. indexOfRefraction: number;
  50349. private _texture;
  50350. /**
  50351. * Stores the clear coat values in a texture.
  50352. */
  50353. texture: Nullable<BaseTexture>;
  50354. private _bumpTexture;
  50355. /**
  50356. * Define the clear coat specific bump texture.
  50357. */
  50358. bumpTexture: Nullable<BaseTexture>;
  50359. private _isTintEnabled;
  50360. /**
  50361. * Defines if the clear coat tint is enabled in the material.
  50362. */
  50363. isTintEnabled: boolean;
  50364. /**
  50365. * Defines the clear coat tint of the material.
  50366. * This is only use if tint is enabled
  50367. */
  50368. tintColor: Color3;
  50369. /**
  50370. * Defines the distance at which the tint color should be found in the
  50371. * clear coat media.
  50372. * This is only use if tint is enabled
  50373. */
  50374. tintColorAtDistance: number;
  50375. /**
  50376. * Defines the clear coat layer thickness.
  50377. * This is only use if tint is enabled
  50378. */
  50379. tintThickness: number;
  50380. private _tintTexture;
  50381. /**
  50382. * Stores the clear tint values in a texture.
  50383. * rgb is tint
  50384. * a is a thickness factor
  50385. */
  50386. tintTexture: Nullable<BaseTexture>;
  50387. /** @hidden */
  50388. private _internalMarkAllSubMeshesAsTexturesDirty;
  50389. /** @hidden */
  50390. _markAllSubMeshesAsTexturesDirty(): void;
  50391. /**
  50392. * Instantiate a new istance of clear coat configuration.
  50393. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50394. */
  50395. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50396. /**
  50397. * Gets wehter the submesh is ready to be used or not.
  50398. * @param defines the list of "defines" to update.
  50399. * @param scene defines the scene the material belongs to.
  50400. * @param engine defines the engine the material belongs to.
  50401. * @param disableBumpMap defines wether the material disables bump or not.
  50402. * @returns - boolean indicating that the submesh is ready or not.
  50403. */
  50404. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50405. /**
  50406. * Checks to see if a texture is used in the material.
  50407. * @param defines the list of "defines" to update.
  50408. * @param scene defines the scene to the material belongs to.
  50409. */
  50410. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50411. /**
  50412. * Binds the material data.
  50413. * @param uniformBuffer defines the Uniform buffer to fill in.
  50414. * @param scene defines the scene the material belongs to.
  50415. * @param engine defines the engine the material belongs to.
  50416. * @param disableBumpMap defines wether the material disables bump or not.
  50417. * @param isFrozen defines wether the material is frozen or not.
  50418. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50419. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50420. */
  50421. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50422. /**
  50423. * Checks to see if a texture is used in the material.
  50424. * @param texture - Base texture to use.
  50425. * @returns - Boolean specifying if a texture is used in the material.
  50426. */
  50427. hasTexture(texture: BaseTexture): boolean;
  50428. /**
  50429. * Returns an array of the actively used textures.
  50430. * @param activeTextures Array of BaseTextures
  50431. */
  50432. getActiveTextures(activeTextures: BaseTexture[]): void;
  50433. /**
  50434. * Returns the animatable textures.
  50435. * @param animatables Array of animatable textures.
  50436. */
  50437. getAnimatables(animatables: IAnimatable[]): void;
  50438. /**
  50439. * Disposes the resources of the material.
  50440. * @param forceDisposeTextures - Forces the disposal of all textures.
  50441. */
  50442. dispose(forceDisposeTextures?: boolean): void;
  50443. /**
  50444. * Get the current class name of the texture useful for serialization or dynamic coding.
  50445. * @returns "PBRClearCoatConfiguration"
  50446. */
  50447. getClassName(): string;
  50448. /**
  50449. * Add fallbacks to the effect fallbacks list.
  50450. * @param defines defines the Base texture to use.
  50451. * @param fallbacks defines the current fallback list.
  50452. * @param currentRank defines the current fallback rank.
  50453. * @returns the new fallback rank.
  50454. */
  50455. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50456. /**
  50457. * Add the required uniforms to the current list.
  50458. * @param uniforms defines the current uniform list.
  50459. */
  50460. static AddUniforms(uniforms: string[]): void;
  50461. /**
  50462. * Add the required samplers to the current list.
  50463. * @param samplers defines the current sampler list.
  50464. */
  50465. static AddSamplers(samplers: string[]): void;
  50466. /**
  50467. * Add the required uniforms to the current buffer.
  50468. * @param uniformBuffer defines the current uniform buffer.
  50469. */
  50470. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50471. /**
  50472. * Makes a duplicate of the current configuration into another one.
  50473. * @param clearCoatConfiguration define the config where to copy the info
  50474. */
  50475. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50476. /**
  50477. * Serializes this clear coat configuration.
  50478. * @returns - An object with the serialized config.
  50479. */
  50480. serialize(): any;
  50481. /**
  50482. * Parses a anisotropy Configuration from a serialized object.
  50483. * @param source - Serialized object.
  50484. * @param scene Defines the scene we are parsing for
  50485. * @param rootUrl Defines the rootUrl to load from
  50486. */
  50487. parse(source: any, scene: Scene, rootUrl: string): void;
  50488. }
  50489. }
  50490. declare module BABYLON {
  50491. /**
  50492. * @hidden
  50493. */
  50494. export interface IMaterialAnisotropicDefines {
  50495. ANISOTROPIC: boolean;
  50496. ANISOTROPIC_TEXTURE: boolean;
  50497. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50498. MAINUV1: boolean;
  50499. _areTexturesDirty: boolean;
  50500. _needUVs: boolean;
  50501. }
  50502. /**
  50503. * Define the code related to the anisotropic parameters of the pbr material.
  50504. */
  50505. export class PBRAnisotropicConfiguration {
  50506. private _isEnabled;
  50507. /**
  50508. * Defines if the anisotropy is enabled in the material.
  50509. */
  50510. isEnabled: boolean;
  50511. /**
  50512. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50513. */
  50514. intensity: number;
  50515. /**
  50516. * Defines if the effect is along the tangents, bitangents or in between.
  50517. * By default, the effect is "strectching" the highlights along the tangents.
  50518. */
  50519. direction: Vector2;
  50520. private _texture;
  50521. /**
  50522. * Stores the anisotropy values in a texture.
  50523. * rg is direction (like normal from -1 to 1)
  50524. * b is a intensity
  50525. */
  50526. texture: Nullable<BaseTexture>;
  50527. /** @hidden */
  50528. private _internalMarkAllSubMeshesAsTexturesDirty;
  50529. /** @hidden */
  50530. _markAllSubMeshesAsTexturesDirty(): void;
  50531. /**
  50532. * Instantiate a new istance of anisotropy configuration.
  50533. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50534. */
  50535. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50536. /**
  50537. * Specifies that the submesh is ready to be used.
  50538. * @param defines the list of "defines" to update.
  50539. * @param scene defines the scene the material belongs to.
  50540. * @returns - boolean indicating that the submesh is ready or not.
  50541. */
  50542. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50543. /**
  50544. * Checks to see if a texture is used in the material.
  50545. * @param defines the list of "defines" to update.
  50546. * @param mesh the mesh we are preparing the defines for.
  50547. * @param scene defines the scene the material belongs to.
  50548. */
  50549. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50550. /**
  50551. * Binds the material data.
  50552. * @param uniformBuffer defines the Uniform buffer to fill in.
  50553. * @param scene defines the scene the material belongs to.
  50554. * @param isFrozen defines wether the material is frozen or not.
  50555. */
  50556. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50557. /**
  50558. * Checks to see if a texture is used in the material.
  50559. * @param texture - Base texture to use.
  50560. * @returns - Boolean specifying if a texture is used in the material.
  50561. */
  50562. hasTexture(texture: BaseTexture): boolean;
  50563. /**
  50564. * Returns an array of the actively used textures.
  50565. * @param activeTextures Array of BaseTextures
  50566. */
  50567. getActiveTextures(activeTextures: BaseTexture[]): void;
  50568. /**
  50569. * Returns the animatable textures.
  50570. * @param animatables Array of animatable textures.
  50571. */
  50572. getAnimatables(animatables: IAnimatable[]): void;
  50573. /**
  50574. * Disposes the resources of the material.
  50575. * @param forceDisposeTextures - Forces the disposal of all textures.
  50576. */
  50577. dispose(forceDisposeTextures?: boolean): void;
  50578. /**
  50579. * Get the current class name of the texture useful for serialization or dynamic coding.
  50580. * @returns "PBRAnisotropicConfiguration"
  50581. */
  50582. getClassName(): string;
  50583. /**
  50584. * Add fallbacks to the effect fallbacks list.
  50585. * @param defines defines the Base texture to use.
  50586. * @param fallbacks defines the current fallback list.
  50587. * @param currentRank defines the current fallback rank.
  50588. * @returns the new fallback rank.
  50589. */
  50590. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50591. /**
  50592. * Add the required uniforms to the current list.
  50593. * @param uniforms defines the current uniform list.
  50594. */
  50595. static AddUniforms(uniforms: string[]): void;
  50596. /**
  50597. * Add the required uniforms to the current buffer.
  50598. * @param uniformBuffer defines the current uniform buffer.
  50599. */
  50600. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50601. /**
  50602. * Add the required samplers to the current list.
  50603. * @param samplers defines the current sampler list.
  50604. */
  50605. static AddSamplers(samplers: string[]): void;
  50606. /**
  50607. * Makes a duplicate of the current configuration into another one.
  50608. * @param anisotropicConfiguration define the config where to copy the info
  50609. */
  50610. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50611. /**
  50612. * Serializes this anisotropy configuration.
  50613. * @returns - An object with the serialized config.
  50614. */
  50615. serialize(): any;
  50616. /**
  50617. * Parses a anisotropy Configuration from a serialized object.
  50618. * @param source - Serialized object.
  50619. * @param scene Defines the scene we are parsing for
  50620. * @param rootUrl Defines the rootUrl to load from
  50621. */
  50622. parse(source: any, scene: Scene, rootUrl: string): void;
  50623. }
  50624. }
  50625. declare module BABYLON {
  50626. /**
  50627. * @hidden
  50628. */
  50629. export interface IMaterialBRDFDefines {
  50630. BRDF_V_HEIGHT_CORRELATED: boolean;
  50631. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50632. SPHERICAL_HARMONICS: boolean;
  50633. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50634. /** @hidden */
  50635. _areMiscDirty: boolean;
  50636. }
  50637. /**
  50638. * Define the code related to the BRDF parameters of the pbr material.
  50639. */
  50640. export class PBRBRDFConfiguration {
  50641. /**
  50642. * Default value used for the energy conservation.
  50643. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50644. */
  50645. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50646. /**
  50647. * Default value used for the Smith Visibility Height Correlated mode.
  50648. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50649. */
  50650. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50651. /**
  50652. * Default value used for the IBL diffuse part.
  50653. * This can help switching back to the polynomials mode globally which is a tiny bit
  50654. * less GPU intensive at the drawback of a lower quality.
  50655. */
  50656. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50657. /**
  50658. * Default value used for activating energy conservation for the specular workflow.
  50659. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50660. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50661. */
  50662. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50663. private _useEnergyConservation;
  50664. /**
  50665. * Defines if the material uses energy conservation.
  50666. */
  50667. useEnergyConservation: boolean;
  50668. private _useSmithVisibilityHeightCorrelated;
  50669. /**
  50670. * LEGACY Mode set to false
  50671. * Defines if the material uses height smith correlated visibility term.
  50672. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50673. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50674. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50675. * Not relying on height correlated will also disable energy conservation.
  50676. */
  50677. useSmithVisibilityHeightCorrelated: boolean;
  50678. private _useSphericalHarmonics;
  50679. /**
  50680. * LEGACY Mode set to false
  50681. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50682. * diffuse part of the IBL.
  50683. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50684. * to the ground truth.
  50685. */
  50686. useSphericalHarmonics: boolean;
  50687. private _useSpecularGlossinessInputEnergyConservation;
  50688. /**
  50689. * Defines if the material uses energy conservation, when the specular workflow is active.
  50690. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50691. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50692. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50693. */
  50694. useSpecularGlossinessInputEnergyConservation: boolean;
  50695. /** @hidden */
  50696. private _internalMarkAllSubMeshesAsMiscDirty;
  50697. /** @hidden */
  50698. _markAllSubMeshesAsMiscDirty(): void;
  50699. /**
  50700. * Instantiate a new istance of clear coat configuration.
  50701. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50702. */
  50703. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50704. /**
  50705. * Checks to see if a texture is used in the material.
  50706. * @param defines the list of "defines" to update.
  50707. */
  50708. prepareDefines(defines: IMaterialBRDFDefines): void;
  50709. /**
  50710. * Get the current class name of the texture useful for serialization or dynamic coding.
  50711. * @returns "PBRClearCoatConfiguration"
  50712. */
  50713. getClassName(): string;
  50714. /**
  50715. * Makes a duplicate of the current configuration into another one.
  50716. * @param brdfConfiguration define the config where to copy the info
  50717. */
  50718. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50719. /**
  50720. * Serializes this BRDF configuration.
  50721. * @returns - An object with the serialized config.
  50722. */
  50723. serialize(): any;
  50724. /**
  50725. * Parses a anisotropy Configuration from a serialized object.
  50726. * @param source - Serialized object.
  50727. * @param scene Defines the scene we are parsing for
  50728. * @param rootUrl Defines the rootUrl to load from
  50729. */
  50730. parse(source: any, scene: Scene, rootUrl: string): void;
  50731. }
  50732. }
  50733. declare module BABYLON {
  50734. /**
  50735. * @hidden
  50736. */
  50737. export interface IMaterialSheenDefines {
  50738. SHEEN: boolean;
  50739. SHEEN_TEXTURE: boolean;
  50740. SHEEN_TEXTUREDIRECTUV: number;
  50741. SHEEN_LINKWITHALBEDO: boolean;
  50742. SHEEN_ROUGHNESS: boolean;
  50743. SHEEN_ALBEDOSCALING: boolean;
  50744. /** @hidden */
  50745. _areTexturesDirty: boolean;
  50746. }
  50747. /**
  50748. * Define the code related to the Sheen parameters of the pbr material.
  50749. */
  50750. export class PBRSheenConfiguration {
  50751. private _isEnabled;
  50752. /**
  50753. * Defines if the material uses sheen.
  50754. */
  50755. isEnabled: boolean;
  50756. private _linkSheenWithAlbedo;
  50757. /**
  50758. * Defines if the sheen is linked to the sheen color.
  50759. */
  50760. linkSheenWithAlbedo: boolean;
  50761. /**
  50762. * Defines the sheen intensity.
  50763. */
  50764. intensity: number;
  50765. /**
  50766. * Defines the sheen color.
  50767. */
  50768. color: Color3;
  50769. private _texture;
  50770. /**
  50771. * Stores the sheen tint values in a texture.
  50772. * rgb is tint
  50773. * a is a intensity
  50774. */
  50775. texture: Nullable<BaseTexture>;
  50776. private _roughness;
  50777. /**
  50778. * Defines the sheen roughness.
  50779. * It is not taken into account if linkSheenWithAlbedo is true.
  50780. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50781. */
  50782. roughness: Nullable<number>;
  50783. private _albedoScaling;
  50784. /**
  50785. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50786. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50787. * making it easier to setup and tweak the effect
  50788. */
  50789. albedoScaling: boolean;
  50790. /** @hidden */
  50791. private _internalMarkAllSubMeshesAsTexturesDirty;
  50792. /** @hidden */
  50793. _markAllSubMeshesAsTexturesDirty(): void;
  50794. /**
  50795. * Instantiate a new istance of clear coat configuration.
  50796. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50797. */
  50798. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50799. /**
  50800. * Specifies that the submesh is ready to be used.
  50801. * @param defines the list of "defines" to update.
  50802. * @param scene defines the scene the material belongs to.
  50803. * @returns - boolean indicating that the submesh is ready or not.
  50804. */
  50805. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50806. /**
  50807. * Checks to see if a texture is used in the material.
  50808. * @param defines the list of "defines" to update.
  50809. * @param scene defines the scene the material belongs to.
  50810. */
  50811. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50812. /**
  50813. * Binds the material data.
  50814. * @param uniformBuffer defines the Uniform buffer to fill in.
  50815. * @param scene defines the scene the material belongs to.
  50816. * @param isFrozen defines wether the material is frozen or not.
  50817. */
  50818. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50819. /**
  50820. * Checks to see if a texture is used in the material.
  50821. * @param texture - Base texture to use.
  50822. * @returns - Boolean specifying if a texture is used in the material.
  50823. */
  50824. hasTexture(texture: BaseTexture): boolean;
  50825. /**
  50826. * Returns an array of the actively used textures.
  50827. * @param activeTextures Array of BaseTextures
  50828. */
  50829. getActiveTextures(activeTextures: BaseTexture[]): void;
  50830. /**
  50831. * Returns the animatable textures.
  50832. * @param animatables Array of animatable textures.
  50833. */
  50834. getAnimatables(animatables: IAnimatable[]): void;
  50835. /**
  50836. * Disposes the resources of the material.
  50837. * @param forceDisposeTextures - Forces the disposal of all textures.
  50838. */
  50839. dispose(forceDisposeTextures?: boolean): void;
  50840. /**
  50841. * Get the current class name of the texture useful for serialization or dynamic coding.
  50842. * @returns "PBRSheenConfiguration"
  50843. */
  50844. getClassName(): string;
  50845. /**
  50846. * Add fallbacks to the effect fallbacks list.
  50847. * @param defines defines the Base texture to use.
  50848. * @param fallbacks defines the current fallback list.
  50849. * @param currentRank defines the current fallback rank.
  50850. * @returns the new fallback rank.
  50851. */
  50852. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50853. /**
  50854. * Add the required uniforms to the current list.
  50855. * @param uniforms defines the current uniform list.
  50856. */
  50857. static AddUniforms(uniforms: string[]): void;
  50858. /**
  50859. * Add the required uniforms to the current buffer.
  50860. * @param uniformBuffer defines the current uniform buffer.
  50861. */
  50862. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50863. /**
  50864. * Add the required samplers to the current list.
  50865. * @param samplers defines the current sampler list.
  50866. */
  50867. static AddSamplers(samplers: string[]): void;
  50868. /**
  50869. * Makes a duplicate of the current configuration into another one.
  50870. * @param sheenConfiguration define the config where to copy the info
  50871. */
  50872. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50873. /**
  50874. * Serializes this BRDF configuration.
  50875. * @returns - An object with the serialized config.
  50876. */
  50877. serialize(): any;
  50878. /**
  50879. * Parses a anisotropy Configuration from a serialized object.
  50880. * @param source - Serialized object.
  50881. * @param scene Defines the scene we are parsing for
  50882. * @param rootUrl Defines the rootUrl to load from
  50883. */
  50884. parse(source: any, scene: Scene, rootUrl: string): void;
  50885. }
  50886. }
  50887. declare module BABYLON {
  50888. /**
  50889. * @hidden
  50890. */
  50891. export interface IMaterialSubSurfaceDefines {
  50892. SUBSURFACE: boolean;
  50893. SS_REFRACTION: boolean;
  50894. SS_TRANSLUCENCY: boolean;
  50895. SS_SCATERRING: boolean;
  50896. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50897. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50898. SS_REFRACTIONMAP_3D: boolean;
  50899. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50900. SS_LODINREFRACTIONALPHA: boolean;
  50901. SS_GAMMAREFRACTION: boolean;
  50902. SS_RGBDREFRACTION: boolean;
  50903. SS_LINEARSPECULARREFRACTION: boolean;
  50904. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50905. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50906. /** @hidden */
  50907. _areTexturesDirty: boolean;
  50908. }
  50909. /**
  50910. * Define the code related to the sub surface parameters of the pbr material.
  50911. */
  50912. export class PBRSubSurfaceConfiguration {
  50913. private _isRefractionEnabled;
  50914. /**
  50915. * Defines if the refraction is enabled in the material.
  50916. */
  50917. isRefractionEnabled: boolean;
  50918. private _isTranslucencyEnabled;
  50919. /**
  50920. * Defines if the translucency is enabled in the material.
  50921. */
  50922. isTranslucencyEnabled: boolean;
  50923. private _isScatteringEnabled;
  50924. /**
  50925. * Defines the refraction intensity of the material.
  50926. * The refraction when enabled replaces the Diffuse part of the material.
  50927. * The intensity helps transitionning between diffuse and refraction.
  50928. */
  50929. refractionIntensity: number;
  50930. /**
  50931. * Defines the translucency intensity of the material.
  50932. * When translucency has been enabled, this defines how much of the "translucency"
  50933. * is addded to the diffuse part of the material.
  50934. */
  50935. translucencyIntensity: number;
  50936. /**
  50937. * Defines the scattering intensity of the material.
  50938. * When scattering has been enabled, this defines how much of the "scattered light"
  50939. * is addded to the diffuse part of the material.
  50940. */
  50941. scatteringIntensity: number;
  50942. private _thicknessTexture;
  50943. /**
  50944. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50945. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50946. * 0 would mean minimumThickness
  50947. * 1 would mean maximumThickness
  50948. * The other channels might be use as a mask to vary the different effects intensity.
  50949. */
  50950. thicknessTexture: Nullable<BaseTexture>;
  50951. private _refractionTexture;
  50952. /**
  50953. * Defines the texture to use for refraction.
  50954. */
  50955. refractionTexture: Nullable<BaseTexture>;
  50956. private _indexOfRefraction;
  50957. /**
  50958. * Defines the index of refraction used in the material.
  50959. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50960. */
  50961. indexOfRefraction: number;
  50962. private _invertRefractionY;
  50963. /**
  50964. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50965. */
  50966. invertRefractionY: boolean;
  50967. private _linkRefractionWithTransparency;
  50968. /**
  50969. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50970. * Materials half opaque for instance using refraction could benefit from this control.
  50971. */
  50972. linkRefractionWithTransparency: boolean;
  50973. /**
  50974. * Defines the minimum thickness stored in the thickness map.
  50975. * If no thickness map is defined, this value will be used to simulate thickness.
  50976. */
  50977. minimumThickness: number;
  50978. /**
  50979. * Defines the maximum thickness stored in the thickness map.
  50980. */
  50981. maximumThickness: number;
  50982. /**
  50983. * Defines the volume tint of the material.
  50984. * This is used for both translucency and scattering.
  50985. */
  50986. tintColor: Color3;
  50987. /**
  50988. * Defines the distance at which the tint color should be found in the media.
  50989. * This is used for refraction only.
  50990. */
  50991. tintColorAtDistance: number;
  50992. /**
  50993. * Defines how far each channel transmit through the media.
  50994. * It is defined as a color to simplify it selection.
  50995. */
  50996. diffusionDistance: Color3;
  50997. private _useMaskFromThicknessTexture;
  50998. /**
  50999. * Stores the intensity of the different subsurface effects in the thickness texture.
  51000. * * the green channel is the translucency intensity.
  51001. * * the blue channel is the scattering intensity.
  51002. * * the alpha channel is the refraction intensity.
  51003. */
  51004. useMaskFromThicknessTexture: boolean;
  51005. /** @hidden */
  51006. private _internalMarkAllSubMeshesAsTexturesDirty;
  51007. /** @hidden */
  51008. _markAllSubMeshesAsTexturesDirty(): void;
  51009. /**
  51010. * Instantiate a new istance of sub surface configuration.
  51011. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51012. */
  51013. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51014. /**
  51015. * Gets wehter the submesh is ready to be used or not.
  51016. * @param defines the list of "defines" to update.
  51017. * @param scene defines the scene the material belongs to.
  51018. * @returns - boolean indicating that the submesh is ready or not.
  51019. */
  51020. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51021. /**
  51022. * Checks to see if a texture is used in the material.
  51023. * @param defines the list of "defines" to update.
  51024. * @param scene defines the scene to the material belongs to.
  51025. */
  51026. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51027. /**
  51028. * Binds the material data.
  51029. * @param uniformBuffer defines the Uniform buffer to fill in.
  51030. * @param scene defines the scene the material belongs to.
  51031. * @param engine defines the engine the material belongs to.
  51032. * @param isFrozen defines wether the material is frozen or not.
  51033. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51034. */
  51035. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51036. /**
  51037. * Unbinds the material from the mesh.
  51038. * @param activeEffect defines the effect that should be unbound from.
  51039. * @returns true if unbound, otherwise false
  51040. */
  51041. unbind(activeEffect: Effect): boolean;
  51042. /**
  51043. * Returns the texture used for refraction or null if none is used.
  51044. * @param scene defines the scene the material belongs to.
  51045. * @returns - Refraction texture if present. If no refraction texture and refraction
  51046. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51047. */
  51048. private _getRefractionTexture;
  51049. /**
  51050. * Returns true if alpha blending should be disabled.
  51051. */
  51052. get disableAlphaBlending(): boolean;
  51053. /**
  51054. * Fills the list of render target textures.
  51055. * @param renderTargets the list of render targets to update
  51056. */
  51057. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51058. /**
  51059. * Checks to see if a texture is used in the material.
  51060. * @param texture - Base texture to use.
  51061. * @returns - Boolean specifying if a texture is used in the material.
  51062. */
  51063. hasTexture(texture: BaseTexture): boolean;
  51064. /**
  51065. * Gets a boolean indicating that current material needs to register RTT
  51066. * @returns true if this uses a render target otherwise false.
  51067. */
  51068. hasRenderTargetTextures(): boolean;
  51069. /**
  51070. * Returns an array of the actively used textures.
  51071. * @param activeTextures Array of BaseTextures
  51072. */
  51073. getActiveTextures(activeTextures: BaseTexture[]): void;
  51074. /**
  51075. * Returns the animatable textures.
  51076. * @param animatables Array of animatable textures.
  51077. */
  51078. getAnimatables(animatables: IAnimatable[]): void;
  51079. /**
  51080. * Disposes the resources of the material.
  51081. * @param forceDisposeTextures - Forces the disposal of all textures.
  51082. */
  51083. dispose(forceDisposeTextures?: boolean): void;
  51084. /**
  51085. * Get the current class name of the texture useful for serialization or dynamic coding.
  51086. * @returns "PBRSubSurfaceConfiguration"
  51087. */
  51088. getClassName(): string;
  51089. /**
  51090. * Add fallbacks to the effect fallbacks list.
  51091. * @param defines defines the Base texture to use.
  51092. * @param fallbacks defines the current fallback list.
  51093. * @param currentRank defines the current fallback rank.
  51094. * @returns the new fallback rank.
  51095. */
  51096. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51097. /**
  51098. * Add the required uniforms to the current list.
  51099. * @param uniforms defines the current uniform list.
  51100. */
  51101. static AddUniforms(uniforms: string[]): void;
  51102. /**
  51103. * Add the required samplers to the current list.
  51104. * @param samplers defines the current sampler list.
  51105. */
  51106. static AddSamplers(samplers: string[]): void;
  51107. /**
  51108. * Add the required uniforms to the current buffer.
  51109. * @param uniformBuffer defines the current uniform buffer.
  51110. */
  51111. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51112. /**
  51113. * Makes a duplicate of the current configuration into another one.
  51114. * @param configuration define the config where to copy the info
  51115. */
  51116. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51117. /**
  51118. * Serializes this Sub Surface configuration.
  51119. * @returns - An object with the serialized config.
  51120. */
  51121. serialize(): any;
  51122. /**
  51123. * Parses a anisotropy Configuration from a serialized object.
  51124. * @param source - Serialized object.
  51125. * @param scene Defines the scene we are parsing for
  51126. * @param rootUrl Defines the rootUrl to load from
  51127. */
  51128. parse(source: any, scene: Scene, rootUrl: string): void;
  51129. }
  51130. }
  51131. declare module BABYLON {
  51132. /** @hidden */
  51133. export var pbrFragmentDeclaration: {
  51134. name: string;
  51135. shader: string;
  51136. };
  51137. }
  51138. declare module BABYLON {
  51139. /** @hidden */
  51140. export var pbrUboDeclaration: {
  51141. name: string;
  51142. shader: string;
  51143. };
  51144. }
  51145. declare module BABYLON {
  51146. /** @hidden */
  51147. export var pbrFragmentExtraDeclaration: {
  51148. name: string;
  51149. shader: string;
  51150. };
  51151. }
  51152. declare module BABYLON {
  51153. /** @hidden */
  51154. export var pbrFragmentSamplersDeclaration: {
  51155. name: string;
  51156. shader: string;
  51157. };
  51158. }
  51159. declare module BABYLON {
  51160. /** @hidden */
  51161. export var pbrHelperFunctions: {
  51162. name: string;
  51163. shader: string;
  51164. };
  51165. }
  51166. declare module BABYLON {
  51167. /** @hidden */
  51168. export var harmonicsFunctions: {
  51169. name: string;
  51170. shader: string;
  51171. };
  51172. }
  51173. declare module BABYLON {
  51174. /** @hidden */
  51175. export var pbrDirectLightingSetupFunctions: {
  51176. name: string;
  51177. shader: string;
  51178. };
  51179. }
  51180. declare module BABYLON {
  51181. /** @hidden */
  51182. export var pbrDirectLightingFalloffFunctions: {
  51183. name: string;
  51184. shader: string;
  51185. };
  51186. }
  51187. declare module BABYLON {
  51188. /** @hidden */
  51189. export var pbrBRDFFunctions: {
  51190. name: string;
  51191. shader: string;
  51192. };
  51193. }
  51194. declare module BABYLON {
  51195. /** @hidden */
  51196. export var pbrDirectLightingFunctions: {
  51197. name: string;
  51198. shader: string;
  51199. };
  51200. }
  51201. declare module BABYLON {
  51202. /** @hidden */
  51203. export var pbrIBLFunctions: {
  51204. name: string;
  51205. shader: string;
  51206. };
  51207. }
  51208. declare module BABYLON {
  51209. /** @hidden */
  51210. export var pbrBlockAlbedoOpacity: {
  51211. name: string;
  51212. shader: string;
  51213. };
  51214. }
  51215. declare module BABYLON {
  51216. /** @hidden */
  51217. export var pbrBlockReflectivity: {
  51218. name: string;
  51219. shader: string;
  51220. };
  51221. }
  51222. declare module BABYLON {
  51223. /** @hidden */
  51224. export var pbrBlockAmbientOcclusion: {
  51225. name: string;
  51226. shader: string;
  51227. };
  51228. }
  51229. declare module BABYLON {
  51230. /** @hidden */
  51231. export var pbrBlockAlphaFresnel: {
  51232. name: string;
  51233. shader: string;
  51234. };
  51235. }
  51236. declare module BABYLON {
  51237. /** @hidden */
  51238. export var pbrBlockAnisotropic: {
  51239. name: string;
  51240. shader: string;
  51241. };
  51242. }
  51243. declare module BABYLON {
  51244. /** @hidden */
  51245. export var pbrBlockReflection: {
  51246. name: string;
  51247. shader: string;
  51248. };
  51249. }
  51250. declare module BABYLON {
  51251. /** @hidden */
  51252. export var pbrBlockSheen: {
  51253. name: string;
  51254. shader: string;
  51255. };
  51256. }
  51257. declare module BABYLON {
  51258. /** @hidden */
  51259. export var pbrBlockClearcoat: {
  51260. name: string;
  51261. shader: string;
  51262. };
  51263. }
  51264. declare module BABYLON {
  51265. /** @hidden */
  51266. export var pbrBlockSubSurface: {
  51267. name: string;
  51268. shader: string;
  51269. };
  51270. }
  51271. declare module BABYLON {
  51272. /** @hidden */
  51273. export var pbrBlockNormalGeometric: {
  51274. name: string;
  51275. shader: string;
  51276. };
  51277. }
  51278. declare module BABYLON {
  51279. /** @hidden */
  51280. export var pbrBlockNormalFinal: {
  51281. name: string;
  51282. shader: string;
  51283. };
  51284. }
  51285. declare module BABYLON {
  51286. /** @hidden */
  51287. export var pbrBlockGeometryInfo: {
  51288. name: string;
  51289. shader: string;
  51290. };
  51291. }
  51292. declare module BABYLON {
  51293. /** @hidden */
  51294. export var pbrBlockReflectance0: {
  51295. name: string;
  51296. shader: string;
  51297. };
  51298. }
  51299. declare module BABYLON {
  51300. /** @hidden */
  51301. export var pbrBlockReflectance: {
  51302. name: string;
  51303. shader: string;
  51304. };
  51305. }
  51306. declare module BABYLON {
  51307. /** @hidden */
  51308. export var pbrBlockDirectLighting: {
  51309. name: string;
  51310. shader: string;
  51311. };
  51312. }
  51313. declare module BABYLON {
  51314. /** @hidden */
  51315. export var pbrBlockFinalLitComponents: {
  51316. name: string;
  51317. shader: string;
  51318. };
  51319. }
  51320. declare module BABYLON {
  51321. /** @hidden */
  51322. export var pbrBlockFinalUnlitComponents: {
  51323. name: string;
  51324. shader: string;
  51325. };
  51326. }
  51327. declare module BABYLON {
  51328. /** @hidden */
  51329. export var pbrBlockFinalColorComposition: {
  51330. name: string;
  51331. shader: string;
  51332. };
  51333. }
  51334. declare module BABYLON {
  51335. /** @hidden */
  51336. export var pbrBlockImageProcessing: {
  51337. name: string;
  51338. shader: string;
  51339. };
  51340. }
  51341. declare module BABYLON {
  51342. /** @hidden */
  51343. export var pbrDebug: {
  51344. name: string;
  51345. shader: string;
  51346. };
  51347. }
  51348. declare module BABYLON {
  51349. /** @hidden */
  51350. export var pbrPixelShader: {
  51351. name: string;
  51352. shader: string;
  51353. };
  51354. }
  51355. declare module BABYLON {
  51356. /** @hidden */
  51357. export var pbrVertexDeclaration: {
  51358. name: string;
  51359. shader: string;
  51360. };
  51361. }
  51362. declare module BABYLON {
  51363. /** @hidden */
  51364. export var pbrVertexShader: {
  51365. name: string;
  51366. shader: string;
  51367. };
  51368. }
  51369. declare module BABYLON {
  51370. /**
  51371. * Manages the defines for the PBR Material.
  51372. * @hidden
  51373. */
  51374. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51375. PBR: boolean;
  51376. MAINUV1: boolean;
  51377. MAINUV2: boolean;
  51378. UV1: boolean;
  51379. UV2: boolean;
  51380. ALBEDO: boolean;
  51381. GAMMAALBEDO: boolean;
  51382. ALBEDODIRECTUV: number;
  51383. VERTEXCOLOR: boolean;
  51384. AMBIENT: boolean;
  51385. AMBIENTDIRECTUV: number;
  51386. AMBIENTINGRAYSCALE: boolean;
  51387. OPACITY: boolean;
  51388. VERTEXALPHA: boolean;
  51389. OPACITYDIRECTUV: number;
  51390. OPACITYRGB: boolean;
  51391. ALPHATEST: boolean;
  51392. DEPTHPREPASS: boolean;
  51393. ALPHABLEND: boolean;
  51394. ALPHAFROMALBEDO: boolean;
  51395. ALPHATESTVALUE: string;
  51396. SPECULAROVERALPHA: boolean;
  51397. RADIANCEOVERALPHA: boolean;
  51398. ALPHAFRESNEL: boolean;
  51399. LINEARALPHAFRESNEL: boolean;
  51400. PREMULTIPLYALPHA: boolean;
  51401. EMISSIVE: boolean;
  51402. EMISSIVEDIRECTUV: number;
  51403. REFLECTIVITY: boolean;
  51404. REFLECTIVITYDIRECTUV: number;
  51405. SPECULARTERM: boolean;
  51406. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51407. MICROSURFACEAUTOMATIC: boolean;
  51408. LODBASEDMICROSFURACE: boolean;
  51409. MICROSURFACEMAP: boolean;
  51410. MICROSURFACEMAPDIRECTUV: number;
  51411. METALLICWORKFLOW: boolean;
  51412. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51413. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51414. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51415. AOSTOREINMETALMAPRED: boolean;
  51416. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51417. ENVIRONMENTBRDF: boolean;
  51418. ENVIRONMENTBRDF_RGBD: boolean;
  51419. NORMAL: boolean;
  51420. TANGENT: boolean;
  51421. BUMP: boolean;
  51422. BUMPDIRECTUV: number;
  51423. OBJECTSPACE_NORMALMAP: boolean;
  51424. PARALLAX: boolean;
  51425. PARALLAXOCCLUSION: boolean;
  51426. NORMALXYSCALE: boolean;
  51427. LIGHTMAP: boolean;
  51428. LIGHTMAPDIRECTUV: number;
  51429. USELIGHTMAPASSHADOWMAP: boolean;
  51430. GAMMALIGHTMAP: boolean;
  51431. RGBDLIGHTMAP: boolean;
  51432. REFLECTION: boolean;
  51433. REFLECTIONMAP_3D: boolean;
  51434. REFLECTIONMAP_SPHERICAL: boolean;
  51435. REFLECTIONMAP_PLANAR: boolean;
  51436. REFLECTIONMAP_CUBIC: boolean;
  51437. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51438. REFLECTIONMAP_PROJECTION: boolean;
  51439. REFLECTIONMAP_SKYBOX: boolean;
  51440. REFLECTIONMAP_EXPLICIT: boolean;
  51441. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51442. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51443. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51444. INVERTCUBICMAP: boolean;
  51445. USESPHERICALFROMREFLECTIONMAP: boolean;
  51446. USEIRRADIANCEMAP: boolean;
  51447. SPHERICAL_HARMONICS: boolean;
  51448. USESPHERICALINVERTEX: boolean;
  51449. REFLECTIONMAP_OPPOSITEZ: boolean;
  51450. LODINREFLECTIONALPHA: boolean;
  51451. GAMMAREFLECTION: boolean;
  51452. RGBDREFLECTION: boolean;
  51453. LINEARSPECULARREFLECTION: boolean;
  51454. RADIANCEOCCLUSION: boolean;
  51455. HORIZONOCCLUSION: boolean;
  51456. INSTANCES: boolean;
  51457. NUM_BONE_INFLUENCERS: number;
  51458. BonesPerMesh: number;
  51459. BONETEXTURE: boolean;
  51460. NONUNIFORMSCALING: boolean;
  51461. MORPHTARGETS: boolean;
  51462. MORPHTARGETS_NORMAL: boolean;
  51463. MORPHTARGETS_TANGENT: boolean;
  51464. MORPHTARGETS_UV: boolean;
  51465. NUM_MORPH_INFLUENCERS: number;
  51466. IMAGEPROCESSING: boolean;
  51467. VIGNETTE: boolean;
  51468. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51469. VIGNETTEBLENDMODEOPAQUE: boolean;
  51470. TONEMAPPING: boolean;
  51471. TONEMAPPING_ACES: boolean;
  51472. CONTRAST: boolean;
  51473. COLORCURVES: boolean;
  51474. COLORGRADING: boolean;
  51475. COLORGRADING3D: boolean;
  51476. SAMPLER3DGREENDEPTH: boolean;
  51477. SAMPLER3DBGRMAP: boolean;
  51478. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51479. EXPOSURE: boolean;
  51480. MULTIVIEW: boolean;
  51481. USEPHYSICALLIGHTFALLOFF: boolean;
  51482. USEGLTFLIGHTFALLOFF: boolean;
  51483. TWOSIDEDLIGHTING: boolean;
  51484. SHADOWFLOAT: boolean;
  51485. CLIPPLANE: boolean;
  51486. CLIPPLANE2: boolean;
  51487. CLIPPLANE3: boolean;
  51488. CLIPPLANE4: boolean;
  51489. CLIPPLANE5: boolean;
  51490. CLIPPLANE6: boolean;
  51491. POINTSIZE: boolean;
  51492. FOG: boolean;
  51493. LOGARITHMICDEPTH: boolean;
  51494. FORCENORMALFORWARD: boolean;
  51495. SPECULARAA: boolean;
  51496. CLEARCOAT: boolean;
  51497. CLEARCOAT_DEFAULTIOR: boolean;
  51498. CLEARCOAT_TEXTURE: boolean;
  51499. CLEARCOAT_TEXTUREDIRECTUV: number;
  51500. CLEARCOAT_BUMP: boolean;
  51501. CLEARCOAT_BUMPDIRECTUV: number;
  51502. CLEARCOAT_TINT: boolean;
  51503. CLEARCOAT_TINT_TEXTURE: boolean;
  51504. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51505. ANISOTROPIC: boolean;
  51506. ANISOTROPIC_TEXTURE: boolean;
  51507. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51508. BRDF_V_HEIGHT_CORRELATED: boolean;
  51509. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51510. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51511. SHEEN: boolean;
  51512. SHEEN_TEXTURE: boolean;
  51513. SHEEN_TEXTUREDIRECTUV: number;
  51514. SHEEN_LINKWITHALBEDO: boolean;
  51515. SHEEN_ROUGHNESS: boolean;
  51516. SHEEN_ALBEDOSCALING: boolean;
  51517. SUBSURFACE: boolean;
  51518. SS_REFRACTION: boolean;
  51519. SS_TRANSLUCENCY: boolean;
  51520. SS_SCATERRING: boolean;
  51521. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51522. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51523. SS_REFRACTIONMAP_3D: boolean;
  51524. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51525. SS_LODINREFRACTIONALPHA: boolean;
  51526. SS_GAMMAREFRACTION: boolean;
  51527. SS_RGBDREFRACTION: boolean;
  51528. SS_LINEARSPECULARREFRACTION: boolean;
  51529. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51530. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51531. UNLIT: boolean;
  51532. DEBUGMODE: number;
  51533. /**
  51534. * Initializes the PBR Material defines.
  51535. */
  51536. constructor();
  51537. /**
  51538. * Resets the PBR Material defines.
  51539. */
  51540. reset(): void;
  51541. }
  51542. /**
  51543. * The Physically based material base class of BJS.
  51544. *
  51545. * This offers the main features of a standard PBR material.
  51546. * For more information, please refer to the documentation :
  51547. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51548. */
  51549. export abstract class PBRBaseMaterial extends PushMaterial {
  51550. /**
  51551. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51552. */
  51553. static readonly PBRMATERIAL_OPAQUE: number;
  51554. /**
  51555. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51556. */
  51557. static readonly PBRMATERIAL_ALPHATEST: number;
  51558. /**
  51559. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51560. */
  51561. static readonly PBRMATERIAL_ALPHABLEND: number;
  51562. /**
  51563. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51564. * They are also discarded below the alpha cutoff threshold to improve performances.
  51565. */
  51566. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51567. /**
  51568. * Defines the default value of how much AO map is occluding the analytical lights
  51569. * (point spot...).
  51570. */
  51571. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51572. /**
  51573. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51574. */
  51575. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51576. /**
  51577. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51578. * to enhance interoperability with other engines.
  51579. */
  51580. static readonly LIGHTFALLOFF_GLTF: number;
  51581. /**
  51582. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51583. * to enhance interoperability with other materials.
  51584. */
  51585. static readonly LIGHTFALLOFF_STANDARD: number;
  51586. /**
  51587. * Intensity of the direct lights e.g. the four lights available in your scene.
  51588. * This impacts both the direct diffuse and specular highlights.
  51589. */
  51590. protected _directIntensity: number;
  51591. /**
  51592. * Intensity of the emissive part of the material.
  51593. * This helps controlling the emissive effect without modifying the emissive color.
  51594. */
  51595. protected _emissiveIntensity: number;
  51596. /**
  51597. * Intensity of the environment e.g. how much the environment will light the object
  51598. * either through harmonics for rough material or through the refelction for shiny ones.
  51599. */
  51600. protected _environmentIntensity: number;
  51601. /**
  51602. * This is a special control allowing the reduction of the specular highlights coming from the
  51603. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51604. */
  51605. protected _specularIntensity: number;
  51606. /**
  51607. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51608. */
  51609. private _lightingInfos;
  51610. /**
  51611. * Debug Control allowing disabling the bump map on this material.
  51612. */
  51613. protected _disableBumpMap: boolean;
  51614. /**
  51615. * AKA Diffuse Texture in standard nomenclature.
  51616. */
  51617. protected _albedoTexture: Nullable<BaseTexture>;
  51618. /**
  51619. * AKA Occlusion Texture in other nomenclature.
  51620. */
  51621. protected _ambientTexture: Nullable<BaseTexture>;
  51622. /**
  51623. * AKA Occlusion Texture Intensity in other nomenclature.
  51624. */
  51625. protected _ambientTextureStrength: number;
  51626. /**
  51627. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51628. * 1 means it completely occludes it
  51629. * 0 mean it has no impact
  51630. */
  51631. protected _ambientTextureImpactOnAnalyticalLights: number;
  51632. /**
  51633. * Stores the alpha values in a texture.
  51634. */
  51635. protected _opacityTexture: Nullable<BaseTexture>;
  51636. /**
  51637. * Stores the reflection values in a texture.
  51638. */
  51639. protected _reflectionTexture: Nullable<BaseTexture>;
  51640. /**
  51641. * Stores the emissive values in a texture.
  51642. */
  51643. protected _emissiveTexture: Nullable<BaseTexture>;
  51644. /**
  51645. * AKA Specular texture in other nomenclature.
  51646. */
  51647. protected _reflectivityTexture: Nullable<BaseTexture>;
  51648. /**
  51649. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51650. */
  51651. protected _metallicTexture: Nullable<BaseTexture>;
  51652. /**
  51653. * Specifies the metallic scalar of the metallic/roughness workflow.
  51654. * Can also be used to scale the metalness values of the metallic texture.
  51655. */
  51656. protected _metallic: Nullable<number>;
  51657. /**
  51658. * Specifies the roughness scalar of the metallic/roughness workflow.
  51659. * Can also be used to scale the roughness values of the metallic texture.
  51660. */
  51661. protected _roughness: Nullable<number>;
  51662. /**
  51663. * Specifies the an F0 factor to help configuring the material F0.
  51664. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51665. * to 0.5 the previously hard coded value stays the same.
  51666. * Can also be used to scale the F0 values of the metallic texture.
  51667. */
  51668. protected _metallicF0Factor: number;
  51669. /**
  51670. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51671. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51672. * your expectation as it multiplies with the texture data.
  51673. */
  51674. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51675. /**
  51676. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51677. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51678. */
  51679. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51680. /**
  51681. * Stores surface normal data used to displace a mesh in a texture.
  51682. */
  51683. protected _bumpTexture: Nullable<BaseTexture>;
  51684. /**
  51685. * Stores the pre-calculated light information of a mesh in a texture.
  51686. */
  51687. protected _lightmapTexture: Nullable<BaseTexture>;
  51688. /**
  51689. * The color of a material in ambient lighting.
  51690. */
  51691. protected _ambientColor: Color3;
  51692. /**
  51693. * AKA Diffuse Color in other nomenclature.
  51694. */
  51695. protected _albedoColor: Color3;
  51696. /**
  51697. * AKA Specular Color in other nomenclature.
  51698. */
  51699. protected _reflectivityColor: Color3;
  51700. /**
  51701. * The color applied when light is reflected from a material.
  51702. */
  51703. protected _reflectionColor: Color3;
  51704. /**
  51705. * The color applied when light is emitted from a material.
  51706. */
  51707. protected _emissiveColor: Color3;
  51708. /**
  51709. * AKA Glossiness in other nomenclature.
  51710. */
  51711. protected _microSurface: number;
  51712. /**
  51713. * Specifies that the material will use the light map as a show map.
  51714. */
  51715. protected _useLightmapAsShadowmap: boolean;
  51716. /**
  51717. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51718. * makes the reflect vector face the model (under horizon).
  51719. */
  51720. protected _useHorizonOcclusion: boolean;
  51721. /**
  51722. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51723. * too much the area relying on ambient texture to define their ambient occlusion.
  51724. */
  51725. protected _useRadianceOcclusion: boolean;
  51726. /**
  51727. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51728. */
  51729. protected _useAlphaFromAlbedoTexture: boolean;
  51730. /**
  51731. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51732. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51733. */
  51734. protected _useSpecularOverAlpha: boolean;
  51735. /**
  51736. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51737. */
  51738. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51739. /**
  51740. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51741. */
  51742. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51743. /**
  51744. * Specifies if the metallic texture contains the roughness information in its green channel.
  51745. */
  51746. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51747. /**
  51748. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51749. */
  51750. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51751. /**
  51752. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51753. */
  51754. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51755. /**
  51756. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51757. */
  51758. protected _useAmbientInGrayScale: boolean;
  51759. /**
  51760. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51761. * The material will try to infer what glossiness each pixel should be.
  51762. */
  51763. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51764. /**
  51765. * Defines the falloff type used in this material.
  51766. * It by default is Physical.
  51767. */
  51768. protected _lightFalloff: number;
  51769. /**
  51770. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51771. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51772. */
  51773. protected _useRadianceOverAlpha: boolean;
  51774. /**
  51775. * Allows using an object space normal map (instead of tangent space).
  51776. */
  51777. protected _useObjectSpaceNormalMap: boolean;
  51778. /**
  51779. * Allows using the bump map in parallax mode.
  51780. */
  51781. protected _useParallax: boolean;
  51782. /**
  51783. * Allows using the bump map in parallax occlusion mode.
  51784. */
  51785. protected _useParallaxOcclusion: boolean;
  51786. /**
  51787. * Controls the scale bias of the parallax mode.
  51788. */
  51789. protected _parallaxScaleBias: number;
  51790. /**
  51791. * If sets to true, disables all the lights affecting the material.
  51792. */
  51793. protected _disableLighting: boolean;
  51794. /**
  51795. * Number of Simultaneous lights allowed on the material.
  51796. */
  51797. protected _maxSimultaneousLights: number;
  51798. /**
  51799. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51800. */
  51801. protected _invertNormalMapX: boolean;
  51802. /**
  51803. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51804. */
  51805. protected _invertNormalMapY: boolean;
  51806. /**
  51807. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51808. */
  51809. protected _twoSidedLighting: boolean;
  51810. /**
  51811. * Defines the alpha limits in alpha test mode.
  51812. */
  51813. protected _alphaCutOff: number;
  51814. /**
  51815. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51816. */
  51817. protected _forceAlphaTest: boolean;
  51818. /**
  51819. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51820. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51821. */
  51822. protected _useAlphaFresnel: boolean;
  51823. /**
  51824. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51825. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51826. */
  51827. protected _useLinearAlphaFresnel: boolean;
  51828. /**
  51829. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51830. * from cos thetav and roughness:
  51831. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51832. */
  51833. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51834. /**
  51835. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51836. */
  51837. protected _forceIrradianceInFragment: boolean;
  51838. /**
  51839. * Force normal to face away from face.
  51840. */
  51841. protected _forceNormalForward: boolean;
  51842. /**
  51843. * Enables specular anti aliasing in the PBR shader.
  51844. * It will both interacts on the Geometry for analytical and IBL lighting.
  51845. * It also prefilter the roughness map based on the bump values.
  51846. */
  51847. protected _enableSpecularAntiAliasing: boolean;
  51848. /**
  51849. * Default configuration related to image processing available in the PBR Material.
  51850. */
  51851. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51852. /**
  51853. * Keep track of the image processing observer to allow dispose and replace.
  51854. */
  51855. private _imageProcessingObserver;
  51856. /**
  51857. * Attaches a new image processing configuration to the PBR Material.
  51858. * @param configuration
  51859. */
  51860. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51861. /**
  51862. * Stores the available render targets.
  51863. */
  51864. private _renderTargets;
  51865. /**
  51866. * Sets the global ambient color for the material used in lighting calculations.
  51867. */
  51868. private _globalAmbientColor;
  51869. /**
  51870. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51871. */
  51872. private _useLogarithmicDepth;
  51873. /**
  51874. * If set to true, no lighting calculations will be applied.
  51875. */
  51876. private _unlit;
  51877. private _debugMode;
  51878. /**
  51879. * @hidden
  51880. * This is reserved for the inspector.
  51881. * Defines the material debug mode.
  51882. * It helps seeing only some components of the material while troubleshooting.
  51883. */
  51884. debugMode: number;
  51885. /**
  51886. * @hidden
  51887. * This is reserved for the inspector.
  51888. * Specify from where on screen the debug mode should start.
  51889. * The value goes from -1 (full screen) to 1 (not visible)
  51890. * It helps with side by side comparison against the final render
  51891. * This defaults to -1
  51892. */
  51893. private debugLimit;
  51894. /**
  51895. * @hidden
  51896. * This is reserved for the inspector.
  51897. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51898. * You can use the factor to better multiply the final value.
  51899. */
  51900. private debugFactor;
  51901. /**
  51902. * Defines the clear coat layer parameters for the material.
  51903. */
  51904. readonly clearCoat: PBRClearCoatConfiguration;
  51905. /**
  51906. * Defines the anisotropic parameters for the material.
  51907. */
  51908. readonly anisotropy: PBRAnisotropicConfiguration;
  51909. /**
  51910. * Defines the BRDF parameters for the material.
  51911. */
  51912. readonly brdf: PBRBRDFConfiguration;
  51913. /**
  51914. * Defines the Sheen parameters for the material.
  51915. */
  51916. readonly sheen: PBRSheenConfiguration;
  51917. /**
  51918. * Defines the SubSurface parameters for the material.
  51919. */
  51920. readonly subSurface: PBRSubSurfaceConfiguration;
  51921. /**
  51922. * Custom callback helping to override the default shader used in the material.
  51923. */
  51924. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  51925. protected _rebuildInParallel: boolean;
  51926. /**
  51927. * Instantiates a new PBRMaterial instance.
  51928. *
  51929. * @param name The material name
  51930. * @param scene The scene the material will be use in.
  51931. */
  51932. constructor(name: string, scene: Scene);
  51933. /**
  51934. * Gets a boolean indicating that current material needs to register RTT
  51935. */
  51936. get hasRenderTargetTextures(): boolean;
  51937. /**
  51938. * Gets the name of the material class.
  51939. */
  51940. getClassName(): string;
  51941. /**
  51942. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51943. */
  51944. get useLogarithmicDepth(): boolean;
  51945. /**
  51946. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51947. */
  51948. set useLogarithmicDepth(value: boolean);
  51949. /**
  51950. * Returns true if alpha blending should be disabled.
  51951. */
  51952. protected get _disableAlphaBlending(): boolean;
  51953. /**
  51954. * Specifies whether or not this material should be rendered in alpha blend mode.
  51955. */
  51956. needAlphaBlending(): boolean;
  51957. /**
  51958. * Specifies whether or not this material should be rendered in alpha test mode.
  51959. */
  51960. needAlphaTesting(): boolean;
  51961. /**
  51962. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51963. */
  51964. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51965. /**
  51966. * Gets the texture used for the alpha test.
  51967. */
  51968. getAlphaTestTexture(): Nullable<BaseTexture>;
  51969. /**
  51970. * Specifies that the submesh is ready to be used.
  51971. * @param mesh - BJS mesh.
  51972. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51973. * @param useInstances - Specifies that instances should be used.
  51974. * @returns - boolean indicating that the submesh is ready or not.
  51975. */
  51976. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51977. /**
  51978. * Specifies if the material uses metallic roughness workflow.
  51979. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51980. */
  51981. isMetallicWorkflow(): boolean;
  51982. private _prepareEffect;
  51983. private _prepareDefines;
  51984. /**
  51985. * Force shader compilation
  51986. */
  51987. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51988. /**
  51989. * Initializes the uniform buffer layout for the shader.
  51990. */
  51991. buildUniformLayout(): void;
  51992. /**
  51993. * Unbinds the material from the mesh
  51994. */
  51995. unbind(): void;
  51996. /**
  51997. * Binds the submesh data.
  51998. * @param world - The world matrix.
  51999. * @param mesh - The BJS mesh.
  52000. * @param subMesh - A submesh of the BJS mesh.
  52001. */
  52002. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52003. /**
  52004. * Returns the animatable textures.
  52005. * @returns - Array of animatable textures.
  52006. */
  52007. getAnimatables(): IAnimatable[];
  52008. /**
  52009. * Returns the texture used for reflections.
  52010. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52011. */
  52012. private _getReflectionTexture;
  52013. /**
  52014. * Returns an array of the actively used textures.
  52015. * @returns - Array of BaseTextures
  52016. */
  52017. getActiveTextures(): BaseTexture[];
  52018. /**
  52019. * Checks to see if a texture is used in the material.
  52020. * @param texture - Base texture to use.
  52021. * @returns - Boolean specifying if a texture is used in the material.
  52022. */
  52023. hasTexture(texture: BaseTexture): boolean;
  52024. /**
  52025. * Disposes the resources of the material.
  52026. * @param forceDisposeEffect - Forces the disposal of effects.
  52027. * @param forceDisposeTextures - Forces the disposal of all textures.
  52028. */
  52029. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52030. }
  52031. }
  52032. declare module BABYLON {
  52033. /**
  52034. * The Physically based material of BJS.
  52035. *
  52036. * This offers the main features of a standard PBR material.
  52037. * For more information, please refer to the documentation :
  52038. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52039. */
  52040. export class PBRMaterial extends PBRBaseMaterial {
  52041. /**
  52042. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52043. */
  52044. static readonly PBRMATERIAL_OPAQUE: number;
  52045. /**
  52046. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52047. */
  52048. static readonly PBRMATERIAL_ALPHATEST: number;
  52049. /**
  52050. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52051. */
  52052. static readonly PBRMATERIAL_ALPHABLEND: number;
  52053. /**
  52054. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52055. * They are also discarded below the alpha cutoff threshold to improve performances.
  52056. */
  52057. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52058. /**
  52059. * Defines the default value of how much AO map is occluding the analytical lights
  52060. * (point spot...).
  52061. */
  52062. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52063. /**
  52064. * Intensity of the direct lights e.g. the four lights available in your scene.
  52065. * This impacts both the direct diffuse and specular highlights.
  52066. */
  52067. directIntensity: number;
  52068. /**
  52069. * Intensity of the emissive part of the material.
  52070. * This helps controlling the emissive effect without modifying the emissive color.
  52071. */
  52072. emissiveIntensity: number;
  52073. /**
  52074. * Intensity of the environment e.g. how much the environment will light the object
  52075. * either through harmonics for rough material or through the refelction for shiny ones.
  52076. */
  52077. environmentIntensity: number;
  52078. /**
  52079. * This is a special control allowing the reduction of the specular highlights coming from the
  52080. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52081. */
  52082. specularIntensity: number;
  52083. /**
  52084. * Debug Control allowing disabling the bump map on this material.
  52085. */
  52086. disableBumpMap: boolean;
  52087. /**
  52088. * AKA Diffuse Texture in standard nomenclature.
  52089. */
  52090. albedoTexture: BaseTexture;
  52091. /**
  52092. * AKA Occlusion Texture in other nomenclature.
  52093. */
  52094. ambientTexture: BaseTexture;
  52095. /**
  52096. * AKA Occlusion Texture Intensity in other nomenclature.
  52097. */
  52098. ambientTextureStrength: number;
  52099. /**
  52100. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52101. * 1 means it completely occludes it
  52102. * 0 mean it has no impact
  52103. */
  52104. ambientTextureImpactOnAnalyticalLights: number;
  52105. /**
  52106. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52107. */
  52108. opacityTexture: BaseTexture;
  52109. /**
  52110. * Stores the reflection values in a texture.
  52111. */
  52112. reflectionTexture: Nullable<BaseTexture>;
  52113. /**
  52114. * Stores the emissive values in a texture.
  52115. */
  52116. emissiveTexture: BaseTexture;
  52117. /**
  52118. * AKA Specular texture in other nomenclature.
  52119. */
  52120. reflectivityTexture: BaseTexture;
  52121. /**
  52122. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52123. */
  52124. metallicTexture: BaseTexture;
  52125. /**
  52126. * Specifies the metallic scalar of the metallic/roughness workflow.
  52127. * Can also be used to scale the metalness values of the metallic texture.
  52128. */
  52129. metallic: Nullable<number>;
  52130. /**
  52131. * Specifies the roughness scalar of the metallic/roughness workflow.
  52132. * Can also be used to scale the roughness values of the metallic texture.
  52133. */
  52134. roughness: Nullable<number>;
  52135. /**
  52136. * Specifies the an F0 factor to help configuring the material F0.
  52137. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52138. * to 0.5 the previously hard coded value stays the same.
  52139. * Can also be used to scale the F0 values of the metallic texture.
  52140. */
  52141. metallicF0Factor: number;
  52142. /**
  52143. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52144. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52145. * your expectation as it multiplies with the texture data.
  52146. */
  52147. useMetallicF0FactorFromMetallicTexture: boolean;
  52148. /**
  52149. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52150. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52151. */
  52152. microSurfaceTexture: BaseTexture;
  52153. /**
  52154. * Stores surface normal data used to displace a mesh in a texture.
  52155. */
  52156. bumpTexture: BaseTexture;
  52157. /**
  52158. * Stores the pre-calculated light information of a mesh in a texture.
  52159. */
  52160. lightmapTexture: BaseTexture;
  52161. /**
  52162. * Stores the refracted light information in a texture.
  52163. */
  52164. get refractionTexture(): Nullable<BaseTexture>;
  52165. set refractionTexture(value: Nullable<BaseTexture>);
  52166. /**
  52167. * The color of a material in ambient lighting.
  52168. */
  52169. ambientColor: Color3;
  52170. /**
  52171. * AKA Diffuse Color in other nomenclature.
  52172. */
  52173. albedoColor: Color3;
  52174. /**
  52175. * AKA Specular Color in other nomenclature.
  52176. */
  52177. reflectivityColor: Color3;
  52178. /**
  52179. * The color reflected from the material.
  52180. */
  52181. reflectionColor: Color3;
  52182. /**
  52183. * The color emitted from the material.
  52184. */
  52185. emissiveColor: Color3;
  52186. /**
  52187. * AKA Glossiness in other nomenclature.
  52188. */
  52189. microSurface: number;
  52190. /**
  52191. * source material index of refraction (IOR)' / 'destination material IOR.
  52192. */
  52193. get indexOfRefraction(): number;
  52194. set indexOfRefraction(value: number);
  52195. /**
  52196. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52197. */
  52198. get invertRefractionY(): boolean;
  52199. set invertRefractionY(value: boolean);
  52200. /**
  52201. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52202. * Materials half opaque for instance using refraction could benefit from this control.
  52203. */
  52204. get linkRefractionWithTransparency(): boolean;
  52205. set linkRefractionWithTransparency(value: boolean);
  52206. /**
  52207. * If true, the light map contains occlusion information instead of lighting info.
  52208. */
  52209. useLightmapAsShadowmap: boolean;
  52210. /**
  52211. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52212. */
  52213. useAlphaFromAlbedoTexture: boolean;
  52214. /**
  52215. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52216. */
  52217. forceAlphaTest: boolean;
  52218. /**
  52219. * Defines the alpha limits in alpha test mode.
  52220. */
  52221. alphaCutOff: number;
  52222. /**
  52223. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52224. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52225. */
  52226. useSpecularOverAlpha: boolean;
  52227. /**
  52228. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52229. */
  52230. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52231. /**
  52232. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52233. */
  52234. useRoughnessFromMetallicTextureAlpha: boolean;
  52235. /**
  52236. * Specifies if the metallic texture contains the roughness information in its green channel.
  52237. */
  52238. useRoughnessFromMetallicTextureGreen: boolean;
  52239. /**
  52240. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52241. */
  52242. useMetallnessFromMetallicTextureBlue: boolean;
  52243. /**
  52244. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52245. */
  52246. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52247. /**
  52248. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52249. */
  52250. useAmbientInGrayScale: boolean;
  52251. /**
  52252. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52253. * The material will try to infer what glossiness each pixel should be.
  52254. */
  52255. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52256. /**
  52257. * BJS is using an harcoded light falloff based on a manually sets up range.
  52258. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52259. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52260. */
  52261. get usePhysicalLightFalloff(): boolean;
  52262. /**
  52263. * BJS is using an harcoded light falloff based on a manually sets up range.
  52264. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52265. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52266. */
  52267. set usePhysicalLightFalloff(value: boolean);
  52268. /**
  52269. * In order to support the falloff compatibility with gltf, a special mode has been added
  52270. * to reproduce the gltf light falloff.
  52271. */
  52272. get useGLTFLightFalloff(): boolean;
  52273. /**
  52274. * In order to support the falloff compatibility with gltf, a special mode has been added
  52275. * to reproduce the gltf light falloff.
  52276. */
  52277. set useGLTFLightFalloff(value: boolean);
  52278. /**
  52279. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52280. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52281. */
  52282. useRadianceOverAlpha: boolean;
  52283. /**
  52284. * Allows using an object space normal map (instead of tangent space).
  52285. */
  52286. useObjectSpaceNormalMap: boolean;
  52287. /**
  52288. * Allows using the bump map in parallax mode.
  52289. */
  52290. useParallax: boolean;
  52291. /**
  52292. * Allows using the bump map in parallax occlusion mode.
  52293. */
  52294. useParallaxOcclusion: boolean;
  52295. /**
  52296. * Controls the scale bias of the parallax mode.
  52297. */
  52298. parallaxScaleBias: number;
  52299. /**
  52300. * If sets to true, disables all the lights affecting the material.
  52301. */
  52302. disableLighting: boolean;
  52303. /**
  52304. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52305. */
  52306. forceIrradianceInFragment: boolean;
  52307. /**
  52308. * Number of Simultaneous lights allowed on the material.
  52309. */
  52310. maxSimultaneousLights: number;
  52311. /**
  52312. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52313. */
  52314. invertNormalMapX: boolean;
  52315. /**
  52316. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52317. */
  52318. invertNormalMapY: boolean;
  52319. /**
  52320. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52321. */
  52322. twoSidedLighting: boolean;
  52323. /**
  52324. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52325. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52326. */
  52327. useAlphaFresnel: boolean;
  52328. /**
  52329. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52330. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52331. */
  52332. useLinearAlphaFresnel: boolean;
  52333. /**
  52334. * Let user defines the brdf lookup texture used for IBL.
  52335. * A default 8bit version is embedded but you could point at :
  52336. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52337. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52338. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52339. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52340. */
  52341. environmentBRDFTexture: Nullable<BaseTexture>;
  52342. /**
  52343. * Force normal to face away from face.
  52344. */
  52345. forceNormalForward: boolean;
  52346. /**
  52347. * Enables specular anti aliasing in the PBR shader.
  52348. * It will both interacts on the Geometry for analytical and IBL lighting.
  52349. * It also prefilter the roughness map based on the bump values.
  52350. */
  52351. enableSpecularAntiAliasing: boolean;
  52352. /**
  52353. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52354. * makes the reflect vector face the model (under horizon).
  52355. */
  52356. useHorizonOcclusion: boolean;
  52357. /**
  52358. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52359. * too much the area relying on ambient texture to define their ambient occlusion.
  52360. */
  52361. useRadianceOcclusion: boolean;
  52362. /**
  52363. * If set to true, no lighting calculations will be applied.
  52364. */
  52365. unlit: boolean;
  52366. /**
  52367. * Gets the image processing configuration used either in this material.
  52368. */
  52369. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52370. /**
  52371. * Sets the Default image processing configuration used either in the this material.
  52372. *
  52373. * If sets to null, the scene one is in use.
  52374. */
  52375. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52376. /**
  52377. * Gets wether the color curves effect is enabled.
  52378. */
  52379. get cameraColorCurvesEnabled(): boolean;
  52380. /**
  52381. * Sets wether the color curves effect is enabled.
  52382. */
  52383. set cameraColorCurvesEnabled(value: boolean);
  52384. /**
  52385. * Gets wether the color grading effect is enabled.
  52386. */
  52387. get cameraColorGradingEnabled(): boolean;
  52388. /**
  52389. * Gets wether the color grading effect is enabled.
  52390. */
  52391. set cameraColorGradingEnabled(value: boolean);
  52392. /**
  52393. * Gets wether tonemapping is enabled or not.
  52394. */
  52395. get cameraToneMappingEnabled(): boolean;
  52396. /**
  52397. * Sets wether tonemapping is enabled or not
  52398. */
  52399. set cameraToneMappingEnabled(value: boolean);
  52400. /**
  52401. * The camera exposure used on this material.
  52402. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52403. * This corresponds to a photographic exposure.
  52404. */
  52405. get cameraExposure(): number;
  52406. /**
  52407. * The camera exposure used on this material.
  52408. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52409. * This corresponds to a photographic exposure.
  52410. */
  52411. set cameraExposure(value: number);
  52412. /**
  52413. * Gets The camera contrast used on this material.
  52414. */
  52415. get cameraContrast(): number;
  52416. /**
  52417. * Sets The camera contrast used on this material.
  52418. */
  52419. set cameraContrast(value: number);
  52420. /**
  52421. * Gets the Color Grading 2D Lookup Texture.
  52422. */
  52423. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52424. /**
  52425. * Sets the Color Grading 2D Lookup Texture.
  52426. */
  52427. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52428. /**
  52429. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52430. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52431. * 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;
  52432. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52433. */
  52434. get cameraColorCurves(): Nullable<ColorCurves>;
  52435. /**
  52436. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52437. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52438. * 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;
  52439. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52440. */
  52441. set cameraColorCurves(value: Nullable<ColorCurves>);
  52442. /**
  52443. * Instantiates a new PBRMaterial instance.
  52444. *
  52445. * @param name The material name
  52446. * @param scene The scene the material will be use in.
  52447. */
  52448. constructor(name: string, scene: Scene);
  52449. /**
  52450. * Returns the name of this material class.
  52451. */
  52452. getClassName(): string;
  52453. /**
  52454. * Makes a duplicate of the current material.
  52455. * @param name - name to use for the new material.
  52456. */
  52457. clone(name: string): PBRMaterial;
  52458. /**
  52459. * Serializes this PBR Material.
  52460. * @returns - An object with the serialized material.
  52461. */
  52462. serialize(): any;
  52463. /**
  52464. * Parses a PBR Material from a serialized object.
  52465. * @param source - Serialized object.
  52466. * @param scene - BJS scene instance.
  52467. * @param rootUrl - url for the scene object
  52468. * @returns - PBRMaterial
  52469. */
  52470. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52471. }
  52472. }
  52473. declare module BABYLON {
  52474. /**
  52475. * Direct draw surface info
  52476. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52477. */
  52478. export interface DDSInfo {
  52479. /**
  52480. * Width of the texture
  52481. */
  52482. width: number;
  52483. /**
  52484. * Width of the texture
  52485. */
  52486. height: number;
  52487. /**
  52488. * Number of Mipmaps for the texture
  52489. * @see https://en.wikipedia.org/wiki/Mipmap
  52490. */
  52491. mipmapCount: number;
  52492. /**
  52493. * If the textures format is a known fourCC format
  52494. * @see https://www.fourcc.org/
  52495. */
  52496. isFourCC: boolean;
  52497. /**
  52498. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52499. */
  52500. isRGB: boolean;
  52501. /**
  52502. * If the texture is a lumincance format
  52503. */
  52504. isLuminance: boolean;
  52505. /**
  52506. * If this is a cube texture
  52507. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52508. */
  52509. isCube: boolean;
  52510. /**
  52511. * If the texture is a compressed format eg. FOURCC_DXT1
  52512. */
  52513. isCompressed: boolean;
  52514. /**
  52515. * The dxgiFormat of the texture
  52516. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52517. */
  52518. dxgiFormat: number;
  52519. /**
  52520. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52521. */
  52522. textureType: number;
  52523. /**
  52524. * Sphericle polynomial created for the dds texture
  52525. */
  52526. sphericalPolynomial?: SphericalPolynomial;
  52527. }
  52528. /**
  52529. * Class used to provide DDS decompression tools
  52530. */
  52531. export class DDSTools {
  52532. /**
  52533. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52534. */
  52535. static StoreLODInAlphaChannel: boolean;
  52536. /**
  52537. * Gets DDS information from an array buffer
  52538. * @param data defines the array buffer view to read data from
  52539. * @returns the DDS information
  52540. */
  52541. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52542. private static _FloatView;
  52543. private static _Int32View;
  52544. private static _ToHalfFloat;
  52545. private static _FromHalfFloat;
  52546. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52547. private static _GetHalfFloatRGBAArrayBuffer;
  52548. private static _GetFloatRGBAArrayBuffer;
  52549. private static _GetFloatAsUIntRGBAArrayBuffer;
  52550. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52551. private static _GetRGBAArrayBuffer;
  52552. private static _ExtractLongWordOrder;
  52553. private static _GetRGBArrayBuffer;
  52554. private static _GetLuminanceArrayBuffer;
  52555. /**
  52556. * Uploads DDS Levels to a Babylon Texture
  52557. * @hidden
  52558. */
  52559. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52560. }
  52561. interface ThinEngine {
  52562. /**
  52563. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52564. * @param rootUrl defines the url where the file to load is located
  52565. * @param scene defines the current scene
  52566. * @param lodScale defines scale to apply to the mip map selection
  52567. * @param lodOffset defines offset to apply to the mip map selection
  52568. * @param onLoad defines an optional callback raised when the texture is loaded
  52569. * @param onError defines an optional callback raised if there is an issue to load the texture
  52570. * @param format defines the format of the data
  52571. * @param forcedExtension defines the extension to use to pick the right loader
  52572. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52573. * @returns the cube texture as an InternalTexture
  52574. */
  52575. 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;
  52576. }
  52577. }
  52578. declare module BABYLON {
  52579. /**
  52580. * Implementation of the DDS Texture Loader.
  52581. * @hidden
  52582. */
  52583. export class _DDSTextureLoader implements IInternalTextureLoader {
  52584. /**
  52585. * Defines wether the loader supports cascade loading the different faces.
  52586. */
  52587. readonly supportCascades: boolean;
  52588. /**
  52589. * This returns if the loader support the current file information.
  52590. * @param extension defines the file extension of the file being loaded
  52591. * @returns true if the loader can load the specified file
  52592. */
  52593. canLoad(extension: string): boolean;
  52594. /**
  52595. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52596. * @param data contains the texture data
  52597. * @param texture defines the BabylonJS internal texture
  52598. * @param createPolynomials will be true if polynomials have been requested
  52599. * @param onLoad defines the callback to trigger once the texture is ready
  52600. * @param onError defines the callback to trigger in case of error
  52601. */
  52602. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52603. /**
  52604. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52605. * @param data contains the texture data
  52606. * @param texture defines the BabylonJS internal texture
  52607. * @param callback defines the method to call once ready to upload
  52608. */
  52609. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52610. }
  52611. }
  52612. declare module BABYLON {
  52613. /**
  52614. * Implementation of the ENV Texture Loader.
  52615. * @hidden
  52616. */
  52617. export class _ENVTextureLoader implements IInternalTextureLoader {
  52618. /**
  52619. * Defines wether the loader supports cascade loading the different faces.
  52620. */
  52621. readonly supportCascades: boolean;
  52622. /**
  52623. * This returns if the loader support the current file information.
  52624. * @param extension defines the file extension of the file being loaded
  52625. * @returns true if the loader can load the specified file
  52626. */
  52627. canLoad(extension: string): boolean;
  52628. /**
  52629. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52630. * @param data contains the texture data
  52631. * @param texture defines the BabylonJS internal texture
  52632. * @param createPolynomials will be true if polynomials have been requested
  52633. * @param onLoad defines the callback to trigger once the texture is ready
  52634. * @param onError defines the callback to trigger in case of error
  52635. */
  52636. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52637. /**
  52638. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52639. * @param data contains the texture data
  52640. * @param texture defines the BabylonJS internal texture
  52641. * @param callback defines the method to call once ready to upload
  52642. */
  52643. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52644. }
  52645. }
  52646. declare module BABYLON {
  52647. /**
  52648. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52649. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52650. */
  52651. export class KhronosTextureContainer {
  52652. /** contents of the KTX container file */
  52653. data: ArrayBufferView;
  52654. private static HEADER_LEN;
  52655. private static COMPRESSED_2D;
  52656. private static COMPRESSED_3D;
  52657. private static TEX_2D;
  52658. private static TEX_3D;
  52659. /**
  52660. * Gets the openGL type
  52661. */
  52662. glType: number;
  52663. /**
  52664. * Gets the openGL type size
  52665. */
  52666. glTypeSize: number;
  52667. /**
  52668. * Gets the openGL format
  52669. */
  52670. glFormat: number;
  52671. /**
  52672. * Gets the openGL internal format
  52673. */
  52674. glInternalFormat: number;
  52675. /**
  52676. * Gets the base internal format
  52677. */
  52678. glBaseInternalFormat: number;
  52679. /**
  52680. * Gets image width in pixel
  52681. */
  52682. pixelWidth: number;
  52683. /**
  52684. * Gets image height in pixel
  52685. */
  52686. pixelHeight: number;
  52687. /**
  52688. * Gets image depth in pixels
  52689. */
  52690. pixelDepth: number;
  52691. /**
  52692. * Gets the number of array elements
  52693. */
  52694. numberOfArrayElements: number;
  52695. /**
  52696. * Gets the number of faces
  52697. */
  52698. numberOfFaces: number;
  52699. /**
  52700. * Gets the number of mipmap levels
  52701. */
  52702. numberOfMipmapLevels: number;
  52703. /**
  52704. * Gets the bytes of key value data
  52705. */
  52706. bytesOfKeyValueData: number;
  52707. /**
  52708. * Gets the load type
  52709. */
  52710. loadType: number;
  52711. /**
  52712. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52713. */
  52714. isInvalid: boolean;
  52715. /**
  52716. * Creates a new KhronosTextureContainer
  52717. * @param data contents of the KTX container file
  52718. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52719. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52720. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52721. */
  52722. constructor(
  52723. /** contents of the KTX container file */
  52724. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52725. /**
  52726. * Uploads KTX content to a Babylon Texture.
  52727. * It is assumed that the texture has already been created & is currently bound
  52728. * @hidden
  52729. */
  52730. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52731. private _upload2DCompressedLevels;
  52732. /**
  52733. * Checks if the given data starts with a KTX file identifier.
  52734. * @param data the data to check
  52735. * @returns true if the data is a KTX file or false otherwise
  52736. */
  52737. static IsValid(data: ArrayBufferView): boolean;
  52738. }
  52739. }
  52740. declare module BABYLON {
  52741. /**
  52742. * Class for loading KTX2 files
  52743. * !!! Experimental Extension Subject to Changes !!!
  52744. * @hidden
  52745. */
  52746. export class KhronosTextureContainer2 {
  52747. private static _ModulePromise;
  52748. private static _TranscodeFormat;
  52749. constructor(engine: ThinEngine);
  52750. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52751. private _determineTranscodeFormat;
  52752. /**
  52753. * Checks if the given data starts with a KTX2 file identifier.
  52754. * @param data the data to check
  52755. * @returns true if the data is a KTX2 file or false otherwise
  52756. */
  52757. static IsValid(data: ArrayBufferView): boolean;
  52758. }
  52759. }
  52760. declare module BABYLON {
  52761. /**
  52762. * Implementation of the KTX Texture Loader.
  52763. * @hidden
  52764. */
  52765. export class _KTXTextureLoader implements IInternalTextureLoader {
  52766. /**
  52767. * Defines wether the loader supports cascade loading the different faces.
  52768. */
  52769. readonly supportCascades: boolean;
  52770. /**
  52771. * This returns if the loader support the current file information.
  52772. * @param extension defines the file extension of the file being loaded
  52773. * @returns true if the loader can load the specified file
  52774. */
  52775. canLoad(extension: string): boolean;
  52776. /**
  52777. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52778. * @param data contains the texture data
  52779. * @param texture defines the BabylonJS internal texture
  52780. * @param createPolynomials will be true if polynomials have been requested
  52781. * @param onLoad defines the callback to trigger once the texture is ready
  52782. * @param onError defines the callback to trigger in case of error
  52783. */
  52784. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52785. /**
  52786. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52787. * @param data contains the texture data
  52788. * @param texture defines the BabylonJS internal texture
  52789. * @param callback defines the method to call once ready to upload
  52790. */
  52791. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52792. }
  52793. }
  52794. declare module BABYLON {
  52795. /** @hidden */
  52796. export var _forceSceneHelpersToBundle: boolean;
  52797. interface Scene {
  52798. /**
  52799. * Creates a default light for the scene.
  52800. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52801. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52802. */
  52803. createDefaultLight(replace?: boolean): void;
  52804. /**
  52805. * Creates a default camera for the scene.
  52806. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52807. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52808. * @param replace has default false, when true replaces the active camera in the scene
  52809. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52810. */
  52811. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52812. /**
  52813. * Creates a default camera and a default light.
  52814. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52815. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52816. * @param replace has the default false, when true replaces the active camera/light in the scene
  52817. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52818. */
  52819. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52820. /**
  52821. * Creates a new sky box
  52822. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52823. * @param environmentTexture defines the texture to use as environment texture
  52824. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52825. * @param scale defines the overall scale of the skybox
  52826. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52827. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52828. * @returns a new mesh holding the sky box
  52829. */
  52830. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52831. /**
  52832. * Creates a new environment
  52833. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52834. * @param options defines the options you can use to configure the environment
  52835. * @returns the new EnvironmentHelper
  52836. */
  52837. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52838. /**
  52839. * Creates a new VREXperienceHelper
  52840. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52841. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52842. * @returns a new VREXperienceHelper
  52843. */
  52844. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52845. /**
  52846. * Creates a new WebXRDefaultExperience
  52847. * @see http://doc.babylonjs.com/how_to/webxr
  52848. * @param options experience options
  52849. * @returns a promise for a new WebXRDefaultExperience
  52850. */
  52851. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52852. }
  52853. }
  52854. declare module BABYLON {
  52855. /**
  52856. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52857. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52858. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52859. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52860. */
  52861. export class VideoDome extends TransformNode {
  52862. /**
  52863. * Define the video source as a Monoscopic panoramic 360 video.
  52864. */
  52865. static readonly MODE_MONOSCOPIC: number;
  52866. /**
  52867. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52868. */
  52869. static readonly MODE_TOPBOTTOM: number;
  52870. /**
  52871. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52872. */
  52873. static readonly MODE_SIDEBYSIDE: number;
  52874. private _halfDome;
  52875. private _useDirectMapping;
  52876. /**
  52877. * The video texture being displayed on the sphere
  52878. */
  52879. protected _videoTexture: VideoTexture;
  52880. /**
  52881. * Gets the video texture being displayed on the sphere
  52882. */
  52883. get videoTexture(): VideoTexture;
  52884. /**
  52885. * The skybox material
  52886. */
  52887. protected _material: BackgroundMaterial;
  52888. /**
  52889. * The surface used for the skybox
  52890. */
  52891. protected _mesh: Mesh;
  52892. /**
  52893. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52894. */
  52895. private _halfDomeMask;
  52896. /**
  52897. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52898. * Also see the options.resolution property.
  52899. */
  52900. get fovMultiplier(): number;
  52901. set fovMultiplier(value: number);
  52902. private _videoMode;
  52903. /**
  52904. * Gets or set the current video mode for the video. It can be:
  52905. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52906. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52907. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52908. */
  52909. get videoMode(): number;
  52910. set videoMode(value: number);
  52911. /**
  52912. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52913. *
  52914. */
  52915. get halfDome(): boolean;
  52916. /**
  52917. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52918. */
  52919. set halfDome(enabled: boolean);
  52920. /**
  52921. * Oberserver used in Stereoscopic VR Mode.
  52922. */
  52923. private _onBeforeCameraRenderObserver;
  52924. /**
  52925. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52926. * @param name Element's name, child elements will append suffixes for their own names.
  52927. * @param urlsOrVideo defines the url(s) or the video element to use
  52928. * @param options An object containing optional or exposed sub element properties
  52929. */
  52930. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52931. resolution?: number;
  52932. clickToPlay?: boolean;
  52933. autoPlay?: boolean;
  52934. loop?: boolean;
  52935. size?: number;
  52936. poster?: string;
  52937. faceForward?: boolean;
  52938. useDirectMapping?: boolean;
  52939. halfDomeMode?: boolean;
  52940. }, scene: Scene);
  52941. private _changeVideoMode;
  52942. /**
  52943. * Releases resources associated with this node.
  52944. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52945. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52946. */
  52947. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52948. }
  52949. }
  52950. declare module BABYLON {
  52951. /**
  52952. * This class can be used to get instrumentation data from a Babylon engine
  52953. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52954. */
  52955. export class EngineInstrumentation implements IDisposable {
  52956. /**
  52957. * Define the instrumented engine.
  52958. */
  52959. engine: Engine;
  52960. private _captureGPUFrameTime;
  52961. private _gpuFrameTimeToken;
  52962. private _gpuFrameTime;
  52963. private _captureShaderCompilationTime;
  52964. private _shaderCompilationTime;
  52965. private _onBeginFrameObserver;
  52966. private _onEndFrameObserver;
  52967. private _onBeforeShaderCompilationObserver;
  52968. private _onAfterShaderCompilationObserver;
  52969. /**
  52970. * Gets the perf counter used for GPU frame time
  52971. */
  52972. get gpuFrameTimeCounter(): PerfCounter;
  52973. /**
  52974. * Gets the GPU frame time capture status
  52975. */
  52976. get captureGPUFrameTime(): boolean;
  52977. /**
  52978. * Enable or disable the GPU frame time capture
  52979. */
  52980. set captureGPUFrameTime(value: boolean);
  52981. /**
  52982. * Gets the perf counter used for shader compilation time
  52983. */
  52984. get shaderCompilationTimeCounter(): PerfCounter;
  52985. /**
  52986. * Gets the shader compilation time capture status
  52987. */
  52988. get captureShaderCompilationTime(): boolean;
  52989. /**
  52990. * Enable or disable the shader compilation time capture
  52991. */
  52992. set captureShaderCompilationTime(value: boolean);
  52993. /**
  52994. * Instantiates a new engine instrumentation.
  52995. * This class can be used to get instrumentation data from a Babylon engine
  52996. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52997. * @param engine Defines the engine to instrument
  52998. */
  52999. constructor(
  53000. /**
  53001. * Define the instrumented engine.
  53002. */
  53003. engine: Engine);
  53004. /**
  53005. * Dispose and release associated resources.
  53006. */
  53007. dispose(): void;
  53008. }
  53009. }
  53010. declare module BABYLON {
  53011. /**
  53012. * This class can be used to get instrumentation data from a Babylon engine
  53013. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53014. */
  53015. export class SceneInstrumentation implements IDisposable {
  53016. /**
  53017. * Defines the scene to instrument
  53018. */
  53019. scene: Scene;
  53020. private _captureActiveMeshesEvaluationTime;
  53021. private _activeMeshesEvaluationTime;
  53022. private _captureRenderTargetsRenderTime;
  53023. private _renderTargetsRenderTime;
  53024. private _captureFrameTime;
  53025. private _frameTime;
  53026. private _captureRenderTime;
  53027. private _renderTime;
  53028. private _captureInterFrameTime;
  53029. private _interFrameTime;
  53030. private _captureParticlesRenderTime;
  53031. private _particlesRenderTime;
  53032. private _captureSpritesRenderTime;
  53033. private _spritesRenderTime;
  53034. private _capturePhysicsTime;
  53035. private _physicsTime;
  53036. private _captureAnimationsTime;
  53037. private _animationsTime;
  53038. private _captureCameraRenderTime;
  53039. private _cameraRenderTime;
  53040. private _onBeforeActiveMeshesEvaluationObserver;
  53041. private _onAfterActiveMeshesEvaluationObserver;
  53042. private _onBeforeRenderTargetsRenderObserver;
  53043. private _onAfterRenderTargetsRenderObserver;
  53044. private _onAfterRenderObserver;
  53045. private _onBeforeDrawPhaseObserver;
  53046. private _onAfterDrawPhaseObserver;
  53047. private _onBeforeAnimationsObserver;
  53048. private _onBeforeParticlesRenderingObserver;
  53049. private _onAfterParticlesRenderingObserver;
  53050. private _onBeforeSpritesRenderingObserver;
  53051. private _onAfterSpritesRenderingObserver;
  53052. private _onBeforePhysicsObserver;
  53053. private _onAfterPhysicsObserver;
  53054. private _onAfterAnimationsObserver;
  53055. private _onBeforeCameraRenderObserver;
  53056. private _onAfterCameraRenderObserver;
  53057. /**
  53058. * Gets the perf counter used for active meshes evaluation time
  53059. */
  53060. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53061. /**
  53062. * Gets the active meshes evaluation time capture status
  53063. */
  53064. get captureActiveMeshesEvaluationTime(): boolean;
  53065. /**
  53066. * Enable or disable the active meshes evaluation time capture
  53067. */
  53068. set captureActiveMeshesEvaluationTime(value: boolean);
  53069. /**
  53070. * Gets the perf counter used for render targets render time
  53071. */
  53072. get renderTargetsRenderTimeCounter(): PerfCounter;
  53073. /**
  53074. * Gets the render targets render time capture status
  53075. */
  53076. get captureRenderTargetsRenderTime(): boolean;
  53077. /**
  53078. * Enable or disable the render targets render time capture
  53079. */
  53080. set captureRenderTargetsRenderTime(value: boolean);
  53081. /**
  53082. * Gets the perf counter used for particles render time
  53083. */
  53084. get particlesRenderTimeCounter(): PerfCounter;
  53085. /**
  53086. * Gets the particles render time capture status
  53087. */
  53088. get captureParticlesRenderTime(): boolean;
  53089. /**
  53090. * Enable or disable the particles render time capture
  53091. */
  53092. set captureParticlesRenderTime(value: boolean);
  53093. /**
  53094. * Gets the perf counter used for sprites render time
  53095. */
  53096. get spritesRenderTimeCounter(): PerfCounter;
  53097. /**
  53098. * Gets the sprites render time capture status
  53099. */
  53100. get captureSpritesRenderTime(): boolean;
  53101. /**
  53102. * Enable or disable the sprites render time capture
  53103. */
  53104. set captureSpritesRenderTime(value: boolean);
  53105. /**
  53106. * Gets the perf counter used for physics time
  53107. */
  53108. get physicsTimeCounter(): PerfCounter;
  53109. /**
  53110. * Gets the physics time capture status
  53111. */
  53112. get capturePhysicsTime(): boolean;
  53113. /**
  53114. * Enable or disable the physics time capture
  53115. */
  53116. set capturePhysicsTime(value: boolean);
  53117. /**
  53118. * Gets the perf counter used for animations time
  53119. */
  53120. get animationsTimeCounter(): PerfCounter;
  53121. /**
  53122. * Gets the animations time capture status
  53123. */
  53124. get captureAnimationsTime(): boolean;
  53125. /**
  53126. * Enable or disable the animations time capture
  53127. */
  53128. set captureAnimationsTime(value: boolean);
  53129. /**
  53130. * Gets the perf counter used for frame time capture
  53131. */
  53132. get frameTimeCounter(): PerfCounter;
  53133. /**
  53134. * Gets the frame time capture status
  53135. */
  53136. get captureFrameTime(): boolean;
  53137. /**
  53138. * Enable or disable the frame time capture
  53139. */
  53140. set captureFrameTime(value: boolean);
  53141. /**
  53142. * Gets the perf counter used for inter-frames time capture
  53143. */
  53144. get interFrameTimeCounter(): PerfCounter;
  53145. /**
  53146. * Gets the inter-frames time capture status
  53147. */
  53148. get captureInterFrameTime(): boolean;
  53149. /**
  53150. * Enable or disable the inter-frames time capture
  53151. */
  53152. set captureInterFrameTime(value: boolean);
  53153. /**
  53154. * Gets the perf counter used for render time capture
  53155. */
  53156. get renderTimeCounter(): PerfCounter;
  53157. /**
  53158. * Gets the render time capture status
  53159. */
  53160. get captureRenderTime(): boolean;
  53161. /**
  53162. * Enable or disable the render time capture
  53163. */
  53164. set captureRenderTime(value: boolean);
  53165. /**
  53166. * Gets the perf counter used for camera render time capture
  53167. */
  53168. get cameraRenderTimeCounter(): PerfCounter;
  53169. /**
  53170. * Gets the camera render time capture status
  53171. */
  53172. get captureCameraRenderTime(): boolean;
  53173. /**
  53174. * Enable or disable the camera render time capture
  53175. */
  53176. set captureCameraRenderTime(value: boolean);
  53177. /**
  53178. * Gets the perf counter used for draw calls
  53179. */
  53180. get drawCallsCounter(): PerfCounter;
  53181. /**
  53182. * Instantiates a new scene instrumentation.
  53183. * This class can be used to get instrumentation data from a Babylon engine
  53184. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53185. * @param scene Defines the scene to instrument
  53186. */
  53187. constructor(
  53188. /**
  53189. * Defines the scene to instrument
  53190. */
  53191. scene: Scene);
  53192. /**
  53193. * Dispose and release associated resources.
  53194. */
  53195. dispose(): void;
  53196. }
  53197. }
  53198. declare module BABYLON {
  53199. /** @hidden */
  53200. export var glowMapGenerationPixelShader: {
  53201. name: string;
  53202. shader: string;
  53203. };
  53204. }
  53205. declare module BABYLON {
  53206. /** @hidden */
  53207. export var glowMapGenerationVertexShader: {
  53208. name: string;
  53209. shader: string;
  53210. };
  53211. }
  53212. declare module BABYLON {
  53213. /**
  53214. * Effect layer options. This helps customizing the behaviour
  53215. * of the effect layer.
  53216. */
  53217. export interface IEffectLayerOptions {
  53218. /**
  53219. * Multiplication factor apply to the canvas size to compute the render target size
  53220. * used to generated the objects (the smaller the faster).
  53221. */
  53222. mainTextureRatio: number;
  53223. /**
  53224. * Enforces a fixed size texture to ensure effect stability across devices.
  53225. */
  53226. mainTextureFixedSize?: number;
  53227. /**
  53228. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53229. */
  53230. alphaBlendingMode: number;
  53231. /**
  53232. * The camera attached to the layer.
  53233. */
  53234. camera: Nullable<Camera>;
  53235. /**
  53236. * The rendering group to draw the layer in.
  53237. */
  53238. renderingGroupId: number;
  53239. }
  53240. /**
  53241. * The effect layer Helps adding post process effect blended with the main pass.
  53242. *
  53243. * This can be for instance use to generate glow or higlight effects on the scene.
  53244. *
  53245. * The effect layer class can not be used directly and is intented to inherited from to be
  53246. * customized per effects.
  53247. */
  53248. export abstract class EffectLayer {
  53249. private _vertexBuffers;
  53250. private _indexBuffer;
  53251. private _cachedDefines;
  53252. private _effectLayerMapGenerationEffect;
  53253. private _effectLayerOptions;
  53254. private _mergeEffect;
  53255. protected _scene: Scene;
  53256. protected _engine: Engine;
  53257. protected _maxSize: number;
  53258. protected _mainTextureDesiredSize: ISize;
  53259. protected _mainTexture: RenderTargetTexture;
  53260. protected _shouldRender: boolean;
  53261. protected _postProcesses: PostProcess[];
  53262. protected _textures: BaseTexture[];
  53263. protected _emissiveTextureAndColor: {
  53264. texture: Nullable<BaseTexture>;
  53265. color: Color4;
  53266. };
  53267. /**
  53268. * The name of the layer
  53269. */
  53270. name: string;
  53271. /**
  53272. * The clear color of the texture used to generate the glow map.
  53273. */
  53274. neutralColor: Color4;
  53275. /**
  53276. * Specifies whether the highlight layer is enabled or not.
  53277. */
  53278. isEnabled: boolean;
  53279. /**
  53280. * Gets the camera attached to the layer.
  53281. */
  53282. get camera(): Nullable<Camera>;
  53283. /**
  53284. * Gets the rendering group id the layer should render in.
  53285. */
  53286. get renderingGroupId(): number;
  53287. set renderingGroupId(renderingGroupId: number);
  53288. /**
  53289. * An event triggered when the effect layer has been disposed.
  53290. */
  53291. onDisposeObservable: Observable<EffectLayer>;
  53292. /**
  53293. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53294. */
  53295. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53296. /**
  53297. * An event triggered when the generated texture is being merged in the scene.
  53298. */
  53299. onBeforeComposeObservable: Observable<EffectLayer>;
  53300. /**
  53301. * An event triggered when the mesh is rendered into the effect render target.
  53302. */
  53303. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53304. /**
  53305. * An event triggered after the mesh has been rendered into the effect render target.
  53306. */
  53307. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53308. /**
  53309. * An event triggered when the generated texture has been merged in the scene.
  53310. */
  53311. onAfterComposeObservable: Observable<EffectLayer>;
  53312. /**
  53313. * An event triggered when the efffect layer changes its size.
  53314. */
  53315. onSizeChangedObservable: Observable<EffectLayer>;
  53316. /** @hidden */
  53317. static _SceneComponentInitialization: (scene: Scene) => void;
  53318. /**
  53319. * Instantiates a new effect Layer and references it in the scene.
  53320. * @param name The name of the layer
  53321. * @param scene The scene to use the layer in
  53322. */
  53323. constructor(
  53324. /** The Friendly of the effect in the scene */
  53325. name: string, scene: Scene);
  53326. /**
  53327. * Get the effect name of the layer.
  53328. * @return The effect name
  53329. */
  53330. abstract getEffectName(): string;
  53331. /**
  53332. * Checks for the readiness of the element composing the layer.
  53333. * @param subMesh the mesh to check for
  53334. * @param useInstances specify whether or not to use instances to render the mesh
  53335. * @return true if ready otherwise, false
  53336. */
  53337. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53338. /**
  53339. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53340. * @returns true if the effect requires stencil during the main canvas render pass.
  53341. */
  53342. abstract needStencil(): boolean;
  53343. /**
  53344. * Create the merge effect. This is the shader use to blit the information back
  53345. * to the main canvas at the end of the scene rendering.
  53346. * @returns The effect containing the shader used to merge the effect on the main canvas
  53347. */
  53348. protected abstract _createMergeEffect(): Effect;
  53349. /**
  53350. * Creates the render target textures and post processes used in the effect layer.
  53351. */
  53352. protected abstract _createTextureAndPostProcesses(): void;
  53353. /**
  53354. * Implementation specific of rendering the generating effect on the main canvas.
  53355. * @param effect The effect used to render through
  53356. */
  53357. protected abstract _internalRender(effect: Effect): void;
  53358. /**
  53359. * Sets the required values for both the emissive texture and and the main color.
  53360. */
  53361. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53362. /**
  53363. * Free any resources and references associated to a mesh.
  53364. * Internal use
  53365. * @param mesh The mesh to free.
  53366. */
  53367. abstract _disposeMesh(mesh: Mesh): void;
  53368. /**
  53369. * Serializes this layer (Glow or Highlight for example)
  53370. * @returns a serialized layer object
  53371. */
  53372. abstract serialize?(): any;
  53373. /**
  53374. * Initializes the effect layer with the required options.
  53375. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53376. */
  53377. protected _init(options: Partial<IEffectLayerOptions>): void;
  53378. /**
  53379. * Generates the index buffer of the full screen quad blending to the main canvas.
  53380. */
  53381. private _generateIndexBuffer;
  53382. /**
  53383. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53384. */
  53385. private _generateVertexBuffer;
  53386. /**
  53387. * Sets the main texture desired size which is the closest power of two
  53388. * of the engine canvas size.
  53389. */
  53390. private _setMainTextureSize;
  53391. /**
  53392. * Creates the main texture for the effect layer.
  53393. */
  53394. protected _createMainTexture(): void;
  53395. /**
  53396. * Adds specific effects defines.
  53397. * @param defines The defines to add specifics to.
  53398. */
  53399. protected _addCustomEffectDefines(defines: string[]): void;
  53400. /**
  53401. * Checks for the readiness of the element composing the layer.
  53402. * @param subMesh the mesh to check for
  53403. * @param useInstances specify whether or not to use instances to render the mesh
  53404. * @param emissiveTexture the associated emissive texture used to generate the glow
  53405. * @return true if ready otherwise, false
  53406. */
  53407. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53408. /**
  53409. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53410. */
  53411. render(): void;
  53412. /**
  53413. * Determine if a given mesh will be used in the current effect.
  53414. * @param mesh mesh to test
  53415. * @returns true if the mesh will be used
  53416. */
  53417. hasMesh(mesh: AbstractMesh): boolean;
  53418. /**
  53419. * Returns true if the layer contains information to display, otherwise false.
  53420. * @returns true if the glow layer should be rendered
  53421. */
  53422. shouldRender(): boolean;
  53423. /**
  53424. * Returns true if the mesh should render, otherwise false.
  53425. * @param mesh The mesh to render
  53426. * @returns true if it should render otherwise false
  53427. */
  53428. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53429. /**
  53430. * Returns true if the mesh can be rendered, otherwise false.
  53431. * @param mesh The mesh to render
  53432. * @param material The material used on the mesh
  53433. * @returns true if it can be rendered otherwise false
  53434. */
  53435. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53436. /**
  53437. * Returns true if the mesh should render, otherwise false.
  53438. * @param mesh The mesh to render
  53439. * @returns true if it should render otherwise false
  53440. */
  53441. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53442. /**
  53443. * Renders the submesh passed in parameter to the generation map.
  53444. */
  53445. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53446. /**
  53447. * Defines whether the current material of the mesh should be use to render the effect.
  53448. * @param mesh defines the current mesh to render
  53449. */
  53450. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53451. /**
  53452. * Rebuild the required buffers.
  53453. * @hidden Internal use only.
  53454. */
  53455. _rebuild(): void;
  53456. /**
  53457. * Dispose only the render target textures and post process.
  53458. */
  53459. private _disposeTextureAndPostProcesses;
  53460. /**
  53461. * Dispose the highlight layer and free resources.
  53462. */
  53463. dispose(): void;
  53464. /**
  53465. * Gets the class name of the effect layer
  53466. * @returns the string with the class name of the effect layer
  53467. */
  53468. getClassName(): string;
  53469. /**
  53470. * Creates an effect layer from parsed effect layer data
  53471. * @param parsedEffectLayer defines effect layer data
  53472. * @param scene defines the current scene
  53473. * @param rootUrl defines the root URL containing the effect layer information
  53474. * @returns a parsed effect Layer
  53475. */
  53476. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53477. }
  53478. }
  53479. declare module BABYLON {
  53480. interface AbstractScene {
  53481. /**
  53482. * The list of effect layers (highlights/glow) added to the scene
  53483. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53484. * @see http://doc.babylonjs.com/how_to/glow_layer
  53485. */
  53486. effectLayers: Array<EffectLayer>;
  53487. /**
  53488. * Removes the given effect layer from this scene.
  53489. * @param toRemove defines the effect layer to remove
  53490. * @returns the index of the removed effect layer
  53491. */
  53492. removeEffectLayer(toRemove: EffectLayer): number;
  53493. /**
  53494. * Adds the given effect layer to this scene
  53495. * @param newEffectLayer defines the effect layer to add
  53496. */
  53497. addEffectLayer(newEffectLayer: EffectLayer): void;
  53498. }
  53499. /**
  53500. * Defines the layer scene component responsible to manage any effect layers
  53501. * in a given scene.
  53502. */
  53503. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53504. /**
  53505. * The component name helpfull to identify the component in the list of scene components.
  53506. */
  53507. readonly name: string;
  53508. /**
  53509. * The scene the component belongs to.
  53510. */
  53511. scene: Scene;
  53512. private _engine;
  53513. private _renderEffects;
  53514. private _needStencil;
  53515. private _previousStencilState;
  53516. /**
  53517. * Creates a new instance of the component for the given scene
  53518. * @param scene Defines the scene to register the component in
  53519. */
  53520. constructor(scene: Scene);
  53521. /**
  53522. * Registers the component in a given scene
  53523. */
  53524. register(): void;
  53525. /**
  53526. * Rebuilds the elements related to this component in case of
  53527. * context lost for instance.
  53528. */
  53529. rebuild(): void;
  53530. /**
  53531. * Serializes the component data to the specified json object
  53532. * @param serializationObject The object to serialize to
  53533. */
  53534. serialize(serializationObject: any): void;
  53535. /**
  53536. * Adds all the elements from the container to the scene
  53537. * @param container the container holding the elements
  53538. */
  53539. addFromContainer(container: AbstractScene): void;
  53540. /**
  53541. * Removes all the elements in the container from the scene
  53542. * @param container contains the elements to remove
  53543. * @param dispose if the removed element should be disposed (default: false)
  53544. */
  53545. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53546. /**
  53547. * Disposes the component and the associated ressources.
  53548. */
  53549. dispose(): void;
  53550. private _isReadyForMesh;
  53551. private _renderMainTexture;
  53552. private _setStencil;
  53553. private _setStencilBack;
  53554. private _draw;
  53555. private _drawCamera;
  53556. private _drawRenderingGroup;
  53557. }
  53558. }
  53559. declare module BABYLON {
  53560. /** @hidden */
  53561. export var glowMapMergePixelShader: {
  53562. name: string;
  53563. shader: string;
  53564. };
  53565. }
  53566. declare module BABYLON {
  53567. /** @hidden */
  53568. export var glowMapMergeVertexShader: {
  53569. name: string;
  53570. shader: string;
  53571. };
  53572. }
  53573. declare module BABYLON {
  53574. interface AbstractScene {
  53575. /**
  53576. * Return a the first highlight layer of the scene with a given name.
  53577. * @param name The name of the highlight layer to look for.
  53578. * @return The highlight layer if found otherwise null.
  53579. */
  53580. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53581. }
  53582. /**
  53583. * Glow layer options. This helps customizing the behaviour
  53584. * of the glow layer.
  53585. */
  53586. export interface IGlowLayerOptions {
  53587. /**
  53588. * Multiplication factor apply to the canvas size to compute the render target size
  53589. * used to generated the glowing objects (the smaller the faster).
  53590. */
  53591. mainTextureRatio: number;
  53592. /**
  53593. * Enforces a fixed size texture to ensure resize independant blur.
  53594. */
  53595. mainTextureFixedSize?: number;
  53596. /**
  53597. * How big is the kernel of the blur texture.
  53598. */
  53599. blurKernelSize: number;
  53600. /**
  53601. * The camera attached to the layer.
  53602. */
  53603. camera: Nullable<Camera>;
  53604. /**
  53605. * Enable MSAA by chosing the number of samples.
  53606. */
  53607. mainTextureSamples?: number;
  53608. /**
  53609. * The rendering group to draw the layer in.
  53610. */
  53611. renderingGroupId: number;
  53612. }
  53613. /**
  53614. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53615. *
  53616. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53617. *
  53618. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53619. */
  53620. export class GlowLayer extends EffectLayer {
  53621. /**
  53622. * Effect Name of the layer.
  53623. */
  53624. static readonly EffectName: string;
  53625. /**
  53626. * The default blur kernel size used for the glow.
  53627. */
  53628. static DefaultBlurKernelSize: number;
  53629. /**
  53630. * The default texture size ratio used for the glow.
  53631. */
  53632. static DefaultTextureRatio: number;
  53633. /**
  53634. * Sets the kernel size of the blur.
  53635. */
  53636. set blurKernelSize(value: number);
  53637. /**
  53638. * Gets the kernel size of the blur.
  53639. */
  53640. get blurKernelSize(): number;
  53641. /**
  53642. * Sets the glow intensity.
  53643. */
  53644. set intensity(value: number);
  53645. /**
  53646. * Gets the glow intensity.
  53647. */
  53648. get intensity(): number;
  53649. private _options;
  53650. private _intensity;
  53651. private _horizontalBlurPostprocess1;
  53652. private _verticalBlurPostprocess1;
  53653. private _horizontalBlurPostprocess2;
  53654. private _verticalBlurPostprocess2;
  53655. private _blurTexture1;
  53656. private _blurTexture2;
  53657. private _postProcesses1;
  53658. private _postProcesses2;
  53659. private _includedOnlyMeshes;
  53660. private _excludedMeshes;
  53661. private _meshesUsingTheirOwnMaterials;
  53662. /**
  53663. * Callback used to let the user override the color selection on a per mesh basis
  53664. */
  53665. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53666. /**
  53667. * Callback used to let the user override the texture selection on a per mesh basis
  53668. */
  53669. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53670. /**
  53671. * Instantiates a new glow Layer and references it to the scene.
  53672. * @param name The name of the layer
  53673. * @param scene The scene to use the layer in
  53674. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53675. */
  53676. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53677. /**
  53678. * Get the effect name of the layer.
  53679. * @return The effect name
  53680. */
  53681. getEffectName(): string;
  53682. /**
  53683. * Create the merge effect. This is the shader use to blit the information back
  53684. * to the main canvas at the end of the scene rendering.
  53685. */
  53686. protected _createMergeEffect(): Effect;
  53687. /**
  53688. * Creates the render target textures and post processes used in the glow layer.
  53689. */
  53690. protected _createTextureAndPostProcesses(): void;
  53691. /**
  53692. * Checks for the readiness of the element composing the layer.
  53693. * @param subMesh the mesh to check for
  53694. * @param useInstances specify wether or not to use instances to render the mesh
  53695. * @param emissiveTexture the associated emissive texture used to generate the glow
  53696. * @return true if ready otherwise, false
  53697. */
  53698. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53699. /**
  53700. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53701. */
  53702. needStencil(): boolean;
  53703. /**
  53704. * Returns true if the mesh can be rendered, otherwise false.
  53705. * @param mesh The mesh to render
  53706. * @param material The material used on the mesh
  53707. * @returns true if it can be rendered otherwise false
  53708. */
  53709. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53710. /**
  53711. * Implementation specific of rendering the generating effect on the main canvas.
  53712. * @param effect The effect used to render through
  53713. */
  53714. protected _internalRender(effect: Effect): void;
  53715. /**
  53716. * Sets the required values for both the emissive texture and and the main color.
  53717. */
  53718. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53719. /**
  53720. * Returns true if the mesh should render, otherwise false.
  53721. * @param mesh The mesh to render
  53722. * @returns true if it should render otherwise false
  53723. */
  53724. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53725. /**
  53726. * Adds specific effects defines.
  53727. * @param defines The defines to add specifics to.
  53728. */
  53729. protected _addCustomEffectDefines(defines: string[]): void;
  53730. /**
  53731. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53732. * @param mesh The mesh to exclude from the glow layer
  53733. */
  53734. addExcludedMesh(mesh: Mesh): void;
  53735. /**
  53736. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53737. * @param mesh The mesh to remove
  53738. */
  53739. removeExcludedMesh(mesh: Mesh): void;
  53740. /**
  53741. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53742. * @param mesh The mesh to include in the glow layer
  53743. */
  53744. addIncludedOnlyMesh(mesh: Mesh): void;
  53745. /**
  53746. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53747. * @param mesh The mesh to remove
  53748. */
  53749. removeIncludedOnlyMesh(mesh: Mesh): void;
  53750. /**
  53751. * Determine if a given mesh will be used in the glow layer
  53752. * @param mesh The mesh to test
  53753. * @returns true if the mesh will be highlighted by the current glow layer
  53754. */
  53755. hasMesh(mesh: AbstractMesh): boolean;
  53756. /**
  53757. * Defines whether the current material of the mesh should be use to render the effect.
  53758. * @param mesh defines the current mesh to render
  53759. */
  53760. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53761. /**
  53762. * Add a mesh to be rendered through its own material and not with emissive only.
  53763. * @param mesh The mesh for which we need to use its material
  53764. */
  53765. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53766. /**
  53767. * Remove a mesh from being rendered through its own material and not with emissive only.
  53768. * @param mesh The mesh for which we need to not use its material
  53769. */
  53770. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53771. /**
  53772. * Free any resources and references associated to a mesh.
  53773. * Internal use
  53774. * @param mesh The mesh to free.
  53775. * @hidden
  53776. */
  53777. _disposeMesh(mesh: Mesh): void;
  53778. /**
  53779. * Gets the class name of the effect layer
  53780. * @returns the string with the class name of the effect layer
  53781. */
  53782. getClassName(): string;
  53783. /**
  53784. * Serializes this glow layer
  53785. * @returns a serialized glow layer object
  53786. */
  53787. serialize(): any;
  53788. /**
  53789. * Creates a Glow Layer from parsed glow layer data
  53790. * @param parsedGlowLayer defines glow layer data
  53791. * @param scene defines the current scene
  53792. * @param rootUrl defines the root URL containing the glow layer information
  53793. * @returns a parsed Glow Layer
  53794. */
  53795. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53796. }
  53797. }
  53798. declare module BABYLON {
  53799. /** @hidden */
  53800. export var glowBlurPostProcessPixelShader: {
  53801. name: string;
  53802. shader: string;
  53803. };
  53804. }
  53805. declare module BABYLON {
  53806. interface AbstractScene {
  53807. /**
  53808. * Return a the first highlight layer of the scene with a given name.
  53809. * @param name The name of the highlight layer to look for.
  53810. * @return The highlight layer if found otherwise null.
  53811. */
  53812. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53813. }
  53814. /**
  53815. * Highlight layer options. This helps customizing the behaviour
  53816. * of the highlight layer.
  53817. */
  53818. export interface IHighlightLayerOptions {
  53819. /**
  53820. * Multiplication factor apply to the canvas size to compute the render target size
  53821. * used to generated the glowing objects (the smaller the faster).
  53822. */
  53823. mainTextureRatio: number;
  53824. /**
  53825. * Enforces a fixed size texture to ensure resize independant blur.
  53826. */
  53827. mainTextureFixedSize?: number;
  53828. /**
  53829. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53830. * of the picture to blur (the smaller the faster).
  53831. */
  53832. blurTextureSizeRatio: number;
  53833. /**
  53834. * How big in texel of the blur texture is the vertical blur.
  53835. */
  53836. blurVerticalSize: number;
  53837. /**
  53838. * How big in texel of the blur texture is the horizontal blur.
  53839. */
  53840. blurHorizontalSize: number;
  53841. /**
  53842. * Alpha blending mode used to apply the blur. Default is combine.
  53843. */
  53844. alphaBlendingMode: number;
  53845. /**
  53846. * The camera attached to the layer.
  53847. */
  53848. camera: Nullable<Camera>;
  53849. /**
  53850. * Should we display highlight as a solid stroke?
  53851. */
  53852. isStroke?: boolean;
  53853. /**
  53854. * The rendering group to draw the layer in.
  53855. */
  53856. renderingGroupId: number;
  53857. }
  53858. /**
  53859. * The highlight layer Helps adding a glow effect around a mesh.
  53860. *
  53861. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53862. * glowy meshes to your scene.
  53863. *
  53864. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53865. */
  53866. export class HighlightLayer extends EffectLayer {
  53867. name: string;
  53868. /**
  53869. * Effect Name of the highlight layer.
  53870. */
  53871. static readonly EffectName: string;
  53872. /**
  53873. * The neutral color used during the preparation of the glow effect.
  53874. * This is black by default as the blend operation is a blend operation.
  53875. */
  53876. static NeutralColor: Color4;
  53877. /**
  53878. * Stencil value used for glowing meshes.
  53879. */
  53880. static GlowingMeshStencilReference: number;
  53881. /**
  53882. * Stencil value used for the other meshes in the scene.
  53883. */
  53884. static NormalMeshStencilReference: number;
  53885. /**
  53886. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53887. */
  53888. innerGlow: boolean;
  53889. /**
  53890. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53891. */
  53892. outerGlow: boolean;
  53893. /**
  53894. * Specifies the horizontal size of the blur.
  53895. */
  53896. set blurHorizontalSize(value: number);
  53897. /**
  53898. * Specifies the vertical size of the blur.
  53899. */
  53900. set blurVerticalSize(value: number);
  53901. /**
  53902. * Gets the horizontal size of the blur.
  53903. */
  53904. get blurHorizontalSize(): number;
  53905. /**
  53906. * Gets the vertical size of the blur.
  53907. */
  53908. get blurVerticalSize(): number;
  53909. /**
  53910. * An event triggered when the highlight layer is being blurred.
  53911. */
  53912. onBeforeBlurObservable: Observable<HighlightLayer>;
  53913. /**
  53914. * An event triggered when the highlight layer has been blurred.
  53915. */
  53916. onAfterBlurObservable: Observable<HighlightLayer>;
  53917. private _instanceGlowingMeshStencilReference;
  53918. private _options;
  53919. private _downSamplePostprocess;
  53920. private _horizontalBlurPostprocess;
  53921. private _verticalBlurPostprocess;
  53922. private _blurTexture;
  53923. private _meshes;
  53924. private _excludedMeshes;
  53925. /**
  53926. * Instantiates a new highlight Layer and references it to the scene..
  53927. * @param name The name of the layer
  53928. * @param scene The scene to use the layer in
  53929. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53930. */
  53931. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53932. /**
  53933. * Get the effect name of the layer.
  53934. * @return The effect name
  53935. */
  53936. getEffectName(): string;
  53937. /**
  53938. * Create the merge effect. This is the shader use to blit the information back
  53939. * to the main canvas at the end of the scene rendering.
  53940. */
  53941. protected _createMergeEffect(): Effect;
  53942. /**
  53943. * Creates the render target textures and post processes used in the highlight layer.
  53944. */
  53945. protected _createTextureAndPostProcesses(): void;
  53946. /**
  53947. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53948. */
  53949. needStencil(): boolean;
  53950. /**
  53951. * Checks for the readiness of the element composing the layer.
  53952. * @param subMesh the mesh to check for
  53953. * @param useInstances specify wether or not to use instances to render the mesh
  53954. * @param emissiveTexture the associated emissive texture used to generate the glow
  53955. * @return true if ready otherwise, false
  53956. */
  53957. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53958. /**
  53959. * Implementation specific of rendering the generating effect on the main canvas.
  53960. * @param effect The effect used to render through
  53961. */
  53962. protected _internalRender(effect: Effect): void;
  53963. /**
  53964. * Returns true if the layer contains information to display, otherwise false.
  53965. */
  53966. shouldRender(): boolean;
  53967. /**
  53968. * Returns true if the mesh should render, otherwise false.
  53969. * @param mesh The mesh to render
  53970. * @returns true if it should render otherwise false
  53971. */
  53972. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53973. /**
  53974. * Sets the required values for both the emissive texture and and the main color.
  53975. */
  53976. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53977. /**
  53978. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53979. * @param mesh The mesh to exclude from the highlight layer
  53980. */
  53981. addExcludedMesh(mesh: Mesh): void;
  53982. /**
  53983. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53984. * @param mesh The mesh to highlight
  53985. */
  53986. removeExcludedMesh(mesh: Mesh): void;
  53987. /**
  53988. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53989. * @param mesh mesh to test
  53990. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53991. */
  53992. hasMesh(mesh: AbstractMesh): boolean;
  53993. /**
  53994. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53995. * @param mesh The mesh to highlight
  53996. * @param color The color of the highlight
  53997. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53998. */
  53999. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54000. /**
  54001. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54002. * @param mesh The mesh to highlight
  54003. */
  54004. removeMesh(mesh: Mesh): void;
  54005. /**
  54006. * Remove all the meshes currently referenced in the highlight layer
  54007. */
  54008. removeAllMeshes(): void;
  54009. /**
  54010. * Force the stencil to the normal expected value for none glowing parts
  54011. */
  54012. private _defaultStencilReference;
  54013. /**
  54014. * Free any resources and references associated to a mesh.
  54015. * Internal use
  54016. * @param mesh The mesh to free.
  54017. * @hidden
  54018. */
  54019. _disposeMesh(mesh: Mesh): void;
  54020. /**
  54021. * Dispose the highlight layer and free resources.
  54022. */
  54023. dispose(): void;
  54024. /**
  54025. * Gets the class name of the effect layer
  54026. * @returns the string with the class name of the effect layer
  54027. */
  54028. getClassName(): string;
  54029. /**
  54030. * Serializes this Highlight layer
  54031. * @returns a serialized Highlight layer object
  54032. */
  54033. serialize(): any;
  54034. /**
  54035. * Creates a Highlight layer from parsed Highlight layer data
  54036. * @param parsedHightlightLayer defines the Highlight layer data
  54037. * @param scene defines the current scene
  54038. * @param rootUrl defines the root URL containing the Highlight layer information
  54039. * @returns a parsed Highlight layer
  54040. */
  54041. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54042. }
  54043. }
  54044. declare module BABYLON {
  54045. interface AbstractScene {
  54046. /**
  54047. * The list of layers (background and foreground) of the scene
  54048. */
  54049. layers: Array<Layer>;
  54050. }
  54051. /**
  54052. * Defines the layer scene component responsible to manage any layers
  54053. * in a given scene.
  54054. */
  54055. export class LayerSceneComponent implements ISceneComponent {
  54056. /**
  54057. * The component name helpfull to identify the component in the list of scene components.
  54058. */
  54059. readonly name: string;
  54060. /**
  54061. * The scene the component belongs to.
  54062. */
  54063. scene: Scene;
  54064. private _engine;
  54065. /**
  54066. * Creates a new instance of the component for the given scene
  54067. * @param scene Defines the scene to register the component in
  54068. */
  54069. constructor(scene: Scene);
  54070. /**
  54071. * Registers the component in a given scene
  54072. */
  54073. register(): void;
  54074. /**
  54075. * Rebuilds the elements related to this component in case of
  54076. * context lost for instance.
  54077. */
  54078. rebuild(): void;
  54079. /**
  54080. * Disposes the component and the associated ressources.
  54081. */
  54082. dispose(): void;
  54083. private _draw;
  54084. private _drawCameraPredicate;
  54085. private _drawCameraBackground;
  54086. private _drawCameraForeground;
  54087. private _drawRenderTargetPredicate;
  54088. private _drawRenderTargetBackground;
  54089. private _drawRenderTargetForeground;
  54090. /**
  54091. * Adds all the elements from the container to the scene
  54092. * @param container the container holding the elements
  54093. */
  54094. addFromContainer(container: AbstractScene): void;
  54095. /**
  54096. * Removes all the elements in the container from the scene
  54097. * @param container contains the elements to remove
  54098. * @param dispose if the removed element should be disposed (default: false)
  54099. */
  54100. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54101. }
  54102. }
  54103. declare module BABYLON {
  54104. /** @hidden */
  54105. export var layerPixelShader: {
  54106. name: string;
  54107. shader: string;
  54108. };
  54109. }
  54110. declare module BABYLON {
  54111. /** @hidden */
  54112. export var layerVertexShader: {
  54113. name: string;
  54114. shader: string;
  54115. };
  54116. }
  54117. declare module BABYLON {
  54118. /**
  54119. * This represents a full screen 2d layer.
  54120. * This can be useful to display a picture in the background of your scene for instance.
  54121. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54122. */
  54123. export class Layer {
  54124. /**
  54125. * Define the name of the layer.
  54126. */
  54127. name: string;
  54128. /**
  54129. * Define the texture the layer should display.
  54130. */
  54131. texture: Nullable<Texture>;
  54132. /**
  54133. * Is the layer in background or foreground.
  54134. */
  54135. isBackground: boolean;
  54136. /**
  54137. * Define the color of the layer (instead of texture).
  54138. */
  54139. color: Color4;
  54140. /**
  54141. * Define the scale of the layer in order to zoom in out of the texture.
  54142. */
  54143. scale: Vector2;
  54144. /**
  54145. * Define an offset for the layer in order to shift the texture.
  54146. */
  54147. offset: Vector2;
  54148. /**
  54149. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54150. */
  54151. alphaBlendingMode: number;
  54152. /**
  54153. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54154. * Alpha test will not mix with the background color in case of transparency.
  54155. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54156. */
  54157. alphaTest: boolean;
  54158. /**
  54159. * Define a mask to restrict the layer to only some of the scene cameras.
  54160. */
  54161. layerMask: number;
  54162. /**
  54163. * Define the list of render target the layer is visible into.
  54164. */
  54165. renderTargetTextures: RenderTargetTexture[];
  54166. /**
  54167. * Define if the layer is only used in renderTarget or if it also
  54168. * renders in the main frame buffer of the canvas.
  54169. */
  54170. renderOnlyInRenderTargetTextures: boolean;
  54171. private _scene;
  54172. private _vertexBuffers;
  54173. private _indexBuffer;
  54174. private _effect;
  54175. private _previousDefines;
  54176. /**
  54177. * An event triggered when the layer is disposed.
  54178. */
  54179. onDisposeObservable: Observable<Layer>;
  54180. private _onDisposeObserver;
  54181. /**
  54182. * Back compatibility with callback before the onDisposeObservable existed.
  54183. * The set callback will be triggered when the layer has been disposed.
  54184. */
  54185. set onDispose(callback: () => void);
  54186. /**
  54187. * An event triggered before rendering the scene
  54188. */
  54189. onBeforeRenderObservable: Observable<Layer>;
  54190. private _onBeforeRenderObserver;
  54191. /**
  54192. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54193. * The set callback will be triggered just before rendering the layer.
  54194. */
  54195. set onBeforeRender(callback: () => void);
  54196. /**
  54197. * An event triggered after rendering the scene
  54198. */
  54199. onAfterRenderObservable: Observable<Layer>;
  54200. private _onAfterRenderObserver;
  54201. /**
  54202. * Back compatibility with callback before the onAfterRenderObservable existed.
  54203. * The set callback will be triggered just after rendering the layer.
  54204. */
  54205. set onAfterRender(callback: () => void);
  54206. /**
  54207. * Instantiates a new layer.
  54208. * This represents a full screen 2d layer.
  54209. * This can be useful to display a picture in the background of your scene for instance.
  54210. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54211. * @param name Define the name of the layer in the scene
  54212. * @param imgUrl Define the url of the texture to display in the layer
  54213. * @param scene Define the scene the layer belongs to
  54214. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54215. * @param color Defines a color for the layer
  54216. */
  54217. constructor(
  54218. /**
  54219. * Define the name of the layer.
  54220. */
  54221. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54222. private _createIndexBuffer;
  54223. /** @hidden */
  54224. _rebuild(): void;
  54225. /**
  54226. * Renders the layer in the scene.
  54227. */
  54228. render(): void;
  54229. /**
  54230. * Disposes and releases the associated ressources.
  54231. */
  54232. dispose(): void;
  54233. }
  54234. }
  54235. declare module BABYLON {
  54236. /** @hidden */
  54237. export var lensFlarePixelShader: {
  54238. name: string;
  54239. shader: string;
  54240. };
  54241. }
  54242. declare module BABYLON {
  54243. /** @hidden */
  54244. export var lensFlareVertexShader: {
  54245. name: string;
  54246. shader: string;
  54247. };
  54248. }
  54249. declare module BABYLON {
  54250. /**
  54251. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54252. * It is usually composed of several `lensFlare`.
  54253. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54254. */
  54255. export class LensFlareSystem {
  54256. /**
  54257. * Define the name of the lens flare system
  54258. */
  54259. name: string;
  54260. /**
  54261. * List of lens flares used in this system.
  54262. */
  54263. lensFlares: LensFlare[];
  54264. /**
  54265. * Define a limit from the border the lens flare can be visible.
  54266. */
  54267. borderLimit: number;
  54268. /**
  54269. * Define a viewport border we do not want to see the lens flare in.
  54270. */
  54271. viewportBorder: number;
  54272. /**
  54273. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54274. */
  54275. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54276. /**
  54277. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54278. */
  54279. layerMask: number;
  54280. /**
  54281. * Define the id of the lens flare system in the scene.
  54282. * (equal to name by default)
  54283. */
  54284. id: string;
  54285. private _scene;
  54286. private _emitter;
  54287. private _vertexBuffers;
  54288. private _indexBuffer;
  54289. private _effect;
  54290. private _positionX;
  54291. private _positionY;
  54292. private _isEnabled;
  54293. /** @hidden */
  54294. static _SceneComponentInitialization: (scene: Scene) => void;
  54295. /**
  54296. * Instantiates a lens flare system.
  54297. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54298. * It is usually composed of several `lensFlare`.
  54299. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54300. * @param name Define the name of the lens flare system in the scene
  54301. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54302. * @param scene Define the scene the lens flare system belongs to
  54303. */
  54304. constructor(
  54305. /**
  54306. * Define the name of the lens flare system
  54307. */
  54308. name: string, emitter: any, scene: Scene);
  54309. /**
  54310. * Define if the lens flare system is enabled.
  54311. */
  54312. get isEnabled(): boolean;
  54313. set isEnabled(value: boolean);
  54314. /**
  54315. * Get the scene the effects belongs to.
  54316. * @returns the scene holding the lens flare system
  54317. */
  54318. getScene(): Scene;
  54319. /**
  54320. * Get the emitter of the lens flare system.
  54321. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54322. * @returns the emitter of the lens flare system
  54323. */
  54324. getEmitter(): any;
  54325. /**
  54326. * Set the emitter of the lens flare system.
  54327. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54328. * @param newEmitter Define the new emitter of the system
  54329. */
  54330. setEmitter(newEmitter: any): void;
  54331. /**
  54332. * Get the lens flare system emitter position.
  54333. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54334. * @returns the position
  54335. */
  54336. getEmitterPosition(): Vector3;
  54337. /**
  54338. * @hidden
  54339. */
  54340. computeEffectivePosition(globalViewport: Viewport): boolean;
  54341. /** @hidden */
  54342. _isVisible(): boolean;
  54343. /**
  54344. * @hidden
  54345. */
  54346. render(): boolean;
  54347. /**
  54348. * Dispose and release the lens flare with its associated resources.
  54349. */
  54350. dispose(): void;
  54351. /**
  54352. * Parse a lens flare system from a JSON repressentation
  54353. * @param parsedLensFlareSystem Define the JSON to parse
  54354. * @param scene Define the scene the parsed system should be instantiated in
  54355. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54356. * @returns the parsed system
  54357. */
  54358. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54359. /**
  54360. * Serialize the current Lens Flare System into a JSON representation.
  54361. * @returns the serialized JSON
  54362. */
  54363. serialize(): any;
  54364. }
  54365. }
  54366. declare module BABYLON {
  54367. /**
  54368. * This represents one of the lens effect in a `lensFlareSystem`.
  54369. * It controls one of the indiviual texture used in the effect.
  54370. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54371. */
  54372. export class LensFlare {
  54373. /**
  54374. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54375. */
  54376. size: number;
  54377. /**
  54378. * 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.
  54379. */
  54380. position: number;
  54381. /**
  54382. * Define the lens color.
  54383. */
  54384. color: Color3;
  54385. /**
  54386. * Define the lens texture.
  54387. */
  54388. texture: Nullable<Texture>;
  54389. /**
  54390. * Define the alpha mode to render this particular lens.
  54391. */
  54392. alphaMode: number;
  54393. private _system;
  54394. /**
  54395. * Creates a new Lens Flare.
  54396. * This represents one of the lens effect in a `lensFlareSystem`.
  54397. * It controls one of the indiviual texture used in the effect.
  54398. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54399. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54400. * @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.
  54401. * @param color Define the lens color
  54402. * @param imgUrl Define the lens texture url
  54403. * @param system Define the `lensFlareSystem` this flare is part of
  54404. * @returns The newly created Lens Flare
  54405. */
  54406. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54407. /**
  54408. * Instantiates a new Lens Flare.
  54409. * This represents one of the lens effect in a `lensFlareSystem`.
  54410. * It controls one of the indiviual texture used in the effect.
  54411. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54412. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54413. * @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.
  54414. * @param color Define the lens color
  54415. * @param imgUrl Define the lens texture url
  54416. * @param system Define the `lensFlareSystem` this flare is part of
  54417. */
  54418. constructor(
  54419. /**
  54420. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54421. */
  54422. size: number,
  54423. /**
  54424. * 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.
  54425. */
  54426. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54427. /**
  54428. * Dispose and release the lens flare with its associated resources.
  54429. */
  54430. dispose(): void;
  54431. }
  54432. }
  54433. declare module BABYLON {
  54434. interface AbstractScene {
  54435. /**
  54436. * The list of lens flare system added to the scene
  54437. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54438. */
  54439. lensFlareSystems: Array<LensFlareSystem>;
  54440. /**
  54441. * Removes the given lens flare system from this scene.
  54442. * @param toRemove The lens flare system to remove
  54443. * @returns The index of the removed lens flare system
  54444. */
  54445. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54446. /**
  54447. * Adds the given lens flare system to this scene
  54448. * @param newLensFlareSystem The lens flare system to add
  54449. */
  54450. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54451. /**
  54452. * Gets a lens flare system using its name
  54453. * @param name defines the name to look for
  54454. * @returns the lens flare system or null if not found
  54455. */
  54456. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54457. /**
  54458. * Gets a lens flare system using its id
  54459. * @param id defines the id to look for
  54460. * @returns the lens flare system or null if not found
  54461. */
  54462. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54463. }
  54464. /**
  54465. * Defines the lens flare scene component responsible to manage any lens flares
  54466. * in a given scene.
  54467. */
  54468. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54469. /**
  54470. * The component name helpfull to identify the component in the list of scene components.
  54471. */
  54472. readonly name: string;
  54473. /**
  54474. * The scene the component belongs to.
  54475. */
  54476. scene: Scene;
  54477. /**
  54478. * Creates a new instance of the component for the given scene
  54479. * @param scene Defines the scene to register the component in
  54480. */
  54481. constructor(scene: Scene);
  54482. /**
  54483. * Registers the component in a given scene
  54484. */
  54485. register(): void;
  54486. /**
  54487. * Rebuilds the elements related to this component in case of
  54488. * context lost for instance.
  54489. */
  54490. rebuild(): void;
  54491. /**
  54492. * Adds all the elements from the container to the scene
  54493. * @param container the container holding the elements
  54494. */
  54495. addFromContainer(container: AbstractScene): void;
  54496. /**
  54497. * Removes all the elements in the container from the scene
  54498. * @param container contains the elements to remove
  54499. * @param dispose if the removed element should be disposed (default: false)
  54500. */
  54501. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54502. /**
  54503. * Serializes the component data to the specified json object
  54504. * @param serializationObject The object to serialize to
  54505. */
  54506. serialize(serializationObject: any): void;
  54507. /**
  54508. * Disposes the component and the associated ressources.
  54509. */
  54510. dispose(): void;
  54511. private _draw;
  54512. }
  54513. }
  54514. declare module BABYLON {
  54515. /** @hidden */
  54516. export var depthPixelShader: {
  54517. name: string;
  54518. shader: string;
  54519. };
  54520. }
  54521. declare module BABYLON {
  54522. /** @hidden */
  54523. export var depthVertexShader: {
  54524. name: string;
  54525. shader: string;
  54526. };
  54527. }
  54528. declare module BABYLON {
  54529. /**
  54530. * This represents a depth renderer in Babylon.
  54531. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54532. */
  54533. export class DepthRenderer {
  54534. private _scene;
  54535. private _depthMap;
  54536. private _effect;
  54537. private readonly _storeNonLinearDepth;
  54538. private readonly _clearColor;
  54539. /** Get if the depth renderer is using packed depth or not */
  54540. readonly isPacked: boolean;
  54541. private _cachedDefines;
  54542. private _camera;
  54543. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54544. enabled: boolean;
  54545. /**
  54546. * Specifiess that the depth renderer will only be used within
  54547. * the camera it is created for.
  54548. * This can help forcing its rendering during the camera processing.
  54549. */
  54550. useOnlyInActiveCamera: boolean;
  54551. /** @hidden */
  54552. static _SceneComponentInitialization: (scene: Scene) => void;
  54553. /**
  54554. * Instantiates a depth renderer
  54555. * @param scene The scene the renderer belongs to
  54556. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54557. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54558. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54559. */
  54560. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54561. /**
  54562. * Creates the depth rendering effect and checks if the effect is ready.
  54563. * @param subMesh The submesh to be used to render the depth map of
  54564. * @param useInstances If multiple world instances should be used
  54565. * @returns if the depth renderer is ready to render the depth map
  54566. */
  54567. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54568. /**
  54569. * Gets the texture which the depth map will be written to.
  54570. * @returns The depth map texture
  54571. */
  54572. getDepthMap(): RenderTargetTexture;
  54573. /**
  54574. * Disposes of the depth renderer.
  54575. */
  54576. dispose(): void;
  54577. }
  54578. }
  54579. declare module BABYLON {
  54580. /** @hidden */
  54581. export var minmaxReduxPixelShader: {
  54582. name: string;
  54583. shader: string;
  54584. };
  54585. }
  54586. declare module BABYLON {
  54587. /**
  54588. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54589. * and maximum values from all values of the texture.
  54590. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54591. * The source values are read from the red channel of the texture.
  54592. */
  54593. export class MinMaxReducer {
  54594. /**
  54595. * Observable triggered when the computation has been performed
  54596. */
  54597. onAfterReductionPerformed: Observable<{
  54598. min: number;
  54599. max: number;
  54600. }>;
  54601. protected _camera: Camera;
  54602. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54603. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54604. protected _postProcessManager: PostProcessManager;
  54605. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54606. protected _forceFullscreenViewport: boolean;
  54607. /**
  54608. * Creates a min/max reducer
  54609. * @param camera The camera to use for the post processes
  54610. */
  54611. constructor(camera: Camera);
  54612. /**
  54613. * Gets the texture used to read the values from.
  54614. */
  54615. get sourceTexture(): Nullable<RenderTargetTexture>;
  54616. /**
  54617. * Sets the source texture to read the values from.
  54618. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54619. * because in such textures '1' value must not be taken into account to compute the maximum
  54620. * as this value is used to clear the texture.
  54621. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54622. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54623. * @param depthRedux Indicates if the texture is a depth texture or not
  54624. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54625. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54626. */
  54627. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54628. /**
  54629. * Defines the refresh rate of the computation.
  54630. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54631. */
  54632. get refreshRate(): number;
  54633. set refreshRate(value: number);
  54634. protected _activated: boolean;
  54635. /**
  54636. * Gets the activation status of the reducer
  54637. */
  54638. get activated(): boolean;
  54639. /**
  54640. * Activates the reduction computation.
  54641. * When activated, the observers registered in onAfterReductionPerformed are
  54642. * called after the compuation is performed
  54643. */
  54644. activate(): void;
  54645. /**
  54646. * Deactivates the reduction computation.
  54647. */
  54648. deactivate(): void;
  54649. /**
  54650. * Disposes the min/max reducer
  54651. * @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.
  54652. */
  54653. dispose(disposeAll?: boolean): void;
  54654. }
  54655. }
  54656. declare module BABYLON {
  54657. /**
  54658. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54659. */
  54660. export class DepthReducer extends MinMaxReducer {
  54661. private _depthRenderer;
  54662. private _depthRendererId;
  54663. /**
  54664. * Gets the depth renderer used for the computation.
  54665. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54666. */
  54667. get depthRenderer(): Nullable<DepthRenderer>;
  54668. /**
  54669. * Creates a depth reducer
  54670. * @param camera The camera used to render the depth texture
  54671. */
  54672. constructor(camera: Camera);
  54673. /**
  54674. * Sets the depth renderer to use to generate the depth map
  54675. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54676. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54677. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54678. */
  54679. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54680. /** @hidden */
  54681. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54682. /**
  54683. * Activates the reduction computation.
  54684. * When activated, the observers registered in onAfterReductionPerformed are
  54685. * called after the compuation is performed
  54686. */
  54687. activate(): void;
  54688. /**
  54689. * Deactivates the reduction computation.
  54690. */
  54691. deactivate(): void;
  54692. /**
  54693. * Disposes the depth reducer
  54694. * @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.
  54695. */
  54696. dispose(disposeAll?: boolean): void;
  54697. }
  54698. }
  54699. declare module BABYLON {
  54700. /**
  54701. * A CSM implementation allowing casting shadows on large scenes.
  54702. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54703. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54704. */
  54705. export class CascadedShadowGenerator extends ShadowGenerator {
  54706. private static readonly frustumCornersNDCSpace;
  54707. /**
  54708. * Name of the CSM class
  54709. */
  54710. static CLASSNAME: string;
  54711. /**
  54712. * Defines the default number of cascades used by the CSM.
  54713. */
  54714. static readonly DEFAULT_CASCADES_COUNT: number;
  54715. /**
  54716. * Defines the minimum number of cascades used by the CSM.
  54717. */
  54718. static readonly MIN_CASCADES_COUNT: number;
  54719. /**
  54720. * Defines the maximum number of cascades used by the CSM.
  54721. */
  54722. static readonly MAX_CASCADES_COUNT: number;
  54723. protected _validateFilter(filter: number): number;
  54724. /**
  54725. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54726. */
  54727. penumbraDarkness: number;
  54728. private _numCascades;
  54729. /**
  54730. * Gets or set the number of cascades used by the CSM.
  54731. */
  54732. get numCascades(): number;
  54733. set numCascades(value: number);
  54734. /**
  54735. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54736. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54737. */
  54738. stabilizeCascades: boolean;
  54739. private _freezeShadowCastersBoundingInfo;
  54740. private _freezeShadowCastersBoundingInfoObservable;
  54741. /**
  54742. * Enables or disables the shadow casters bounding info computation.
  54743. * If your shadow casters don't move, you can disable this feature.
  54744. * If it is enabled, the bounding box computation is done every frame.
  54745. */
  54746. get freezeShadowCastersBoundingInfo(): boolean;
  54747. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54748. private _scbiMin;
  54749. private _scbiMax;
  54750. protected _computeShadowCastersBoundingInfo(): void;
  54751. protected _shadowCastersBoundingInfo: BoundingInfo;
  54752. /**
  54753. * Gets or sets the shadow casters bounding info.
  54754. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54755. * so that the system won't overwrite the bounds you provide
  54756. */
  54757. get shadowCastersBoundingInfo(): BoundingInfo;
  54758. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54759. protected _breaksAreDirty: boolean;
  54760. protected _minDistance: number;
  54761. protected _maxDistance: number;
  54762. /**
  54763. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54764. *
  54765. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54766. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54767. * @param min minimal distance for the breaks (default to 0.)
  54768. * @param max maximal distance for the breaks (default to 1.)
  54769. */
  54770. setMinMaxDistance(min: number, max: number): void;
  54771. /** Gets the minimal distance used in the cascade break computation */
  54772. get minDistance(): number;
  54773. /** Gets the maximal distance used in the cascade break computation */
  54774. get maxDistance(): number;
  54775. /**
  54776. * Gets the class name of that object
  54777. * @returns "CascadedShadowGenerator"
  54778. */
  54779. getClassName(): string;
  54780. private _cascadeMinExtents;
  54781. private _cascadeMaxExtents;
  54782. /**
  54783. * Gets a cascade minimum extents
  54784. * @param cascadeIndex index of the cascade
  54785. * @returns the minimum cascade extents
  54786. */
  54787. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54788. /**
  54789. * Gets a cascade maximum extents
  54790. * @param cascadeIndex index of the cascade
  54791. * @returns the maximum cascade extents
  54792. */
  54793. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54794. private _cascades;
  54795. private _currentLayer;
  54796. private _viewSpaceFrustumsZ;
  54797. private _viewMatrices;
  54798. private _projectionMatrices;
  54799. private _transformMatrices;
  54800. private _transformMatricesAsArray;
  54801. private _frustumLengths;
  54802. private _lightSizeUVCorrection;
  54803. private _depthCorrection;
  54804. private _frustumCornersWorldSpace;
  54805. private _frustumCenter;
  54806. private _shadowCameraPos;
  54807. private _shadowMaxZ;
  54808. /**
  54809. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54810. * It defaults to camera.maxZ
  54811. */
  54812. get shadowMaxZ(): number;
  54813. /**
  54814. * Sets the shadow max z distance.
  54815. */
  54816. set shadowMaxZ(value: number);
  54817. protected _debug: boolean;
  54818. /**
  54819. * Gets or sets the debug flag.
  54820. * When enabled, the cascades are materialized by different colors on the screen.
  54821. */
  54822. get debug(): boolean;
  54823. set debug(dbg: boolean);
  54824. private _depthClamp;
  54825. /**
  54826. * Gets or sets the depth clamping value.
  54827. *
  54828. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54829. * to account for the shadow casters far away.
  54830. *
  54831. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54832. */
  54833. get depthClamp(): boolean;
  54834. set depthClamp(value: boolean);
  54835. private _cascadeBlendPercentage;
  54836. /**
  54837. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54838. * It defaults to 0.1 (10% blending).
  54839. */
  54840. get cascadeBlendPercentage(): number;
  54841. set cascadeBlendPercentage(value: number);
  54842. private _lambda;
  54843. /**
  54844. * Gets or set the lambda parameter.
  54845. * This parameter is used to split the camera frustum and create the cascades.
  54846. * 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.
  54847. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54848. */
  54849. get lambda(): number;
  54850. set lambda(value: number);
  54851. /**
  54852. * Gets the view matrix corresponding to a given cascade
  54853. * @param cascadeNum cascade to retrieve the view matrix from
  54854. * @returns the cascade view matrix
  54855. */
  54856. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54857. /**
  54858. * Gets the projection matrix corresponding to a given cascade
  54859. * @param cascadeNum cascade to retrieve the projection matrix from
  54860. * @returns the cascade projection matrix
  54861. */
  54862. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54863. /**
  54864. * Gets the transformation matrix corresponding to a given cascade
  54865. * @param cascadeNum cascade to retrieve the transformation matrix from
  54866. * @returns the cascade transformation matrix
  54867. */
  54868. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54869. private _depthRenderer;
  54870. /**
  54871. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54872. *
  54873. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54874. *
  54875. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54876. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54877. * @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
  54878. */
  54879. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54880. private _depthReducer;
  54881. private _autoCalcDepthBounds;
  54882. /**
  54883. * Gets or sets the autoCalcDepthBounds property.
  54884. *
  54885. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54886. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54887. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54888. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54889. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54890. */
  54891. get autoCalcDepthBounds(): boolean;
  54892. set autoCalcDepthBounds(value: boolean);
  54893. /**
  54894. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54895. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54896. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54897. * for setting the refresh rate on the renderer yourself!
  54898. */
  54899. get autoCalcDepthBoundsRefreshRate(): number;
  54900. set autoCalcDepthBoundsRefreshRate(value: number);
  54901. /**
  54902. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54903. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54904. * you change the camera near/far planes!
  54905. */
  54906. splitFrustum(): void;
  54907. private _splitFrustum;
  54908. private _computeMatrices;
  54909. private _computeFrustumInWorldSpace;
  54910. private _computeCascadeFrustum;
  54911. /**
  54912. * Support test.
  54913. */
  54914. static get IsSupported(): boolean;
  54915. /** @hidden */
  54916. static _SceneComponentInitialization: (scene: Scene) => void;
  54917. /**
  54918. * Creates a Cascaded Shadow Generator object.
  54919. * A ShadowGenerator is the required tool to use the shadows.
  54920. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54921. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54922. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54923. * @param light The directional light object generating the shadows.
  54924. * @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.
  54925. */
  54926. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54927. protected _initializeGenerator(): void;
  54928. protected _createTargetRenderTexture(): void;
  54929. protected _initializeShadowMap(): void;
  54930. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54931. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54932. /**
  54933. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54934. * @param defines Defines of the material we want to update
  54935. * @param lightIndex Index of the light in the enabled light list of the material
  54936. */
  54937. prepareDefines(defines: any, lightIndex: number): void;
  54938. /**
  54939. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54940. * defined in the generator but impacting the effect).
  54941. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54942. * @param effect The effect we are binfing the information for
  54943. */
  54944. bindShadowLight(lightIndex: string, effect: Effect): void;
  54945. /**
  54946. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54947. * (eq to view projection * shadow projection matrices)
  54948. * @returns The transform matrix used to create the shadow map
  54949. */
  54950. getTransformMatrix(): Matrix;
  54951. /**
  54952. * Disposes the ShadowGenerator.
  54953. * Returns nothing.
  54954. */
  54955. dispose(): void;
  54956. /**
  54957. * Serializes the shadow generator setup to a json object.
  54958. * @returns The serialized JSON object
  54959. */
  54960. serialize(): any;
  54961. /**
  54962. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54963. * @param parsedShadowGenerator The JSON object to parse
  54964. * @param scene The scene to create the shadow map for
  54965. * @returns The parsed shadow generator
  54966. */
  54967. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54968. }
  54969. }
  54970. declare module BABYLON {
  54971. /**
  54972. * Defines the shadow generator component responsible to manage any shadow generators
  54973. * in a given scene.
  54974. */
  54975. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54976. /**
  54977. * The component name helpfull to identify the component in the list of scene components.
  54978. */
  54979. readonly name: string;
  54980. /**
  54981. * The scene the component belongs to.
  54982. */
  54983. scene: Scene;
  54984. /**
  54985. * Creates a new instance of the component for the given scene
  54986. * @param scene Defines the scene to register the component in
  54987. */
  54988. constructor(scene: Scene);
  54989. /**
  54990. * Registers the component in a given scene
  54991. */
  54992. register(): void;
  54993. /**
  54994. * Rebuilds the elements related to this component in case of
  54995. * context lost for instance.
  54996. */
  54997. rebuild(): void;
  54998. /**
  54999. * Serializes the component data to the specified json object
  55000. * @param serializationObject The object to serialize to
  55001. */
  55002. serialize(serializationObject: any): void;
  55003. /**
  55004. * Adds all the elements from the container to the scene
  55005. * @param container the container holding the elements
  55006. */
  55007. addFromContainer(container: AbstractScene): void;
  55008. /**
  55009. * Removes all the elements in the container from the scene
  55010. * @param container contains the elements to remove
  55011. * @param dispose if the removed element should be disposed (default: false)
  55012. */
  55013. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55014. /**
  55015. * Rebuilds the elements related to this component in case of
  55016. * context lost for instance.
  55017. */
  55018. dispose(): void;
  55019. private _gatherRenderTargets;
  55020. }
  55021. }
  55022. declare module BABYLON {
  55023. /**
  55024. * A point light is a light defined by an unique point in world space.
  55025. * The light is emitted in every direction from this point.
  55026. * A good example of a point light is a standard light bulb.
  55027. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55028. */
  55029. export class PointLight extends ShadowLight {
  55030. private _shadowAngle;
  55031. /**
  55032. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55033. * This specifies what angle the shadow will use to be created.
  55034. *
  55035. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55036. */
  55037. get shadowAngle(): number;
  55038. /**
  55039. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55040. * This specifies what angle the shadow will use to be created.
  55041. *
  55042. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55043. */
  55044. set shadowAngle(value: number);
  55045. /**
  55046. * Gets the direction if it has been set.
  55047. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55048. */
  55049. get direction(): Vector3;
  55050. /**
  55051. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55052. */
  55053. set direction(value: Vector3);
  55054. /**
  55055. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55056. * A PointLight emits the light in every direction.
  55057. * It can cast shadows.
  55058. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55059. * ```javascript
  55060. * var pointLight = new PointLight("pl", camera.position, scene);
  55061. * ```
  55062. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55063. * @param name The light friendly name
  55064. * @param position The position of the point light in the scene
  55065. * @param scene The scene the lights belongs to
  55066. */
  55067. constructor(name: string, position: Vector3, scene: Scene);
  55068. /**
  55069. * Returns the string "PointLight"
  55070. * @returns the class name
  55071. */
  55072. getClassName(): string;
  55073. /**
  55074. * Returns the integer 0.
  55075. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55076. */
  55077. getTypeID(): number;
  55078. /**
  55079. * Specifies wether or not the shadowmap should be a cube texture.
  55080. * @returns true if the shadowmap needs to be a cube texture.
  55081. */
  55082. needCube(): boolean;
  55083. /**
  55084. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55085. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55086. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55087. */
  55088. getShadowDirection(faceIndex?: number): Vector3;
  55089. /**
  55090. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55091. * - fov = PI / 2
  55092. * - aspect ratio : 1.0
  55093. * - z-near and far equal to the active camera minZ and maxZ.
  55094. * Returns the PointLight.
  55095. */
  55096. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55097. protected _buildUniformLayout(): void;
  55098. /**
  55099. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55100. * @param effect The effect to update
  55101. * @param lightIndex The index of the light in the effect to update
  55102. * @returns The point light
  55103. */
  55104. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55105. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55106. /**
  55107. * Prepares the list of defines specific to the light type.
  55108. * @param defines the list of defines
  55109. * @param lightIndex defines the index of the light for the effect
  55110. */
  55111. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55112. }
  55113. }
  55114. declare module BABYLON {
  55115. /**
  55116. * Header information of HDR texture files.
  55117. */
  55118. export interface HDRInfo {
  55119. /**
  55120. * The height of the texture in pixels.
  55121. */
  55122. height: number;
  55123. /**
  55124. * The width of the texture in pixels.
  55125. */
  55126. width: number;
  55127. /**
  55128. * The index of the beginning of the data in the binary file.
  55129. */
  55130. dataPosition: number;
  55131. }
  55132. /**
  55133. * This groups tools to convert HDR texture to native colors array.
  55134. */
  55135. export class HDRTools {
  55136. private static Ldexp;
  55137. private static Rgbe2float;
  55138. private static readStringLine;
  55139. /**
  55140. * Reads header information from an RGBE texture stored in a native array.
  55141. * More information on this format are available here:
  55142. * https://en.wikipedia.org/wiki/RGBE_image_format
  55143. *
  55144. * @param uint8array The binary file stored in native array.
  55145. * @return The header information.
  55146. */
  55147. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55148. /**
  55149. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55150. * This RGBE texture needs to store the information as a panorama.
  55151. *
  55152. * More information on this format are available here:
  55153. * https://en.wikipedia.org/wiki/RGBE_image_format
  55154. *
  55155. * @param buffer The binary file stored in an array buffer.
  55156. * @param size The expected size of the extracted cubemap.
  55157. * @return The Cube Map information.
  55158. */
  55159. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55160. /**
  55161. * Returns the pixels data extracted from an RGBE texture.
  55162. * This pixels will be stored left to right up to down in the R G B order in one array.
  55163. *
  55164. * More information on this format are available here:
  55165. * https://en.wikipedia.org/wiki/RGBE_image_format
  55166. *
  55167. * @param uint8array The binary file stored in an array buffer.
  55168. * @param hdrInfo The header information of the file.
  55169. * @return The pixels data in RGB right to left up to down order.
  55170. */
  55171. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55172. private static RGBE_ReadPixels_RLE;
  55173. }
  55174. }
  55175. declare module BABYLON {
  55176. /**
  55177. * This represents a texture coming from an HDR input.
  55178. *
  55179. * The only supported format is currently panorama picture stored in RGBE format.
  55180. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55181. */
  55182. export class HDRCubeTexture extends BaseTexture {
  55183. private static _facesMapping;
  55184. private _generateHarmonics;
  55185. private _noMipmap;
  55186. private _textureMatrix;
  55187. private _size;
  55188. private _onLoad;
  55189. private _onError;
  55190. /**
  55191. * The texture URL.
  55192. */
  55193. url: string;
  55194. /**
  55195. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55196. */
  55197. coordinatesMode: number;
  55198. protected _isBlocking: boolean;
  55199. /**
  55200. * Sets wether or not the texture is blocking during loading.
  55201. */
  55202. set isBlocking(value: boolean);
  55203. /**
  55204. * Gets wether or not the texture is blocking during loading.
  55205. */
  55206. get isBlocking(): boolean;
  55207. protected _rotationY: number;
  55208. /**
  55209. * Sets texture matrix rotation angle around Y axis in radians.
  55210. */
  55211. set rotationY(value: number);
  55212. /**
  55213. * Gets texture matrix rotation angle around Y axis radians.
  55214. */
  55215. get rotationY(): number;
  55216. /**
  55217. * Gets or sets the center of the bounding box associated with the cube texture
  55218. * It must define where the camera used to render the texture was set
  55219. */
  55220. boundingBoxPosition: Vector3;
  55221. private _boundingBoxSize;
  55222. /**
  55223. * Gets or sets the size of the bounding box associated with the cube texture
  55224. * When defined, the cubemap will switch to local mode
  55225. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55226. * @example https://www.babylonjs-playground.com/#RNASML
  55227. */
  55228. set boundingBoxSize(value: Vector3);
  55229. get boundingBoxSize(): Vector3;
  55230. /**
  55231. * Instantiates an HDRTexture from the following parameters.
  55232. *
  55233. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55234. * @param scene The scene the texture will be used in
  55235. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55236. * @param noMipmap Forces to not generate the mipmap if true
  55237. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55238. * @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)
  55239. * @param reserved Reserved flag for internal use.
  55240. */
  55241. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55242. /**
  55243. * Get the current class name of the texture useful for serialization or dynamic coding.
  55244. * @returns "HDRCubeTexture"
  55245. */
  55246. getClassName(): string;
  55247. /**
  55248. * Occurs when the file is raw .hdr file.
  55249. */
  55250. private loadTexture;
  55251. clone(): HDRCubeTexture;
  55252. delayLoad(): void;
  55253. /**
  55254. * Get the texture reflection matrix used to rotate/transform the reflection.
  55255. * @returns the reflection matrix
  55256. */
  55257. getReflectionTextureMatrix(): Matrix;
  55258. /**
  55259. * Set the texture reflection matrix used to rotate/transform the reflection.
  55260. * @param value Define the reflection matrix to set
  55261. */
  55262. setReflectionTextureMatrix(value: Matrix): void;
  55263. /**
  55264. * Parses a JSON representation of an HDR Texture in order to create the texture
  55265. * @param parsedTexture Define the JSON representation
  55266. * @param scene Define the scene the texture should be created in
  55267. * @param rootUrl Define the root url in case we need to load relative dependencies
  55268. * @returns the newly created texture after parsing
  55269. */
  55270. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55271. serialize(): any;
  55272. }
  55273. }
  55274. declare module BABYLON {
  55275. /**
  55276. * Class used to control physics engine
  55277. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55278. */
  55279. export class PhysicsEngine implements IPhysicsEngine {
  55280. private _physicsPlugin;
  55281. /**
  55282. * Global value used to control the smallest number supported by the simulation
  55283. */
  55284. static Epsilon: number;
  55285. private _impostors;
  55286. private _joints;
  55287. private _subTimeStep;
  55288. /**
  55289. * Gets the gravity vector used by the simulation
  55290. */
  55291. gravity: Vector3;
  55292. /**
  55293. * Factory used to create the default physics plugin.
  55294. * @returns The default physics plugin
  55295. */
  55296. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55297. /**
  55298. * Creates a new Physics Engine
  55299. * @param gravity defines the gravity vector used by the simulation
  55300. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55301. */
  55302. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55303. /**
  55304. * Sets the gravity vector used by the simulation
  55305. * @param gravity defines the gravity vector to use
  55306. */
  55307. setGravity(gravity: Vector3): void;
  55308. /**
  55309. * Set the time step of the physics engine.
  55310. * Default is 1/60.
  55311. * To slow it down, enter 1/600 for example.
  55312. * To speed it up, 1/30
  55313. * @param newTimeStep defines the new timestep to apply to this world.
  55314. */
  55315. setTimeStep(newTimeStep?: number): void;
  55316. /**
  55317. * Get the time step of the physics engine.
  55318. * @returns the current time step
  55319. */
  55320. getTimeStep(): number;
  55321. /**
  55322. * Set the sub time step of the physics engine.
  55323. * Default is 0 meaning there is no sub steps
  55324. * To increase physics resolution precision, set a small value (like 1 ms)
  55325. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55326. */
  55327. setSubTimeStep(subTimeStep?: number): void;
  55328. /**
  55329. * Get the sub time step of the physics engine.
  55330. * @returns the current sub time step
  55331. */
  55332. getSubTimeStep(): number;
  55333. /**
  55334. * Release all resources
  55335. */
  55336. dispose(): void;
  55337. /**
  55338. * Gets the name of the current physics plugin
  55339. * @returns the name of the plugin
  55340. */
  55341. getPhysicsPluginName(): string;
  55342. /**
  55343. * Adding a new impostor for the impostor tracking.
  55344. * This will be done by the impostor itself.
  55345. * @param impostor the impostor to add
  55346. */
  55347. addImpostor(impostor: PhysicsImpostor): void;
  55348. /**
  55349. * Remove an impostor from the engine.
  55350. * This impostor and its mesh will not longer be updated by the physics engine.
  55351. * @param impostor the impostor to remove
  55352. */
  55353. removeImpostor(impostor: PhysicsImpostor): void;
  55354. /**
  55355. * Add a joint to the physics engine
  55356. * @param mainImpostor defines the main impostor to which the joint is added.
  55357. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55358. * @param joint defines the joint that will connect both impostors.
  55359. */
  55360. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55361. /**
  55362. * Removes a joint from the simulation
  55363. * @param mainImpostor defines the impostor used with the joint
  55364. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55365. * @param joint defines the joint to remove
  55366. */
  55367. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55368. /**
  55369. * Called by the scene. No need to call it.
  55370. * @param delta defines the timespam between frames
  55371. */
  55372. _step(delta: number): void;
  55373. /**
  55374. * Gets the current plugin used to run the simulation
  55375. * @returns current plugin
  55376. */
  55377. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55378. /**
  55379. * Gets the list of physic impostors
  55380. * @returns an array of PhysicsImpostor
  55381. */
  55382. getImpostors(): Array<PhysicsImpostor>;
  55383. /**
  55384. * Gets the impostor for a physics enabled object
  55385. * @param object defines the object impersonated by the impostor
  55386. * @returns the PhysicsImpostor or null if not found
  55387. */
  55388. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55389. /**
  55390. * Gets the impostor for a physics body object
  55391. * @param body defines physics body used by the impostor
  55392. * @returns the PhysicsImpostor or null if not found
  55393. */
  55394. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55395. /**
  55396. * Does a raycast in the physics world
  55397. * @param from when should the ray start?
  55398. * @param to when should the ray end?
  55399. * @returns PhysicsRaycastResult
  55400. */
  55401. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55402. }
  55403. }
  55404. declare module BABYLON {
  55405. /** @hidden */
  55406. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55407. private _useDeltaForWorldStep;
  55408. world: any;
  55409. name: string;
  55410. private _physicsMaterials;
  55411. private _fixedTimeStep;
  55412. private _cannonRaycastResult;
  55413. private _raycastResult;
  55414. private _physicsBodysToRemoveAfterStep;
  55415. BJSCANNON: any;
  55416. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55417. setGravity(gravity: Vector3): void;
  55418. setTimeStep(timeStep: number): void;
  55419. getTimeStep(): number;
  55420. executeStep(delta: number): void;
  55421. private _removeMarkedPhysicsBodiesFromWorld;
  55422. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55423. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55424. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55425. private _processChildMeshes;
  55426. removePhysicsBody(impostor: PhysicsImpostor): void;
  55427. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55428. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55429. private _addMaterial;
  55430. private _checkWithEpsilon;
  55431. private _createShape;
  55432. private _createHeightmap;
  55433. private _minus90X;
  55434. private _plus90X;
  55435. private _tmpPosition;
  55436. private _tmpDeltaPosition;
  55437. private _tmpUnityRotation;
  55438. private _updatePhysicsBodyTransformation;
  55439. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55440. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55441. isSupported(): boolean;
  55442. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55443. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55444. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55445. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55446. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55447. getBodyMass(impostor: PhysicsImpostor): number;
  55448. getBodyFriction(impostor: PhysicsImpostor): number;
  55449. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55450. getBodyRestitution(impostor: PhysicsImpostor): number;
  55451. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55452. sleepBody(impostor: PhysicsImpostor): void;
  55453. wakeUpBody(impostor: PhysicsImpostor): void;
  55454. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55455. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55456. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55457. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55458. getRadius(impostor: PhysicsImpostor): number;
  55459. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55460. dispose(): void;
  55461. private _extendNamespace;
  55462. /**
  55463. * Does a raycast in the physics world
  55464. * @param from when should the ray start?
  55465. * @param to when should the ray end?
  55466. * @returns PhysicsRaycastResult
  55467. */
  55468. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55469. }
  55470. }
  55471. declare module BABYLON {
  55472. /** @hidden */
  55473. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55474. world: any;
  55475. name: string;
  55476. BJSOIMO: any;
  55477. private _raycastResult;
  55478. constructor(iterations?: number, oimoInjection?: any);
  55479. setGravity(gravity: Vector3): void;
  55480. setTimeStep(timeStep: number): void;
  55481. getTimeStep(): number;
  55482. private _tmpImpostorsArray;
  55483. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55484. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55485. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55486. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55487. private _tmpPositionVector;
  55488. removePhysicsBody(impostor: PhysicsImpostor): void;
  55489. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55490. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55491. isSupported(): boolean;
  55492. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55493. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55494. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55495. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55496. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55497. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55498. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55499. getBodyMass(impostor: PhysicsImpostor): number;
  55500. getBodyFriction(impostor: PhysicsImpostor): number;
  55501. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55502. getBodyRestitution(impostor: PhysicsImpostor): number;
  55503. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55504. sleepBody(impostor: PhysicsImpostor): void;
  55505. wakeUpBody(impostor: PhysicsImpostor): void;
  55506. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55507. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55508. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55509. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55510. getRadius(impostor: PhysicsImpostor): number;
  55511. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55512. dispose(): void;
  55513. /**
  55514. * Does a raycast in the physics world
  55515. * @param from when should the ray start?
  55516. * @param to when should the ray end?
  55517. * @returns PhysicsRaycastResult
  55518. */
  55519. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55520. }
  55521. }
  55522. declare module BABYLON {
  55523. /**
  55524. * Class containing static functions to help procedurally build meshes
  55525. */
  55526. export class RibbonBuilder {
  55527. /**
  55528. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55529. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55530. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55531. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55532. * * 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
  55533. * * 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
  55534. * * 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
  55535. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55536. * * 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
  55537. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55538. * * 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
  55539. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55540. * * 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
  55541. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55543. * @param name defines the name of the mesh
  55544. * @param options defines the options used to create the mesh
  55545. * @param scene defines the hosting scene
  55546. * @returns the ribbon mesh
  55547. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55548. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55549. */
  55550. static CreateRibbon(name: string, options: {
  55551. pathArray: Vector3[][];
  55552. closeArray?: boolean;
  55553. closePath?: boolean;
  55554. offset?: number;
  55555. updatable?: boolean;
  55556. sideOrientation?: number;
  55557. frontUVs?: Vector4;
  55558. backUVs?: Vector4;
  55559. instance?: Mesh;
  55560. invertUV?: boolean;
  55561. uvs?: Vector2[];
  55562. colors?: Color4[];
  55563. }, scene?: Nullable<Scene>): Mesh;
  55564. }
  55565. }
  55566. declare module BABYLON {
  55567. /**
  55568. * Class containing static functions to help procedurally build meshes
  55569. */
  55570. export class ShapeBuilder {
  55571. /**
  55572. * 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.
  55573. * * 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.
  55574. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55575. * * 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.
  55576. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55577. * * 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
  55578. * * 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
  55579. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55581. * * 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
  55582. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55584. * @param name defines the name of the mesh
  55585. * @param options defines the options used to create the mesh
  55586. * @param scene defines the hosting scene
  55587. * @returns the extruded shape mesh
  55588. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55590. */
  55591. static ExtrudeShape(name: string, options: {
  55592. shape: Vector3[];
  55593. path: Vector3[];
  55594. scale?: number;
  55595. rotation?: number;
  55596. cap?: number;
  55597. updatable?: boolean;
  55598. sideOrientation?: number;
  55599. frontUVs?: Vector4;
  55600. backUVs?: Vector4;
  55601. instance?: Mesh;
  55602. invertUV?: boolean;
  55603. }, scene?: Nullable<Scene>): Mesh;
  55604. /**
  55605. * Creates an custom extruded shape mesh.
  55606. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55607. * * 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.
  55608. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55609. * * 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
  55610. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55611. * * 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
  55612. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55613. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55614. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55615. * * 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
  55616. * * 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
  55617. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55619. * * 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
  55620. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55622. * @param name defines the name of the mesh
  55623. * @param options defines the options used to create the mesh
  55624. * @param scene defines the hosting scene
  55625. * @returns the custom extruded shape mesh
  55626. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55627. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55628. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55629. */
  55630. static ExtrudeShapeCustom(name: string, options: {
  55631. shape: Vector3[];
  55632. path: Vector3[];
  55633. scaleFunction?: any;
  55634. rotationFunction?: any;
  55635. ribbonCloseArray?: boolean;
  55636. ribbonClosePath?: boolean;
  55637. cap?: number;
  55638. updatable?: boolean;
  55639. sideOrientation?: number;
  55640. frontUVs?: Vector4;
  55641. backUVs?: Vector4;
  55642. instance?: Mesh;
  55643. invertUV?: boolean;
  55644. }, scene?: Nullable<Scene>): Mesh;
  55645. private static _ExtrudeShapeGeneric;
  55646. }
  55647. }
  55648. declare module BABYLON {
  55649. /**
  55650. * AmmoJS Physics plugin
  55651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55652. * @see https://github.com/kripken/ammo.js/
  55653. */
  55654. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55655. private _useDeltaForWorldStep;
  55656. /**
  55657. * Reference to the Ammo library
  55658. */
  55659. bjsAMMO: any;
  55660. /**
  55661. * Created ammoJS world which physics bodies are added to
  55662. */
  55663. world: any;
  55664. /**
  55665. * Name of the plugin
  55666. */
  55667. name: string;
  55668. private _timeStep;
  55669. private _fixedTimeStep;
  55670. private _maxSteps;
  55671. private _tmpQuaternion;
  55672. private _tmpAmmoTransform;
  55673. private _tmpAmmoQuaternion;
  55674. private _tmpAmmoConcreteContactResultCallback;
  55675. private _collisionConfiguration;
  55676. private _dispatcher;
  55677. private _overlappingPairCache;
  55678. private _solver;
  55679. private _softBodySolver;
  55680. private _tmpAmmoVectorA;
  55681. private _tmpAmmoVectorB;
  55682. private _tmpAmmoVectorC;
  55683. private _tmpAmmoVectorD;
  55684. private _tmpContactCallbackResult;
  55685. private _tmpAmmoVectorRCA;
  55686. private _tmpAmmoVectorRCB;
  55687. private _raycastResult;
  55688. private static readonly DISABLE_COLLISION_FLAG;
  55689. private static readonly KINEMATIC_FLAG;
  55690. private static readonly DISABLE_DEACTIVATION_FLAG;
  55691. /**
  55692. * Initializes the ammoJS plugin
  55693. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55694. * @param ammoInjection can be used to inject your own ammo reference
  55695. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55696. */
  55697. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55698. /**
  55699. * Sets the gravity of the physics world (m/(s^2))
  55700. * @param gravity Gravity to set
  55701. */
  55702. setGravity(gravity: Vector3): void;
  55703. /**
  55704. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55705. * @param timeStep timestep to use in seconds
  55706. */
  55707. setTimeStep(timeStep: number): void;
  55708. /**
  55709. * 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)
  55710. * @param fixedTimeStep fixedTimeStep to use in seconds
  55711. */
  55712. setFixedTimeStep(fixedTimeStep: number): void;
  55713. /**
  55714. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55715. * @param maxSteps the maximum number of steps by the physics engine per frame
  55716. */
  55717. setMaxSteps(maxSteps: number): void;
  55718. /**
  55719. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55720. * @returns the current timestep in seconds
  55721. */
  55722. getTimeStep(): number;
  55723. /**
  55724. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55725. */
  55726. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55727. private _isImpostorInContact;
  55728. private _isImpostorPairInContact;
  55729. private _stepSimulation;
  55730. /**
  55731. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55732. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55733. * After the step the babylon meshes are set to the position of the physics imposters
  55734. * @param delta amount of time to step forward
  55735. * @param impostors array of imposters to update before/after the step
  55736. */
  55737. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55738. /**
  55739. * Update babylon mesh to match physics world object
  55740. * @param impostor imposter to match
  55741. */
  55742. private _afterSoftStep;
  55743. /**
  55744. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55745. * @param impostor imposter to match
  55746. */
  55747. private _ropeStep;
  55748. /**
  55749. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55750. * @param impostor imposter to match
  55751. */
  55752. private _softbodyOrClothStep;
  55753. private _tmpVector;
  55754. private _tmpMatrix;
  55755. /**
  55756. * Applies an impulse on the imposter
  55757. * @param impostor imposter to apply impulse to
  55758. * @param force amount of force to be applied to the imposter
  55759. * @param contactPoint the location to apply the impulse on the imposter
  55760. */
  55761. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55762. /**
  55763. * Applies a force on the imposter
  55764. * @param impostor imposter to apply force
  55765. * @param force amount of force to be applied to the imposter
  55766. * @param contactPoint the location to apply the force on the imposter
  55767. */
  55768. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55769. /**
  55770. * Creates a physics body using the plugin
  55771. * @param impostor the imposter to create the physics body on
  55772. */
  55773. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55774. /**
  55775. * Removes the physics body from the imposter and disposes of the body's memory
  55776. * @param impostor imposter to remove the physics body from
  55777. */
  55778. removePhysicsBody(impostor: PhysicsImpostor): void;
  55779. /**
  55780. * Generates a joint
  55781. * @param impostorJoint the imposter joint to create the joint with
  55782. */
  55783. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55784. /**
  55785. * Removes a joint
  55786. * @param impostorJoint the imposter joint to remove the joint from
  55787. */
  55788. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55789. private _addMeshVerts;
  55790. /**
  55791. * Initialise the soft body vertices to match its object's (mesh) vertices
  55792. * Softbody vertices (nodes) are in world space and to match this
  55793. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55794. * @param impostor to create the softbody for
  55795. */
  55796. private _softVertexData;
  55797. /**
  55798. * Create an impostor's soft body
  55799. * @param impostor to create the softbody for
  55800. */
  55801. private _createSoftbody;
  55802. /**
  55803. * Create cloth for an impostor
  55804. * @param impostor to create the softbody for
  55805. */
  55806. private _createCloth;
  55807. /**
  55808. * Create rope for an impostor
  55809. * @param impostor to create the softbody for
  55810. */
  55811. private _createRope;
  55812. /**
  55813. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55814. * @param impostor to create the custom physics shape for
  55815. */
  55816. private _createCustom;
  55817. private _addHullVerts;
  55818. private _createShape;
  55819. /**
  55820. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55821. * @param impostor imposter containing the physics body and babylon object
  55822. */
  55823. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55824. /**
  55825. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55826. * @param impostor imposter containing the physics body and babylon object
  55827. * @param newPosition new position
  55828. * @param newRotation new rotation
  55829. */
  55830. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55831. /**
  55832. * If this plugin is supported
  55833. * @returns true if its supported
  55834. */
  55835. isSupported(): boolean;
  55836. /**
  55837. * Sets the linear velocity of the physics body
  55838. * @param impostor imposter to set the velocity on
  55839. * @param velocity velocity to set
  55840. */
  55841. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55842. /**
  55843. * Sets the angular velocity of the physics body
  55844. * @param impostor imposter to set the velocity on
  55845. * @param velocity velocity to set
  55846. */
  55847. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55848. /**
  55849. * gets the linear velocity
  55850. * @param impostor imposter to get linear velocity from
  55851. * @returns linear velocity
  55852. */
  55853. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55854. /**
  55855. * gets the angular velocity
  55856. * @param impostor imposter to get angular velocity from
  55857. * @returns angular velocity
  55858. */
  55859. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55860. /**
  55861. * Sets the mass of physics body
  55862. * @param impostor imposter to set the mass on
  55863. * @param mass mass to set
  55864. */
  55865. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55866. /**
  55867. * Gets the mass of the physics body
  55868. * @param impostor imposter to get the mass from
  55869. * @returns mass
  55870. */
  55871. getBodyMass(impostor: PhysicsImpostor): number;
  55872. /**
  55873. * Gets friction of the impostor
  55874. * @param impostor impostor to get friction from
  55875. * @returns friction value
  55876. */
  55877. getBodyFriction(impostor: PhysicsImpostor): number;
  55878. /**
  55879. * Sets friction of the impostor
  55880. * @param impostor impostor to set friction on
  55881. * @param friction friction value
  55882. */
  55883. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55884. /**
  55885. * Gets restitution of the impostor
  55886. * @param impostor impostor to get restitution from
  55887. * @returns restitution value
  55888. */
  55889. getBodyRestitution(impostor: PhysicsImpostor): number;
  55890. /**
  55891. * Sets resitution of the impostor
  55892. * @param impostor impostor to set resitution on
  55893. * @param restitution resitution value
  55894. */
  55895. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55896. /**
  55897. * Gets pressure inside the impostor
  55898. * @param impostor impostor to get pressure from
  55899. * @returns pressure value
  55900. */
  55901. getBodyPressure(impostor: PhysicsImpostor): number;
  55902. /**
  55903. * Sets pressure inside a soft body impostor
  55904. * Cloth and rope must remain 0 pressure
  55905. * @param impostor impostor to set pressure on
  55906. * @param pressure pressure value
  55907. */
  55908. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55909. /**
  55910. * Gets stiffness of the impostor
  55911. * @param impostor impostor to get stiffness from
  55912. * @returns pressure value
  55913. */
  55914. getBodyStiffness(impostor: PhysicsImpostor): number;
  55915. /**
  55916. * Sets stiffness of the impostor
  55917. * @param impostor impostor to set stiffness on
  55918. * @param stiffness stiffness value from 0 to 1
  55919. */
  55920. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55921. /**
  55922. * Gets velocityIterations of the impostor
  55923. * @param impostor impostor to get velocity iterations from
  55924. * @returns velocityIterations value
  55925. */
  55926. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55927. /**
  55928. * Sets velocityIterations of the impostor
  55929. * @param impostor impostor to set velocity iterations on
  55930. * @param velocityIterations velocityIterations value
  55931. */
  55932. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55933. /**
  55934. * Gets positionIterations of the impostor
  55935. * @param impostor impostor to get position iterations from
  55936. * @returns positionIterations value
  55937. */
  55938. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55939. /**
  55940. * Sets positionIterations of the impostor
  55941. * @param impostor impostor to set position on
  55942. * @param positionIterations positionIterations value
  55943. */
  55944. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55945. /**
  55946. * Append an anchor to a cloth object
  55947. * @param impostor is the cloth impostor to add anchor to
  55948. * @param otherImpostor is the rigid impostor to anchor to
  55949. * @param width ratio across width from 0 to 1
  55950. * @param height ratio up height from 0 to 1
  55951. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55952. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55953. */
  55954. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55955. /**
  55956. * Append an hook to a rope object
  55957. * @param impostor is the rope impostor to add hook to
  55958. * @param otherImpostor is the rigid impostor to hook to
  55959. * @param length ratio along the rope from 0 to 1
  55960. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55961. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55962. */
  55963. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55964. /**
  55965. * Sleeps the physics body and stops it from being active
  55966. * @param impostor impostor to sleep
  55967. */
  55968. sleepBody(impostor: PhysicsImpostor): void;
  55969. /**
  55970. * Activates the physics body
  55971. * @param impostor impostor to activate
  55972. */
  55973. wakeUpBody(impostor: PhysicsImpostor): void;
  55974. /**
  55975. * Updates the distance parameters of the joint
  55976. * @param joint joint to update
  55977. * @param maxDistance maximum distance of the joint
  55978. * @param minDistance minimum distance of the joint
  55979. */
  55980. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55981. /**
  55982. * Sets a motor on the joint
  55983. * @param joint joint to set motor on
  55984. * @param speed speed of the motor
  55985. * @param maxForce maximum force of the motor
  55986. * @param motorIndex index of the motor
  55987. */
  55988. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55989. /**
  55990. * Sets the motors limit
  55991. * @param joint joint to set limit on
  55992. * @param upperLimit upper limit
  55993. * @param lowerLimit lower limit
  55994. */
  55995. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55996. /**
  55997. * Syncs the position and rotation of a mesh with the impostor
  55998. * @param mesh mesh to sync
  55999. * @param impostor impostor to update the mesh with
  56000. */
  56001. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56002. /**
  56003. * Gets the radius of the impostor
  56004. * @param impostor impostor to get radius from
  56005. * @returns the radius
  56006. */
  56007. getRadius(impostor: PhysicsImpostor): number;
  56008. /**
  56009. * Gets the box size of the impostor
  56010. * @param impostor impostor to get box size from
  56011. * @param result the resulting box size
  56012. */
  56013. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56014. /**
  56015. * Disposes of the impostor
  56016. */
  56017. dispose(): void;
  56018. /**
  56019. * Does a raycast in the physics world
  56020. * @param from when should the ray start?
  56021. * @param to when should the ray end?
  56022. * @returns PhysicsRaycastResult
  56023. */
  56024. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56025. }
  56026. }
  56027. declare module BABYLON {
  56028. interface AbstractScene {
  56029. /**
  56030. * The list of reflection probes added to the scene
  56031. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56032. */
  56033. reflectionProbes: Array<ReflectionProbe>;
  56034. /**
  56035. * Removes the given reflection probe from this scene.
  56036. * @param toRemove The reflection probe to remove
  56037. * @returns The index of the removed reflection probe
  56038. */
  56039. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56040. /**
  56041. * Adds the given reflection probe to this scene.
  56042. * @param newReflectionProbe The reflection probe to add
  56043. */
  56044. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56045. }
  56046. /**
  56047. * Class used to generate realtime reflection / refraction cube textures
  56048. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56049. */
  56050. export class ReflectionProbe {
  56051. /** defines the name of the probe */
  56052. name: string;
  56053. private _scene;
  56054. private _renderTargetTexture;
  56055. private _projectionMatrix;
  56056. private _viewMatrix;
  56057. private _target;
  56058. private _add;
  56059. private _attachedMesh;
  56060. private _invertYAxis;
  56061. /** Gets or sets probe position (center of the cube map) */
  56062. position: Vector3;
  56063. /**
  56064. * Creates a new reflection probe
  56065. * @param name defines the name of the probe
  56066. * @param size defines the texture resolution (for each face)
  56067. * @param scene defines the hosting scene
  56068. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56069. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56070. */
  56071. constructor(
  56072. /** defines the name of the probe */
  56073. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56074. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56075. get samples(): number;
  56076. set samples(value: number);
  56077. /** Gets or sets the refresh rate to use (on every frame by default) */
  56078. get refreshRate(): number;
  56079. set refreshRate(value: number);
  56080. /**
  56081. * Gets the hosting scene
  56082. * @returns a Scene
  56083. */
  56084. getScene(): Scene;
  56085. /** Gets the internal CubeTexture used to render to */
  56086. get cubeTexture(): RenderTargetTexture;
  56087. /** Gets the list of meshes to render */
  56088. get renderList(): Nullable<AbstractMesh[]>;
  56089. /**
  56090. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56091. * @param mesh defines the mesh to attach to
  56092. */
  56093. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56094. /**
  56095. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56096. * @param renderingGroupId The rendering group id corresponding to its index
  56097. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56098. */
  56099. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56100. /**
  56101. * Clean all associated resources
  56102. */
  56103. dispose(): void;
  56104. /**
  56105. * Converts the reflection probe information to a readable string for debug purpose.
  56106. * @param fullDetails Supports for multiple levels of logging within scene loading
  56107. * @returns the human readable reflection probe info
  56108. */
  56109. toString(fullDetails?: boolean): string;
  56110. /**
  56111. * Get the class name of the relfection probe.
  56112. * @returns "ReflectionProbe"
  56113. */
  56114. getClassName(): string;
  56115. /**
  56116. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56117. * @returns The JSON representation of the texture
  56118. */
  56119. serialize(): any;
  56120. /**
  56121. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56122. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56123. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56124. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56125. * @returns The parsed reflection probe if successful
  56126. */
  56127. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56128. }
  56129. }
  56130. declare module BABYLON {
  56131. /** @hidden */
  56132. export var _BabylonLoaderRegistered: boolean;
  56133. /**
  56134. * Helps setting up some configuration for the babylon file loader.
  56135. */
  56136. export class BabylonFileLoaderConfiguration {
  56137. /**
  56138. * The loader does not allow injecting custom physix engine into the plugins.
  56139. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56140. * So you could set this variable to your engine import to make it work.
  56141. */
  56142. static LoaderInjectedPhysicsEngine: any;
  56143. }
  56144. }
  56145. declare module BABYLON {
  56146. /**
  56147. * The Physically based simple base material of BJS.
  56148. *
  56149. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56150. * It is used as the base class for both the specGloss and metalRough conventions.
  56151. */
  56152. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56153. /**
  56154. * Number of Simultaneous lights allowed on the material.
  56155. */
  56156. maxSimultaneousLights: number;
  56157. /**
  56158. * If sets to true, disables all the lights affecting the material.
  56159. */
  56160. disableLighting: boolean;
  56161. /**
  56162. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56163. */
  56164. environmentTexture: BaseTexture;
  56165. /**
  56166. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56167. */
  56168. invertNormalMapX: boolean;
  56169. /**
  56170. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56171. */
  56172. invertNormalMapY: boolean;
  56173. /**
  56174. * Normal map used in the model.
  56175. */
  56176. normalTexture: BaseTexture;
  56177. /**
  56178. * Emissivie color used to self-illuminate the model.
  56179. */
  56180. emissiveColor: Color3;
  56181. /**
  56182. * Emissivie texture used to self-illuminate the model.
  56183. */
  56184. emissiveTexture: BaseTexture;
  56185. /**
  56186. * Occlusion Channel Strenght.
  56187. */
  56188. occlusionStrength: number;
  56189. /**
  56190. * Occlusion Texture of the material (adding extra occlusion effects).
  56191. */
  56192. occlusionTexture: BaseTexture;
  56193. /**
  56194. * Defines the alpha limits in alpha test mode.
  56195. */
  56196. alphaCutOff: number;
  56197. /**
  56198. * Gets the current double sided mode.
  56199. */
  56200. get doubleSided(): boolean;
  56201. /**
  56202. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56203. */
  56204. set doubleSided(value: boolean);
  56205. /**
  56206. * Stores the pre-calculated light information of a mesh in a texture.
  56207. */
  56208. lightmapTexture: BaseTexture;
  56209. /**
  56210. * If true, the light map contains occlusion information instead of lighting info.
  56211. */
  56212. useLightmapAsShadowmap: boolean;
  56213. /**
  56214. * Instantiates a new PBRMaterial instance.
  56215. *
  56216. * @param name The material name
  56217. * @param scene The scene the material will be use in.
  56218. */
  56219. constructor(name: string, scene: Scene);
  56220. getClassName(): string;
  56221. }
  56222. }
  56223. declare module BABYLON {
  56224. /**
  56225. * The PBR material of BJS following the metal roughness convention.
  56226. *
  56227. * This fits to the PBR convention in the GLTF definition:
  56228. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56229. */
  56230. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56231. /**
  56232. * The base color has two different interpretations depending on the value of metalness.
  56233. * When the material is a metal, the base color is the specific measured reflectance value
  56234. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56235. * of the material.
  56236. */
  56237. baseColor: Color3;
  56238. /**
  56239. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56240. * well as opacity information in the alpha channel.
  56241. */
  56242. baseTexture: BaseTexture;
  56243. /**
  56244. * Specifies the metallic scalar value of the material.
  56245. * Can also be used to scale the metalness values of the metallic texture.
  56246. */
  56247. metallic: number;
  56248. /**
  56249. * Specifies the roughness scalar value of the material.
  56250. * Can also be used to scale the roughness values of the metallic texture.
  56251. */
  56252. roughness: number;
  56253. /**
  56254. * Texture containing both the metallic value in the B channel and the
  56255. * roughness value in the G channel to keep better precision.
  56256. */
  56257. metallicRoughnessTexture: BaseTexture;
  56258. /**
  56259. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56260. *
  56261. * @param name The material name
  56262. * @param scene The scene the material will be use in.
  56263. */
  56264. constructor(name: string, scene: Scene);
  56265. /**
  56266. * Return the currrent class name of the material.
  56267. */
  56268. getClassName(): string;
  56269. /**
  56270. * Makes a duplicate of the current material.
  56271. * @param name - name to use for the new material.
  56272. */
  56273. clone(name: string): PBRMetallicRoughnessMaterial;
  56274. /**
  56275. * Serialize the material to a parsable JSON object.
  56276. */
  56277. serialize(): any;
  56278. /**
  56279. * Parses a JSON object correponding to the serialize function.
  56280. */
  56281. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56282. }
  56283. }
  56284. declare module BABYLON {
  56285. /**
  56286. * The PBR material of BJS following the specular glossiness convention.
  56287. *
  56288. * This fits to the PBR convention in the GLTF definition:
  56289. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56290. */
  56291. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56292. /**
  56293. * Specifies the diffuse color of the material.
  56294. */
  56295. diffuseColor: Color3;
  56296. /**
  56297. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56298. * channel.
  56299. */
  56300. diffuseTexture: BaseTexture;
  56301. /**
  56302. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56303. */
  56304. specularColor: Color3;
  56305. /**
  56306. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56307. */
  56308. glossiness: number;
  56309. /**
  56310. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56311. */
  56312. specularGlossinessTexture: BaseTexture;
  56313. /**
  56314. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56315. *
  56316. * @param name The material name
  56317. * @param scene The scene the material will be use in.
  56318. */
  56319. constructor(name: string, scene: Scene);
  56320. /**
  56321. * Return the currrent class name of the material.
  56322. */
  56323. getClassName(): string;
  56324. /**
  56325. * Makes a duplicate of the current material.
  56326. * @param name - name to use for the new material.
  56327. */
  56328. clone(name: string): PBRSpecularGlossinessMaterial;
  56329. /**
  56330. * Serialize the material to a parsable JSON object.
  56331. */
  56332. serialize(): any;
  56333. /**
  56334. * Parses a JSON object correponding to the serialize function.
  56335. */
  56336. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56337. }
  56338. }
  56339. declare module BABYLON {
  56340. /**
  56341. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56342. * It can help converting any input color in a desired output one. This can then be used to create effects
  56343. * from sepia, black and white to sixties or futuristic rendering...
  56344. *
  56345. * The only supported format is currently 3dl.
  56346. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56347. */
  56348. export class ColorGradingTexture extends BaseTexture {
  56349. /**
  56350. * The current texture matrix. (will always be identity in color grading texture)
  56351. */
  56352. private _textureMatrix;
  56353. /**
  56354. * The texture URL.
  56355. */
  56356. url: string;
  56357. /**
  56358. * Empty line regex stored for GC.
  56359. */
  56360. private static _noneEmptyLineRegex;
  56361. private _engine;
  56362. /**
  56363. * Instantiates a ColorGradingTexture from the following parameters.
  56364. *
  56365. * @param url The location of the color gradind data (currently only supporting 3dl)
  56366. * @param scene The scene the texture will be used in
  56367. */
  56368. constructor(url: string, scene: Scene);
  56369. /**
  56370. * Returns the texture matrix used in most of the material.
  56371. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56372. */
  56373. getTextureMatrix(): Matrix;
  56374. /**
  56375. * Occurs when the file being loaded is a .3dl LUT file.
  56376. */
  56377. private load3dlTexture;
  56378. /**
  56379. * Starts the loading process of the texture.
  56380. */
  56381. private loadTexture;
  56382. /**
  56383. * Clones the color gradind texture.
  56384. */
  56385. clone(): ColorGradingTexture;
  56386. /**
  56387. * Called during delayed load for textures.
  56388. */
  56389. delayLoad(): void;
  56390. /**
  56391. * Parses a color grading texture serialized by Babylon.
  56392. * @param parsedTexture The texture information being parsedTexture
  56393. * @param scene The scene to load the texture in
  56394. * @param rootUrl The root url of the data assets to load
  56395. * @return A color gradind texture
  56396. */
  56397. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56398. /**
  56399. * Serializes the LUT texture to json format.
  56400. */
  56401. serialize(): any;
  56402. }
  56403. }
  56404. declare module BABYLON {
  56405. /**
  56406. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56407. */
  56408. export class EquiRectangularCubeTexture extends BaseTexture {
  56409. /** The six faces of the cube. */
  56410. private static _FacesMapping;
  56411. private _noMipmap;
  56412. private _onLoad;
  56413. private _onError;
  56414. /** The size of the cubemap. */
  56415. private _size;
  56416. /** The buffer of the image. */
  56417. private _buffer;
  56418. /** The width of the input image. */
  56419. private _width;
  56420. /** The height of the input image. */
  56421. private _height;
  56422. /** The URL to the image. */
  56423. url: string;
  56424. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56425. coordinatesMode: number;
  56426. /**
  56427. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56428. * @param url The location of the image
  56429. * @param scene The scene the texture will be used in
  56430. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56431. * @param noMipmap Forces to not generate the mipmap if true
  56432. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56433. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56434. * @param onLoad — defines a callback called when texture is loaded
  56435. * @param onError — defines a callback called if there is an error
  56436. */
  56437. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56438. /**
  56439. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56440. */
  56441. private loadImage;
  56442. /**
  56443. * Convert the image buffer into a cubemap and create a CubeTexture.
  56444. */
  56445. private loadTexture;
  56446. /**
  56447. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56448. * @param buffer The ArrayBuffer that should be converted.
  56449. * @returns The buffer as Float32Array.
  56450. */
  56451. private getFloat32ArrayFromArrayBuffer;
  56452. /**
  56453. * Get the current class name of the texture useful for serialization or dynamic coding.
  56454. * @returns "EquiRectangularCubeTexture"
  56455. */
  56456. getClassName(): string;
  56457. /**
  56458. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56459. * @returns A clone of the current EquiRectangularCubeTexture.
  56460. */
  56461. clone(): EquiRectangularCubeTexture;
  56462. }
  56463. }
  56464. declare module BABYLON {
  56465. /**
  56466. * Based on jsTGALoader - Javascript loader for TGA file
  56467. * By Vincent Thibault
  56468. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56469. */
  56470. export class TGATools {
  56471. private static _TYPE_INDEXED;
  56472. private static _TYPE_RGB;
  56473. private static _TYPE_GREY;
  56474. private static _TYPE_RLE_INDEXED;
  56475. private static _TYPE_RLE_RGB;
  56476. private static _TYPE_RLE_GREY;
  56477. private static _ORIGIN_MASK;
  56478. private static _ORIGIN_SHIFT;
  56479. private static _ORIGIN_BL;
  56480. private static _ORIGIN_BR;
  56481. private static _ORIGIN_UL;
  56482. private static _ORIGIN_UR;
  56483. /**
  56484. * Gets the header of a TGA file
  56485. * @param data defines the TGA data
  56486. * @returns the header
  56487. */
  56488. static GetTGAHeader(data: Uint8Array): any;
  56489. /**
  56490. * Uploads TGA content to a Babylon Texture
  56491. * @hidden
  56492. */
  56493. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56494. /** @hidden */
  56495. 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;
  56496. /** @hidden */
  56497. 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;
  56498. /** @hidden */
  56499. 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;
  56500. /** @hidden */
  56501. 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;
  56502. /** @hidden */
  56503. 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;
  56504. /** @hidden */
  56505. 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;
  56506. }
  56507. }
  56508. declare module BABYLON {
  56509. /**
  56510. * Implementation of the TGA Texture Loader.
  56511. * @hidden
  56512. */
  56513. export class _TGATextureLoader implements IInternalTextureLoader {
  56514. /**
  56515. * Defines wether the loader supports cascade loading the different faces.
  56516. */
  56517. readonly supportCascades: boolean;
  56518. /**
  56519. * This returns if the loader support the current file information.
  56520. * @param extension defines the file extension of the file being loaded
  56521. * @returns true if the loader can load the specified file
  56522. */
  56523. canLoad(extension: string): boolean;
  56524. /**
  56525. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56526. * @param data contains the texture data
  56527. * @param texture defines the BabylonJS internal texture
  56528. * @param createPolynomials will be true if polynomials have been requested
  56529. * @param onLoad defines the callback to trigger once the texture is ready
  56530. * @param onError defines the callback to trigger in case of error
  56531. */
  56532. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56533. /**
  56534. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56535. * @param data contains the texture data
  56536. * @param texture defines the BabylonJS internal texture
  56537. * @param callback defines the method to call once ready to upload
  56538. */
  56539. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56540. }
  56541. }
  56542. declare module BABYLON {
  56543. /**
  56544. * Info about the .basis files
  56545. */
  56546. class BasisFileInfo {
  56547. /**
  56548. * If the file has alpha
  56549. */
  56550. hasAlpha: boolean;
  56551. /**
  56552. * Info about each image of the basis file
  56553. */
  56554. images: Array<{
  56555. levels: Array<{
  56556. width: number;
  56557. height: number;
  56558. transcodedPixels: ArrayBufferView;
  56559. }>;
  56560. }>;
  56561. }
  56562. /**
  56563. * Result of transcoding a basis file
  56564. */
  56565. class TranscodeResult {
  56566. /**
  56567. * Info about the .basis file
  56568. */
  56569. fileInfo: BasisFileInfo;
  56570. /**
  56571. * Format to use when loading the file
  56572. */
  56573. format: number;
  56574. }
  56575. /**
  56576. * Configuration options for the Basis transcoder
  56577. */
  56578. export class BasisTranscodeConfiguration {
  56579. /**
  56580. * Supported compression formats used to determine the supported output format of the transcoder
  56581. */
  56582. supportedCompressionFormats?: {
  56583. /**
  56584. * etc1 compression format
  56585. */
  56586. etc1?: boolean;
  56587. /**
  56588. * s3tc compression format
  56589. */
  56590. s3tc?: boolean;
  56591. /**
  56592. * pvrtc compression format
  56593. */
  56594. pvrtc?: boolean;
  56595. /**
  56596. * etc2 compression format
  56597. */
  56598. etc2?: boolean;
  56599. };
  56600. /**
  56601. * If mipmap levels should be loaded for transcoded images (Default: true)
  56602. */
  56603. loadMipmapLevels?: boolean;
  56604. /**
  56605. * Index of a single image to load (Default: all images)
  56606. */
  56607. loadSingleImage?: number;
  56608. }
  56609. /**
  56610. * Used to load .Basis files
  56611. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56612. */
  56613. export class BasisTools {
  56614. private static _IgnoreSupportedFormats;
  56615. /**
  56616. * URL to use when loading the basis transcoder
  56617. */
  56618. static JSModuleURL: string;
  56619. /**
  56620. * URL to use when loading the wasm module for the transcoder
  56621. */
  56622. static WasmModuleURL: string;
  56623. /**
  56624. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56625. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56626. * @returns internal format corresponding to the Basis format
  56627. */
  56628. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56629. private static _WorkerPromise;
  56630. private static _Worker;
  56631. private static _actionId;
  56632. private static _CreateWorkerAsync;
  56633. /**
  56634. * Transcodes a loaded image file to compressed pixel data
  56635. * @param data image data to transcode
  56636. * @param config configuration options for the transcoding
  56637. * @returns a promise resulting in the transcoded image
  56638. */
  56639. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56640. /**
  56641. * Loads a texture from the transcode result
  56642. * @param texture texture load to
  56643. * @param transcodeResult the result of transcoding the basis file to load from
  56644. */
  56645. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56646. }
  56647. }
  56648. declare module BABYLON {
  56649. /**
  56650. * Loader for .basis file format
  56651. */
  56652. export class _BasisTextureLoader implements IInternalTextureLoader {
  56653. /**
  56654. * Defines whether the loader supports cascade loading the different faces.
  56655. */
  56656. readonly supportCascades: boolean;
  56657. /**
  56658. * This returns if the loader support the current file information.
  56659. * @param extension defines the file extension of the file being loaded
  56660. * @returns true if the loader can load the specified file
  56661. */
  56662. canLoad(extension: string): boolean;
  56663. /**
  56664. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56665. * @param data contains the texture data
  56666. * @param texture defines the BabylonJS internal texture
  56667. * @param createPolynomials will be true if polynomials have been requested
  56668. * @param onLoad defines the callback to trigger once the texture is ready
  56669. * @param onError defines the callback to trigger in case of error
  56670. */
  56671. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56672. /**
  56673. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56674. * @param data contains the texture data
  56675. * @param texture defines the BabylonJS internal texture
  56676. * @param callback defines the method to call once ready to upload
  56677. */
  56678. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56679. }
  56680. }
  56681. declare module BABYLON {
  56682. /**
  56683. * 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.
  56684. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56685. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56686. */
  56687. export class CustomProceduralTexture extends ProceduralTexture {
  56688. private _animate;
  56689. private _time;
  56690. private _config;
  56691. private _texturePath;
  56692. /**
  56693. * Instantiates a new Custom Procedural Texture.
  56694. * 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.
  56695. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56696. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56697. * @param name Define the name of the texture
  56698. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56699. * @param size Define the size of the texture to create
  56700. * @param scene Define the scene the texture belongs to
  56701. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56702. * @param generateMipMaps Define if the texture should creates mip maps or not
  56703. */
  56704. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56705. private _loadJson;
  56706. /**
  56707. * Is the texture ready to be used ? (rendered at least once)
  56708. * @returns true if ready, otherwise, false.
  56709. */
  56710. isReady(): boolean;
  56711. /**
  56712. * Render the texture to its associated render target.
  56713. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56714. */
  56715. render(useCameraPostProcess?: boolean): void;
  56716. /**
  56717. * Update the list of dependant textures samplers in the shader.
  56718. */
  56719. updateTextures(): void;
  56720. /**
  56721. * Update the uniform values of the procedural texture in the shader.
  56722. */
  56723. updateShaderUniforms(): void;
  56724. /**
  56725. * Define if the texture animates or not.
  56726. */
  56727. get animate(): boolean;
  56728. set animate(value: boolean);
  56729. }
  56730. }
  56731. declare module BABYLON {
  56732. /** @hidden */
  56733. export var noisePixelShader: {
  56734. name: string;
  56735. shader: string;
  56736. };
  56737. }
  56738. declare module BABYLON {
  56739. /**
  56740. * Class used to generate noise procedural textures
  56741. */
  56742. export class NoiseProceduralTexture extends ProceduralTexture {
  56743. private _time;
  56744. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56745. brightness: number;
  56746. /** Defines the number of octaves to process */
  56747. octaves: number;
  56748. /** Defines the level of persistence (0.8 by default) */
  56749. persistence: number;
  56750. /** Gets or sets animation speed factor (default is 1) */
  56751. animationSpeedFactor: number;
  56752. /**
  56753. * Creates a new NoiseProceduralTexture
  56754. * @param name defines the name fo the texture
  56755. * @param size defines the size of the texture (default is 256)
  56756. * @param scene defines the hosting scene
  56757. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56758. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56759. */
  56760. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56761. private _updateShaderUniforms;
  56762. protected _getDefines(): string;
  56763. /** Generate the current state of the procedural texture */
  56764. render(useCameraPostProcess?: boolean): void;
  56765. /**
  56766. * Serializes this noise procedural texture
  56767. * @returns a serialized noise procedural texture object
  56768. */
  56769. serialize(): any;
  56770. /**
  56771. * Clone the texture.
  56772. * @returns the cloned texture
  56773. */
  56774. clone(): NoiseProceduralTexture;
  56775. /**
  56776. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56777. * @param parsedTexture defines parsed texture data
  56778. * @param scene defines the current scene
  56779. * @param rootUrl defines the root URL containing noise procedural texture information
  56780. * @returns a parsed NoiseProceduralTexture
  56781. */
  56782. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56783. }
  56784. }
  56785. declare module BABYLON {
  56786. /**
  56787. * Raw cube texture where the raw buffers are passed in
  56788. */
  56789. export class RawCubeTexture extends CubeTexture {
  56790. /**
  56791. * Creates a cube texture where the raw buffers are passed in.
  56792. * @param scene defines the scene the texture is attached to
  56793. * @param data defines the array of data to use to create each face
  56794. * @param size defines the size of the textures
  56795. * @param format defines the format of the data
  56796. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56797. * @param generateMipMaps defines if the engine should generate the mip levels
  56798. * @param invertY defines if data must be stored with Y axis inverted
  56799. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56800. * @param compression defines the compression used (null by default)
  56801. */
  56802. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56803. /**
  56804. * Updates the raw cube texture.
  56805. * @param data defines the data to store
  56806. * @param format defines the data format
  56807. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56808. * @param invertY defines if data must be stored with Y axis inverted
  56809. * @param compression defines the compression used (null by default)
  56810. * @param level defines which level of the texture to update
  56811. */
  56812. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56813. /**
  56814. * Updates a raw cube texture with RGBD encoded data.
  56815. * @param data defines the array of data [mipmap][face] to use to create each face
  56816. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56817. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56818. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56819. * @returns a promsie that resolves when the operation is complete
  56820. */
  56821. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56822. /**
  56823. * Clones the raw cube texture.
  56824. * @return a new cube texture
  56825. */
  56826. clone(): CubeTexture;
  56827. /** @hidden */
  56828. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56829. }
  56830. }
  56831. declare module BABYLON {
  56832. /**
  56833. * Class used to store 3D textures containing user data
  56834. */
  56835. export class RawTexture3D extends Texture {
  56836. /** Gets or sets the texture format to use */
  56837. format: number;
  56838. private _engine;
  56839. /**
  56840. * Create a new RawTexture3D
  56841. * @param data defines the data of the texture
  56842. * @param width defines the width of the texture
  56843. * @param height defines the height of the texture
  56844. * @param depth defines the depth of the texture
  56845. * @param format defines the texture format to use
  56846. * @param scene defines the hosting scene
  56847. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56848. * @param invertY defines if texture must be stored with Y axis inverted
  56849. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56850. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56851. */
  56852. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56853. /** Gets or sets the texture format to use */
  56854. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56855. /**
  56856. * Update the texture with new data
  56857. * @param data defines the data to store in the texture
  56858. */
  56859. update(data: ArrayBufferView): void;
  56860. }
  56861. }
  56862. declare module BABYLON {
  56863. /**
  56864. * Class used to store 2D array textures containing user data
  56865. */
  56866. export class RawTexture2DArray extends Texture {
  56867. /** Gets or sets the texture format to use */
  56868. format: number;
  56869. private _engine;
  56870. /**
  56871. * Create a new RawTexture2DArray
  56872. * @param data defines the data of the texture
  56873. * @param width defines the width of the texture
  56874. * @param height defines the height of the texture
  56875. * @param depth defines the number of layers of the texture
  56876. * @param format defines the texture format to use
  56877. * @param scene defines the hosting scene
  56878. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56879. * @param invertY defines if texture must be stored with Y axis inverted
  56880. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56881. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56882. */
  56883. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56884. /** Gets or sets the texture format to use */
  56885. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56886. /**
  56887. * Update the texture with new data
  56888. * @param data defines the data to store in the texture
  56889. */
  56890. update(data: ArrayBufferView): void;
  56891. }
  56892. }
  56893. declare module BABYLON {
  56894. /**
  56895. * Creates a refraction texture used by refraction channel of the standard material.
  56896. * It is like a mirror but to see through a material.
  56897. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56898. */
  56899. export class RefractionTexture extends RenderTargetTexture {
  56900. /**
  56901. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56902. * 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.
  56903. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56904. */
  56905. refractionPlane: Plane;
  56906. /**
  56907. * Define how deep under the surface we should see.
  56908. */
  56909. depth: number;
  56910. /**
  56911. * Creates a refraction texture used by refraction channel of the standard material.
  56912. * It is like a mirror but to see through a material.
  56913. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56914. * @param name Define the texture name
  56915. * @param size Define the size of the underlying texture
  56916. * @param scene Define the scene the refraction belongs to
  56917. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56918. */
  56919. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56920. /**
  56921. * Clone the refraction texture.
  56922. * @returns the cloned texture
  56923. */
  56924. clone(): RefractionTexture;
  56925. /**
  56926. * Serialize the texture to a JSON representation you could use in Parse later on
  56927. * @returns the serialized JSON representation
  56928. */
  56929. serialize(): any;
  56930. }
  56931. }
  56932. declare module BABYLON {
  56933. /**
  56934. * Defines the options related to the creation of an HtmlElementTexture
  56935. */
  56936. export interface IHtmlElementTextureOptions {
  56937. /**
  56938. * Defines wether mip maps should be created or not.
  56939. */
  56940. generateMipMaps?: boolean;
  56941. /**
  56942. * Defines the sampling mode of the texture.
  56943. */
  56944. samplingMode?: number;
  56945. /**
  56946. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56947. */
  56948. engine: Nullable<ThinEngine>;
  56949. /**
  56950. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56951. */
  56952. scene: Nullable<Scene>;
  56953. }
  56954. /**
  56955. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56956. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56957. * is automatically managed.
  56958. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56959. * in your application.
  56960. *
  56961. * As the update is not automatic, you need to call them manually.
  56962. */
  56963. export class HtmlElementTexture extends BaseTexture {
  56964. /**
  56965. * The texture URL.
  56966. */
  56967. element: HTMLVideoElement | HTMLCanvasElement;
  56968. private static readonly DefaultOptions;
  56969. private _textureMatrix;
  56970. private _engine;
  56971. private _isVideo;
  56972. private _generateMipMaps;
  56973. private _samplingMode;
  56974. /**
  56975. * Instantiates a HtmlElementTexture from the following parameters.
  56976. *
  56977. * @param name Defines the name of the texture
  56978. * @param element Defines the video or canvas the texture is filled with
  56979. * @param options Defines the other none mandatory texture creation options
  56980. */
  56981. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56982. private _createInternalTexture;
  56983. /**
  56984. * Returns the texture matrix used in most of the material.
  56985. */
  56986. getTextureMatrix(): Matrix;
  56987. /**
  56988. * Updates the content of the texture.
  56989. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56990. */
  56991. update(invertY?: Nullable<boolean>): void;
  56992. }
  56993. }
  56994. declare module BABYLON {
  56995. /**
  56996. * Defines the basic options interface of a TexturePacker Frame
  56997. */
  56998. export interface ITexturePackerFrame {
  56999. /**
  57000. * The frame ID
  57001. */
  57002. id: number;
  57003. /**
  57004. * The frames Scale
  57005. */
  57006. scale: Vector2;
  57007. /**
  57008. * The Frames offset
  57009. */
  57010. offset: Vector2;
  57011. }
  57012. /**
  57013. * This is a support class for frame Data on texture packer sets.
  57014. */
  57015. export class TexturePackerFrame implements ITexturePackerFrame {
  57016. /**
  57017. * The frame ID
  57018. */
  57019. id: number;
  57020. /**
  57021. * The frames Scale
  57022. */
  57023. scale: Vector2;
  57024. /**
  57025. * The Frames offset
  57026. */
  57027. offset: Vector2;
  57028. /**
  57029. * Initializes a texture package frame.
  57030. * @param id The numerical frame identifier
  57031. * @param scale Scalar Vector2 for UV frame
  57032. * @param offset Vector2 for the frame position in UV units.
  57033. * @returns TexturePackerFrame
  57034. */
  57035. constructor(id: number, scale: Vector2, offset: Vector2);
  57036. }
  57037. }
  57038. declare module BABYLON {
  57039. /**
  57040. * Defines the basic options interface of a TexturePacker
  57041. */
  57042. export interface ITexturePackerOptions {
  57043. /**
  57044. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57045. */
  57046. map?: string[];
  57047. /**
  57048. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57049. */
  57050. uvsIn?: string;
  57051. /**
  57052. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57053. */
  57054. uvsOut?: string;
  57055. /**
  57056. * number representing the layout style. Defaults to LAYOUT_STRIP
  57057. */
  57058. layout?: number;
  57059. /**
  57060. * number of columns if using custom column count layout(2). This defaults to 4.
  57061. */
  57062. colnum?: number;
  57063. /**
  57064. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57065. */
  57066. updateInputMeshes?: boolean;
  57067. /**
  57068. * boolean flag to dispose all the source textures. Defaults to true.
  57069. */
  57070. disposeSources?: boolean;
  57071. /**
  57072. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57073. */
  57074. fillBlanks?: boolean;
  57075. /**
  57076. * string value representing the context fill style color. Defaults to 'black'.
  57077. */
  57078. customFillColor?: string;
  57079. /**
  57080. * Width and Height Value of each Frame in the TexturePacker Sets
  57081. */
  57082. frameSize?: number;
  57083. /**
  57084. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57085. */
  57086. paddingRatio?: number;
  57087. /**
  57088. * Number that declares the fill method for the padding gutter.
  57089. */
  57090. paddingMode?: number;
  57091. /**
  57092. * If in SUBUV_COLOR padding mode what color to use.
  57093. */
  57094. paddingColor?: Color3 | Color4;
  57095. }
  57096. /**
  57097. * Defines the basic interface of a TexturePacker JSON File
  57098. */
  57099. export interface ITexturePackerJSON {
  57100. /**
  57101. * The frame ID
  57102. */
  57103. name: string;
  57104. /**
  57105. * The base64 channel data
  57106. */
  57107. sets: any;
  57108. /**
  57109. * The options of the Packer
  57110. */
  57111. options: ITexturePackerOptions;
  57112. /**
  57113. * The frame data of the Packer
  57114. */
  57115. frames: Array<number>;
  57116. }
  57117. /**
  57118. * This is a support class that generates a series of packed texture sets.
  57119. * @see https://doc.babylonjs.com/babylon101/materials
  57120. */
  57121. export class TexturePacker {
  57122. /** Packer Layout Constant 0 */
  57123. static readonly LAYOUT_STRIP: number;
  57124. /** Packer Layout Constant 1 */
  57125. static readonly LAYOUT_POWER2: number;
  57126. /** Packer Layout Constant 2 */
  57127. static readonly LAYOUT_COLNUM: number;
  57128. /** Packer Layout Constant 0 */
  57129. static readonly SUBUV_WRAP: number;
  57130. /** Packer Layout Constant 1 */
  57131. static readonly SUBUV_EXTEND: number;
  57132. /** Packer Layout Constant 2 */
  57133. static readonly SUBUV_COLOR: number;
  57134. /** The Name of the Texture Package */
  57135. name: string;
  57136. /** The scene scope of the TexturePacker */
  57137. scene: Scene;
  57138. /** The Meshes to target */
  57139. meshes: AbstractMesh[];
  57140. /** Arguments passed with the Constructor */
  57141. options: ITexturePackerOptions;
  57142. /** The promise that is started upon initialization */
  57143. promise: Nullable<Promise<TexturePacker | string>>;
  57144. /** The Container object for the channel sets that are generated */
  57145. sets: object;
  57146. /** The Container array for the frames that are generated */
  57147. frames: TexturePackerFrame[];
  57148. /** The expected number of textures the system is parsing. */
  57149. private _expecting;
  57150. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57151. private _paddingValue;
  57152. /**
  57153. * Initializes a texture package series from an array of meshes or a single mesh.
  57154. * @param name The name of the package
  57155. * @param meshes The target meshes to compose the package from
  57156. * @param options The arguments that texture packer should follow while building.
  57157. * @param scene The scene which the textures are scoped to.
  57158. * @returns TexturePacker
  57159. */
  57160. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57161. /**
  57162. * Starts the package process
  57163. * @param resolve The promises resolution function
  57164. * @returns TexturePacker
  57165. */
  57166. private _createFrames;
  57167. /**
  57168. * Calculates the Size of the Channel Sets
  57169. * @returns Vector2
  57170. */
  57171. private _calculateSize;
  57172. /**
  57173. * Calculates the UV data for the frames.
  57174. * @param baseSize the base frameSize
  57175. * @param padding the base frame padding
  57176. * @param dtSize size of the Dynamic Texture for that channel
  57177. * @param dtUnits is 1/dtSize
  57178. * @param update flag to update the input meshes
  57179. */
  57180. private _calculateMeshUVFrames;
  57181. /**
  57182. * Calculates the frames Offset.
  57183. * @param index of the frame
  57184. * @returns Vector2
  57185. */
  57186. private _getFrameOffset;
  57187. /**
  57188. * Updates a Mesh to the frame data
  57189. * @param mesh that is the target
  57190. * @param frameID or the frame index
  57191. */
  57192. private _updateMeshUV;
  57193. /**
  57194. * Updates a Meshes materials to use the texture packer channels
  57195. * @param m is the mesh to target
  57196. * @param force all channels on the packer to be set.
  57197. */
  57198. private _updateTextureReferences;
  57199. /**
  57200. * Public method to set a Mesh to a frame
  57201. * @param m that is the target
  57202. * @param frameID or the frame index
  57203. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57204. */
  57205. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57206. /**
  57207. * Starts the async promise to compile the texture packer.
  57208. * @returns Promise<void>
  57209. */
  57210. processAsync(): Promise<void>;
  57211. /**
  57212. * Disposes all textures associated with this packer
  57213. */
  57214. dispose(): void;
  57215. /**
  57216. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57217. * @param imageType is the image type to use.
  57218. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57219. */
  57220. download(imageType?: string, quality?: number): void;
  57221. /**
  57222. * Public method to load a texturePacker JSON file.
  57223. * @param data of the JSON file in string format.
  57224. */
  57225. updateFromJSON(data: string): void;
  57226. }
  57227. }
  57228. declare module BABYLON {
  57229. /**
  57230. * Enum used to define the target of a block
  57231. */
  57232. export enum NodeMaterialBlockTargets {
  57233. /** Vertex shader */
  57234. Vertex = 1,
  57235. /** Fragment shader */
  57236. Fragment = 2,
  57237. /** Neutral */
  57238. Neutral = 4,
  57239. /** Vertex and Fragment */
  57240. VertexAndFragment = 3
  57241. }
  57242. }
  57243. declare module BABYLON {
  57244. /**
  57245. * Defines the kind of connection point for node based material
  57246. */
  57247. export enum NodeMaterialBlockConnectionPointTypes {
  57248. /** Float */
  57249. Float = 1,
  57250. /** Int */
  57251. Int = 2,
  57252. /** Vector2 */
  57253. Vector2 = 4,
  57254. /** Vector3 */
  57255. Vector3 = 8,
  57256. /** Vector4 */
  57257. Vector4 = 16,
  57258. /** Color3 */
  57259. Color3 = 32,
  57260. /** Color4 */
  57261. Color4 = 64,
  57262. /** Matrix */
  57263. Matrix = 128,
  57264. /** Detect type based on connection */
  57265. AutoDetect = 1024,
  57266. /** Output type that will be defined by input type */
  57267. BasedOnInput = 2048
  57268. }
  57269. }
  57270. declare module BABYLON {
  57271. /**
  57272. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57273. */
  57274. export enum NodeMaterialBlockConnectionPointMode {
  57275. /** Value is an uniform */
  57276. Uniform = 0,
  57277. /** Value is a mesh attribute */
  57278. Attribute = 1,
  57279. /** Value is a varying between vertex and fragment shaders */
  57280. Varying = 2,
  57281. /** Mode is undefined */
  57282. Undefined = 3
  57283. }
  57284. }
  57285. declare module BABYLON {
  57286. /**
  57287. * Enum used to define system values e.g. values automatically provided by the system
  57288. */
  57289. export enum NodeMaterialSystemValues {
  57290. /** World */
  57291. World = 1,
  57292. /** View */
  57293. View = 2,
  57294. /** Projection */
  57295. Projection = 3,
  57296. /** ViewProjection */
  57297. ViewProjection = 4,
  57298. /** WorldView */
  57299. WorldView = 5,
  57300. /** WorldViewProjection */
  57301. WorldViewProjection = 6,
  57302. /** CameraPosition */
  57303. CameraPosition = 7,
  57304. /** Fog Color */
  57305. FogColor = 8,
  57306. /** Delta time */
  57307. DeltaTime = 9
  57308. }
  57309. }
  57310. declare module BABYLON {
  57311. /**
  57312. * Root class for all node material optimizers
  57313. */
  57314. export class NodeMaterialOptimizer {
  57315. /**
  57316. * Function used to optimize a NodeMaterial graph
  57317. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57318. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57319. */
  57320. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57321. }
  57322. }
  57323. declare module BABYLON {
  57324. /**
  57325. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57326. */
  57327. export class TransformBlock extends NodeMaterialBlock {
  57328. /**
  57329. * Defines the value to use to complement W value to transform it to a Vector4
  57330. */
  57331. complementW: number;
  57332. /**
  57333. * Defines the value to use to complement z value to transform it to a Vector4
  57334. */
  57335. complementZ: number;
  57336. /**
  57337. * Creates a new TransformBlock
  57338. * @param name defines the block name
  57339. */
  57340. constructor(name: string);
  57341. /**
  57342. * Gets the current class name
  57343. * @returns the class name
  57344. */
  57345. getClassName(): string;
  57346. /**
  57347. * Gets the vector input
  57348. */
  57349. get vector(): NodeMaterialConnectionPoint;
  57350. /**
  57351. * Gets the output component
  57352. */
  57353. get output(): NodeMaterialConnectionPoint;
  57354. /**
  57355. * Gets the xyz output component
  57356. */
  57357. get xyz(): NodeMaterialConnectionPoint;
  57358. /**
  57359. * Gets the matrix transform input
  57360. */
  57361. get transform(): NodeMaterialConnectionPoint;
  57362. protected _buildBlock(state: NodeMaterialBuildState): this;
  57363. serialize(): any;
  57364. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57365. protected _dumpPropertiesCode(): string;
  57366. }
  57367. }
  57368. declare module BABYLON {
  57369. /**
  57370. * Block used to output the vertex position
  57371. */
  57372. export class VertexOutputBlock extends NodeMaterialBlock {
  57373. /**
  57374. * Creates a new VertexOutputBlock
  57375. * @param name defines the block name
  57376. */
  57377. constructor(name: string);
  57378. /**
  57379. * Gets the current class name
  57380. * @returns the class name
  57381. */
  57382. getClassName(): string;
  57383. /**
  57384. * Gets the vector input component
  57385. */
  57386. get vector(): NodeMaterialConnectionPoint;
  57387. protected _buildBlock(state: NodeMaterialBuildState): this;
  57388. }
  57389. }
  57390. declare module BABYLON {
  57391. /**
  57392. * Block used to output the final color
  57393. */
  57394. export class FragmentOutputBlock extends NodeMaterialBlock {
  57395. /**
  57396. * Create a new FragmentOutputBlock
  57397. * @param name defines the block name
  57398. */
  57399. constructor(name: string);
  57400. /**
  57401. * Gets the current class name
  57402. * @returns the class name
  57403. */
  57404. getClassName(): string;
  57405. /**
  57406. * Gets the rgba input component
  57407. */
  57408. get rgba(): NodeMaterialConnectionPoint;
  57409. /**
  57410. * Gets the rgb input component
  57411. */
  57412. get rgb(): NodeMaterialConnectionPoint;
  57413. /**
  57414. * Gets the a input component
  57415. */
  57416. get a(): NodeMaterialConnectionPoint;
  57417. protected _buildBlock(state: NodeMaterialBuildState): this;
  57418. }
  57419. }
  57420. declare module BABYLON {
  57421. /**
  57422. * Block used to read a reflection texture from a sampler
  57423. */
  57424. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57425. private _define3DName;
  57426. private _defineCubicName;
  57427. private _defineExplicitName;
  57428. private _defineProjectionName;
  57429. private _defineLocalCubicName;
  57430. private _defineSphericalName;
  57431. private _definePlanarName;
  57432. private _defineEquirectangularName;
  57433. private _defineMirroredEquirectangularFixedName;
  57434. private _defineEquirectangularFixedName;
  57435. private _defineSkyboxName;
  57436. private _cubeSamplerName;
  57437. private _2DSamplerName;
  57438. private _positionUVWName;
  57439. private _directionWName;
  57440. private _reflectionCoordsName;
  57441. private _reflection2DCoordsName;
  57442. private _reflectionColorName;
  57443. private _reflectionMatrixName;
  57444. /**
  57445. * Gets or sets the texture associated with the node
  57446. */
  57447. texture: Nullable<BaseTexture>;
  57448. /**
  57449. * Create a new TextureBlock
  57450. * @param name defines the block name
  57451. */
  57452. constructor(name: string);
  57453. /**
  57454. * Gets the current class name
  57455. * @returns the class name
  57456. */
  57457. getClassName(): string;
  57458. /**
  57459. * Gets the world position input component
  57460. */
  57461. get position(): NodeMaterialConnectionPoint;
  57462. /**
  57463. * Gets the world position input component
  57464. */
  57465. get worldPosition(): NodeMaterialConnectionPoint;
  57466. /**
  57467. * Gets the world normal input component
  57468. */
  57469. get worldNormal(): NodeMaterialConnectionPoint;
  57470. /**
  57471. * Gets the world input component
  57472. */
  57473. get world(): NodeMaterialConnectionPoint;
  57474. /**
  57475. * Gets the camera (or eye) position component
  57476. */
  57477. get cameraPosition(): NodeMaterialConnectionPoint;
  57478. /**
  57479. * Gets the view input component
  57480. */
  57481. get view(): NodeMaterialConnectionPoint;
  57482. /**
  57483. * Gets the rgb output component
  57484. */
  57485. get rgb(): NodeMaterialConnectionPoint;
  57486. /**
  57487. * Gets the r output component
  57488. */
  57489. get r(): NodeMaterialConnectionPoint;
  57490. /**
  57491. * Gets the g output component
  57492. */
  57493. get g(): NodeMaterialConnectionPoint;
  57494. /**
  57495. * Gets the b output component
  57496. */
  57497. get b(): NodeMaterialConnectionPoint;
  57498. autoConfigure(material: NodeMaterial): void;
  57499. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57500. isReady(): boolean;
  57501. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57502. private _injectVertexCode;
  57503. private _writeOutput;
  57504. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57505. protected _dumpPropertiesCode(): string;
  57506. serialize(): any;
  57507. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57508. }
  57509. }
  57510. declare module BABYLON {
  57511. /**
  57512. * Interface used to configure the node material editor
  57513. */
  57514. export interface INodeMaterialEditorOptions {
  57515. /** Define the URl to load node editor script */
  57516. editorURL?: string;
  57517. }
  57518. /** @hidden */
  57519. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57520. NORMAL: boolean;
  57521. TANGENT: boolean;
  57522. UV1: boolean;
  57523. /** BONES */
  57524. NUM_BONE_INFLUENCERS: number;
  57525. BonesPerMesh: number;
  57526. BONETEXTURE: boolean;
  57527. /** MORPH TARGETS */
  57528. MORPHTARGETS: boolean;
  57529. MORPHTARGETS_NORMAL: boolean;
  57530. MORPHTARGETS_TANGENT: boolean;
  57531. MORPHTARGETS_UV: boolean;
  57532. NUM_MORPH_INFLUENCERS: number;
  57533. /** IMAGE PROCESSING */
  57534. IMAGEPROCESSING: boolean;
  57535. VIGNETTE: boolean;
  57536. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57537. VIGNETTEBLENDMODEOPAQUE: boolean;
  57538. TONEMAPPING: boolean;
  57539. TONEMAPPING_ACES: boolean;
  57540. CONTRAST: boolean;
  57541. EXPOSURE: boolean;
  57542. COLORCURVES: boolean;
  57543. COLORGRADING: boolean;
  57544. COLORGRADING3D: boolean;
  57545. SAMPLER3DGREENDEPTH: boolean;
  57546. SAMPLER3DBGRMAP: boolean;
  57547. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57548. /** MISC. */
  57549. BUMPDIRECTUV: number;
  57550. constructor();
  57551. setValue(name: string, value: boolean): void;
  57552. }
  57553. /**
  57554. * Class used to configure NodeMaterial
  57555. */
  57556. export interface INodeMaterialOptions {
  57557. /**
  57558. * Defines if blocks should emit comments
  57559. */
  57560. emitComments: boolean;
  57561. }
  57562. /**
  57563. * Class used to create a node based material built by assembling shader blocks
  57564. */
  57565. export class NodeMaterial extends PushMaterial {
  57566. private static _BuildIdGenerator;
  57567. private _options;
  57568. private _vertexCompilationState;
  57569. private _fragmentCompilationState;
  57570. private _sharedData;
  57571. private _buildId;
  57572. private _buildWasSuccessful;
  57573. private _cachedWorldViewMatrix;
  57574. private _cachedWorldViewProjectionMatrix;
  57575. private _optimizers;
  57576. private _animationFrame;
  57577. /** Define the Url to load node editor script */
  57578. static EditorURL: string;
  57579. /** Define the Url to load snippets */
  57580. static SnippetUrl: string;
  57581. private BJSNODEMATERIALEDITOR;
  57582. /** Get the inspector from bundle or global */
  57583. private _getGlobalNodeMaterialEditor;
  57584. /**
  57585. * Snippet ID if the material was created from the snippet server
  57586. */
  57587. snippetId: string;
  57588. /**
  57589. * Gets or sets data used by visual editor
  57590. * @see https://nme.babylonjs.com
  57591. */
  57592. editorData: any;
  57593. /**
  57594. * 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)
  57595. */
  57596. ignoreAlpha: boolean;
  57597. /**
  57598. * Defines the maximum number of lights that can be used in the material
  57599. */
  57600. maxSimultaneousLights: number;
  57601. /**
  57602. * Observable raised when the material is built
  57603. */
  57604. onBuildObservable: Observable<NodeMaterial>;
  57605. /**
  57606. * Gets or sets the root nodes of the material vertex shader
  57607. */
  57608. _vertexOutputNodes: NodeMaterialBlock[];
  57609. /**
  57610. * Gets or sets the root nodes of the material fragment (pixel) shader
  57611. */
  57612. _fragmentOutputNodes: NodeMaterialBlock[];
  57613. /** Gets or sets options to control the node material overall behavior */
  57614. get options(): INodeMaterialOptions;
  57615. set options(options: INodeMaterialOptions);
  57616. /**
  57617. * Default configuration related to image processing available in the standard Material.
  57618. */
  57619. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57620. /**
  57621. * Gets the image processing configuration used either in this material.
  57622. */
  57623. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57624. /**
  57625. * Sets the Default image processing configuration used either in the this material.
  57626. *
  57627. * If sets to null, the scene one is in use.
  57628. */
  57629. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57630. /**
  57631. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57632. */
  57633. attachedBlocks: NodeMaterialBlock[];
  57634. /**
  57635. * Create a new node based material
  57636. * @param name defines the material name
  57637. * @param scene defines the hosting scene
  57638. * @param options defines creation option
  57639. */
  57640. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57641. /**
  57642. * Gets the current class name of the material e.g. "NodeMaterial"
  57643. * @returns the class name
  57644. */
  57645. getClassName(): string;
  57646. /**
  57647. * Keep track of the image processing observer to allow dispose and replace.
  57648. */
  57649. private _imageProcessingObserver;
  57650. /**
  57651. * Attaches a new image processing configuration to the Standard Material.
  57652. * @param configuration
  57653. */
  57654. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57655. /**
  57656. * Get a block by its name
  57657. * @param name defines the name of the block to retrieve
  57658. * @returns the required block or null if not found
  57659. */
  57660. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57661. /**
  57662. * Get a block by its name
  57663. * @param predicate defines the predicate used to find the good candidate
  57664. * @returns the required block or null if not found
  57665. */
  57666. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57667. /**
  57668. * Get an input block by its name
  57669. * @param predicate defines the predicate used to find the good candidate
  57670. * @returns the required input block or null if not found
  57671. */
  57672. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57673. /**
  57674. * Gets the list of input blocks attached to this material
  57675. * @returns an array of InputBlocks
  57676. */
  57677. getInputBlocks(): InputBlock[];
  57678. /**
  57679. * Adds a new optimizer to the list of optimizers
  57680. * @param optimizer defines the optimizers to add
  57681. * @returns the current material
  57682. */
  57683. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57684. /**
  57685. * Remove an optimizer from the list of optimizers
  57686. * @param optimizer defines the optimizers to remove
  57687. * @returns the current material
  57688. */
  57689. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57690. /**
  57691. * Add a new block to the list of output nodes
  57692. * @param node defines the node to add
  57693. * @returns the current material
  57694. */
  57695. addOutputNode(node: NodeMaterialBlock): this;
  57696. /**
  57697. * Remove a block from the list of root nodes
  57698. * @param node defines the node to remove
  57699. * @returns the current material
  57700. */
  57701. removeOutputNode(node: NodeMaterialBlock): this;
  57702. private _addVertexOutputNode;
  57703. private _removeVertexOutputNode;
  57704. private _addFragmentOutputNode;
  57705. private _removeFragmentOutputNode;
  57706. /**
  57707. * Specifies if the material will require alpha blending
  57708. * @returns a boolean specifying if alpha blending is needed
  57709. */
  57710. needAlphaBlending(): boolean;
  57711. /**
  57712. * Specifies if this material should be rendered in alpha test mode
  57713. * @returns a boolean specifying if an alpha test is needed.
  57714. */
  57715. needAlphaTesting(): boolean;
  57716. private _initializeBlock;
  57717. private _resetDualBlocks;
  57718. /**
  57719. * Remove a block from the current node material
  57720. * @param block defines the block to remove
  57721. */
  57722. removeBlock(block: NodeMaterialBlock): void;
  57723. /**
  57724. * Build the material and generates the inner effect
  57725. * @param verbose defines if the build should log activity
  57726. */
  57727. build(verbose?: boolean): void;
  57728. /**
  57729. * Runs an otpimization phase to try to improve the shader code
  57730. */
  57731. optimize(): void;
  57732. private _prepareDefinesForAttributes;
  57733. /**
  57734. * Get if the submesh is ready to be used and all its information available.
  57735. * Child classes can use it to update shaders
  57736. * @param mesh defines the mesh to check
  57737. * @param subMesh defines which submesh to check
  57738. * @param useInstances specifies that instances should be used
  57739. * @returns a boolean indicating that the submesh is ready or not
  57740. */
  57741. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57742. /**
  57743. * Get a string representing the shaders built by the current node graph
  57744. */
  57745. get compiledShaders(): string;
  57746. /**
  57747. * Binds the world matrix to the material
  57748. * @param world defines the world transformation matrix
  57749. */
  57750. bindOnlyWorldMatrix(world: Matrix): void;
  57751. /**
  57752. * Binds the submesh to this material by preparing the effect and shader to draw
  57753. * @param world defines the world transformation matrix
  57754. * @param mesh defines the mesh containing the submesh
  57755. * @param subMesh defines the submesh to bind the material to
  57756. */
  57757. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57758. /**
  57759. * Gets the active textures from the material
  57760. * @returns an array of textures
  57761. */
  57762. getActiveTextures(): BaseTexture[];
  57763. /**
  57764. * Gets the list of texture blocks
  57765. * @returns an array of texture blocks
  57766. */
  57767. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57768. /**
  57769. * Specifies if the material uses a texture
  57770. * @param texture defines the texture to check against the material
  57771. * @returns a boolean specifying if the material uses the texture
  57772. */
  57773. hasTexture(texture: BaseTexture): boolean;
  57774. /**
  57775. * Disposes the material
  57776. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57777. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57778. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57779. */
  57780. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57781. /** Creates the node editor window. */
  57782. private _createNodeEditor;
  57783. /**
  57784. * Launch the node material editor
  57785. * @param config Define the configuration of the editor
  57786. * @return a promise fulfilled when the node editor is visible
  57787. */
  57788. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57789. /**
  57790. * Clear the current material
  57791. */
  57792. clear(): void;
  57793. /**
  57794. * Clear the current material and set it to a default state
  57795. */
  57796. setToDefault(): void;
  57797. /**
  57798. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57799. * @param url defines the url to load from
  57800. * @returns a promise that will fullfil when the material is fully loaded
  57801. */
  57802. loadAsync(url: string): Promise<void>;
  57803. private _gatherBlocks;
  57804. /**
  57805. * Generate a string containing the code declaration required to create an equivalent of this material
  57806. * @returns a string
  57807. */
  57808. generateCode(): string;
  57809. /**
  57810. * Serializes this material in a JSON representation
  57811. * @returns the serialized material object
  57812. */
  57813. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57814. private _restoreConnections;
  57815. /**
  57816. * Clear the current graph and load a new one from a serialization object
  57817. * @param source defines the JSON representation of the material
  57818. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57819. */
  57820. loadFromSerialization(source: any, rootUrl?: string): void;
  57821. /**
  57822. * Makes a duplicate of the current material.
  57823. * @param name - name to use for the new material.
  57824. */
  57825. clone(name: string): NodeMaterial;
  57826. /**
  57827. * Creates a node material from parsed material data
  57828. * @param source defines the JSON representation of the material
  57829. * @param scene defines the hosting scene
  57830. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57831. * @returns a new node material
  57832. */
  57833. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57834. /**
  57835. * Creates a node material from a snippet saved in a remote file
  57836. * @param name defines the name of the material to create
  57837. * @param url defines the url to load from
  57838. * @param scene defines the hosting scene
  57839. * @returns a promise that will resolve to the new node material
  57840. */
  57841. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57842. /**
  57843. * Creates a node material from a snippet saved by the node material editor
  57844. * @param snippetId defines the snippet to load
  57845. * @param scene defines the hosting scene
  57846. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57847. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  57848. * @returns a promise that will resolve to the new node material
  57849. */
  57850. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  57851. /**
  57852. * Creates a new node material set to default basic configuration
  57853. * @param name defines the name of the material
  57854. * @param scene defines the hosting scene
  57855. * @returns a new NodeMaterial
  57856. */
  57857. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57858. }
  57859. }
  57860. declare module BABYLON {
  57861. /**
  57862. * Block used to read a texture from a sampler
  57863. */
  57864. export class TextureBlock extends NodeMaterialBlock {
  57865. private _defineName;
  57866. private _linearDefineName;
  57867. private _tempTextureRead;
  57868. private _samplerName;
  57869. private _transformedUVName;
  57870. private _textureTransformName;
  57871. private _textureInfoName;
  57872. private _mainUVName;
  57873. private _mainUVDefineName;
  57874. /**
  57875. * Gets or sets the texture associated with the node
  57876. */
  57877. texture: Nullable<Texture>;
  57878. /**
  57879. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57880. */
  57881. convertToGammaSpace: boolean;
  57882. /**
  57883. * Create a new TextureBlock
  57884. * @param name defines the block name
  57885. */
  57886. constructor(name: string);
  57887. /**
  57888. * Gets the current class name
  57889. * @returns the class name
  57890. */
  57891. getClassName(): string;
  57892. /**
  57893. * Gets the uv input component
  57894. */
  57895. get uv(): NodeMaterialConnectionPoint;
  57896. /**
  57897. * Gets the rgba output component
  57898. */
  57899. get rgba(): NodeMaterialConnectionPoint;
  57900. /**
  57901. * Gets the rgb output component
  57902. */
  57903. get rgb(): NodeMaterialConnectionPoint;
  57904. /**
  57905. * Gets the r output component
  57906. */
  57907. get r(): NodeMaterialConnectionPoint;
  57908. /**
  57909. * Gets the g output component
  57910. */
  57911. get g(): NodeMaterialConnectionPoint;
  57912. /**
  57913. * Gets the b output component
  57914. */
  57915. get b(): NodeMaterialConnectionPoint;
  57916. /**
  57917. * Gets the a output component
  57918. */
  57919. get a(): NodeMaterialConnectionPoint;
  57920. get target(): NodeMaterialBlockTargets;
  57921. autoConfigure(material: NodeMaterial): void;
  57922. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57923. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57924. isReady(): boolean;
  57925. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57926. private get _isMixed();
  57927. private _injectVertexCode;
  57928. private _writeTextureRead;
  57929. private _writeOutput;
  57930. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57931. protected _dumpPropertiesCode(): string;
  57932. serialize(): any;
  57933. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57934. }
  57935. }
  57936. declare module BABYLON {
  57937. /**
  57938. * Class used to store shared data between 2 NodeMaterialBuildState
  57939. */
  57940. export class NodeMaterialBuildStateSharedData {
  57941. /**
  57942. * Gets the list of emitted varyings
  57943. */
  57944. temps: string[];
  57945. /**
  57946. * Gets the list of emitted varyings
  57947. */
  57948. varyings: string[];
  57949. /**
  57950. * Gets the varying declaration string
  57951. */
  57952. varyingDeclaration: string;
  57953. /**
  57954. * Input blocks
  57955. */
  57956. inputBlocks: InputBlock[];
  57957. /**
  57958. * Input blocks
  57959. */
  57960. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57961. /**
  57962. * Bindable blocks (Blocks that need to set data to the effect)
  57963. */
  57964. bindableBlocks: NodeMaterialBlock[];
  57965. /**
  57966. * List of blocks that can provide a compilation fallback
  57967. */
  57968. blocksWithFallbacks: NodeMaterialBlock[];
  57969. /**
  57970. * List of blocks that can provide a define update
  57971. */
  57972. blocksWithDefines: NodeMaterialBlock[];
  57973. /**
  57974. * List of blocks that can provide a repeatable content
  57975. */
  57976. repeatableContentBlocks: NodeMaterialBlock[];
  57977. /**
  57978. * List of blocks that can provide a dynamic list of uniforms
  57979. */
  57980. dynamicUniformBlocks: NodeMaterialBlock[];
  57981. /**
  57982. * List of blocks that can block the isReady function for the material
  57983. */
  57984. blockingBlocks: NodeMaterialBlock[];
  57985. /**
  57986. * Gets the list of animated inputs
  57987. */
  57988. animatedInputs: InputBlock[];
  57989. /**
  57990. * Build Id used to avoid multiple recompilations
  57991. */
  57992. buildId: number;
  57993. /** List of emitted variables */
  57994. variableNames: {
  57995. [key: string]: number;
  57996. };
  57997. /** List of emitted defines */
  57998. defineNames: {
  57999. [key: string]: number;
  58000. };
  58001. /** Should emit comments? */
  58002. emitComments: boolean;
  58003. /** Emit build activity */
  58004. verbose: boolean;
  58005. /** Gets or sets the hosting scene */
  58006. scene: Scene;
  58007. /**
  58008. * Gets the compilation hints emitted at compilation time
  58009. */
  58010. hints: {
  58011. needWorldViewMatrix: boolean;
  58012. needWorldViewProjectionMatrix: boolean;
  58013. needAlphaBlending: boolean;
  58014. needAlphaTesting: boolean;
  58015. };
  58016. /**
  58017. * List of compilation checks
  58018. */
  58019. checks: {
  58020. emitVertex: boolean;
  58021. emitFragment: boolean;
  58022. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58023. };
  58024. /** Creates a new shared data */
  58025. constructor();
  58026. /**
  58027. * Emits console errors and exceptions if there is a failing check
  58028. */
  58029. emitErrors(): void;
  58030. }
  58031. }
  58032. declare module BABYLON {
  58033. /**
  58034. * Class used to store node based material build state
  58035. */
  58036. export class NodeMaterialBuildState {
  58037. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58038. supportUniformBuffers: boolean;
  58039. /**
  58040. * Gets the list of emitted attributes
  58041. */
  58042. attributes: string[];
  58043. /**
  58044. * Gets the list of emitted uniforms
  58045. */
  58046. uniforms: string[];
  58047. /**
  58048. * Gets the list of emitted constants
  58049. */
  58050. constants: string[];
  58051. /**
  58052. * Gets the list of emitted samplers
  58053. */
  58054. samplers: string[];
  58055. /**
  58056. * Gets the list of emitted functions
  58057. */
  58058. functions: {
  58059. [key: string]: string;
  58060. };
  58061. /**
  58062. * Gets the list of emitted extensions
  58063. */
  58064. extensions: {
  58065. [key: string]: string;
  58066. };
  58067. /**
  58068. * Gets the target of the compilation state
  58069. */
  58070. target: NodeMaterialBlockTargets;
  58071. /**
  58072. * Gets the list of emitted counters
  58073. */
  58074. counters: {
  58075. [key: string]: number;
  58076. };
  58077. /**
  58078. * Shared data between multiple NodeMaterialBuildState instances
  58079. */
  58080. sharedData: NodeMaterialBuildStateSharedData;
  58081. /** @hidden */
  58082. _vertexState: NodeMaterialBuildState;
  58083. /** @hidden */
  58084. _attributeDeclaration: string;
  58085. /** @hidden */
  58086. _uniformDeclaration: string;
  58087. /** @hidden */
  58088. _constantDeclaration: string;
  58089. /** @hidden */
  58090. _samplerDeclaration: string;
  58091. /** @hidden */
  58092. _varyingTransfer: string;
  58093. private _repeatableContentAnchorIndex;
  58094. /** @hidden */
  58095. _builtCompilationString: string;
  58096. /**
  58097. * Gets the emitted compilation strings
  58098. */
  58099. compilationString: string;
  58100. /**
  58101. * Finalize the compilation strings
  58102. * @param state defines the current compilation state
  58103. */
  58104. finalize(state: NodeMaterialBuildState): void;
  58105. /** @hidden */
  58106. get _repeatableContentAnchor(): string;
  58107. /** @hidden */
  58108. _getFreeVariableName(prefix: string): string;
  58109. /** @hidden */
  58110. _getFreeDefineName(prefix: string): string;
  58111. /** @hidden */
  58112. _excludeVariableName(name: string): void;
  58113. /** @hidden */
  58114. _emit2DSampler(name: string): void;
  58115. /** @hidden */
  58116. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58117. /** @hidden */
  58118. _emitExtension(name: string, extension: string): void;
  58119. /** @hidden */
  58120. _emitFunction(name: string, code: string, comments: string): void;
  58121. /** @hidden */
  58122. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58123. replaceStrings?: {
  58124. search: RegExp;
  58125. replace: string;
  58126. }[];
  58127. repeatKey?: string;
  58128. }): string;
  58129. /** @hidden */
  58130. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58131. repeatKey?: string;
  58132. removeAttributes?: boolean;
  58133. removeUniforms?: boolean;
  58134. removeVaryings?: boolean;
  58135. removeIfDef?: boolean;
  58136. replaceStrings?: {
  58137. search: RegExp;
  58138. replace: string;
  58139. }[];
  58140. }, storeKey?: string): void;
  58141. /** @hidden */
  58142. _registerTempVariable(name: string): boolean;
  58143. /** @hidden */
  58144. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58145. /** @hidden */
  58146. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58147. /** @hidden */
  58148. _emitFloat(value: number): string;
  58149. }
  58150. }
  58151. declare module BABYLON {
  58152. /**
  58153. * Defines a block that can be used inside a node based material
  58154. */
  58155. export class NodeMaterialBlock {
  58156. private _buildId;
  58157. private _buildTarget;
  58158. private _target;
  58159. private _isFinalMerger;
  58160. private _isInput;
  58161. protected _isUnique: boolean;
  58162. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58163. inputsAreExclusive: boolean;
  58164. /** @hidden */
  58165. _codeVariableName: string;
  58166. /** @hidden */
  58167. _inputs: NodeMaterialConnectionPoint[];
  58168. /** @hidden */
  58169. _outputs: NodeMaterialConnectionPoint[];
  58170. /** @hidden */
  58171. _preparationId: number;
  58172. /**
  58173. * Gets or sets the name of the block
  58174. */
  58175. name: string;
  58176. /**
  58177. * Gets or sets the unique id of the node
  58178. */
  58179. uniqueId: number;
  58180. /**
  58181. * Gets or sets the comments associated with this block
  58182. */
  58183. comments: string;
  58184. /**
  58185. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58186. */
  58187. get isUnique(): boolean;
  58188. /**
  58189. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58190. */
  58191. get isFinalMerger(): boolean;
  58192. /**
  58193. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58194. */
  58195. get isInput(): boolean;
  58196. /**
  58197. * Gets or sets the build Id
  58198. */
  58199. get buildId(): number;
  58200. set buildId(value: number);
  58201. /**
  58202. * Gets or sets the target of the block
  58203. */
  58204. get target(): NodeMaterialBlockTargets;
  58205. set target(value: NodeMaterialBlockTargets);
  58206. /**
  58207. * Gets the list of input points
  58208. */
  58209. get inputs(): NodeMaterialConnectionPoint[];
  58210. /** Gets the list of output points */
  58211. get outputs(): NodeMaterialConnectionPoint[];
  58212. /**
  58213. * Find an input by its name
  58214. * @param name defines the name of the input to look for
  58215. * @returns the input or null if not found
  58216. */
  58217. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58218. /**
  58219. * Find an output by its name
  58220. * @param name defines the name of the outputto look for
  58221. * @returns the output or null if not found
  58222. */
  58223. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58224. /**
  58225. * Creates a new NodeMaterialBlock
  58226. * @param name defines the block name
  58227. * @param target defines the target of that block (Vertex by default)
  58228. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58229. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58230. */
  58231. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58232. /**
  58233. * Initialize the block and prepare the context for build
  58234. * @param state defines the state that will be used for the build
  58235. */
  58236. initialize(state: NodeMaterialBuildState): void;
  58237. /**
  58238. * Bind data to effect. Will only be called for blocks with isBindable === true
  58239. * @param effect defines the effect to bind data to
  58240. * @param nodeMaterial defines the hosting NodeMaterial
  58241. * @param mesh defines the mesh that will be rendered
  58242. */
  58243. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58244. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58245. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58246. protected _writeFloat(value: number): string;
  58247. /**
  58248. * Gets the current class name e.g. "NodeMaterialBlock"
  58249. * @returns the class name
  58250. */
  58251. getClassName(): string;
  58252. /**
  58253. * Register a new input. Must be called inside a block constructor
  58254. * @param name defines the connection point name
  58255. * @param type defines the connection point type
  58256. * @param isOptional defines a boolean indicating that this input can be omitted
  58257. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58258. * @returns the current block
  58259. */
  58260. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58261. /**
  58262. * Register a new output. Must be called inside a block constructor
  58263. * @param name defines the connection point name
  58264. * @param type defines the connection point type
  58265. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58266. * @returns the current block
  58267. */
  58268. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58269. /**
  58270. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58271. * @param forOutput defines an optional connection point to check compatibility with
  58272. * @returns the first available input or null
  58273. */
  58274. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58275. /**
  58276. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58277. * @param forBlock defines an optional block to check compatibility with
  58278. * @returns the first available input or null
  58279. */
  58280. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58281. /**
  58282. * Gets the sibling of the given output
  58283. * @param current defines the current output
  58284. * @returns the next output in the list or null
  58285. */
  58286. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58287. /**
  58288. * Connect current block with another block
  58289. * @param other defines the block to connect with
  58290. * @param options define the various options to help pick the right connections
  58291. * @returns the current block
  58292. */
  58293. connectTo(other: NodeMaterialBlock, options?: {
  58294. input?: string;
  58295. output?: string;
  58296. outputSwizzle?: string;
  58297. }): this | undefined;
  58298. protected _buildBlock(state: NodeMaterialBuildState): void;
  58299. /**
  58300. * Add uniforms, samplers and uniform buffers at compilation time
  58301. * @param state defines the state to update
  58302. * @param nodeMaterial defines the node material requesting the update
  58303. * @param defines defines the material defines to update
  58304. * @param uniformBuffers defines the list of uniform buffer names
  58305. */
  58306. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58307. /**
  58308. * Add potential fallbacks if shader compilation fails
  58309. * @param mesh defines the mesh to be rendered
  58310. * @param fallbacks defines the current prioritized list of fallbacks
  58311. */
  58312. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58313. /**
  58314. * Initialize defines for shader compilation
  58315. * @param mesh defines the mesh to be rendered
  58316. * @param nodeMaterial defines the node material requesting the update
  58317. * @param defines defines the material defines to update
  58318. * @param useInstances specifies that instances should be used
  58319. */
  58320. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58321. /**
  58322. * Update defines for shader compilation
  58323. * @param mesh defines the mesh to be rendered
  58324. * @param nodeMaterial defines the node material requesting the update
  58325. * @param defines defines the material defines to update
  58326. * @param useInstances specifies that instances should be used
  58327. */
  58328. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58329. /**
  58330. * Lets the block try to connect some inputs automatically
  58331. * @param material defines the hosting NodeMaterial
  58332. */
  58333. autoConfigure(material: NodeMaterial): void;
  58334. /**
  58335. * Function called when a block is declared as repeatable content generator
  58336. * @param vertexShaderState defines the current compilation state for the vertex shader
  58337. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58338. * @param mesh defines the mesh to be rendered
  58339. * @param defines defines the material defines to update
  58340. */
  58341. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58342. /**
  58343. * Checks if the block is ready
  58344. * @param mesh defines the mesh to be rendered
  58345. * @param nodeMaterial defines the node material requesting the update
  58346. * @param defines defines the material defines to update
  58347. * @param useInstances specifies that instances should be used
  58348. * @returns true if the block is ready
  58349. */
  58350. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58351. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58352. private _processBuild;
  58353. /**
  58354. * Compile the current node and generate the shader code
  58355. * @param state defines the current compilation state (uniforms, samplers, current string)
  58356. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58357. * @returns true if already built
  58358. */
  58359. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58360. protected _inputRename(name: string): string;
  58361. protected _outputRename(name: string): string;
  58362. protected _dumpPropertiesCode(): string;
  58363. /** @hidden */
  58364. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58365. /** @hidden */
  58366. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58367. /**
  58368. * Clone the current block to a new identical block
  58369. * @param scene defines the hosting scene
  58370. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58371. * @returns a copy of the current block
  58372. */
  58373. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58374. /**
  58375. * Serializes this block in a JSON representation
  58376. * @returns the serialized block object
  58377. */
  58378. serialize(): any;
  58379. /** @hidden */
  58380. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58381. /**
  58382. * Release resources
  58383. */
  58384. dispose(): void;
  58385. }
  58386. }
  58387. declare module BABYLON {
  58388. /**
  58389. * Enum defining the type of animations supported by InputBlock
  58390. */
  58391. export enum AnimatedInputBlockTypes {
  58392. /** No animation */
  58393. None = 0,
  58394. /** Time based animation. Will only work for floats */
  58395. Time = 1
  58396. }
  58397. }
  58398. declare module BABYLON {
  58399. /**
  58400. * Block used to expose an input value
  58401. */
  58402. export class InputBlock extends NodeMaterialBlock {
  58403. private _mode;
  58404. private _associatedVariableName;
  58405. private _storedValue;
  58406. private _valueCallback;
  58407. private _type;
  58408. private _animationType;
  58409. /** Gets or set a value used to limit the range of float values */
  58410. min: number;
  58411. /** Gets or set a value used to limit the range of float values */
  58412. max: number;
  58413. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58414. isBoolean: boolean;
  58415. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58416. matrixMode: number;
  58417. /** @hidden */
  58418. _systemValue: Nullable<NodeMaterialSystemValues>;
  58419. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58420. visibleInInspector: boolean;
  58421. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58422. isConstant: boolean;
  58423. /** Gets or sets the group to use to display this block in the Inspector */
  58424. groupInInspector: string;
  58425. /** Gets an observable raised when the value is changed */
  58426. onValueChangedObservable: Observable<InputBlock>;
  58427. /**
  58428. * Gets or sets the connection point type (default is float)
  58429. */
  58430. get type(): NodeMaterialBlockConnectionPointTypes;
  58431. /**
  58432. * Creates a new InputBlock
  58433. * @param name defines the block name
  58434. * @param target defines the target of that block (Vertex by default)
  58435. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58436. */
  58437. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58438. /**
  58439. * Gets the output component
  58440. */
  58441. get output(): NodeMaterialConnectionPoint;
  58442. /**
  58443. * Set the source of this connection point to a vertex attribute
  58444. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58445. * @returns the current connection point
  58446. */
  58447. setAsAttribute(attributeName?: string): InputBlock;
  58448. /**
  58449. * Set the source of this connection point to a system value
  58450. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58451. * @returns the current connection point
  58452. */
  58453. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58454. /**
  58455. * Gets or sets the value of that point.
  58456. * Please note that this value will be ignored if valueCallback is defined
  58457. */
  58458. get value(): any;
  58459. set value(value: any);
  58460. /**
  58461. * Gets or sets a callback used to get the value of that point.
  58462. * Please note that setting this value will force the connection point to ignore the value property
  58463. */
  58464. get valueCallback(): () => any;
  58465. set valueCallback(value: () => any);
  58466. /**
  58467. * Gets or sets the associated variable name in the shader
  58468. */
  58469. get associatedVariableName(): string;
  58470. set associatedVariableName(value: string);
  58471. /** Gets or sets the type of animation applied to the input */
  58472. get animationType(): AnimatedInputBlockTypes;
  58473. set animationType(value: AnimatedInputBlockTypes);
  58474. /**
  58475. * Gets a boolean indicating that this connection point not defined yet
  58476. */
  58477. get isUndefined(): boolean;
  58478. /**
  58479. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58480. * In this case the connection point name must be the name of the uniform to use.
  58481. * Can only be set on inputs
  58482. */
  58483. get isUniform(): boolean;
  58484. set isUniform(value: boolean);
  58485. /**
  58486. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58487. * In this case the connection point name must be the name of the attribute to use
  58488. * Can only be set on inputs
  58489. */
  58490. get isAttribute(): boolean;
  58491. set isAttribute(value: boolean);
  58492. /**
  58493. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58494. * Can only be set on exit points
  58495. */
  58496. get isVarying(): boolean;
  58497. set isVarying(value: boolean);
  58498. /**
  58499. * Gets a boolean indicating that the current connection point is a system value
  58500. */
  58501. get isSystemValue(): boolean;
  58502. /**
  58503. * Gets or sets the current well known value or null if not defined as a system value
  58504. */
  58505. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58506. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58507. /**
  58508. * Gets the current class name
  58509. * @returns the class name
  58510. */
  58511. getClassName(): string;
  58512. /**
  58513. * Animate the input if animationType !== None
  58514. * @param scene defines the rendering scene
  58515. */
  58516. animate(scene: Scene): void;
  58517. private _emitDefine;
  58518. initialize(state: NodeMaterialBuildState): void;
  58519. /**
  58520. * Set the input block to its default value (based on its type)
  58521. */
  58522. setDefaultValue(): void;
  58523. private _emitConstant;
  58524. private _emit;
  58525. /** @hidden */
  58526. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58527. /** @hidden */
  58528. _transmit(effect: Effect, scene: Scene): void;
  58529. protected _buildBlock(state: NodeMaterialBuildState): void;
  58530. protected _dumpPropertiesCode(): string;
  58531. dispose(): void;
  58532. serialize(): any;
  58533. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58534. }
  58535. }
  58536. declare module BABYLON {
  58537. /**
  58538. * Enum used to define the compatibility state between two connection points
  58539. */
  58540. export enum NodeMaterialConnectionPointCompatibilityStates {
  58541. /** Points are compatibles */
  58542. Compatible = 0,
  58543. /** Points are incompatible because of their types */
  58544. TypeIncompatible = 1,
  58545. /** Points are incompatible because of their targets (vertex vs fragment) */
  58546. TargetIncompatible = 2
  58547. }
  58548. /**
  58549. * Defines the direction of a connection point
  58550. */
  58551. export enum NodeMaterialConnectionPointDirection {
  58552. /** Input */
  58553. Input = 0,
  58554. /** Output */
  58555. Output = 1
  58556. }
  58557. /**
  58558. * Defines a connection point for a block
  58559. */
  58560. export class NodeMaterialConnectionPoint {
  58561. /** @hidden */
  58562. _ownerBlock: NodeMaterialBlock;
  58563. /** @hidden */
  58564. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58565. private _endpoints;
  58566. private _associatedVariableName;
  58567. private _direction;
  58568. /** @hidden */
  58569. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58570. /** @hidden */
  58571. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58572. private _type;
  58573. /** @hidden */
  58574. _enforceAssociatedVariableName: boolean;
  58575. /** Gets the direction of the point */
  58576. get direction(): NodeMaterialConnectionPointDirection;
  58577. /**
  58578. * Gets or sets the additional types supported by this connection point
  58579. */
  58580. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58581. /**
  58582. * Gets or sets the additional types excluded by this connection point
  58583. */
  58584. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58585. /**
  58586. * Observable triggered when this point is connected
  58587. */
  58588. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58589. /**
  58590. * Gets or sets the associated variable name in the shader
  58591. */
  58592. get associatedVariableName(): string;
  58593. set associatedVariableName(value: string);
  58594. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58595. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58596. /**
  58597. * Gets or sets the connection point type (default is float)
  58598. */
  58599. get type(): NodeMaterialBlockConnectionPointTypes;
  58600. set type(value: NodeMaterialBlockConnectionPointTypes);
  58601. /**
  58602. * Gets or sets the connection point name
  58603. */
  58604. name: string;
  58605. /**
  58606. * Gets or sets a boolean indicating that this connection point can be omitted
  58607. */
  58608. isOptional: boolean;
  58609. /**
  58610. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58611. */
  58612. define: string;
  58613. /** @hidden */
  58614. _prioritizeVertex: boolean;
  58615. private _target;
  58616. /** Gets or sets the target of that connection point */
  58617. get target(): NodeMaterialBlockTargets;
  58618. set target(value: NodeMaterialBlockTargets);
  58619. /**
  58620. * Gets a boolean indicating that the current point is connected
  58621. */
  58622. get isConnected(): boolean;
  58623. /**
  58624. * Gets a boolean indicating that the current point is connected to an input block
  58625. */
  58626. get isConnectedToInputBlock(): boolean;
  58627. /**
  58628. * Gets a the connected input block (if any)
  58629. */
  58630. get connectInputBlock(): Nullable<InputBlock>;
  58631. /** Get the other side of the connection (if any) */
  58632. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58633. /** Get the block that owns this connection point */
  58634. get ownerBlock(): NodeMaterialBlock;
  58635. /** Get the block connected on the other side of this connection (if any) */
  58636. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58637. /** Get the block connected on the endpoints of this connection (if any) */
  58638. get connectedBlocks(): Array<NodeMaterialBlock>;
  58639. /** Gets the list of connected endpoints */
  58640. get endpoints(): NodeMaterialConnectionPoint[];
  58641. /** Gets a boolean indicating if that output point is connected to at least one input */
  58642. get hasEndpoints(): boolean;
  58643. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58644. get isConnectedInVertexShader(): boolean;
  58645. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58646. get isConnectedInFragmentShader(): boolean;
  58647. /**
  58648. * Creates a new connection point
  58649. * @param name defines the connection point name
  58650. * @param ownerBlock defines the block hosting this connection point
  58651. * @param direction defines the direction of the connection point
  58652. */
  58653. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58654. /**
  58655. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58656. * @returns the class name
  58657. */
  58658. getClassName(): string;
  58659. /**
  58660. * Gets a boolean indicating if the current point can be connected to another point
  58661. * @param connectionPoint defines the other connection point
  58662. * @returns a boolean
  58663. */
  58664. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58665. /**
  58666. * Gets a number indicating if the current point can be connected to another point
  58667. * @param connectionPoint defines the other connection point
  58668. * @returns a number defining the compatibility state
  58669. */
  58670. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58671. /**
  58672. * Connect this point to another connection point
  58673. * @param connectionPoint defines the other connection point
  58674. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58675. * @returns the current connection point
  58676. */
  58677. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58678. /**
  58679. * Disconnect this point from one of his endpoint
  58680. * @param endpoint defines the other connection point
  58681. * @returns the current connection point
  58682. */
  58683. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58684. /**
  58685. * Serializes this point in a JSON representation
  58686. * @returns the serialized point object
  58687. */
  58688. serialize(): any;
  58689. /**
  58690. * Release resources
  58691. */
  58692. dispose(): void;
  58693. }
  58694. }
  58695. declare module BABYLON {
  58696. /**
  58697. * Block used to add support for vertex skinning (bones)
  58698. */
  58699. export class BonesBlock extends NodeMaterialBlock {
  58700. /**
  58701. * Creates a new BonesBlock
  58702. * @param name defines the block name
  58703. */
  58704. constructor(name: string);
  58705. /**
  58706. * Initialize the block and prepare the context for build
  58707. * @param state defines the state that will be used for the build
  58708. */
  58709. initialize(state: NodeMaterialBuildState): void;
  58710. /**
  58711. * Gets the current class name
  58712. * @returns the class name
  58713. */
  58714. getClassName(): string;
  58715. /**
  58716. * Gets the matrix indices input component
  58717. */
  58718. get matricesIndices(): NodeMaterialConnectionPoint;
  58719. /**
  58720. * Gets the matrix weights input component
  58721. */
  58722. get matricesWeights(): NodeMaterialConnectionPoint;
  58723. /**
  58724. * Gets the extra matrix indices input component
  58725. */
  58726. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58727. /**
  58728. * Gets the extra matrix weights input component
  58729. */
  58730. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58731. /**
  58732. * Gets the world input component
  58733. */
  58734. get world(): NodeMaterialConnectionPoint;
  58735. /**
  58736. * Gets the output component
  58737. */
  58738. get output(): NodeMaterialConnectionPoint;
  58739. autoConfigure(material: NodeMaterial): void;
  58740. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58741. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58742. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58743. protected _buildBlock(state: NodeMaterialBuildState): this;
  58744. }
  58745. }
  58746. declare module BABYLON {
  58747. /**
  58748. * Block used to add support for instances
  58749. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58750. */
  58751. export class InstancesBlock extends NodeMaterialBlock {
  58752. /**
  58753. * Creates a new InstancesBlock
  58754. * @param name defines the block name
  58755. */
  58756. constructor(name: string);
  58757. /**
  58758. * Gets the current class name
  58759. * @returns the class name
  58760. */
  58761. getClassName(): string;
  58762. /**
  58763. * Gets the first world row input component
  58764. */
  58765. get world0(): NodeMaterialConnectionPoint;
  58766. /**
  58767. * Gets the second world row input component
  58768. */
  58769. get world1(): NodeMaterialConnectionPoint;
  58770. /**
  58771. * Gets the third world row input component
  58772. */
  58773. get world2(): NodeMaterialConnectionPoint;
  58774. /**
  58775. * Gets the forth world row input component
  58776. */
  58777. get world3(): NodeMaterialConnectionPoint;
  58778. /**
  58779. * Gets the world input component
  58780. */
  58781. get world(): NodeMaterialConnectionPoint;
  58782. /**
  58783. * Gets the output component
  58784. */
  58785. get output(): NodeMaterialConnectionPoint;
  58786. /**
  58787. * Gets the isntanceID component
  58788. */
  58789. get instanceID(): NodeMaterialConnectionPoint;
  58790. autoConfigure(material: NodeMaterial): void;
  58791. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58792. protected _buildBlock(state: NodeMaterialBuildState): this;
  58793. }
  58794. }
  58795. declare module BABYLON {
  58796. /**
  58797. * Block used to add morph targets support to vertex shader
  58798. */
  58799. export class MorphTargetsBlock extends NodeMaterialBlock {
  58800. private _repeatableContentAnchor;
  58801. /**
  58802. * Create a new MorphTargetsBlock
  58803. * @param name defines the block name
  58804. */
  58805. constructor(name: string);
  58806. /**
  58807. * Gets the current class name
  58808. * @returns the class name
  58809. */
  58810. getClassName(): string;
  58811. /**
  58812. * Gets the position input component
  58813. */
  58814. get position(): NodeMaterialConnectionPoint;
  58815. /**
  58816. * Gets the normal input component
  58817. */
  58818. get normal(): NodeMaterialConnectionPoint;
  58819. /**
  58820. * Gets the tangent input component
  58821. */
  58822. get tangent(): NodeMaterialConnectionPoint;
  58823. /**
  58824. * Gets the tangent input component
  58825. */
  58826. get uv(): NodeMaterialConnectionPoint;
  58827. /**
  58828. * Gets the position output component
  58829. */
  58830. get positionOutput(): NodeMaterialConnectionPoint;
  58831. /**
  58832. * Gets the normal output component
  58833. */
  58834. get normalOutput(): NodeMaterialConnectionPoint;
  58835. /**
  58836. * Gets the tangent output component
  58837. */
  58838. get tangentOutput(): NodeMaterialConnectionPoint;
  58839. /**
  58840. * Gets the tangent output component
  58841. */
  58842. get uvOutput(): NodeMaterialConnectionPoint;
  58843. initialize(state: NodeMaterialBuildState): void;
  58844. autoConfigure(material: NodeMaterial): void;
  58845. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58846. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58847. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58848. protected _buildBlock(state: NodeMaterialBuildState): this;
  58849. }
  58850. }
  58851. declare module BABYLON {
  58852. /**
  58853. * Block used to get data information from a light
  58854. */
  58855. export class LightInformationBlock extends NodeMaterialBlock {
  58856. private _lightDataUniformName;
  58857. private _lightColorUniformName;
  58858. private _lightTypeDefineName;
  58859. /**
  58860. * Gets or sets the light associated with this block
  58861. */
  58862. light: Nullable<Light>;
  58863. /**
  58864. * Creates a new LightInformationBlock
  58865. * @param name defines the block name
  58866. */
  58867. constructor(name: string);
  58868. /**
  58869. * Gets the current class name
  58870. * @returns the class name
  58871. */
  58872. getClassName(): string;
  58873. /**
  58874. * Gets the world position input component
  58875. */
  58876. get worldPosition(): NodeMaterialConnectionPoint;
  58877. /**
  58878. * Gets the direction output component
  58879. */
  58880. get direction(): NodeMaterialConnectionPoint;
  58881. /**
  58882. * Gets the direction output component
  58883. */
  58884. get color(): NodeMaterialConnectionPoint;
  58885. /**
  58886. * Gets the direction output component
  58887. */
  58888. get intensity(): NodeMaterialConnectionPoint;
  58889. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58890. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58891. protected _buildBlock(state: NodeMaterialBuildState): this;
  58892. serialize(): any;
  58893. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58894. }
  58895. }
  58896. declare module BABYLON {
  58897. /**
  58898. * Block used to add image processing support to fragment shader
  58899. */
  58900. export class ImageProcessingBlock extends NodeMaterialBlock {
  58901. /**
  58902. * Create a new ImageProcessingBlock
  58903. * @param name defines the block name
  58904. */
  58905. constructor(name: string);
  58906. /**
  58907. * Gets the current class name
  58908. * @returns the class name
  58909. */
  58910. getClassName(): string;
  58911. /**
  58912. * Gets the color input component
  58913. */
  58914. get color(): NodeMaterialConnectionPoint;
  58915. /**
  58916. * Gets the output component
  58917. */
  58918. get output(): NodeMaterialConnectionPoint;
  58919. /**
  58920. * Initialize the block and prepare the context for build
  58921. * @param state defines the state that will be used for the build
  58922. */
  58923. initialize(state: NodeMaterialBuildState): void;
  58924. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58926. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58927. protected _buildBlock(state: NodeMaterialBuildState): this;
  58928. }
  58929. }
  58930. declare module BABYLON {
  58931. /**
  58932. * Block used to pertub normals based on a normal map
  58933. */
  58934. export class PerturbNormalBlock extends NodeMaterialBlock {
  58935. private _tangentSpaceParameterName;
  58936. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58937. invertX: boolean;
  58938. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58939. invertY: boolean;
  58940. /**
  58941. * Create a new PerturbNormalBlock
  58942. * @param name defines the block name
  58943. */
  58944. constructor(name: string);
  58945. /**
  58946. * Gets the current class name
  58947. * @returns the class name
  58948. */
  58949. getClassName(): string;
  58950. /**
  58951. * Gets the world position input component
  58952. */
  58953. get worldPosition(): NodeMaterialConnectionPoint;
  58954. /**
  58955. * Gets the world normal input component
  58956. */
  58957. get worldNormal(): NodeMaterialConnectionPoint;
  58958. /**
  58959. * Gets the world tangent input component
  58960. */
  58961. get worldTangent(): NodeMaterialConnectionPoint;
  58962. /**
  58963. * Gets the uv input component
  58964. */
  58965. get uv(): NodeMaterialConnectionPoint;
  58966. /**
  58967. * Gets the normal map color input component
  58968. */
  58969. get normalMapColor(): NodeMaterialConnectionPoint;
  58970. /**
  58971. * Gets the strength input component
  58972. */
  58973. get strength(): NodeMaterialConnectionPoint;
  58974. /**
  58975. * Gets the output component
  58976. */
  58977. get output(): NodeMaterialConnectionPoint;
  58978. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58979. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58980. autoConfigure(material: NodeMaterial): void;
  58981. protected _buildBlock(state: NodeMaterialBuildState): this;
  58982. protected _dumpPropertiesCode(): string;
  58983. serialize(): any;
  58984. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58985. }
  58986. }
  58987. declare module BABYLON {
  58988. /**
  58989. * Block used to discard a pixel if a value is smaller than a cutoff
  58990. */
  58991. export class DiscardBlock extends NodeMaterialBlock {
  58992. /**
  58993. * Create a new DiscardBlock
  58994. * @param name defines the block name
  58995. */
  58996. constructor(name: string);
  58997. /**
  58998. * Gets the current class name
  58999. * @returns the class name
  59000. */
  59001. getClassName(): string;
  59002. /**
  59003. * Gets the color input component
  59004. */
  59005. get value(): NodeMaterialConnectionPoint;
  59006. /**
  59007. * Gets the cutoff input component
  59008. */
  59009. get cutoff(): NodeMaterialConnectionPoint;
  59010. protected _buildBlock(state: NodeMaterialBuildState): this;
  59011. }
  59012. }
  59013. declare module BABYLON {
  59014. /**
  59015. * Block used to test if the fragment shader is front facing
  59016. */
  59017. export class FrontFacingBlock extends NodeMaterialBlock {
  59018. /**
  59019. * Creates a new FrontFacingBlock
  59020. * @param name defines the block name
  59021. */
  59022. constructor(name: string);
  59023. /**
  59024. * Gets the current class name
  59025. * @returns the class name
  59026. */
  59027. getClassName(): string;
  59028. /**
  59029. * Gets the output component
  59030. */
  59031. get output(): NodeMaterialConnectionPoint;
  59032. protected _buildBlock(state: NodeMaterialBuildState): this;
  59033. }
  59034. }
  59035. declare module BABYLON {
  59036. /**
  59037. * Block used to get the derivative value on x and y of a given input
  59038. */
  59039. export class DerivativeBlock extends NodeMaterialBlock {
  59040. /**
  59041. * Create a new DerivativeBlock
  59042. * @param name defines the block name
  59043. */
  59044. constructor(name: string);
  59045. /**
  59046. * Gets the current class name
  59047. * @returns the class name
  59048. */
  59049. getClassName(): string;
  59050. /**
  59051. * Gets the input component
  59052. */
  59053. get input(): NodeMaterialConnectionPoint;
  59054. /**
  59055. * Gets the derivative output on x
  59056. */
  59057. get dx(): NodeMaterialConnectionPoint;
  59058. /**
  59059. * Gets the derivative output on y
  59060. */
  59061. get dy(): NodeMaterialConnectionPoint;
  59062. protected _buildBlock(state: NodeMaterialBuildState): this;
  59063. }
  59064. }
  59065. declare module BABYLON {
  59066. /**
  59067. * Block used to add support for scene fog
  59068. */
  59069. export class FogBlock extends NodeMaterialBlock {
  59070. private _fogDistanceName;
  59071. private _fogParameters;
  59072. /**
  59073. * Create a new FogBlock
  59074. * @param name defines the block name
  59075. */
  59076. constructor(name: string);
  59077. /**
  59078. * Gets the current class name
  59079. * @returns the class name
  59080. */
  59081. getClassName(): string;
  59082. /**
  59083. * Gets the world position input component
  59084. */
  59085. get worldPosition(): NodeMaterialConnectionPoint;
  59086. /**
  59087. * Gets the view input component
  59088. */
  59089. get view(): NodeMaterialConnectionPoint;
  59090. /**
  59091. * Gets the color input component
  59092. */
  59093. get input(): NodeMaterialConnectionPoint;
  59094. /**
  59095. * Gets the fog color input component
  59096. */
  59097. get fogColor(): NodeMaterialConnectionPoint;
  59098. /**
  59099. * Gets the output component
  59100. */
  59101. get output(): NodeMaterialConnectionPoint;
  59102. autoConfigure(material: NodeMaterial): void;
  59103. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59104. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59105. protected _buildBlock(state: NodeMaterialBuildState): this;
  59106. }
  59107. }
  59108. declare module BABYLON {
  59109. /**
  59110. * Block used to add light in the fragment shader
  59111. */
  59112. export class LightBlock extends NodeMaterialBlock {
  59113. private _lightId;
  59114. /**
  59115. * Gets or sets the light associated with this block
  59116. */
  59117. light: Nullable<Light>;
  59118. /**
  59119. * Create a new LightBlock
  59120. * @param name defines the block name
  59121. */
  59122. constructor(name: string);
  59123. /**
  59124. * Gets the current class name
  59125. * @returns the class name
  59126. */
  59127. getClassName(): string;
  59128. /**
  59129. * Gets the world position input component
  59130. */
  59131. get worldPosition(): NodeMaterialConnectionPoint;
  59132. /**
  59133. * Gets the world normal input component
  59134. */
  59135. get worldNormal(): NodeMaterialConnectionPoint;
  59136. /**
  59137. * Gets the camera (or eye) position component
  59138. */
  59139. get cameraPosition(): NodeMaterialConnectionPoint;
  59140. /**
  59141. * Gets the glossiness component
  59142. */
  59143. get glossiness(): NodeMaterialConnectionPoint;
  59144. /**
  59145. * Gets the glossinness power component
  59146. */
  59147. get glossPower(): NodeMaterialConnectionPoint;
  59148. /**
  59149. * Gets the diffuse color component
  59150. */
  59151. get diffuseColor(): NodeMaterialConnectionPoint;
  59152. /**
  59153. * Gets the specular color component
  59154. */
  59155. get specularColor(): NodeMaterialConnectionPoint;
  59156. /**
  59157. * Gets the diffuse output component
  59158. */
  59159. get diffuseOutput(): NodeMaterialConnectionPoint;
  59160. /**
  59161. * Gets the specular output component
  59162. */
  59163. get specularOutput(): NodeMaterialConnectionPoint;
  59164. /**
  59165. * Gets the shadow output component
  59166. */
  59167. get shadow(): NodeMaterialConnectionPoint;
  59168. autoConfigure(material: NodeMaterial): void;
  59169. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59170. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59171. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59172. private _injectVertexCode;
  59173. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59174. serialize(): any;
  59175. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59176. }
  59177. }
  59178. declare module BABYLON {
  59179. /**
  59180. * Block used to multiply 2 values
  59181. */
  59182. export class MultiplyBlock extends NodeMaterialBlock {
  59183. /**
  59184. * Creates a new MultiplyBlock
  59185. * @param name defines the block name
  59186. */
  59187. constructor(name: string);
  59188. /**
  59189. * Gets the current class name
  59190. * @returns the class name
  59191. */
  59192. getClassName(): string;
  59193. /**
  59194. * Gets the left operand input component
  59195. */
  59196. get left(): NodeMaterialConnectionPoint;
  59197. /**
  59198. * Gets the right operand input component
  59199. */
  59200. get right(): NodeMaterialConnectionPoint;
  59201. /**
  59202. * Gets the output component
  59203. */
  59204. get output(): NodeMaterialConnectionPoint;
  59205. protected _buildBlock(state: NodeMaterialBuildState): this;
  59206. }
  59207. }
  59208. declare module BABYLON {
  59209. /**
  59210. * Block used to add 2 vectors
  59211. */
  59212. export class AddBlock extends NodeMaterialBlock {
  59213. /**
  59214. * Creates a new AddBlock
  59215. * @param name defines the block name
  59216. */
  59217. constructor(name: string);
  59218. /**
  59219. * Gets the current class name
  59220. * @returns the class name
  59221. */
  59222. getClassName(): string;
  59223. /**
  59224. * Gets the left operand input component
  59225. */
  59226. get left(): NodeMaterialConnectionPoint;
  59227. /**
  59228. * Gets the right operand input component
  59229. */
  59230. get right(): NodeMaterialConnectionPoint;
  59231. /**
  59232. * Gets the output component
  59233. */
  59234. get output(): NodeMaterialConnectionPoint;
  59235. protected _buildBlock(state: NodeMaterialBuildState): this;
  59236. }
  59237. }
  59238. declare module BABYLON {
  59239. /**
  59240. * Block used to scale a vector by a float
  59241. */
  59242. export class ScaleBlock extends NodeMaterialBlock {
  59243. /**
  59244. * Creates a new ScaleBlock
  59245. * @param name defines the block name
  59246. */
  59247. constructor(name: string);
  59248. /**
  59249. * Gets the current class name
  59250. * @returns the class name
  59251. */
  59252. getClassName(): string;
  59253. /**
  59254. * Gets the input component
  59255. */
  59256. get input(): NodeMaterialConnectionPoint;
  59257. /**
  59258. * Gets the factor input component
  59259. */
  59260. get factor(): NodeMaterialConnectionPoint;
  59261. /**
  59262. * Gets the output component
  59263. */
  59264. get output(): NodeMaterialConnectionPoint;
  59265. protected _buildBlock(state: NodeMaterialBuildState): this;
  59266. }
  59267. }
  59268. declare module BABYLON {
  59269. /**
  59270. * Block used to clamp a float
  59271. */
  59272. export class ClampBlock extends NodeMaterialBlock {
  59273. /** Gets or sets the minimum range */
  59274. minimum: number;
  59275. /** Gets or sets the maximum range */
  59276. maximum: number;
  59277. /**
  59278. * Creates a new ClampBlock
  59279. * @param name defines the block name
  59280. */
  59281. constructor(name: string);
  59282. /**
  59283. * Gets the current class name
  59284. * @returns the class name
  59285. */
  59286. getClassName(): string;
  59287. /**
  59288. * Gets the value input component
  59289. */
  59290. get value(): NodeMaterialConnectionPoint;
  59291. /**
  59292. * Gets the output component
  59293. */
  59294. get output(): NodeMaterialConnectionPoint;
  59295. protected _buildBlock(state: NodeMaterialBuildState): this;
  59296. protected _dumpPropertiesCode(): string;
  59297. serialize(): any;
  59298. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59299. }
  59300. }
  59301. declare module BABYLON {
  59302. /**
  59303. * Block used to apply a cross product between 2 vectors
  59304. */
  59305. export class CrossBlock extends NodeMaterialBlock {
  59306. /**
  59307. * Creates a new CrossBlock
  59308. * @param name defines the block name
  59309. */
  59310. constructor(name: string);
  59311. /**
  59312. * Gets the current class name
  59313. * @returns the class name
  59314. */
  59315. getClassName(): string;
  59316. /**
  59317. * Gets the left operand input component
  59318. */
  59319. get left(): NodeMaterialConnectionPoint;
  59320. /**
  59321. * Gets the right operand input component
  59322. */
  59323. get right(): NodeMaterialConnectionPoint;
  59324. /**
  59325. * Gets the output component
  59326. */
  59327. get output(): NodeMaterialConnectionPoint;
  59328. protected _buildBlock(state: NodeMaterialBuildState): this;
  59329. }
  59330. }
  59331. declare module BABYLON {
  59332. /**
  59333. * Block used to apply a dot product between 2 vectors
  59334. */
  59335. export class DotBlock extends NodeMaterialBlock {
  59336. /**
  59337. * Creates a new DotBlock
  59338. * @param name defines the block name
  59339. */
  59340. constructor(name: string);
  59341. /**
  59342. * Gets the current class name
  59343. * @returns the class name
  59344. */
  59345. getClassName(): string;
  59346. /**
  59347. * Gets the left operand input component
  59348. */
  59349. get left(): NodeMaterialConnectionPoint;
  59350. /**
  59351. * Gets the right operand input component
  59352. */
  59353. get right(): NodeMaterialConnectionPoint;
  59354. /**
  59355. * Gets the output component
  59356. */
  59357. get output(): NodeMaterialConnectionPoint;
  59358. protected _buildBlock(state: NodeMaterialBuildState): this;
  59359. }
  59360. }
  59361. declare module BABYLON {
  59362. /**
  59363. * Block used to remap a float from a range to a new one
  59364. */
  59365. export class RemapBlock extends NodeMaterialBlock {
  59366. /**
  59367. * Gets or sets the source range
  59368. */
  59369. sourceRange: Vector2;
  59370. /**
  59371. * Gets or sets the target range
  59372. */
  59373. targetRange: Vector2;
  59374. /**
  59375. * Creates a new RemapBlock
  59376. * @param name defines the block name
  59377. */
  59378. constructor(name: string);
  59379. /**
  59380. * Gets the current class name
  59381. * @returns the class name
  59382. */
  59383. getClassName(): string;
  59384. /**
  59385. * Gets the input component
  59386. */
  59387. get input(): NodeMaterialConnectionPoint;
  59388. /**
  59389. * Gets the source min input component
  59390. */
  59391. get sourceMin(): NodeMaterialConnectionPoint;
  59392. /**
  59393. * Gets the source max input component
  59394. */
  59395. get sourceMax(): NodeMaterialConnectionPoint;
  59396. /**
  59397. * Gets the target min input component
  59398. */
  59399. get targetMin(): NodeMaterialConnectionPoint;
  59400. /**
  59401. * Gets the target max input component
  59402. */
  59403. get targetMax(): NodeMaterialConnectionPoint;
  59404. /**
  59405. * Gets the output component
  59406. */
  59407. get output(): NodeMaterialConnectionPoint;
  59408. protected _buildBlock(state: NodeMaterialBuildState): this;
  59409. protected _dumpPropertiesCode(): string;
  59410. serialize(): any;
  59411. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59412. }
  59413. }
  59414. declare module BABYLON {
  59415. /**
  59416. * Block used to normalize a vector
  59417. */
  59418. export class NormalizeBlock extends NodeMaterialBlock {
  59419. /**
  59420. * Creates a new NormalizeBlock
  59421. * @param name defines the block name
  59422. */
  59423. constructor(name: string);
  59424. /**
  59425. * Gets the current class name
  59426. * @returns the class name
  59427. */
  59428. getClassName(): string;
  59429. /**
  59430. * Gets the input component
  59431. */
  59432. get input(): NodeMaterialConnectionPoint;
  59433. /**
  59434. * Gets the output component
  59435. */
  59436. get output(): NodeMaterialConnectionPoint;
  59437. protected _buildBlock(state: NodeMaterialBuildState): this;
  59438. }
  59439. }
  59440. declare module BABYLON {
  59441. /**
  59442. * Operations supported by the Trigonometry block
  59443. */
  59444. export enum TrigonometryBlockOperations {
  59445. /** Cos */
  59446. Cos = 0,
  59447. /** Sin */
  59448. Sin = 1,
  59449. /** Abs */
  59450. Abs = 2,
  59451. /** Exp */
  59452. Exp = 3,
  59453. /** Exp2 */
  59454. Exp2 = 4,
  59455. /** Round */
  59456. Round = 5,
  59457. /** Floor */
  59458. Floor = 6,
  59459. /** Ceiling */
  59460. Ceiling = 7,
  59461. /** Square root */
  59462. Sqrt = 8,
  59463. /** Log */
  59464. Log = 9,
  59465. /** Tangent */
  59466. Tan = 10,
  59467. /** Arc tangent */
  59468. ArcTan = 11,
  59469. /** Arc cosinus */
  59470. ArcCos = 12,
  59471. /** Arc sinus */
  59472. ArcSin = 13,
  59473. /** Fraction */
  59474. Fract = 14,
  59475. /** Sign */
  59476. Sign = 15,
  59477. /** To radians (from degrees) */
  59478. Radians = 16,
  59479. /** To degrees (from radians) */
  59480. Degrees = 17
  59481. }
  59482. /**
  59483. * Block used to apply trigonometry operation to floats
  59484. */
  59485. export class TrigonometryBlock extends NodeMaterialBlock {
  59486. /**
  59487. * Gets or sets the operation applied by the block
  59488. */
  59489. operation: TrigonometryBlockOperations;
  59490. /**
  59491. * Creates a new TrigonometryBlock
  59492. * @param name defines the block name
  59493. */
  59494. constructor(name: string);
  59495. /**
  59496. * Gets the current class name
  59497. * @returns the class name
  59498. */
  59499. getClassName(): string;
  59500. /**
  59501. * Gets the input component
  59502. */
  59503. get input(): NodeMaterialConnectionPoint;
  59504. /**
  59505. * Gets the output component
  59506. */
  59507. get output(): NodeMaterialConnectionPoint;
  59508. protected _buildBlock(state: NodeMaterialBuildState): this;
  59509. serialize(): any;
  59510. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59511. protected _dumpPropertiesCode(): string;
  59512. }
  59513. }
  59514. declare module BABYLON {
  59515. /**
  59516. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59517. */
  59518. export class ColorMergerBlock extends NodeMaterialBlock {
  59519. /**
  59520. * Create a new ColorMergerBlock
  59521. * @param name defines the block name
  59522. */
  59523. constructor(name: string);
  59524. /**
  59525. * Gets the current class name
  59526. * @returns the class name
  59527. */
  59528. getClassName(): string;
  59529. /**
  59530. * Gets the rgb component (input)
  59531. */
  59532. get rgbIn(): NodeMaterialConnectionPoint;
  59533. /**
  59534. * Gets the r component (input)
  59535. */
  59536. get r(): NodeMaterialConnectionPoint;
  59537. /**
  59538. * Gets the g component (input)
  59539. */
  59540. get g(): NodeMaterialConnectionPoint;
  59541. /**
  59542. * Gets the b component (input)
  59543. */
  59544. get b(): NodeMaterialConnectionPoint;
  59545. /**
  59546. * Gets the a component (input)
  59547. */
  59548. get a(): NodeMaterialConnectionPoint;
  59549. /**
  59550. * Gets the rgba component (output)
  59551. */
  59552. get rgba(): NodeMaterialConnectionPoint;
  59553. /**
  59554. * Gets the rgb component (output)
  59555. */
  59556. get rgbOut(): NodeMaterialConnectionPoint;
  59557. /**
  59558. * Gets the rgb component (output)
  59559. * @deprecated Please use rgbOut instead.
  59560. */
  59561. get rgb(): NodeMaterialConnectionPoint;
  59562. protected _buildBlock(state: NodeMaterialBuildState): this;
  59563. }
  59564. }
  59565. declare module BABYLON {
  59566. /**
  59567. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59568. */
  59569. export class VectorMergerBlock extends NodeMaterialBlock {
  59570. /**
  59571. * Create a new VectorMergerBlock
  59572. * @param name defines the block name
  59573. */
  59574. constructor(name: string);
  59575. /**
  59576. * Gets the current class name
  59577. * @returns the class name
  59578. */
  59579. getClassName(): string;
  59580. /**
  59581. * Gets the xyz component (input)
  59582. */
  59583. get xyzIn(): NodeMaterialConnectionPoint;
  59584. /**
  59585. * Gets the xy component (input)
  59586. */
  59587. get xyIn(): NodeMaterialConnectionPoint;
  59588. /**
  59589. * Gets the x component (input)
  59590. */
  59591. get x(): NodeMaterialConnectionPoint;
  59592. /**
  59593. * Gets the y component (input)
  59594. */
  59595. get y(): NodeMaterialConnectionPoint;
  59596. /**
  59597. * Gets the z component (input)
  59598. */
  59599. get z(): NodeMaterialConnectionPoint;
  59600. /**
  59601. * Gets the w component (input)
  59602. */
  59603. get w(): NodeMaterialConnectionPoint;
  59604. /**
  59605. * Gets the xyzw component (output)
  59606. */
  59607. get xyzw(): NodeMaterialConnectionPoint;
  59608. /**
  59609. * Gets the xyz component (output)
  59610. */
  59611. get xyzOut(): NodeMaterialConnectionPoint;
  59612. /**
  59613. * Gets the xy component (output)
  59614. */
  59615. get xyOut(): NodeMaterialConnectionPoint;
  59616. /**
  59617. * Gets the xy component (output)
  59618. * @deprecated Please use xyOut instead.
  59619. */
  59620. get xy(): NodeMaterialConnectionPoint;
  59621. /**
  59622. * Gets the xyz component (output)
  59623. * @deprecated Please use xyzOut instead.
  59624. */
  59625. get xyz(): NodeMaterialConnectionPoint;
  59626. protected _buildBlock(state: NodeMaterialBuildState): this;
  59627. }
  59628. }
  59629. declare module BABYLON {
  59630. /**
  59631. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59632. */
  59633. export class ColorSplitterBlock extends NodeMaterialBlock {
  59634. /**
  59635. * Create a new ColorSplitterBlock
  59636. * @param name defines the block name
  59637. */
  59638. constructor(name: string);
  59639. /**
  59640. * Gets the current class name
  59641. * @returns the class name
  59642. */
  59643. getClassName(): string;
  59644. /**
  59645. * Gets the rgba component (input)
  59646. */
  59647. get rgba(): NodeMaterialConnectionPoint;
  59648. /**
  59649. * Gets the rgb component (input)
  59650. */
  59651. get rgbIn(): NodeMaterialConnectionPoint;
  59652. /**
  59653. * Gets the rgb component (output)
  59654. */
  59655. get rgbOut(): NodeMaterialConnectionPoint;
  59656. /**
  59657. * Gets the r component (output)
  59658. */
  59659. get r(): NodeMaterialConnectionPoint;
  59660. /**
  59661. * Gets the g component (output)
  59662. */
  59663. get g(): NodeMaterialConnectionPoint;
  59664. /**
  59665. * Gets the b component (output)
  59666. */
  59667. get b(): NodeMaterialConnectionPoint;
  59668. /**
  59669. * Gets the a component (output)
  59670. */
  59671. get a(): NodeMaterialConnectionPoint;
  59672. protected _inputRename(name: string): string;
  59673. protected _outputRename(name: string): string;
  59674. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59675. }
  59676. }
  59677. declare module BABYLON {
  59678. /**
  59679. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59680. */
  59681. export class VectorSplitterBlock extends NodeMaterialBlock {
  59682. /**
  59683. * Create a new VectorSplitterBlock
  59684. * @param name defines the block name
  59685. */
  59686. constructor(name: string);
  59687. /**
  59688. * Gets the current class name
  59689. * @returns the class name
  59690. */
  59691. getClassName(): string;
  59692. /**
  59693. * Gets the xyzw component (input)
  59694. */
  59695. get xyzw(): NodeMaterialConnectionPoint;
  59696. /**
  59697. * Gets the xyz component (input)
  59698. */
  59699. get xyzIn(): NodeMaterialConnectionPoint;
  59700. /**
  59701. * Gets the xy component (input)
  59702. */
  59703. get xyIn(): NodeMaterialConnectionPoint;
  59704. /**
  59705. * Gets the xyz component (output)
  59706. */
  59707. get xyzOut(): NodeMaterialConnectionPoint;
  59708. /**
  59709. * Gets the xy component (output)
  59710. */
  59711. get xyOut(): NodeMaterialConnectionPoint;
  59712. /**
  59713. * Gets the x component (output)
  59714. */
  59715. get x(): NodeMaterialConnectionPoint;
  59716. /**
  59717. * Gets the y component (output)
  59718. */
  59719. get y(): NodeMaterialConnectionPoint;
  59720. /**
  59721. * Gets the z component (output)
  59722. */
  59723. get z(): NodeMaterialConnectionPoint;
  59724. /**
  59725. * Gets the w component (output)
  59726. */
  59727. get w(): NodeMaterialConnectionPoint;
  59728. protected _inputRename(name: string): string;
  59729. protected _outputRename(name: string): string;
  59730. protected _buildBlock(state: NodeMaterialBuildState): this;
  59731. }
  59732. }
  59733. declare module BABYLON {
  59734. /**
  59735. * Block used to lerp between 2 values
  59736. */
  59737. export class LerpBlock extends NodeMaterialBlock {
  59738. /**
  59739. * Creates a new LerpBlock
  59740. * @param name defines the block name
  59741. */
  59742. constructor(name: string);
  59743. /**
  59744. * Gets the current class name
  59745. * @returns the class name
  59746. */
  59747. getClassName(): string;
  59748. /**
  59749. * Gets the left operand input component
  59750. */
  59751. get left(): NodeMaterialConnectionPoint;
  59752. /**
  59753. * Gets the right operand input component
  59754. */
  59755. get right(): NodeMaterialConnectionPoint;
  59756. /**
  59757. * Gets the gradient operand input component
  59758. */
  59759. get gradient(): NodeMaterialConnectionPoint;
  59760. /**
  59761. * Gets the output component
  59762. */
  59763. get output(): NodeMaterialConnectionPoint;
  59764. protected _buildBlock(state: NodeMaterialBuildState): this;
  59765. }
  59766. }
  59767. declare module BABYLON {
  59768. /**
  59769. * Block used to divide 2 vectors
  59770. */
  59771. export class DivideBlock extends NodeMaterialBlock {
  59772. /**
  59773. * Creates a new DivideBlock
  59774. * @param name defines the block name
  59775. */
  59776. constructor(name: string);
  59777. /**
  59778. * Gets the current class name
  59779. * @returns the class name
  59780. */
  59781. getClassName(): string;
  59782. /**
  59783. * Gets the left operand input component
  59784. */
  59785. get left(): NodeMaterialConnectionPoint;
  59786. /**
  59787. * Gets the right operand input component
  59788. */
  59789. get right(): NodeMaterialConnectionPoint;
  59790. /**
  59791. * Gets the output component
  59792. */
  59793. get output(): NodeMaterialConnectionPoint;
  59794. protected _buildBlock(state: NodeMaterialBuildState): this;
  59795. }
  59796. }
  59797. declare module BABYLON {
  59798. /**
  59799. * Block used to subtract 2 vectors
  59800. */
  59801. export class SubtractBlock extends NodeMaterialBlock {
  59802. /**
  59803. * Creates a new SubtractBlock
  59804. * @param name defines the block name
  59805. */
  59806. constructor(name: string);
  59807. /**
  59808. * Gets the current class name
  59809. * @returns the class name
  59810. */
  59811. getClassName(): string;
  59812. /**
  59813. * Gets the left operand input component
  59814. */
  59815. get left(): NodeMaterialConnectionPoint;
  59816. /**
  59817. * Gets the right operand input component
  59818. */
  59819. get right(): NodeMaterialConnectionPoint;
  59820. /**
  59821. * Gets the output component
  59822. */
  59823. get output(): NodeMaterialConnectionPoint;
  59824. protected _buildBlock(state: NodeMaterialBuildState): this;
  59825. }
  59826. }
  59827. declare module BABYLON {
  59828. /**
  59829. * Block used to step a value
  59830. */
  59831. export class StepBlock extends NodeMaterialBlock {
  59832. /**
  59833. * Creates a new StepBlock
  59834. * @param name defines the block name
  59835. */
  59836. constructor(name: string);
  59837. /**
  59838. * Gets the current class name
  59839. * @returns the class name
  59840. */
  59841. getClassName(): string;
  59842. /**
  59843. * Gets the value operand input component
  59844. */
  59845. get value(): NodeMaterialConnectionPoint;
  59846. /**
  59847. * Gets the edge operand input component
  59848. */
  59849. get edge(): NodeMaterialConnectionPoint;
  59850. /**
  59851. * Gets the output component
  59852. */
  59853. get output(): NodeMaterialConnectionPoint;
  59854. protected _buildBlock(state: NodeMaterialBuildState): this;
  59855. }
  59856. }
  59857. declare module BABYLON {
  59858. /**
  59859. * Block used to get the opposite (1 - x) of a value
  59860. */
  59861. export class OneMinusBlock extends NodeMaterialBlock {
  59862. /**
  59863. * Creates a new OneMinusBlock
  59864. * @param name defines the block name
  59865. */
  59866. constructor(name: string);
  59867. /**
  59868. * Gets the current class name
  59869. * @returns the class name
  59870. */
  59871. getClassName(): string;
  59872. /**
  59873. * Gets the input component
  59874. */
  59875. get input(): NodeMaterialConnectionPoint;
  59876. /**
  59877. * Gets the output component
  59878. */
  59879. get output(): NodeMaterialConnectionPoint;
  59880. protected _buildBlock(state: NodeMaterialBuildState): this;
  59881. }
  59882. }
  59883. declare module BABYLON {
  59884. /**
  59885. * Block used to get the view direction
  59886. */
  59887. export class ViewDirectionBlock extends NodeMaterialBlock {
  59888. /**
  59889. * Creates a new ViewDirectionBlock
  59890. * @param name defines the block name
  59891. */
  59892. constructor(name: string);
  59893. /**
  59894. * Gets the current class name
  59895. * @returns the class name
  59896. */
  59897. getClassName(): string;
  59898. /**
  59899. * Gets the world position component
  59900. */
  59901. get worldPosition(): NodeMaterialConnectionPoint;
  59902. /**
  59903. * Gets the camera position component
  59904. */
  59905. get cameraPosition(): NodeMaterialConnectionPoint;
  59906. /**
  59907. * Gets the output component
  59908. */
  59909. get output(): NodeMaterialConnectionPoint;
  59910. autoConfigure(material: NodeMaterial): void;
  59911. protected _buildBlock(state: NodeMaterialBuildState): this;
  59912. }
  59913. }
  59914. declare module BABYLON {
  59915. /**
  59916. * Block used to compute fresnel value
  59917. */
  59918. export class FresnelBlock extends NodeMaterialBlock {
  59919. /**
  59920. * Create a new FresnelBlock
  59921. * @param name defines the block name
  59922. */
  59923. constructor(name: string);
  59924. /**
  59925. * Gets the current class name
  59926. * @returns the class name
  59927. */
  59928. getClassName(): string;
  59929. /**
  59930. * Gets the world normal input component
  59931. */
  59932. get worldNormal(): NodeMaterialConnectionPoint;
  59933. /**
  59934. * Gets the view direction input component
  59935. */
  59936. get viewDirection(): NodeMaterialConnectionPoint;
  59937. /**
  59938. * Gets the bias input component
  59939. */
  59940. get bias(): NodeMaterialConnectionPoint;
  59941. /**
  59942. * Gets the camera (or eye) position component
  59943. */
  59944. get power(): NodeMaterialConnectionPoint;
  59945. /**
  59946. * Gets the fresnel output component
  59947. */
  59948. get fresnel(): NodeMaterialConnectionPoint;
  59949. autoConfigure(material: NodeMaterial): void;
  59950. protected _buildBlock(state: NodeMaterialBuildState): this;
  59951. }
  59952. }
  59953. declare module BABYLON {
  59954. /**
  59955. * Block used to get the max of 2 values
  59956. */
  59957. export class MaxBlock extends NodeMaterialBlock {
  59958. /**
  59959. * Creates a new MaxBlock
  59960. * @param name defines the block name
  59961. */
  59962. constructor(name: string);
  59963. /**
  59964. * Gets the current class name
  59965. * @returns the class name
  59966. */
  59967. getClassName(): string;
  59968. /**
  59969. * Gets the left operand input component
  59970. */
  59971. get left(): NodeMaterialConnectionPoint;
  59972. /**
  59973. * Gets the right operand input component
  59974. */
  59975. get right(): NodeMaterialConnectionPoint;
  59976. /**
  59977. * Gets the output component
  59978. */
  59979. get output(): NodeMaterialConnectionPoint;
  59980. protected _buildBlock(state: NodeMaterialBuildState): this;
  59981. }
  59982. }
  59983. declare module BABYLON {
  59984. /**
  59985. * Block used to get the min of 2 values
  59986. */
  59987. export class MinBlock extends NodeMaterialBlock {
  59988. /**
  59989. * Creates a new MinBlock
  59990. * @param name defines the block name
  59991. */
  59992. constructor(name: string);
  59993. /**
  59994. * Gets the current class name
  59995. * @returns the class name
  59996. */
  59997. getClassName(): string;
  59998. /**
  59999. * Gets the left operand input component
  60000. */
  60001. get left(): NodeMaterialConnectionPoint;
  60002. /**
  60003. * Gets the right operand input component
  60004. */
  60005. get right(): NodeMaterialConnectionPoint;
  60006. /**
  60007. * Gets the output component
  60008. */
  60009. get output(): NodeMaterialConnectionPoint;
  60010. protected _buildBlock(state: NodeMaterialBuildState): this;
  60011. }
  60012. }
  60013. declare module BABYLON {
  60014. /**
  60015. * Block used to get the distance between 2 values
  60016. */
  60017. export class DistanceBlock extends NodeMaterialBlock {
  60018. /**
  60019. * Creates a new DistanceBlock
  60020. * @param name defines the block name
  60021. */
  60022. constructor(name: string);
  60023. /**
  60024. * Gets the current class name
  60025. * @returns the class name
  60026. */
  60027. getClassName(): string;
  60028. /**
  60029. * Gets the left operand input component
  60030. */
  60031. get left(): NodeMaterialConnectionPoint;
  60032. /**
  60033. * Gets the right operand input component
  60034. */
  60035. get right(): NodeMaterialConnectionPoint;
  60036. /**
  60037. * Gets the output component
  60038. */
  60039. get output(): NodeMaterialConnectionPoint;
  60040. protected _buildBlock(state: NodeMaterialBuildState): this;
  60041. }
  60042. }
  60043. declare module BABYLON {
  60044. /**
  60045. * Block used to get the length of a vector
  60046. */
  60047. export class LengthBlock extends NodeMaterialBlock {
  60048. /**
  60049. * Creates a new LengthBlock
  60050. * @param name defines the block name
  60051. */
  60052. constructor(name: string);
  60053. /**
  60054. * Gets the current class name
  60055. * @returns the class name
  60056. */
  60057. getClassName(): string;
  60058. /**
  60059. * Gets the value input component
  60060. */
  60061. get value(): NodeMaterialConnectionPoint;
  60062. /**
  60063. * Gets the output component
  60064. */
  60065. get output(): NodeMaterialConnectionPoint;
  60066. protected _buildBlock(state: NodeMaterialBuildState): this;
  60067. }
  60068. }
  60069. declare module BABYLON {
  60070. /**
  60071. * Block used to get negative version of a value (i.e. x * -1)
  60072. */
  60073. export class NegateBlock extends NodeMaterialBlock {
  60074. /**
  60075. * Creates a new NegateBlock
  60076. * @param name defines the block name
  60077. */
  60078. constructor(name: string);
  60079. /**
  60080. * Gets the current class name
  60081. * @returns the class name
  60082. */
  60083. getClassName(): string;
  60084. /**
  60085. * Gets the value input component
  60086. */
  60087. get value(): NodeMaterialConnectionPoint;
  60088. /**
  60089. * Gets the output component
  60090. */
  60091. get output(): NodeMaterialConnectionPoint;
  60092. protected _buildBlock(state: NodeMaterialBuildState): this;
  60093. }
  60094. }
  60095. declare module BABYLON {
  60096. /**
  60097. * Block used to get the value of the first parameter raised to the power of the second
  60098. */
  60099. export class PowBlock extends NodeMaterialBlock {
  60100. /**
  60101. * Creates a new PowBlock
  60102. * @param name defines the block name
  60103. */
  60104. constructor(name: string);
  60105. /**
  60106. * Gets the current class name
  60107. * @returns the class name
  60108. */
  60109. getClassName(): string;
  60110. /**
  60111. * Gets the value operand input component
  60112. */
  60113. get value(): NodeMaterialConnectionPoint;
  60114. /**
  60115. * Gets the power operand input component
  60116. */
  60117. get power(): NodeMaterialConnectionPoint;
  60118. /**
  60119. * Gets the output component
  60120. */
  60121. get output(): NodeMaterialConnectionPoint;
  60122. protected _buildBlock(state: NodeMaterialBuildState): this;
  60123. }
  60124. }
  60125. declare module BABYLON {
  60126. /**
  60127. * Block used to get a random number
  60128. */
  60129. export class RandomNumberBlock extends NodeMaterialBlock {
  60130. /**
  60131. * Creates a new RandomNumberBlock
  60132. * @param name defines the block name
  60133. */
  60134. constructor(name: string);
  60135. /**
  60136. * Gets the current class name
  60137. * @returns the class name
  60138. */
  60139. getClassName(): string;
  60140. /**
  60141. * Gets the seed input component
  60142. */
  60143. get seed(): NodeMaterialConnectionPoint;
  60144. /**
  60145. * Gets the output component
  60146. */
  60147. get output(): NodeMaterialConnectionPoint;
  60148. protected _buildBlock(state: NodeMaterialBuildState): this;
  60149. }
  60150. }
  60151. declare module BABYLON {
  60152. /**
  60153. * Block used to compute arc tangent of 2 values
  60154. */
  60155. export class ArcTan2Block extends NodeMaterialBlock {
  60156. /**
  60157. * Creates a new ArcTan2Block
  60158. * @param name defines the block name
  60159. */
  60160. constructor(name: string);
  60161. /**
  60162. * Gets the current class name
  60163. * @returns the class name
  60164. */
  60165. getClassName(): string;
  60166. /**
  60167. * Gets the x operand input component
  60168. */
  60169. get x(): NodeMaterialConnectionPoint;
  60170. /**
  60171. * Gets the y operand input component
  60172. */
  60173. get y(): NodeMaterialConnectionPoint;
  60174. /**
  60175. * Gets the output component
  60176. */
  60177. get output(): NodeMaterialConnectionPoint;
  60178. protected _buildBlock(state: NodeMaterialBuildState): this;
  60179. }
  60180. }
  60181. declare module BABYLON {
  60182. /**
  60183. * Block used to smooth step a value
  60184. */
  60185. export class SmoothStepBlock extends NodeMaterialBlock {
  60186. /**
  60187. * Creates a new SmoothStepBlock
  60188. * @param name defines the block name
  60189. */
  60190. constructor(name: string);
  60191. /**
  60192. * Gets the current class name
  60193. * @returns the class name
  60194. */
  60195. getClassName(): string;
  60196. /**
  60197. * Gets the value operand input component
  60198. */
  60199. get value(): NodeMaterialConnectionPoint;
  60200. /**
  60201. * Gets the first edge operand input component
  60202. */
  60203. get edge0(): NodeMaterialConnectionPoint;
  60204. /**
  60205. * Gets the second edge operand input component
  60206. */
  60207. get edge1(): NodeMaterialConnectionPoint;
  60208. /**
  60209. * Gets the output component
  60210. */
  60211. get output(): NodeMaterialConnectionPoint;
  60212. protected _buildBlock(state: NodeMaterialBuildState): this;
  60213. }
  60214. }
  60215. declare module BABYLON {
  60216. /**
  60217. * Block used to get the reciprocal (1 / x) of a value
  60218. */
  60219. export class ReciprocalBlock extends NodeMaterialBlock {
  60220. /**
  60221. * Creates a new ReciprocalBlock
  60222. * @param name defines the block name
  60223. */
  60224. constructor(name: string);
  60225. /**
  60226. * Gets the current class name
  60227. * @returns the class name
  60228. */
  60229. getClassName(): string;
  60230. /**
  60231. * Gets the input component
  60232. */
  60233. get input(): NodeMaterialConnectionPoint;
  60234. /**
  60235. * Gets the output component
  60236. */
  60237. get output(): NodeMaterialConnectionPoint;
  60238. protected _buildBlock(state: NodeMaterialBuildState): this;
  60239. }
  60240. }
  60241. declare module BABYLON {
  60242. /**
  60243. * Block used to replace a color by another one
  60244. */
  60245. export class ReplaceColorBlock extends NodeMaterialBlock {
  60246. /**
  60247. * Creates a new ReplaceColorBlock
  60248. * @param name defines the block name
  60249. */
  60250. constructor(name: string);
  60251. /**
  60252. * Gets the current class name
  60253. * @returns the class name
  60254. */
  60255. getClassName(): string;
  60256. /**
  60257. * Gets the value input component
  60258. */
  60259. get value(): NodeMaterialConnectionPoint;
  60260. /**
  60261. * Gets the reference input component
  60262. */
  60263. get reference(): NodeMaterialConnectionPoint;
  60264. /**
  60265. * Gets the distance input component
  60266. */
  60267. get distance(): NodeMaterialConnectionPoint;
  60268. /**
  60269. * Gets the replacement input component
  60270. */
  60271. get replacement(): NodeMaterialConnectionPoint;
  60272. /**
  60273. * Gets the output component
  60274. */
  60275. get output(): NodeMaterialConnectionPoint;
  60276. protected _buildBlock(state: NodeMaterialBuildState): this;
  60277. }
  60278. }
  60279. declare module BABYLON {
  60280. /**
  60281. * Block used to posterize a value
  60282. * @see https://en.wikipedia.org/wiki/Posterization
  60283. */
  60284. export class PosterizeBlock extends NodeMaterialBlock {
  60285. /**
  60286. * Creates a new PosterizeBlock
  60287. * @param name defines the block name
  60288. */
  60289. constructor(name: string);
  60290. /**
  60291. * Gets the current class name
  60292. * @returns the class name
  60293. */
  60294. getClassName(): string;
  60295. /**
  60296. * Gets the value input component
  60297. */
  60298. get value(): NodeMaterialConnectionPoint;
  60299. /**
  60300. * Gets the steps input component
  60301. */
  60302. get steps(): NodeMaterialConnectionPoint;
  60303. /**
  60304. * Gets the output component
  60305. */
  60306. get output(): NodeMaterialConnectionPoint;
  60307. protected _buildBlock(state: NodeMaterialBuildState): this;
  60308. }
  60309. }
  60310. declare module BABYLON {
  60311. /**
  60312. * Operations supported by the Wave block
  60313. */
  60314. export enum WaveBlockKind {
  60315. /** SawTooth */
  60316. SawTooth = 0,
  60317. /** Square */
  60318. Square = 1,
  60319. /** Triangle */
  60320. Triangle = 2
  60321. }
  60322. /**
  60323. * Block used to apply wave operation to floats
  60324. */
  60325. export class WaveBlock extends NodeMaterialBlock {
  60326. /**
  60327. * Gets or sets the kibnd of wave to be applied by the block
  60328. */
  60329. kind: WaveBlockKind;
  60330. /**
  60331. * Creates a new WaveBlock
  60332. * @param name defines the block name
  60333. */
  60334. constructor(name: string);
  60335. /**
  60336. * Gets the current class name
  60337. * @returns the class name
  60338. */
  60339. getClassName(): string;
  60340. /**
  60341. * Gets the input component
  60342. */
  60343. get input(): NodeMaterialConnectionPoint;
  60344. /**
  60345. * Gets the output component
  60346. */
  60347. get output(): NodeMaterialConnectionPoint;
  60348. protected _buildBlock(state: NodeMaterialBuildState): this;
  60349. serialize(): any;
  60350. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60351. }
  60352. }
  60353. declare module BABYLON {
  60354. /**
  60355. * Class used to store a color step for the GradientBlock
  60356. */
  60357. export class GradientBlockColorStep {
  60358. /**
  60359. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60360. */
  60361. step: number;
  60362. /**
  60363. * Gets or sets the color associated with this step
  60364. */
  60365. color: Color3;
  60366. /**
  60367. * Creates a new GradientBlockColorStep
  60368. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60369. * @param color defines the color associated with this step
  60370. */
  60371. constructor(
  60372. /**
  60373. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60374. */
  60375. step: number,
  60376. /**
  60377. * Gets or sets the color associated with this step
  60378. */
  60379. color: Color3);
  60380. }
  60381. /**
  60382. * Block used to return a color from a gradient based on an input value between 0 and 1
  60383. */
  60384. export class GradientBlock extends NodeMaterialBlock {
  60385. /**
  60386. * Gets or sets the list of color steps
  60387. */
  60388. colorSteps: GradientBlockColorStep[];
  60389. /**
  60390. * Creates a new GradientBlock
  60391. * @param name defines the block name
  60392. */
  60393. constructor(name: string);
  60394. /**
  60395. * Gets the current class name
  60396. * @returns the class name
  60397. */
  60398. getClassName(): string;
  60399. /**
  60400. * Gets the gradient input component
  60401. */
  60402. get gradient(): NodeMaterialConnectionPoint;
  60403. /**
  60404. * Gets the output component
  60405. */
  60406. get output(): NodeMaterialConnectionPoint;
  60407. private _writeColorConstant;
  60408. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60409. serialize(): any;
  60410. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60411. protected _dumpPropertiesCode(): string;
  60412. }
  60413. }
  60414. declare module BABYLON {
  60415. /**
  60416. * Block used to normalize lerp between 2 values
  60417. */
  60418. export class NLerpBlock extends NodeMaterialBlock {
  60419. /**
  60420. * Creates a new NLerpBlock
  60421. * @param name defines the block name
  60422. */
  60423. constructor(name: string);
  60424. /**
  60425. * Gets the current class name
  60426. * @returns the class name
  60427. */
  60428. getClassName(): string;
  60429. /**
  60430. * Gets the left operand input component
  60431. */
  60432. get left(): NodeMaterialConnectionPoint;
  60433. /**
  60434. * Gets the right operand input component
  60435. */
  60436. get right(): NodeMaterialConnectionPoint;
  60437. /**
  60438. * Gets the gradient operand input component
  60439. */
  60440. get gradient(): NodeMaterialConnectionPoint;
  60441. /**
  60442. * Gets the output component
  60443. */
  60444. get output(): NodeMaterialConnectionPoint;
  60445. protected _buildBlock(state: NodeMaterialBuildState): this;
  60446. }
  60447. }
  60448. declare module BABYLON {
  60449. /**
  60450. * block used to Generate a Worley Noise 3D Noise Pattern
  60451. */
  60452. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60453. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60454. manhattanDistance: boolean;
  60455. /**
  60456. * Creates a new WorleyNoise3DBlock
  60457. * @param name defines the block name
  60458. */
  60459. constructor(name: string);
  60460. /**
  60461. * Gets the current class name
  60462. * @returns the class name
  60463. */
  60464. getClassName(): string;
  60465. /**
  60466. * Gets the seed input component
  60467. */
  60468. get seed(): NodeMaterialConnectionPoint;
  60469. /**
  60470. * Gets the jitter input component
  60471. */
  60472. get jitter(): NodeMaterialConnectionPoint;
  60473. /**
  60474. * Gets the output component
  60475. */
  60476. get output(): NodeMaterialConnectionPoint;
  60477. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60478. /**
  60479. * Exposes the properties to the UI?
  60480. */
  60481. protected _dumpPropertiesCode(): string;
  60482. /**
  60483. * Exposes the properties to the Seralize?
  60484. */
  60485. serialize(): any;
  60486. /**
  60487. * Exposes the properties to the deseralize?
  60488. */
  60489. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60490. }
  60491. }
  60492. declare module BABYLON {
  60493. /**
  60494. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60495. */
  60496. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60497. /**
  60498. * Creates a new SimplexPerlin3DBlock
  60499. * @param name defines the block name
  60500. */
  60501. constructor(name: string);
  60502. /**
  60503. * Gets the current class name
  60504. * @returns the class name
  60505. */
  60506. getClassName(): string;
  60507. /**
  60508. * Gets the seed operand input component
  60509. */
  60510. get seed(): NodeMaterialConnectionPoint;
  60511. /**
  60512. * Gets the output component
  60513. */
  60514. get output(): NodeMaterialConnectionPoint;
  60515. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60516. }
  60517. }
  60518. declare module BABYLON {
  60519. /**
  60520. * Block used to blend normals
  60521. */
  60522. export class NormalBlendBlock extends NodeMaterialBlock {
  60523. /**
  60524. * Creates a new NormalBlendBlock
  60525. * @param name defines the block name
  60526. */
  60527. constructor(name: string);
  60528. /**
  60529. * Gets the current class name
  60530. * @returns the class name
  60531. */
  60532. getClassName(): string;
  60533. /**
  60534. * Gets the first input component
  60535. */
  60536. get normalMap0(): NodeMaterialConnectionPoint;
  60537. /**
  60538. * Gets the second input component
  60539. */
  60540. get normalMap1(): NodeMaterialConnectionPoint;
  60541. /**
  60542. * Gets the output component
  60543. */
  60544. get output(): NodeMaterialConnectionPoint;
  60545. protected _buildBlock(state: NodeMaterialBuildState): this;
  60546. }
  60547. }
  60548. declare module BABYLON {
  60549. /**
  60550. * Block used to rotate a 2d vector by a given angle
  60551. */
  60552. export class Rotate2dBlock extends NodeMaterialBlock {
  60553. /**
  60554. * Creates a new Rotate2dBlock
  60555. * @param name defines the block name
  60556. */
  60557. constructor(name: string);
  60558. /**
  60559. * Gets the current class name
  60560. * @returns the class name
  60561. */
  60562. getClassName(): string;
  60563. /**
  60564. * Gets the input vector
  60565. */
  60566. get input(): NodeMaterialConnectionPoint;
  60567. /**
  60568. * Gets the input angle
  60569. */
  60570. get angle(): NodeMaterialConnectionPoint;
  60571. /**
  60572. * Gets the output component
  60573. */
  60574. get output(): NodeMaterialConnectionPoint;
  60575. autoConfigure(material: NodeMaterial): void;
  60576. protected _buildBlock(state: NodeMaterialBuildState): this;
  60577. }
  60578. }
  60579. declare module BABYLON {
  60580. /**
  60581. * Block used to get the reflected vector from a direction and a normal
  60582. */
  60583. export class ReflectBlock extends NodeMaterialBlock {
  60584. /**
  60585. * Creates a new ReflectBlock
  60586. * @param name defines the block name
  60587. */
  60588. constructor(name: string);
  60589. /**
  60590. * Gets the current class name
  60591. * @returns the class name
  60592. */
  60593. getClassName(): string;
  60594. /**
  60595. * Gets the incident component
  60596. */
  60597. get incident(): NodeMaterialConnectionPoint;
  60598. /**
  60599. * Gets the normal component
  60600. */
  60601. get normal(): NodeMaterialConnectionPoint;
  60602. /**
  60603. * Gets the output component
  60604. */
  60605. get output(): NodeMaterialConnectionPoint;
  60606. protected _buildBlock(state: NodeMaterialBuildState): this;
  60607. }
  60608. }
  60609. declare module BABYLON {
  60610. /**
  60611. * Block used to get the refracted vector from a direction and a normal
  60612. */
  60613. export class RefractBlock extends NodeMaterialBlock {
  60614. /**
  60615. * Creates a new RefractBlock
  60616. * @param name defines the block name
  60617. */
  60618. constructor(name: string);
  60619. /**
  60620. * Gets the current class name
  60621. * @returns the class name
  60622. */
  60623. getClassName(): string;
  60624. /**
  60625. * Gets the incident component
  60626. */
  60627. get incident(): NodeMaterialConnectionPoint;
  60628. /**
  60629. * Gets the normal component
  60630. */
  60631. get normal(): NodeMaterialConnectionPoint;
  60632. /**
  60633. * Gets the index of refraction component
  60634. */
  60635. get ior(): NodeMaterialConnectionPoint;
  60636. /**
  60637. * Gets the output component
  60638. */
  60639. get output(): NodeMaterialConnectionPoint;
  60640. protected _buildBlock(state: NodeMaterialBuildState): this;
  60641. }
  60642. }
  60643. declare module BABYLON {
  60644. /**
  60645. * Block used to desaturate a color
  60646. */
  60647. export class DesaturateBlock extends NodeMaterialBlock {
  60648. /**
  60649. * Creates a new DesaturateBlock
  60650. * @param name defines the block name
  60651. */
  60652. constructor(name: string);
  60653. /**
  60654. * Gets the current class name
  60655. * @returns the class name
  60656. */
  60657. getClassName(): string;
  60658. /**
  60659. * Gets the color operand input component
  60660. */
  60661. get color(): NodeMaterialConnectionPoint;
  60662. /**
  60663. * Gets the level operand input component
  60664. */
  60665. get level(): NodeMaterialConnectionPoint;
  60666. /**
  60667. * Gets the output component
  60668. */
  60669. get output(): NodeMaterialConnectionPoint;
  60670. protected _buildBlock(state: NodeMaterialBuildState): this;
  60671. }
  60672. }
  60673. declare module BABYLON {
  60674. /**
  60675. * Effect Render Options
  60676. */
  60677. export interface IEffectRendererOptions {
  60678. /**
  60679. * Defines the vertices positions.
  60680. */
  60681. positions?: number[];
  60682. /**
  60683. * Defines the indices.
  60684. */
  60685. indices?: number[];
  60686. }
  60687. /**
  60688. * Helper class to render one or more effects
  60689. */
  60690. export class EffectRenderer {
  60691. private engine;
  60692. private static _DefaultOptions;
  60693. private _vertexBuffers;
  60694. private _indexBuffer;
  60695. private _ringBufferIndex;
  60696. private _ringScreenBuffer;
  60697. private _fullscreenViewport;
  60698. private _getNextFrameBuffer;
  60699. /**
  60700. * Creates an effect renderer
  60701. * @param engine the engine to use for rendering
  60702. * @param options defines the options of the effect renderer
  60703. */
  60704. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60705. /**
  60706. * Sets the current viewport in normalized coordinates 0-1
  60707. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60708. */
  60709. setViewport(viewport?: Viewport): void;
  60710. /**
  60711. * Binds the embedded attributes buffer to the effect.
  60712. * @param effect Defines the effect to bind the attributes for
  60713. */
  60714. bindBuffers(effect: Effect): void;
  60715. /**
  60716. * Sets the current effect wrapper to use during draw.
  60717. * The effect needs to be ready before calling this api.
  60718. * This also sets the default full screen position attribute.
  60719. * @param effectWrapper Defines the effect to draw with
  60720. */
  60721. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60722. /**
  60723. * Draws a full screen quad.
  60724. */
  60725. draw(): void;
  60726. /**
  60727. * renders one or more effects to a specified texture
  60728. * @param effectWrappers list of effects to renderer
  60729. * @param outputTexture texture to draw to, if null it will render to the screen
  60730. */
  60731. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60732. /**
  60733. * Disposes of the effect renderer
  60734. */
  60735. dispose(): void;
  60736. }
  60737. /**
  60738. * Options to create an EffectWrapper
  60739. */
  60740. interface EffectWrapperCreationOptions {
  60741. /**
  60742. * Engine to use to create the effect
  60743. */
  60744. engine: ThinEngine;
  60745. /**
  60746. * Fragment shader for the effect
  60747. */
  60748. fragmentShader: string;
  60749. /**
  60750. * Vertex shader for the effect
  60751. */
  60752. vertexShader?: string;
  60753. /**
  60754. * Attributes to use in the shader
  60755. */
  60756. attributeNames?: Array<string>;
  60757. /**
  60758. * Uniforms to use in the shader
  60759. */
  60760. uniformNames?: Array<string>;
  60761. /**
  60762. * Texture sampler names to use in the shader
  60763. */
  60764. samplerNames?: Array<string>;
  60765. /**
  60766. * The friendly name of the effect displayed in Spector.
  60767. */
  60768. name?: string;
  60769. }
  60770. /**
  60771. * Wraps an effect to be used for rendering
  60772. */
  60773. export class EffectWrapper {
  60774. /**
  60775. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60776. */
  60777. onApplyObservable: Observable<{}>;
  60778. /**
  60779. * The underlying effect
  60780. */
  60781. effect: Effect;
  60782. /**
  60783. * Creates an effect to be renderer
  60784. * @param creationOptions options to create the effect
  60785. */
  60786. constructor(creationOptions: EffectWrapperCreationOptions);
  60787. /**
  60788. * Disposes of the effect wrapper
  60789. */
  60790. dispose(): void;
  60791. }
  60792. }
  60793. declare module BABYLON {
  60794. /**
  60795. * Helper class to push actions to a pool of workers.
  60796. */
  60797. export class WorkerPool implements IDisposable {
  60798. private _workerInfos;
  60799. private _pendingActions;
  60800. /**
  60801. * Constructor
  60802. * @param workers Array of workers to use for actions
  60803. */
  60804. constructor(workers: Array<Worker>);
  60805. /**
  60806. * Terminates all workers and clears any pending actions.
  60807. */
  60808. dispose(): void;
  60809. /**
  60810. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60811. * pended until a worker has completed its action.
  60812. * @param action The action to perform. Call onComplete when the action is complete.
  60813. */
  60814. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60815. private _execute;
  60816. }
  60817. }
  60818. declare module BABYLON {
  60819. /**
  60820. * Configuration for Draco compression
  60821. */
  60822. export interface IDracoCompressionConfiguration {
  60823. /**
  60824. * Configuration for the decoder.
  60825. */
  60826. decoder: {
  60827. /**
  60828. * The url to the WebAssembly module.
  60829. */
  60830. wasmUrl?: string;
  60831. /**
  60832. * The url to the WebAssembly binary.
  60833. */
  60834. wasmBinaryUrl?: string;
  60835. /**
  60836. * The url to the fallback JavaScript module.
  60837. */
  60838. fallbackUrl?: string;
  60839. };
  60840. }
  60841. /**
  60842. * Draco compression (https://google.github.io/draco/)
  60843. *
  60844. * This class wraps the Draco module.
  60845. *
  60846. * **Encoder**
  60847. *
  60848. * The encoder is not currently implemented.
  60849. *
  60850. * **Decoder**
  60851. *
  60852. * 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.
  60853. *
  60854. * To update the configuration, use the following code:
  60855. * ```javascript
  60856. * DracoCompression.Configuration = {
  60857. * decoder: {
  60858. * wasmUrl: "<url to the WebAssembly library>",
  60859. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60860. * fallbackUrl: "<url to the fallback JavaScript library>",
  60861. * }
  60862. * };
  60863. * ```
  60864. *
  60865. * 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.
  60866. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60867. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60868. *
  60869. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60870. * ```javascript
  60871. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60872. * ```
  60873. *
  60874. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60875. */
  60876. export class DracoCompression implements IDisposable {
  60877. private _workerPoolPromise?;
  60878. private _decoderModulePromise?;
  60879. /**
  60880. * The configuration. Defaults to the following urls:
  60881. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60882. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60883. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60884. */
  60885. static Configuration: IDracoCompressionConfiguration;
  60886. /**
  60887. * Returns true if the decoder configuration is available.
  60888. */
  60889. static get DecoderAvailable(): boolean;
  60890. /**
  60891. * Default number of workers to create when creating the draco compression object.
  60892. */
  60893. static DefaultNumWorkers: number;
  60894. private static GetDefaultNumWorkers;
  60895. private static _Default;
  60896. /**
  60897. * Default instance for the draco compression object.
  60898. */
  60899. static get Default(): DracoCompression;
  60900. /**
  60901. * Constructor
  60902. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60903. */
  60904. constructor(numWorkers?: number);
  60905. /**
  60906. * Stop all async operations and release resources.
  60907. */
  60908. dispose(): void;
  60909. /**
  60910. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60911. * @returns a promise that resolves when ready
  60912. */
  60913. whenReadyAsync(): Promise<void>;
  60914. /**
  60915. * Decode Draco compressed mesh data to vertex data.
  60916. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60917. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60918. * @returns A promise that resolves with the decoded vertex data
  60919. */
  60920. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60921. [kind: string]: number;
  60922. }): Promise<VertexData>;
  60923. }
  60924. }
  60925. declare module BABYLON {
  60926. /**
  60927. * Class for building Constructive Solid Geometry
  60928. */
  60929. export class CSG {
  60930. private polygons;
  60931. /**
  60932. * The world matrix
  60933. */
  60934. matrix: Matrix;
  60935. /**
  60936. * Stores the position
  60937. */
  60938. position: Vector3;
  60939. /**
  60940. * Stores the rotation
  60941. */
  60942. rotation: Vector3;
  60943. /**
  60944. * Stores the rotation quaternion
  60945. */
  60946. rotationQuaternion: Nullable<Quaternion>;
  60947. /**
  60948. * Stores the scaling vector
  60949. */
  60950. scaling: Vector3;
  60951. /**
  60952. * Convert the Mesh to CSG
  60953. * @param mesh The Mesh to convert to CSG
  60954. * @returns A new CSG from the Mesh
  60955. */
  60956. static FromMesh(mesh: Mesh): CSG;
  60957. /**
  60958. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60959. * @param polygons Polygons used to construct a CSG solid
  60960. */
  60961. private static FromPolygons;
  60962. /**
  60963. * Clones, or makes a deep copy, of the CSG
  60964. * @returns A new CSG
  60965. */
  60966. clone(): CSG;
  60967. /**
  60968. * Unions this CSG with another CSG
  60969. * @param csg The CSG to union against this CSG
  60970. * @returns The unioned CSG
  60971. */
  60972. union(csg: CSG): CSG;
  60973. /**
  60974. * Unions this CSG with another CSG in place
  60975. * @param csg The CSG to union against this CSG
  60976. */
  60977. unionInPlace(csg: CSG): void;
  60978. /**
  60979. * Subtracts this CSG with another CSG
  60980. * @param csg The CSG to subtract against this CSG
  60981. * @returns A new CSG
  60982. */
  60983. subtract(csg: CSG): CSG;
  60984. /**
  60985. * Subtracts this CSG with another CSG in place
  60986. * @param csg The CSG to subtact against this CSG
  60987. */
  60988. subtractInPlace(csg: CSG): void;
  60989. /**
  60990. * Intersect this CSG with another CSG
  60991. * @param csg The CSG to intersect against this CSG
  60992. * @returns A new CSG
  60993. */
  60994. intersect(csg: CSG): CSG;
  60995. /**
  60996. * Intersects this CSG with another CSG in place
  60997. * @param csg The CSG to intersect against this CSG
  60998. */
  60999. intersectInPlace(csg: CSG): void;
  61000. /**
  61001. * Return a new CSG solid with solid and empty space switched. This solid is
  61002. * not modified.
  61003. * @returns A new CSG solid with solid and empty space switched
  61004. */
  61005. inverse(): CSG;
  61006. /**
  61007. * Inverses the CSG in place
  61008. */
  61009. inverseInPlace(): void;
  61010. /**
  61011. * This is used to keep meshes transformations so they can be restored
  61012. * when we build back a Babylon Mesh
  61013. * NB : All CSG operations are performed in world coordinates
  61014. * @param csg The CSG to copy the transform attributes from
  61015. * @returns This CSG
  61016. */
  61017. copyTransformAttributes(csg: CSG): CSG;
  61018. /**
  61019. * Build Raw mesh from CSG
  61020. * Coordinates here are in world space
  61021. * @param name The name of the mesh geometry
  61022. * @param scene The Scene
  61023. * @param keepSubMeshes Specifies if the submeshes should be kept
  61024. * @returns A new Mesh
  61025. */
  61026. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61027. /**
  61028. * Build Mesh from CSG taking material and transforms into account
  61029. * @param name The name of the Mesh
  61030. * @param material The material of the Mesh
  61031. * @param scene The Scene
  61032. * @param keepSubMeshes Specifies if submeshes should be kept
  61033. * @returns The new Mesh
  61034. */
  61035. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61036. }
  61037. }
  61038. declare module BABYLON {
  61039. /**
  61040. * Class used to create a trail following a mesh
  61041. */
  61042. export class TrailMesh extends Mesh {
  61043. private _generator;
  61044. private _autoStart;
  61045. private _running;
  61046. private _diameter;
  61047. private _length;
  61048. private _sectionPolygonPointsCount;
  61049. private _sectionVectors;
  61050. private _sectionNormalVectors;
  61051. private _beforeRenderObserver;
  61052. /**
  61053. * @constructor
  61054. * @param name The value used by scene.getMeshByName() to do a lookup.
  61055. * @param generator The mesh or transform node to generate a trail.
  61056. * @param scene The scene to add this mesh to.
  61057. * @param diameter Diameter of trailing mesh. Default is 1.
  61058. * @param length Length of trailing mesh. Default is 60.
  61059. * @param autoStart Automatically start trailing mesh. Default true.
  61060. */
  61061. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61062. /**
  61063. * "TrailMesh"
  61064. * @returns "TrailMesh"
  61065. */
  61066. getClassName(): string;
  61067. private _createMesh;
  61068. /**
  61069. * Start trailing mesh.
  61070. */
  61071. start(): void;
  61072. /**
  61073. * Stop trailing mesh.
  61074. */
  61075. stop(): void;
  61076. /**
  61077. * Update trailing mesh geometry.
  61078. */
  61079. update(): void;
  61080. /**
  61081. * Returns a new TrailMesh object.
  61082. * @param name is a string, the name given to the new mesh
  61083. * @param newGenerator use new generator object for cloned trail mesh
  61084. * @returns a new mesh
  61085. */
  61086. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  61087. /**
  61088. * Serializes this trail mesh
  61089. * @param serializationObject object to write serialization to
  61090. */
  61091. serialize(serializationObject: any): void;
  61092. /**
  61093. * Parses a serialized trail mesh
  61094. * @param parsedMesh the serialized mesh
  61095. * @param scene the scene to create the trail mesh in
  61096. * @returns the created trail mesh
  61097. */
  61098. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61099. }
  61100. }
  61101. declare module BABYLON {
  61102. /**
  61103. * Class containing static functions to help procedurally build meshes
  61104. */
  61105. export class TiledBoxBuilder {
  61106. /**
  61107. * Creates a box mesh
  61108. * 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)
  61109. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61111. * * 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
  61112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61113. * @param name defines the name of the mesh
  61114. * @param options defines the options used to create the mesh
  61115. * @param scene defines the hosting scene
  61116. * @returns the box mesh
  61117. */
  61118. static CreateTiledBox(name: string, options: {
  61119. pattern?: number;
  61120. width?: number;
  61121. height?: number;
  61122. depth?: number;
  61123. tileSize?: number;
  61124. tileWidth?: number;
  61125. tileHeight?: number;
  61126. alignHorizontal?: number;
  61127. alignVertical?: number;
  61128. faceUV?: Vector4[];
  61129. faceColors?: Color4[];
  61130. sideOrientation?: number;
  61131. updatable?: boolean;
  61132. }, scene?: Nullable<Scene>): Mesh;
  61133. }
  61134. }
  61135. declare module BABYLON {
  61136. /**
  61137. * Class containing static functions to help procedurally build meshes
  61138. */
  61139. export class TorusKnotBuilder {
  61140. /**
  61141. * Creates a torus knot mesh
  61142. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61143. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61144. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61145. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61147. * * 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
  61148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61149. * @param name defines the name of the mesh
  61150. * @param options defines the options used to create the mesh
  61151. * @param scene defines the hosting scene
  61152. * @returns the torus knot mesh
  61153. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61154. */
  61155. static CreateTorusKnot(name: string, options: {
  61156. radius?: number;
  61157. tube?: number;
  61158. radialSegments?: number;
  61159. tubularSegments?: number;
  61160. p?: number;
  61161. q?: number;
  61162. updatable?: boolean;
  61163. sideOrientation?: number;
  61164. frontUVs?: Vector4;
  61165. backUVs?: Vector4;
  61166. }, scene: any): Mesh;
  61167. }
  61168. }
  61169. declare module BABYLON {
  61170. /**
  61171. * Polygon
  61172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61173. */
  61174. export class Polygon {
  61175. /**
  61176. * Creates a rectangle
  61177. * @param xmin bottom X coord
  61178. * @param ymin bottom Y coord
  61179. * @param xmax top X coord
  61180. * @param ymax top Y coord
  61181. * @returns points that make the resulting rectation
  61182. */
  61183. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61184. /**
  61185. * Creates a circle
  61186. * @param radius radius of circle
  61187. * @param cx scale in x
  61188. * @param cy scale in y
  61189. * @param numberOfSides number of sides that make up the circle
  61190. * @returns points that make the resulting circle
  61191. */
  61192. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61193. /**
  61194. * Creates a polygon from input string
  61195. * @param input Input polygon data
  61196. * @returns the parsed points
  61197. */
  61198. static Parse(input: string): Vector2[];
  61199. /**
  61200. * Starts building a polygon from x and y coordinates
  61201. * @param x x coordinate
  61202. * @param y y coordinate
  61203. * @returns the started path2
  61204. */
  61205. static StartingAt(x: number, y: number): Path2;
  61206. }
  61207. /**
  61208. * Builds a polygon
  61209. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61210. */
  61211. export class PolygonMeshBuilder {
  61212. private _points;
  61213. private _outlinepoints;
  61214. private _holes;
  61215. private _name;
  61216. private _scene;
  61217. private _epoints;
  61218. private _eholes;
  61219. private _addToepoint;
  61220. /**
  61221. * Babylon reference to the earcut plugin.
  61222. */
  61223. bjsEarcut: any;
  61224. /**
  61225. * Creates a PolygonMeshBuilder
  61226. * @param name name of the builder
  61227. * @param contours Path of the polygon
  61228. * @param scene scene to add to when creating the mesh
  61229. * @param earcutInjection can be used to inject your own earcut reference
  61230. */
  61231. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61232. /**
  61233. * Adds a whole within the polygon
  61234. * @param hole Array of points defining the hole
  61235. * @returns this
  61236. */
  61237. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61238. /**
  61239. * Creates the polygon
  61240. * @param updatable If the mesh should be updatable
  61241. * @param depth The depth of the mesh created
  61242. * @returns the created mesh
  61243. */
  61244. build(updatable?: boolean, depth?: number): Mesh;
  61245. /**
  61246. * Creates the polygon
  61247. * @param depth The depth of the mesh created
  61248. * @returns the created VertexData
  61249. */
  61250. buildVertexData(depth?: number): VertexData;
  61251. /**
  61252. * Adds a side to the polygon
  61253. * @param positions points that make the polygon
  61254. * @param normals normals of the polygon
  61255. * @param uvs uvs of the polygon
  61256. * @param indices indices of the polygon
  61257. * @param bounds bounds of the polygon
  61258. * @param points points of the polygon
  61259. * @param depth depth of the polygon
  61260. * @param flip flip of the polygon
  61261. */
  61262. private addSide;
  61263. }
  61264. }
  61265. declare module BABYLON {
  61266. /**
  61267. * Class containing static functions to help procedurally build meshes
  61268. */
  61269. export class PolygonBuilder {
  61270. /**
  61271. * Creates a polygon mesh
  61272. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61273. * * 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
  61274. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61276. * * 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)
  61277. * * Remember you can only change the shape positions, not their number when updating a polygon
  61278. * @param name defines the name of the mesh
  61279. * @param options defines the options used to create the mesh
  61280. * @param scene defines the hosting scene
  61281. * @param earcutInjection can be used to inject your own earcut reference
  61282. * @returns the polygon mesh
  61283. */
  61284. static CreatePolygon(name: string, options: {
  61285. shape: Vector3[];
  61286. holes?: Vector3[][];
  61287. depth?: number;
  61288. faceUV?: Vector4[];
  61289. faceColors?: Color4[];
  61290. updatable?: boolean;
  61291. sideOrientation?: number;
  61292. frontUVs?: Vector4;
  61293. backUVs?: Vector4;
  61294. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61295. /**
  61296. * Creates an extruded polygon mesh, with depth in the Y direction.
  61297. * * 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)
  61298. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61299. * @param name defines the name of the mesh
  61300. * @param options defines the options used to create the mesh
  61301. * @param scene defines the hosting scene
  61302. * @param earcutInjection can be used to inject your own earcut reference
  61303. * @returns the polygon mesh
  61304. */
  61305. static ExtrudePolygon(name: string, options: {
  61306. shape: Vector3[];
  61307. holes?: Vector3[][];
  61308. depth?: number;
  61309. faceUV?: Vector4[];
  61310. faceColors?: Color4[];
  61311. updatable?: boolean;
  61312. sideOrientation?: number;
  61313. frontUVs?: Vector4;
  61314. backUVs?: Vector4;
  61315. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61316. }
  61317. }
  61318. declare module BABYLON {
  61319. /**
  61320. * Class containing static functions to help procedurally build meshes
  61321. */
  61322. export class LatheBuilder {
  61323. /**
  61324. * Creates lathe mesh.
  61325. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61326. * * 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
  61327. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61328. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61329. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61330. * * 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
  61331. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61332. * * 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
  61333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61334. * * 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
  61335. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61337. * @param name defines the name of the mesh
  61338. * @param options defines the options used to create the mesh
  61339. * @param scene defines the hosting scene
  61340. * @returns the lathe mesh
  61341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61342. */
  61343. static CreateLathe(name: string, options: {
  61344. shape: Vector3[];
  61345. radius?: number;
  61346. tessellation?: number;
  61347. clip?: number;
  61348. arc?: number;
  61349. closed?: boolean;
  61350. updatable?: boolean;
  61351. sideOrientation?: number;
  61352. frontUVs?: Vector4;
  61353. backUVs?: Vector4;
  61354. cap?: number;
  61355. invertUV?: boolean;
  61356. }, scene?: Nullable<Scene>): Mesh;
  61357. }
  61358. }
  61359. declare module BABYLON {
  61360. /**
  61361. * Class containing static functions to help procedurally build meshes
  61362. */
  61363. export class TiledPlaneBuilder {
  61364. /**
  61365. * Creates a tiled plane mesh
  61366. * * The parameter `pattern` will, depending on value, do nothing or
  61367. * * * flip (reflect about central vertical) alternate tiles across and up
  61368. * * * flip every tile on alternate rows
  61369. * * * rotate (180 degs) alternate tiles across and up
  61370. * * * rotate every tile on alternate rows
  61371. * * * flip and rotate alternate tiles across and up
  61372. * * * flip and rotate every tile on alternate rows
  61373. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61374. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61375. * * 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
  61376. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61377. * * 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)
  61378. * * 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)
  61379. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61380. * @param name defines the name of the mesh
  61381. * @param options defines the options used to create the mesh
  61382. * @param scene defines the hosting scene
  61383. * @returns the box mesh
  61384. */
  61385. static CreateTiledPlane(name: string, options: {
  61386. pattern?: number;
  61387. tileSize?: number;
  61388. tileWidth?: number;
  61389. tileHeight?: number;
  61390. size?: number;
  61391. width?: number;
  61392. height?: number;
  61393. alignHorizontal?: number;
  61394. alignVertical?: number;
  61395. sideOrientation?: number;
  61396. frontUVs?: Vector4;
  61397. backUVs?: Vector4;
  61398. updatable?: boolean;
  61399. }, scene?: Nullable<Scene>): Mesh;
  61400. }
  61401. }
  61402. declare module BABYLON {
  61403. /**
  61404. * Class containing static functions to help procedurally build meshes
  61405. */
  61406. export class TubeBuilder {
  61407. /**
  61408. * Creates a tube mesh.
  61409. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61410. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61411. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61412. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61413. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61414. * * 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)
  61415. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61416. * * 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
  61417. * * 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
  61418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61419. * * 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
  61420. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61422. * @param name defines the name of the mesh
  61423. * @param options defines the options used to create the mesh
  61424. * @param scene defines the hosting scene
  61425. * @returns the tube mesh
  61426. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61427. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61428. */
  61429. static CreateTube(name: string, options: {
  61430. path: Vector3[];
  61431. radius?: number;
  61432. tessellation?: number;
  61433. radiusFunction?: {
  61434. (i: number, distance: number): number;
  61435. };
  61436. cap?: number;
  61437. arc?: number;
  61438. updatable?: boolean;
  61439. sideOrientation?: number;
  61440. frontUVs?: Vector4;
  61441. backUVs?: Vector4;
  61442. instance?: Mesh;
  61443. invertUV?: boolean;
  61444. }, scene?: Nullable<Scene>): Mesh;
  61445. }
  61446. }
  61447. declare module BABYLON {
  61448. /**
  61449. * Class containing static functions to help procedurally build meshes
  61450. */
  61451. export class IcoSphereBuilder {
  61452. /**
  61453. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61454. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61455. * * 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`)
  61456. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61457. * * 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
  61458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61459. * * 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
  61460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61461. * @param name defines the name of the mesh
  61462. * @param options defines the options used to create the mesh
  61463. * @param scene defines the hosting scene
  61464. * @returns the icosahedron mesh
  61465. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61466. */
  61467. static CreateIcoSphere(name: string, options: {
  61468. radius?: number;
  61469. radiusX?: number;
  61470. radiusY?: number;
  61471. radiusZ?: number;
  61472. flat?: boolean;
  61473. subdivisions?: number;
  61474. sideOrientation?: number;
  61475. frontUVs?: Vector4;
  61476. backUVs?: Vector4;
  61477. updatable?: boolean;
  61478. }, scene?: Nullable<Scene>): Mesh;
  61479. }
  61480. }
  61481. declare module BABYLON {
  61482. /**
  61483. * Class containing static functions to help procedurally build meshes
  61484. */
  61485. export class DecalBuilder {
  61486. /**
  61487. * Creates a decal mesh.
  61488. * 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
  61489. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61490. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61491. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61492. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61493. * @param name defines the name of the mesh
  61494. * @param sourceMesh defines the mesh where the decal must be applied
  61495. * @param options defines the options used to create the mesh
  61496. * @param scene defines the hosting scene
  61497. * @returns the decal mesh
  61498. * @see https://doc.babylonjs.com/how_to/decals
  61499. */
  61500. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61501. position?: Vector3;
  61502. normal?: Vector3;
  61503. size?: Vector3;
  61504. angle?: number;
  61505. }): Mesh;
  61506. }
  61507. }
  61508. declare module BABYLON {
  61509. /**
  61510. * Class containing static functions to help procedurally build meshes
  61511. */
  61512. export class MeshBuilder {
  61513. /**
  61514. * Creates a box mesh
  61515. * * The parameter `size` sets the size (float) of each box side (default 1)
  61516. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61517. * * 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)
  61518. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61520. * * 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
  61521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61522. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61523. * @param name defines the name of the mesh
  61524. * @param options defines the options used to create the mesh
  61525. * @param scene defines the hosting scene
  61526. * @returns the box mesh
  61527. */
  61528. static CreateBox(name: string, options: {
  61529. size?: number;
  61530. width?: number;
  61531. height?: number;
  61532. depth?: number;
  61533. faceUV?: Vector4[];
  61534. faceColors?: Color4[];
  61535. sideOrientation?: number;
  61536. frontUVs?: Vector4;
  61537. backUVs?: Vector4;
  61538. wrap?: boolean;
  61539. topBaseAt?: number;
  61540. bottomBaseAt?: number;
  61541. updatable?: boolean;
  61542. }, scene?: Nullable<Scene>): Mesh;
  61543. /**
  61544. * Creates a tiled box mesh
  61545. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61547. * @param name defines the name of the mesh
  61548. * @param options defines the options used to create the mesh
  61549. * @param scene defines the hosting scene
  61550. * @returns the tiled box mesh
  61551. */
  61552. static CreateTiledBox(name: string, options: {
  61553. pattern?: number;
  61554. size?: number;
  61555. width?: number;
  61556. height?: number;
  61557. depth: number;
  61558. tileSize?: number;
  61559. tileWidth?: number;
  61560. tileHeight?: number;
  61561. faceUV?: Vector4[];
  61562. faceColors?: Color4[];
  61563. alignHorizontal?: number;
  61564. alignVertical?: number;
  61565. sideOrientation?: number;
  61566. updatable?: boolean;
  61567. }, scene?: Nullable<Scene>): Mesh;
  61568. /**
  61569. * Creates a sphere mesh
  61570. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61571. * * 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`)
  61572. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61573. * * 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
  61574. * * 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)
  61575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61576. * * 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
  61577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61578. * @param name defines the name of the mesh
  61579. * @param options defines the options used to create the mesh
  61580. * @param scene defines the hosting scene
  61581. * @returns the sphere mesh
  61582. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61583. */
  61584. static CreateSphere(name: string, options: {
  61585. segments?: number;
  61586. diameter?: number;
  61587. diameterX?: number;
  61588. diameterY?: number;
  61589. diameterZ?: number;
  61590. arc?: number;
  61591. slice?: number;
  61592. sideOrientation?: number;
  61593. frontUVs?: Vector4;
  61594. backUVs?: Vector4;
  61595. updatable?: boolean;
  61596. }, scene?: Nullable<Scene>): Mesh;
  61597. /**
  61598. * Creates a plane polygonal mesh. By default, this is a disc
  61599. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61600. * * 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
  61601. * * 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
  61602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61603. * * 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
  61604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61605. * @param name defines the name of the mesh
  61606. * @param options defines the options used to create the mesh
  61607. * @param scene defines the hosting scene
  61608. * @returns the plane polygonal mesh
  61609. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61610. */
  61611. static CreateDisc(name: string, options: {
  61612. radius?: number;
  61613. tessellation?: number;
  61614. arc?: number;
  61615. updatable?: boolean;
  61616. sideOrientation?: number;
  61617. frontUVs?: Vector4;
  61618. backUVs?: Vector4;
  61619. }, scene?: Nullable<Scene>): Mesh;
  61620. /**
  61621. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61622. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61623. * * 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`)
  61624. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61625. * * 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
  61626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61627. * * 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
  61628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61629. * @param name defines the name of the mesh
  61630. * @param options defines the options used to create the mesh
  61631. * @param scene defines the hosting scene
  61632. * @returns the icosahedron mesh
  61633. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61634. */
  61635. static CreateIcoSphere(name: string, options: {
  61636. radius?: number;
  61637. radiusX?: number;
  61638. radiusY?: number;
  61639. radiusZ?: number;
  61640. flat?: boolean;
  61641. subdivisions?: number;
  61642. sideOrientation?: number;
  61643. frontUVs?: Vector4;
  61644. backUVs?: Vector4;
  61645. updatable?: boolean;
  61646. }, scene?: Nullable<Scene>): Mesh;
  61647. /**
  61648. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61649. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61650. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61651. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61652. * * 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
  61653. * * 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
  61654. * * 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
  61655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61656. * * 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
  61657. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61658. * * 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
  61659. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61660. * * 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
  61661. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61663. * @param name defines the name of the mesh
  61664. * @param options defines the options used to create the mesh
  61665. * @param scene defines the hosting scene
  61666. * @returns the ribbon mesh
  61667. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61668. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61669. */
  61670. static CreateRibbon(name: string, options: {
  61671. pathArray: Vector3[][];
  61672. closeArray?: boolean;
  61673. closePath?: boolean;
  61674. offset?: number;
  61675. updatable?: boolean;
  61676. sideOrientation?: number;
  61677. frontUVs?: Vector4;
  61678. backUVs?: Vector4;
  61679. instance?: Mesh;
  61680. invertUV?: boolean;
  61681. uvs?: Vector2[];
  61682. colors?: Color4[];
  61683. }, scene?: Nullable<Scene>): Mesh;
  61684. /**
  61685. * Creates a cylinder or a cone mesh
  61686. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61687. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61688. * * 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.
  61689. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61690. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61691. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61692. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61693. * * 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).
  61694. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61695. * * 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).
  61696. * * 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
  61697. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61698. * * 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
  61699. * * 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.
  61700. * * If `enclose` is false, a ring surface is one element.
  61701. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61702. * * 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
  61703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61704. * * 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
  61705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61706. * @param name defines the name of the mesh
  61707. * @param options defines the options used to create the mesh
  61708. * @param scene defines the hosting scene
  61709. * @returns the cylinder mesh
  61710. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61711. */
  61712. static CreateCylinder(name: string, options: {
  61713. height?: number;
  61714. diameterTop?: number;
  61715. diameterBottom?: number;
  61716. diameter?: number;
  61717. tessellation?: number;
  61718. subdivisions?: number;
  61719. arc?: number;
  61720. faceColors?: Color4[];
  61721. faceUV?: Vector4[];
  61722. updatable?: boolean;
  61723. hasRings?: boolean;
  61724. enclose?: boolean;
  61725. cap?: number;
  61726. sideOrientation?: number;
  61727. frontUVs?: Vector4;
  61728. backUVs?: Vector4;
  61729. }, scene?: Nullable<Scene>): Mesh;
  61730. /**
  61731. * Creates a torus mesh
  61732. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61733. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61734. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61736. * * 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
  61737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61738. * @param name defines the name of the mesh
  61739. * @param options defines the options used to create the mesh
  61740. * @param scene defines the hosting scene
  61741. * @returns the torus mesh
  61742. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61743. */
  61744. static CreateTorus(name: string, options: {
  61745. diameter?: number;
  61746. thickness?: number;
  61747. tessellation?: number;
  61748. updatable?: boolean;
  61749. sideOrientation?: number;
  61750. frontUVs?: Vector4;
  61751. backUVs?: Vector4;
  61752. }, scene?: Nullable<Scene>): Mesh;
  61753. /**
  61754. * Creates a torus knot mesh
  61755. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61756. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61757. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61758. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61760. * * 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
  61761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61762. * @param name defines the name of the mesh
  61763. * @param options defines the options used to create the mesh
  61764. * @param scene defines the hosting scene
  61765. * @returns the torus knot mesh
  61766. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61767. */
  61768. static CreateTorusKnot(name: string, options: {
  61769. radius?: number;
  61770. tube?: number;
  61771. radialSegments?: number;
  61772. tubularSegments?: number;
  61773. p?: number;
  61774. q?: number;
  61775. updatable?: boolean;
  61776. sideOrientation?: number;
  61777. frontUVs?: Vector4;
  61778. backUVs?: Vector4;
  61779. }, scene?: Nullable<Scene>): Mesh;
  61780. /**
  61781. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61782. * * 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
  61783. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61784. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61785. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61786. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61787. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61788. * * 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
  61789. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61792. * @param name defines the name of the new line system
  61793. * @param options defines the options used to create the line system
  61794. * @param scene defines the hosting scene
  61795. * @returns a new line system mesh
  61796. */
  61797. static CreateLineSystem(name: string, options: {
  61798. lines: Vector3[][];
  61799. updatable?: boolean;
  61800. instance?: Nullable<LinesMesh>;
  61801. colors?: Nullable<Color4[][]>;
  61802. useVertexAlpha?: boolean;
  61803. }, scene: Nullable<Scene>): LinesMesh;
  61804. /**
  61805. * Creates a line mesh
  61806. * 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
  61807. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61808. * * The parameter `points` is an array successive Vector3
  61809. * * 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
  61810. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61811. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61812. * * When updating an instance, remember that only point positions can change, not the number of points
  61813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61815. * @param name defines the name of the new line system
  61816. * @param options defines the options used to create the line system
  61817. * @param scene defines the hosting scene
  61818. * @returns a new line mesh
  61819. */
  61820. static CreateLines(name: string, options: {
  61821. points: Vector3[];
  61822. updatable?: boolean;
  61823. instance?: Nullable<LinesMesh>;
  61824. colors?: Color4[];
  61825. useVertexAlpha?: boolean;
  61826. }, scene?: Nullable<Scene>): LinesMesh;
  61827. /**
  61828. * Creates a dashed line mesh
  61829. * * 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
  61830. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61831. * * The parameter `points` is an array successive Vector3
  61832. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61833. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61834. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61835. * * 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
  61836. * * When updating an instance, remember that only point positions can change, not the number of points
  61837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61838. * @param name defines the name of the mesh
  61839. * @param options defines the options used to create the mesh
  61840. * @param scene defines the hosting scene
  61841. * @returns the dashed line mesh
  61842. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61843. */
  61844. static CreateDashedLines(name: string, options: {
  61845. points: Vector3[];
  61846. dashSize?: number;
  61847. gapSize?: number;
  61848. dashNb?: number;
  61849. updatable?: boolean;
  61850. instance?: LinesMesh;
  61851. }, scene?: Nullable<Scene>): LinesMesh;
  61852. /**
  61853. * 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.
  61854. * * 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.
  61855. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61856. * * 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.
  61857. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61858. * * 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
  61859. * * 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
  61860. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61862. * * 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
  61863. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61865. * @param name defines the name of the mesh
  61866. * @param options defines the options used to create the mesh
  61867. * @param scene defines the hosting scene
  61868. * @returns the extruded shape mesh
  61869. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61871. */
  61872. static ExtrudeShape(name: string, options: {
  61873. shape: Vector3[];
  61874. path: Vector3[];
  61875. scale?: number;
  61876. rotation?: number;
  61877. cap?: number;
  61878. updatable?: boolean;
  61879. sideOrientation?: number;
  61880. frontUVs?: Vector4;
  61881. backUVs?: Vector4;
  61882. instance?: Mesh;
  61883. invertUV?: boolean;
  61884. }, scene?: Nullable<Scene>): Mesh;
  61885. /**
  61886. * Creates an custom extruded shape mesh.
  61887. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61888. * * 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.
  61889. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61890. * * 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
  61891. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61892. * * 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
  61893. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61894. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61895. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61896. * * 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
  61897. * * 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
  61898. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61900. * * 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
  61901. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61903. * @param name defines the name of the mesh
  61904. * @param options defines the options used to create the mesh
  61905. * @param scene defines the hosting scene
  61906. * @returns the custom extruded shape mesh
  61907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61908. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61909. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61910. */
  61911. static ExtrudeShapeCustom(name: string, options: {
  61912. shape: Vector3[];
  61913. path: Vector3[];
  61914. scaleFunction?: any;
  61915. rotationFunction?: any;
  61916. ribbonCloseArray?: boolean;
  61917. ribbonClosePath?: boolean;
  61918. cap?: number;
  61919. updatable?: boolean;
  61920. sideOrientation?: number;
  61921. frontUVs?: Vector4;
  61922. backUVs?: Vector4;
  61923. instance?: Mesh;
  61924. invertUV?: boolean;
  61925. }, scene?: Nullable<Scene>): Mesh;
  61926. /**
  61927. * Creates lathe mesh.
  61928. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61929. * * 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
  61930. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61931. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61932. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61933. * * 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
  61934. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61935. * * 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
  61936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61937. * * 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
  61938. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61940. * @param name defines the name of the mesh
  61941. * @param options defines the options used to create the mesh
  61942. * @param scene defines the hosting scene
  61943. * @returns the lathe mesh
  61944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61945. */
  61946. static CreateLathe(name: string, options: {
  61947. shape: Vector3[];
  61948. radius?: number;
  61949. tessellation?: number;
  61950. clip?: number;
  61951. arc?: number;
  61952. closed?: boolean;
  61953. updatable?: boolean;
  61954. sideOrientation?: number;
  61955. frontUVs?: Vector4;
  61956. backUVs?: Vector4;
  61957. cap?: number;
  61958. invertUV?: boolean;
  61959. }, scene?: Nullable<Scene>): Mesh;
  61960. /**
  61961. * Creates a tiled plane mesh
  61962. * * You can set a limited pattern arrangement with the tiles
  61963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61964. * * 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
  61965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61966. * @param name defines the name of the mesh
  61967. * @param options defines the options used to create the mesh
  61968. * @param scene defines the hosting scene
  61969. * @returns the plane mesh
  61970. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61971. */
  61972. static CreateTiledPlane(name: string, options: {
  61973. pattern?: number;
  61974. tileSize?: number;
  61975. tileWidth?: number;
  61976. tileHeight?: number;
  61977. size?: number;
  61978. width?: number;
  61979. height?: number;
  61980. alignHorizontal?: number;
  61981. alignVertical?: number;
  61982. sideOrientation?: number;
  61983. frontUVs?: Vector4;
  61984. backUVs?: Vector4;
  61985. updatable?: boolean;
  61986. }, scene?: Nullable<Scene>): Mesh;
  61987. /**
  61988. * Creates a plane mesh
  61989. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61990. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61991. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61993. * * 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
  61994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61995. * @param name defines the name of the mesh
  61996. * @param options defines the options used to create the mesh
  61997. * @param scene defines the hosting scene
  61998. * @returns the plane mesh
  61999. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62000. */
  62001. static CreatePlane(name: string, options: {
  62002. size?: number;
  62003. width?: number;
  62004. height?: number;
  62005. sideOrientation?: number;
  62006. frontUVs?: Vector4;
  62007. backUVs?: Vector4;
  62008. updatable?: boolean;
  62009. sourcePlane?: Plane;
  62010. }, scene?: Nullable<Scene>): Mesh;
  62011. /**
  62012. * Creates a ground mesh
  62013. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62014. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62016. * @param name defines the name of the mesh
  62017. * @param options defines the options used to create the mesh
  62018. * @param scene defines the hosting scene
  62019. * @returns the ground mesh
  62020. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62021. */
  62022. static CreateGround(name: string, options: {
  62023. width?: number;
  62024. height?: number;
  62025. subdivisions?: number;
  62026. subdivisionsX?: number;
  62027. subdivisionsY?: number;
  62028. updatable?: boolean;
  62029. }, scene?: Nullable<Scene>): Mesh;
  62030. /**
  62031. * Creates a tiled ground mesh
  62032. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62033. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62034. * * 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
  62035. * * 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
  62036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62037. * @param name defines the name of the mesh
  62038. * @param options defines the options used to create the mesh
  62039. * @param scene defines the hosting scene
  62040. * @returns the tiled ground mesh
  62041. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62042. */
  62043. static CreateTiledGround(name: string, options: {
  62044. xmin: number;
  62045. zmin: number;
  62046. xmax: number;
  62047. zmax: number;
  62048. subdivisions?: {
  62049. w: number;
  62050. h: number;
  62051. };
  62052. precision?: {
  62053. w: number;
  62054. h: number;
  62055. };
  62056. updatable?: boolean;
  62057. }, scene?: Nullable<Scene>): Mesh;
  62058. /**
  62059. * Creates a ground mesh from a height map
  62060. * * The parameter `url` sets the URL of the height map image resource.
  62061. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62062. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62063. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62064. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62065. * * 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.
  62066. * * 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).
  62067. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62069. * @param name defines the name of the mesh
  62070. * @param url defines the url to the height map
  62071. * @param options defines the options used to create the mesh
  62072. * @param scene defines the hosting scene
  62073. * @returns the ground mesh
  62074. * @see https://doc.babylonjs.com/babylon101/height_map
  62075. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62076. */
  62077. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62078. width?: number;
  62079. height?: number;
  62080. subdivisions?: number;
  62081. minHeight?: number;
  62082. maxHeight?: number;
  62083. colorFilter?: Color3;
  62084. alphaFilter?: number;
  62085. updatable?: boolean;
  62086. onReady?: (mesh: GroundMesh) => void;
  62087. }, scene?: Nullable<Scene>): GroundMesh;
  62088. /**
  62089. * Creates a polygon mesh
  62090. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62091. * * 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
  62092. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62094. * * 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)
  62095. * * Remember you can only change the shape positions, not their number when updating a polygon
  62096. * @param name defines the name of the mesh
  62097. * @param options defines the options used to create the mesh
  62098. * @param scene defines the hosting scene
  62099. * @param earcutInjection can be used to inject your own earcut reference
  62100. * @returns the polygon mesh
  62101. */
  62102. static CreatePolygon(name: string, options: {
  62103. shape: Vector3[];
  62104. holes?: Vector3[][];
  62105. depth?: number;
  62106. faceUV?: Vector4[];
  62107. faceColors?: Color4[];
  62108. updatable?: boolean;
  62109. sideOrientation?: number;
  62110. frontUVs?: Vector4;
  62111. backUVs?: Vector4;
  62112. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62113. /**
  62114. * Creates an extruded polygon mesh, with depth in the Y direction.
  62115. * * 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)
  62116. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62117. * @param name defines the name of the mesh
  62118. * @param options defines the options used to create the mesh
  62119. * @param scene defines the hosting scene
  62120. * @param earcutInjection can be used to inject your own earcut reference
  62121. * @returns the polygon mesh
  62122. */
  62123. static ExtrudePolygon(name: string, options: {
  62124. shape: Vector3[];
  62125. holes?: Vector3[][];
  62126. depth?: number;
  62127. faceUV?: Vector4[];
  62128. faceColors?: Color4[];
  62129. updatable?: boolean;
  62130. sideOrientation?: number;
  62131. frontUVs?: Vector4;
  62132. backUVs?: Vector4;
  62133. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62134. /**
  62135. * Creates a tube mesh.
  62136. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62137. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62138. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62139. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62140. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62141. * * 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)
  62142. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62143. * * 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
  62144. * * 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
  62145. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62146. * * 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
  62147. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62149. * @param name defines the name of the mesh
  62150. * @param options defines the options used to create the mesh
  62151. * @param scene defines the hosting scene
  62152. * @returns the tube mesh
  62153. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62154. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62155. */
  62156. static CreateTube(name: string, options: {
  62157. path: Vector3[];
  62158. radius?: number;
  62159. tessellation?: number;
  62160. radiusFunction?: {
  62161. (i: number, distance: number): number;
  62162. };
  62163. cap?: number;
  62164. arc?: number;
  62165. updatable?: boolean;
  62166. sideOrientation?: number;
  62167. frontUVs?: Vector4;
  62168. backUVs?: Vector4;
  62169. instance?: Mesh;
  62170. invertUV?: boolean;
  62171. }, scene?: Nullable<Scene>): Mesh;
  62172. /**
  62173. * Creates a polyhedron mesh
  62174. * * 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
  62175. * * The parameter `size` (positive float, default 1) sets the polygon size
  62176. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62177. * * 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`
  62178. * * 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
  62179. * * 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)`)
  62180. * * 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
  62181. * * 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
  62182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62183. * * 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
  62184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62185. * @param name defines the name of the mesh
  62186. * @param options defines the options used to create the mesh
  62187. * @param scene defines the hosting scene
  62188. * @returns the polyhedron mesh
  62189. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62190. */
  62191. static CreatePolyhedron(name: string, options: {
  62192. type?: number;
  62193. size?: number;
  62194. sizeX?: number;
  62195. sizeY?: number;
  62196. sizeZ?: number;
  62197. custom?: any;
  62198. faceUV?: Vector4[];
  62199. faceColors?: Color4[];
  62200. flat?: boolean;
  62201. updatable?: boolean;
  62202. sideOrientation?: number;
  62203. frontUVs?: Vector4;
  62204. backUVs?: Vector4;
  62205. }, scene?: Nullable<Scene>): Mesh;
  62206. /**
  62207. * Creates a decal mesh.
  62208. * 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
  62209. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62210. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62211. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62212. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62213. * @param name defines the name of the mesh
  62214. * @param sourceMesh defines the mesh where the decal must be applied
  62215. * @param options defines the options used to create the mesh
  62216. * @param scene defines the hosting scene
  62217. * @returns the decal mesh
  62218. * @see https://doc.babylonjs.com/how_to/decals
  62219. */
  62220. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62221. position?: Vector3;
  62222. normal?: Vector3;
  62223. size?: Vector3;
  62224. angle?: number;
  62225. }): Mesh;
  62226. }
  62227. }
  62228. declare module BABYLON {
  62229. /**
  62230. * A simplifier interface for future simplification implementations
  62231. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62232. */
  62233. export interface ISimplifier {
  62234. /**
  62235. * Simplification of a given mesh according to the given settings.
  62236. * Since this requires computation, it is assumed that the function runs async.
  62237. * @param settings The settings of the simplification, including quality and distance
  62238. * @param successCallback A callback that will be called after the mesh was simplified.
  62239. * @param errorCallback in case of an error, this callback will be called. optional.
  62240. */
  62241. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62242. }
  62243. /**
  62244. * Expected simplification settings.
  62245. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62246. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62247. */
  62248. export interface ISimplificationSettings {
  62249. /**
  62250. * Gets or sets the expected quality
  62251. */
  62252. quality: number;
  62253. /**
  62254. * Gets or sets the distance when this optimized version should be used
  62255. */
  62256. distance: number;
  62257. /**
  62258. * Gets an already optimized mesh
  62259. */
  62260. optimizeMesh?: boolean;
  62261. }
  62262. /**
  62263. * Class used to specify simplification options
  62264. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62265. */
  62266. export class SimplificationSettings implements ISimplificationSettings {
  62267. /** expected quality */
  62268. quality: number;
  62269. /** distance when this optimized version should be used */
  62270. distance: number;
  62271. /** already optimized mesh */
  62272. optimizeMesh?: boolean | undefined;
  62273. /**
  62274. * Creates a SimplificationSettings
  62275. * @param quality expected quality
  62276. * @param distance distance when this optimized version should be used
  62277. * @param optimizeMesh already optimized mesh
  62278. */
  62279. constructor(
  62280. /** expected quality */
  62281. quality: number,
  62282. /** distance when this optimized version should be used */
  62283. distance: number,
  62284. /** already optimized mesh */
  62285. optimizeMesh?: boolean | undefined);
  62286. }
  62287. /**
  62288. * Interface used to define a simplification task
  62289. */
  62290. export interface ISimplificationTask {
  62291. /**
  62292. * Array of settings
  62293. */
  62294. settings: Array<ISimplificationSettings>;
  62295. /**
  62296. * Simplification type
  62297. */
  62298. simplificationType: SimplificationType;
  62299. /**
  62300. * Mesh to simplify
  62301. */
  62302. mesh: Mesh;
  62303. /**
  62304. * Callback called on success
  62305. */
  62306. successCallback?: () => void;
  62307. /**
  62308. * Defines if parallel processing can be used
  62309. */
  62310. parallelProcessing: boolean;
  62311. }
  62312. /**
  62313. * Queue used to order the simplification tasks
  62314. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62315. */
  62316. export class SimplificationQueue {
  62317. private _simplificationArray;
  62318. /**
  62319. * Gets a boolean indicating that the process is still running
  62320. */
  62321. running: boolean;
  62322. /**
  62323. * Creates a new queue
  62324. */
  62325. constructor();
  62326. /**
  62327. * Adds a new simplification task
  62328. * @param task defines a task to add
  62329. */
  62330. addTask(task: ISimplificationTask): void;
  62331. /**
  62332. * Execute next task
  62333. */
  62334. executeNext(): void;
  62335. /**
  62336. * Execute a simplification task
  62337. * @param task defines the task to run
  62338. */
  62339. runSimplification(task: ISimplificationTask): void;
  62340. private getSimplifier;
  62341. }
  62342. /**
  62343. * The implemented types of simplification
  62344. * At the moment only Quadratic Error Decimation is implemented
  62345. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62346. */
  62347. export enum SimplificationType {
  62348. /** Quadratic error decimation */
  62349. QUADRATIC = 0
  62350. }
  62351. /**
  62352. * An implementation of the Quadratic Error simplification algorithm.
  62353. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62354. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62355. * @author RaananW
  62356. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62357. */
  62358. export class QuadraticErrorSimplification implements ISimplifier {
  62359. private _mesh;
  62360. private triangles;
  62361. private vertices;
  62362. private references;
  62363. private _reconstructedMesh;
  62364. /** Gets or sets the number pf sync interations */
  62365. syncIterations: number;
  62366. /** Gets or sets the aggressiveness of the simplifier */
  62367. aggressiveness: number;
  62368. /** Gets or sets the number of allowed iterations for decimation */
  62369. decimationIterations: number;
  62370. /** Gets or sets the espilon to use for bounding box computation */
  62371. boundingBoxEpsilon: number;
  62372. /**
  62373. * Creates a new QuadraticErrorSimplification
  62374. * @param _mesh defines the target mesh
  62375. */
  62376. constructor(_mesh: Mesh);
  62377. /**
  62378. * Simplification of a given mesh according to the given settings.
  62379. * Since this requires computation, it is assumed that the function runs async.
  62380. * @param settings The settings of the simplification, including quality and distance
  62381. * @param successCallback A callback that will be called after the mesh was simplified.
  62382. */
  62383. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62384. private runDecimation;
  62385. private initWithMesh;
  62386. private init;
  62387. private reconstructMesh;
  62388. private initDecimatedMesh;
  62389. private isFlipped;
  62390. private updateTriangles;
  62391. private identifyBorder;
  62392. private updateMesh;
  62393. private vertexError;
  62394. private calculateError;
  62395. }
  62396. }
  62397. declare module BABYLON {
  62398. interface Scene {
  62399. /** @hidden (Backing field) */
  62400. _simplificationQueue: SimplificationQueue;
  62401. /**
  62402. * Gets or sets the simplification queue attached to the scene
  62403. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62404. */
  62405. simplificationQueue: SimplificationQueue;
  62406. }
  62407. interface Mesh {
  62408. /**
  62409. * Simplify the mesh according to the given array of settings.
  62410. * Function will return immediately and will simplify async
  62411. * @param settings a collection of simplification settings
  62412. * @param parallelProcessing should all levels calculate parallel or one after the other
  62413. * @param simplificationType the type of simplification to run
  62414. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62415. * @returns the current mesh
  62416. */
  62417. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62418. }
  62419. /**
  62420. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62421. * created in a scene
  62422. */
  62423. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62424. /**
  62425. * The component name helpfull to identify the component in the list of scene components.
  62426. */
  62427. readonly name: string;
  62428. /**
  62429. * The scene the component belongs to.
  62430. */
  62431. scene: Scene;
  62432. /**
  62433. * Creates a new instance of the component for the given scene
  62434. * @param scene Defines the scene to register the component in
  62435. */
  62436. constructor(scene: Scene);
  62437. /**
  62438. * Registers the component in a given scene
  62439. */
  62440. register(): void;
  62441. /**
  62442. * Rebuilds the elements related to this component in case of
  62443. * context lost for instance.
  62444. */
  62445. rebuild(): void;
  62446. /**
  62447. * Disposes the component and the associated ressources
  62448. */
  62449. dispose(): void;
  62450. private _beforeCameraUpdate;
  62451. }
  62452. }
  62453. declare module BABYLON {
  62454. /**
  62455. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62456. */
  62457. export interface INavigationEnginePlugin {
  62458. /**
  62459. * plugin name
  62460. */
  62461. name: string;
  62462. /**
  62463. * Creates a navigation mesh
  62464. * @param meshes array of all the geometry used to compute the navigatio mesh
  62465. * @param parameters bunch of parameters used to filter geometry
  62466. */
  62467. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62468. /**
  62469. * Create a navigation mesh debug mesh
  62470. * @param scene is where the mesh will be added
  62471. * @returns debug display mesh
  62472. */
  62473. createDebugNavMesh(scene: Scene): Mesh;
  62474. /**
  62475. * Get a navigation mesh constrained position, closest to the parameter position
  62476. * @param position world position
  62477. * @returns the closest point to position constrained by the navigation mesh
  62478. */
  62479. getClosestPoint(position: Vector3): Vector3;
  62480. /**
  62481. * Get a navigation mesh constrained position, closest to the parameter position
  62482. * @param position world position
  62483. * @param result output the closest point to position constrained by the navigation mesh
  62484. */
  62485. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62486. /**
  62487. * Get a navigation mesh constrained position, within a particular radius
  62488. * @param position world position
  62489. * @param maxRadius the maximum distance to the constrained world position
  62490. * @returns the closest point to position constrained by the navigation mesh
  62491. */
  62492. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62493. /**
  62494. * Get a navigation mesh constrained position, within a particular radius
  62495. * @param position world position
  62496. * @param maxRadius the maximum distance to the constrained world position
  62497. * @param result output the closest point to position constrained by the navigation mesh
  62498. */
  62499. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62500. /**
  62501. * Compute the final position from a segment made of destination-position
  62502. * @param position world position
  62503. * @param destination world position
  62504. * @returns the resulting point along the navmesh
  62505. */
  62506. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62507. /**
  62508. * Compute the final position from a segment made of destination-position
  62509. * @param position world position
  62510. * @param destination world position
  62511. * @param result output the resulting point along the navmesh
  62512. */
  62513. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62514. /**
  62515. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62516. * @param start world position
  62517. * @param end world position
  62518. * @returns array containing world position composing the path
  62519. */
  62520. computePath(start: Vector3, end: Vector3): Vector3[];
  62521. /**
  62522. * If this plugin is supported
  62523. * @returns true if plugin is supported
  62524. */
  62525. isSupported(): boolean;
  62526. /**
  62527. * Create a new Crowd so you can add agents
  62528. * @param maxAgents the maximum agent count in the crowd
  62529. * @param maxAgentRadius the maximum radius an agent can have
  62530. * @param scene to attach the crowd to
  62531. * @returns the crowd you can add agents to
  62532. */
  62533. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62534. /**
  62535. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62536. * The queries will try to find a solution within those bounds
  62537. * default is (1,1,1)
  62538. * @param extent x,y,z value that define the extent around the queries point of reference
  62539. */
  62540. setDefaultQueryExtent(extent: Vector3): void;
  62541. /**
  62542. * Get the Bounding box extent specified by setDefaultQueryExtent
  62543. * @returns the box extent values
  62544. */
  62545. getDefaultQueryExtent(): Vector3;
  62546. /**
  62547. * build the navmesh from a previously saved state using getNavmeshData
  62548. * @param data the Uint8Array returned by getNavmeshData
  62549. */
  62550. buildFromNavmeshData(data: Uint8Array): void;
  62551. /**
  62552. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62553. * @returns data the Uint8Array that can be saved and reused
  62554. */
  62555. getNavmeshData(): Uint8Array;
  62556. /**
  62557. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62558. * @param result output the box extent values
  62559. */
  62560. getDefaultQueryExtentToRef(result: Vector3): void;
  62561. /**
  62562. * Release all resources
  62563. */
  62564. dispose(): void;
  62565. }
  62566. /**
  62567. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62568. */
  62569. export interface ICrowd {
  62570. /**
  62571. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62572. * You can attach anything to that node. The node position is updated in the scene update tick.
  62573. * @param pos world position that will be constrained by the navigation mesh
  62574. * @param parameters agent parameters
  62575. * @param transform hooked to the agent that will be update by the scene
  62576. * @returns agent index
  62577. */
  62578. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62579. /**
  62580. * Returns the agent position in world space
  62581. * @param index agent index returned by addAgent
  62582. * @returns world space position
  62583. */
  62584. getAgentPosition(index: number): Vector3;
  62585. /**
  62586. * Gets the agent position result in world space
  62587. * @param index agent index returned by addAgent
  62588. * @param result output world space position
  62589. */
  62590. getAgentPositionToRef(index: number, result: Vector3): void;
  62591. /**
  62592. * Gets the agent velocity in world space
  62593. * @param index agent index returned by addAgent
  62594. * @returns world space velocity
  62595. */
  62596. getAgentVelocity(index: number): Vector3;
  62597. /**
  62598. * Gets the agent velocity result in world space
  62599. * @param index agent index returned by addAgent
  62600. * @param result output world space velocity
  62601. */
  62602. getAgentVelocityToRef(index: number, result: Vector3): void;
  62603. /**
  62604. * remove a particular agent previously created
  62605. * @param index agent index returned by addAgent
  62606. */
  62607. removeAgent(index: number): void;
  62608. /**
  62609. * get the list of all agents attached to this crowd
  62610. * @returns list of agent indices
  62611. */
  62612. getAgents(): number[];
  62613. /**
  62614. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62615. * @param deltaTime in seconds
  62616. */
  62617. update(deltaTime: number): void;
  62618. /**
  62619. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62620. * @param index agent index returned by addAgent
  62621. * @param destination targeted world position
  62622. */
  62623. agentGoto(index: number, destination: Vector3): void;
  62624. /**
  62625. * Teleport the agent to a new position
  62626. * @param index agent index returned by addAgent
  62627. * @param destination targeted world position
  62628. */
  62629. agentTeleport(index: number, destination: Vector3): void;
  62630. /**
  62631. * Update agent parameters
  62632. * @param index agent index returned by addAgent
  62633. * @param parameters agent parameters
  62634. */
  62635. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62636. /**
  62637. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62638. * The queries will try to find a solution within those bounds
  62639. * default is (1,1,1)
  62640. * @param extent x,y,z value that define the extent around the queries point of reference
  62641. */
  62642. setDefaultQueryExtent(extent: Vector3): void;
  62643. /**
  62644. * Get the Bounding box extent specified by setDefaultQueryExtent
  62645. * @returns the box extent values
  62646. */
  62647. getDefaultQueryExtent(): Vector3;
  62648. /**
  62649. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62650. * @param result output the box extent values
  62651. */
  62652. getDefaultQueryExtentToRef(result: Vector3): void;
  62653. /**
  62654. * Release all resources
  62655. */
  62656. dispose(): void;
  62657. }
  62658. /**
  62659. * Configures an agent
  62660. */
  62661. export interface IAgentParameters {
  62662. /**
  62663. * Agent radius. [Limit: >= 0]
  62664. */
  62665. radius: number;
  62666. /**
  62667. * Agent height. [Limit: > 0]
  62668. */
  62669. height: number;
  62670. /**
  62671. * Maximum allowed acceleration. [Limit: >= 0]
  62672. */
  62673. maxAcceleration: number;
  62674. /**
  62675. * Maximum allowed speed. [Limit: >= 0]
  62676. */
  62677. maxSpeed: number;
  62678. /**
  62679. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62680. */
  62681. collisionQueryRange: number;
  62682. /**
  62683. * The path visibility optimization range. [Limit: > 0]
  62684. */
  62685. pathOptimizationRange: number;
  62686. /**
  62687. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62688. */
  62689. separationWeight: number;
  62690. }
  62691. /**
  62692. * Configures the navigation mesh creation
  62693. */
  62694. export interface INavMeshParameters {
  62695. /**
  62696. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62697. */
  62698. cs: number;
  62699. /**
  62700. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62701. */
  62702. ch: number;
  62703. /**
  62704. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62705. */
  62706. walkableSlopeAngle: number;
  62707. /**
  62708. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62709. * be considered walkable. [Limit: >= 3] [Units: vx]
  62710. */
  62711. walkableHeight: number;
  62712. /**
  62713. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62714. */
  62715. walkableClimb: number;
  62716. /**
  62717. * The distance to erode/shrink the walkable area of the heightfield away from
  62718. * obstructions. [Limit: >=0] [Units: vx]
  62719. */
  62720. walkableRadius: number;
  62721. /**
  62722. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62723. */
  62724. maxEdgeLen: number;
  62725. /**
  62726. * The maximum distance a simplfied contour's border edges should deviate
  62727. * the original raw contour. [Limit: >=0] [Units: vx]
  62728. */
  62729. maxSimplificationError: number;
  62730. /**
  62731. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62732. */
  62733. minRegionArea: number;
  62734. /**
  62735. * Any regions with a span count smaller than this value will, if possible,
  62736. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62737. */
  62738. mergeRegionArea: number;
  62739. /**
  62740. * The maximum number of vertices allowed for polygons generated during the
  62741. * contour to polygon conversion process. [Limit: >= 3]
  62742. */
  62743. maxVertsPerPoly: number;
  62744. /**
  62745. * Sets the sampling distance to use when generating the detail mesh.
  62746. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62747. */
  62748. detailSampleDist: number;
  62749. /**
  62750. * The maximum distance the detail mesh surface should deviate from heightfield
  62751. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62752. */
  62753. detailSampleMaxError: number;
  62754. }
  62755. }
  62756. declare module BABYLON {
  62757. /**
  62758. * RecastJS navigation plugin
  62759. */
  62760. export class RecastJSPlugin implements INavigationEnginePlugin {
  62761. /**
  62762. * Reference to the Recast library
  62763. */
  62764. bjsRECAST: any;
  62765. /**
  62766. * plugin name
  62767. */
  62768. name: string;
  62769. /**
  62770. * the first navmesh created. We might extend this to support multiple navmeshes
  62771. */
  62772. navMesh: any;
  62773. /**
  62774. * Initializes the recastJS plugin
  62775. * @param recastInjection can be used to inject your own recast reference
  62776. */
  62777. constructor(recastInjection?: any);
  62778. /**
  62779. * Creates a navigation mesh
  62780. * @param meshes array of all the geometry used to compute the navigatio mesh
  62781. * @param parameters bunch of parameters used to filter geometry
  62782. */
  62783. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62784. /**
  62785. * Create a navigation mesh debug mesh
  62786. * @param scene is where the mesh will be added
  62787. * @returns debug display mesh
  62788. */
  62789. createDebugNavMesh(scene: Scene): Mesh;
  62790. /**
  62791. * Get a navigation mesh constrained position, closest to the parameter position
  62792. * @param position world position
  62793. * @returns the closest point to position constrained by the navigation mesh
  62794. */
  62795. getClosestPoint(position: Vector3): Vector3;
  62796. /**
  62797. * Get a navigation mesh constrained position, closest to the parameter position
  62798. * @param position world position
  62799. * @param result output the closest point to position constrained by the navigation mesh
  62800. */
  62801. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62802. /**
  62803. * Get a navigation mesh constrained position, within a particular radius
  62804. * @param position world position
  62805. * @param maxRadius the maximum distance to the constrained world position
  62806. * @returns the closest point to position constrained by the navigation mesh
  62807. */
  62808. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62809. /**
  62810. * Get a navigation mesh constrained position, within a particular radius
  62811. * @param position world position
  62812. * @param maxRadius the maximum distance to the constrained world position
  62813. * @param result output the closest point to position constrained by the navigation mesh
  62814. */
  62815. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62816. /**
  62817. * Compute the final position from a segment made of destination-position
  62818. * @param position world position
  62819. * @param destination world position
  62820. * @returns the resulting point along the navmesh
  62821. */
  62822. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62823. /**
  62824. * Compute the final position from a segment made of destination-position
  62825. * @param position world position
  62826. * @param destination world position
  62827. * @param result output the resulting point along the navmesh
  62828. */
  62829. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62830. /**
  62831. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62832. * @param start world position
  62833. * @param end world position
  62834. * @returns array containing world position composing the path
  62835. */
  62836. computePath(start: Vector3, end: Vector3): Vector3[];
  62837. /**
  62838. * Create a new Crowd so you can add agents
  62839. * @param maxAgents the maximum agent count in the crowd
  62840. * @param maxAgentRadius the maximum radius an agent can have
  62841. * @param scene to attach the crowd to
  62842. * @returns the crowd you can add agents to
  62843. */
  62844. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62845. /**
  62846. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62847. * The queries will try to find a solution within those bounds
  62848. * default is (1,1,1)
  62849. * @param extent x,y,z value that define the extent around the queries point of reference
  62850. */
  62851. setDefaultQueryExtent(extent: Vector3): void;
  62852. /**
  62853. * Get the Bounding box extent specified by setDefaultQueryExtent
  62854. * @returns the box extent values
  62855. */
  62856. getDefaultQueryExtent(): Vector3;
  62857. /**
  62858. * build the navmesh from a previously saved state using getNavmeshData
  62859. * @param data the Uint8Array returned by getNavmeshData
  62860. */
  62861. buildFromNavmeshData(data: Uint8Array): void;
  62862. /**
  62863. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62864. * @returns data the Uint8Array that can be saved and reused
  62865. */
  62866. getNavmeshData(): Uint8Array;
  62867. /**
  62868. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62869. * @param result output the box extent values
  62870. */
  62871. getDefaultQueryExtentToRef(result: Vector3): void;
  62872. /**
  62873. * Disposes
  62874. */
  62875. dispose(): void;
  62876. /**
  62877. * If this plugin is supported
  62878. * @returns true if plugin is supported
  62879. */
  62880. isSupported(): boolean;
  62881. }
  62882. /**
  62883. * Recast detour crowd implementation
  62884. */
  62885. export class RecastJSCrowd implements ICrowd {
  62886. /**
  62887. * Recast/detour plugin
  62888. */
  62889. bjsRECASTPlugin: RecastJSPlugin;
  62890. /**
  62891. * Link to the detour crowd
  62892. */
  62893. recastCrowd: any;
  62894. /**
  62895. * One transform per agent
  62896. */
  62897. transforms: TransformNode[];
  62898. /**
  62899. * All agents created
  62900. */
  62901. agents: number[];
  62902. /**
  62903. * Link to the scene is kept to unregister the crowd from the scene
  62904. */
  62905. private _scene;
  62906. /**
  62907. * Observer for crowd updates
  62908. */
  62909. private _onBeforeAnimationsObserver;
  62910. /**
  62911. * Constructor
  62912. * @param plugin recastJS plugin
  62913. * @param maxAgents the maximum agent count in the crowd
  62914. * @param maxAgentRadius the maximum radius an agent can have
  62915. * @param scene to attach the crowd to
  62916. * @returns the crowd you can add agents to
  62917. */
  62918. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62919. /**
  62920. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62921. * You can attach anything to that node. The node position is updated in the scene update tick.
  62922. * @param pos world position that will be constrained by the navigation mesh
  62923. * @param parameters agent parameters
  62924. * @param transform hooked to the agent that will be update by the scene
  62925. * @returns agent index
  62926. */
  62927. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62928. /**
  62929. * Returns the agent position in world space
  62930. * @param index agent index returned by addAgent
  62931. * @returns world space position
  62932. */
  62933. getAgentPosition(index: number): Vector3;
  62934. /**
  62935. * Returns the agent position result in world space
  62936. * @param index agent index returned by addAgent
  62937. * @param result output world space position
  62938. */
  62939. getAgentPositionToRef(index: number, result: Vector3): void;
  62940. /**
  62941. * Returns the agent velocity in world space
  62942. * @param index agent index returned by addAgent
  62943. * @returns world space velocity
  62944. */
  62945. getAgentVelocity(index: number): Vector3;
  62946. /**
  62947. * Returns the agent velocity result in world space
  62948. * @param index agent index returned by addAgent
  62949. * @param result output world space velocity
  62950. */
  62951. getAgentVelocityToRef(index: number, result: Vector3): void;
  62952. /**
  62953. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62954. * @param index agent index returned by addAgent
  62955. * @param destination targeted world position
  62956. */
  62957. agentGoto(index: number, destination: Vector3): void;
  62958. /**
  62959. * Teleport the agent to a new position
  62960. * @param index agent index returned by addAgent
  62961. * @param destination targeted world position
  62962. */
  62963. agentTeleport(index: number, destination: Vector3): void;
  62964. /**
  62965. * Update agent parameters
  62966. * @param index agent index returned by addAgent
  62967. * @param parameters agent parameters
  62968. */
  62969. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62970. /**
  62971. * remove a particular agent previously created
  62972. * @param index agent index returned by addAgent
  62973. */
  62974. removeAgent(index: number): void;
  62975. /**
  62976. * get the list of all agents attached to this crowd
  62977. * @returns list of agent indices
  62978. */
  62979. getAgents(): number[];
  62980. /**
  62981. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62982. * @param deltaTime in seconds
  62983. */
  62984. update(deltaTime: number): void;
  62985. /**
  62986. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62987. * The queries will try to find a solution within those bounds
  62988. * default is (1,1,1)
  62989. * @param extent x,y,z value that define the extent around the queries point of reference
  62990. */
  62991. setDefaultQueryExtent(extent: Vector3): void;
  62992. /**
  62993. * Get the Bounding box extent specified by setDefaultQueryExtent
  62994. * @returns the box extent values
  62995. */
  62996. getDefaultQueryExtent(): Vector3;
  62997. /**
  62998. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62999. * @param result output the box extent values
  63000. */
  63001. getDefaultQueryExtentToRef(result: Vector3): void;
  63002. /**
  63003. * Release all resources
  63004. */
  63005. dispose(): void;
  63006. }
  63007. }
  63008. declare module BABYLON {
  63009. /**
  63010. * Class used to enable access to IndexedDB
  63011. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63012. */
  63013. export class Database implements IOfflineProvider {
  63014. private _callbackManifestChecked;
  63015. private _currentSceneUrl;
  63016. private _db;
  63017. private _enableSceneOffline;
  63018. private _enableTexturesOffline;
  63019. private _manifestVersionFound;
  63020. private _mustUpdateRessources;
  63021. private _hasReachedQuota;
  63022. private _isSupported;
  63023. private _idbFactory;
  63024. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63025. private static IsUASupportingBlobStorage;
  63026. /**
  63027. * Gets a boolean indicating if Database storate is enabled (off by default)
  63028. */
  63029. static IDBStorageEnabled: boolean;
  63030. /**
  63031. * Gets a boolean indicating if scene must be saved in the database
  63032. */
  63033. get enableSceneOffline(): boolean;
  63034. /**
  63035. * Gets a boolean indicating if textures must be saved in the database
  63036. */
  63037. get enableTexturesOffline(): boolean;
  63038. /**
  63039. * Creates a new Database
  63040. * @param urlToScene defines the url to load the scene
  63041. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63042. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63043. */
  63044. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63045. private static _ParseURL;
  63046. private static _ReturnFullUrlLocation;
  63047. private _checkManifestFile;
  63048. /**
  63049. * Open the database and make it available
  63050. * @param successCallback defines the callback to call on success
  63051. * @param errorCallback defines the callback to call on error
  63052. */
  63053. open(successCallback: () => void, errorCallback: () => void): void;
  63054. /**
  63055. * Loads an image from the database
  63056. * @param url defines the url to load from
  63057. * @param image defines the target DOM image
  63058. */
  63059. loadImage(url: string, image: HTMLImageElement): void;
  63060. private _loadImageFromDBAsync;
  63061. private _saveImageIntoDBAsync;
  63062. private _checkVersionFromDB;
  63063. private _loadVersionFromDBAsync;
  63064. private _saveVersionIntoDBAsync;
  63065. /**
  63066. * Loads a file from database
  63067. * @param url defines the URL to load from
  63068. * @param sceneLoaded defines a callback to call on success
  63069. * @param progressCallBack defines a callback to call when progress changed
  63070. * @param errorCallback defines a callback to call on error
  63071. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63072. */
  63073. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63074. private _loadFileAsync;
  63075. private _saveFileAsync;
  63076. /**
  63077. * Validates if xhr data is correct
  63078. * @param xhr defines the request to validate
  63079. * @param dataType defines the expected data type
  63080. * @returns true if data is correct
  63081. */
  63082. private static _ValidateXHRData;
  63083. }
  63084. }
  63085. declare module BABYLON {
  63086. /** @hidden */
  63087. export var gpuUpdateParticlesPixelShader: {
  63088. name: string;
  63089. shader: string;
  63090. };
  63091. }
  63092. declare module BABYLON {
  63093. /** @hidden */
  63094. export var gpuUpdateParticlesVertexShader: {
  63095. name: string;
  63096. shader: string;
  63097. };
  63098. }
  63099. declare module BABYLON {
  63100. /** @hidden */
  63101. export var clipPlaneFragmentDeclaration2: {
  63102. name: string;
  63103. shader: string;
  63104. };
  63105. }
  63106. declare module BABYLON {
  63107. /** @hidden */
  63108. export var gpuRenderParticlesPixelShader: {
  63109. name: string;
  63110. shader: string;
  63111. };
  63112. }
  63113. declare module BABYLON {
  63114. /** @hidden */
  63115. export var clipPlaneVertexDeclaration2: {
  63116. name: string;
  63117. shader: string;
  63118. };
  63119. }
  63120. declare module BABYLON {
  63121. /** @hidden */
  63122. export var gpuRenderParticlesVertexShader: {
  63123. name: string;
  63124. shader: string;
  63125. };
  63126. }
  63127. declare module BABYLON {
  63128. /**
  63129. * This represents a GPU particle system in Babylon
  63130. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63131. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63132. */
  63133. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63134. /**
  63135. * The layer mask we are rendering the particles through.
  63136. */
  63137. layerMask: number;
  63138. private _capacity;
  63139. private _activeCount;
  63140. private _currentActiveCount;
  63141. private _accumulatedCount;
  63142. private _renderEffect;
  63143. private _updateEffect;
  63144. private _buffer0;
  63145. private _buffer1;
  63146. private _spriteBuffer;
  63147. private _updateVAO;
  63148. private _renderVAO;
  63149. private _targetIndex;
  63150. private _sourceBuffer;
  63151. private _targetBuffer;
  63152. private _engine;
  63153. private _currentRenderId;
  63154. private _started;
  63155. private _stopped;
  63156. private _timeDelta;
  63157. private _randomTexture;
  63158. private _randomTexture2;
  63159. private _attributesStrideSize;
  63160. private _updateEffectOptions;
  63161. private _randomTextureSize;
  63162. private _actualFrame;
  63163. private readonly _rawTextureWidth;
  63164. /**
  63165. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63166. */
  63167. static get IsSupported(): boolean;
  63168. /**
  63169. * An event triggered when the system is disposed.
  63170. */
  63171. onDisposeObservable: Observable<GPUParticleSystem>;
  63172. /**
  63173. * Gets the maximum number of particles active at the same time.
  63174. * @returns The max number of active particles.
  63175. */
  63176. getCapacity(): number;
  63177. /**
  63178. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63179. * to override the particles.
  63180. */
  63181. forceDepthWrite: boolean;
  63182. /**
  63183. * Gets or set the number of active particles
  63184. */
  63185. get activeParticleCount(): number;
  63186. set activeParticleCount(value: number);
  63187. private _preWarmDone;
  63188. /**
  63189. * Specifies if the particles are updated in emitter local space or world space.
  63190. * This is always false for GPU particles
  63191. */
  63192. get isLocal(): boolean;
  63193. set isLocal(value: boolean);
  63194. /**
  63195. * Is this system ready to be used/rendered
  63196. * @return true if the system is ready
  63197. */
  63198. isReady(): boolean;
  63199. /**
  63200. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63201. * @returns True if it has been started, otherwise false.
  63202. */
  63203. isStarted(): boolean;
  63204. /**
  63205. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63206. * @returns True if it has been stopped, otherwise false.
  63207. */
  63208. isStopped(): boolean;
  63209. /**
  63210. * Gets a boolean indicating that the system is stopping
  63211. * @returns true if the system is currently stopping
  63212. */
  63213. isStopping(): boolean;
  63214. /**
  63215. * Gets the number of particles active at the same time.
  63216. * @returns The number of active particles.
  63217. */
  63218. getActiveCount(): number;
  63219. /**
  63220. * Starts the particle system and begins to emit
  63221. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63222. */
  63223. start(delay?: number): void;
  63224. /**
  63225. * Stops the particle system.
  63226. */
  63227. stop(): void;
  63228. /**
  63229. * Remove all active particles
  63230. */
  63231. reset(): void;
  63232. /**
  63233. * Returns the string "GPUParticleSystem"
  63234. * @returns a string containing the class name
  63235. */
  63236. getClassName(): string;
  63237. private _colorGradientsTexture;
  63238. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63239. /**
  63240. * Adds a new color gradient
  63241. * @param gradient defines the gradient to use (between 0 and 1)
  63242. * @param color1 defines the color to affect to the specified gradient
  63243. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63244. * @returns the current particle system
  63245. */
  63246. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63247. private _refreshColorGradient;
  63248. /** Force the system to rebuild all gradients */
  63249. forceRefreshGradients(): void;
  63250. /**
  63251. * Remove a specific color gradient
  63252. * @param gradient defines the gradient to remove
  63253. * @returns the current particle system
  63254. */
  63255. removeColorGradient(gradient: number): GPUParticleSystem;
  63256. private _angularSpeedGradientsTexture;
  63257. private _sizeGradientsTexture;
  63258. private _velocityGradientsTexture;
  63259. private _limitVelocityGradientsTexture;
  63260. private _dragGradientsTexture;
  63261. private _addFactorGradient;
  63262. /**
  63263. * Adds a new size gradient
  63264. * @param gradient defines the gradient to use (between 0 and 1)
  63265. * @param factor defines the size factor to affect to the specified gradient
  63266. * @returns the current particle system
  63267. */
  63268. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63269. /**
  63270. * Remove a specific size gradient
  63271. * @param gradient defines the gradient to remove
  63272. * @returns the current particle system
  63273. */
  63274. removeSizeGradient(gradient: number): GPUParticleSystem;
  63275. private _refreshFactorGradient;
  63276. /**
  63277. * Adds a new angular speed gradient
  63278. * @param gradient defines the gradient to use (between 0 and 1)
  63279. * @param factor defines the angular speed to affect to the specified gradient
  63280. * @returns the current particle system
  63281. */
  63282. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63283. /**
  63284. * Remove a specific angular speed gradient
  63285. * @param gradient defines the gradient to remove
  63286. * @returns the current particle system
  63287. */
  63288. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63289. /**
  63290. * Adds a new velocity gradient
  63291. * @param gradient defines the gradient to use (between 0 and 1)
  63292. * @param factor defines the velocity to affect to the specified gradient
  63293. * @returns the current particle system
  63294. */
  63295. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63296. /**
  63297. * Remove a specific velocity gradient
  63298. * @param gradient defines the gradient to remove
  63299. * @returns the current particle system
  63300. */
  63301. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63302. /**
  63303. * Adds a new limit velocity gradient
  63304. * @param gradient defines the gradient to use (between 0 and 1)
  63305. * @param factor defines the limit velocity value to affect to the specified gradient
  63306. * @returns the current particle system
  63307. */
  63308. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63309. /**
  63310. * Remove a specific limit velocity gradient
  63311. * @param gradient defines the gradient to remove
  63312. * @returns the current particle system
  63313. */
  63314. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63315. /**
  63316. * Adds a new drag gradient
  63317. * @param gradient defines the gradient to use (between 0 and 1)
  63318. * @param factor defines the drag value to affect to the specified gradient
  63319. * @returns the current particle system
  63320. */
  63321. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63322. /**
  63323. * Remove a specific drag gradient
  63324. * @param gradient defines the gradient to remove
  63325. * @returns the current particle system
  63326. */
  63327. removeDragGradient(gradient: number): GPUParticleSystem;
  63328. /**
  63329. * Not supported by GPUParticleSystem
  63330. * @param gradient defines the gradient to use (between 0 and 1)
  63331. * @param factor defines the emit rate value to affect to the specified gradient
  63332. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63333. * @returns the current particle system
  63334. */
  63335. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63336. /**
  63337. * Not supported by GPUParticleSystem
  63338. * @param gradient defines the gradient to remove
  63339. * @returns the current particle system
  63340. */
  63341. removeEmitRateGradient(gradient: number): IParticleSystem;
  63342. /**
  63343. * Not supported by GPUParticleSystem
  63344. * @param gradient defines the gradient to use (between 0 and 1)
  63345. * @param factor defines the start size value to affect to the specified gradient
  63346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63347. * @returns the current particle system
  63348. */
  63349. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63350. /**
  63351. * Not supported by GPUParticleSystem
  63352. * @param gradient defines the gradient to remove
  63353. * @returns the current particle system
  63354. */
  63355. removeStartSizeGradient(gradient: number): IParticleSystem;
  63356. /**
  63357. * Not supported by GPUParticleSystem
  63358. * @param gradient defines the gradient to use (between 0 and 1)
  63359. * @param min defines the color remap minimal range
  63360. * @param max defines the color remap maximal range
  63361. * @returns the current particle system
  63362. */
  63363. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63364. /**
  63365. * Not supported by GPUParticleSystem
  63366. * @param gradient defines the gradient to remove
  63367. * @returns the current particle system
  63368. */
  63369. removeColorRemapGradient(): IParticleSystem;
  63370. /**
  63371. * Not supported by GPUParticleSystem
  63372. * @param gradient defines the gradient to use (between 0 and 1)
  63373. * @param min defines the alpha remap minimal range
  63374. * @param max defines the alpha remap maximal range
  63375. * @returns the current particle system
  63376. */
  63377. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63378. /**
  63379. * Not supported by GPUParticleSystem
  63380. * @param gradient defines the gradient to remove
  63381. * @returns the current particle system
  63382. */
  63383. removeAlphaRemapGradient(): IParticleSystem;
  63384. /**
  63385. * Not supported by GPUParticleSystem
  63386. * @param gradient defines the gradient to use (between 0 and 1)
  63387. * @param color defines the color to affect to the specified gradient
  63388. * @returns the current particle system
  63389. */
  63390. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63391. /**
  63392. * Not supported by GPUParticleSystem
  63393. * @param gradient defines the gradient to remove
  63394. * @returns the current particle system
  63395. */
  63396. removeRampGradient(): IParticleSystem;
  63397. /**
  63398. * Not supported by GPUParticleSystem
  63399. * @returns the list of ramp gradients
  63400. */
  63401. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63402. /**
  63403. * Not supported by GPUParticleSystem
  63404. * Gets or sets a boolean indicating that ramp gradients must be used
  63405. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63406. */
  63407. get useRampGradients(): boolean;
  63408. set useRampGradients(value: boolean);
  63409. /**
  63410. * Not supported by GPUParticleSystem
  63411. * @param gradient defines the gradient to use (between 0 and 1)
  63412. * @param factor defines the life time factor to affect to the specified gradient
  63413. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63414. * @returns the current particle system
  63415. */
  63416. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63417. /**
  63418. * Not supported by GPUParticleSystem
  63419. * @param gradient defines the gradient to remove
  63420. * @returns the current particle system
  63421. */
  63422. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63423. /**
  63424. * Instantiates a GPU particle system.
  63425. * 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.
  63426. * @param name The name of the particle system
  63427. * @param options The options used to create the system
  63428. * @param scene The scene the particle system belongs to
  63429. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63430. */
  63431. constructor(name: string, options: Partial<{
  63432. capacity: number;
  63433. randomTextureSize: number;
  63434. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63435. protected _reset(): void;
  63436. private _createUpdateVAO;
  63437. private _createRenderVAO;
  63438. private _initialize;
  63439. /** @hidden */
  63440. _recreateUpdateEffect(): void;
  63441. /** @hidden */
  63442. _recreateRenderEffect(): void;
  63443. /**
  63444. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63445. * @param preWarm defines if we are in the pre-warmimg phase
  63446. */
  63447. animate(preWarm?: boolean): void;
  63448. private _createFactorGradientTexture;
  63449. private _createSizeGradientTexture;
  63450. private _createAngularSpeedGradientTexture;
  63451. private _createVelocityGradientTexture;
  63452. private _createLimitVelocityGradientTexture;
  63453. private _createDragGradientTexture;
  63454. private _createColorGradientTexture;
  63455. /**
  63456. * Renders the particle system in its current state
  63457. * @param preWarm defines if the system should only update the particles but not render them
  63458. * @returns the current number of particles
  63459. */
  63460. render(preWarm?: boolean): number;
  63461. /**
  63462. * Rebuilds the particle system
  63463. */
  63464. rebuild(): void;
  63465. private _releaseBuffers;
  63466. private _releaseVAOs;
  63467. /**
  63468. * Disposes the particle system and free the associated resources
  63469. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63470. */
  63471. dispose(disposeTexture?: boolean): void;
  63472. /**
  63473. * Clones the particle system.
  63474. * @param name The name of the cloned object
  63475. * @param newEmitter The new emitter to use
  63476. * @returns the cloned particle system
  63477. */
  63478. clone(name: string, newEmitter: any): GPUParticleSystem;
  63479. /**
  63480. * Serializes the particle system to a JSON object.
  63481. * @returns the JSON object
  63482. */
  63483. serialize(): any;
  63484. /**
  63485. * Parses a JSON object to create a GPU particle system.
  63486. * @param parsedParticleSystem The JSON object to parse
  63487. * @param scene The scene to create the particle system in
  63488. * @param rootUrl The root url to use to load external dependencies like texture
  63489. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63490. * @returns the parsed GPU particle system
  63491. */
  63492. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63493. }
  63494. }
  63495. declare module BABYLON {
  63496. /**
  63497. * Represents a set of particle systems working together to create a specific effect
  63498. */
  63499. export class ParticleSystemSet implements IDisposable {
  63500. /**
  63501. * Gets or sets base Assets URL
  63502. */
  63503. static BaseAssetsUrl: string;
  63504. private _emitterCreationOptions;
  63505. private _emitterNode;
  63506. /**
  63507. * Gets the particle system list
  63508. */
  63509. systems: IParticleSystem[];
  63510. /**
  63511. * Gets the emitter node used with this set
  63512. */
  63513. get emitterNode(): Nullable<TransformNode>;
  63514. /**
  63515. * Creates a new emitter mesh as a sphere
  63516. * @param options defines the options used to create the sphere
  63517. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63518. * @param scene defines the hosting scene
  63519. */
  63520. setEmitterAsSphere(options: {
  63521. diameter: number;
  63522. segments: number;
  63523. color: Color3;
  63524. }, renderingGroupId: number, scene: Scene): void;
  63525. /**
  63526. * Starts all particle systems of the set
  63527. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63528. */
  63529. start(emitter?: AbstractMesh): void;
  63530. /**
  63531. * Release all associated resources
  63532. */
  63533. dispose(): void;
  63534. /**
  63535. * Serialize the set into a JSON compatible object
  63536. * @returns a JSON compatible representation of the set
  63537. */
  63538. serialize(): any;
  63539. /**
  63540. * Parse a new ParticleSystemSet from a serialized source
  63541. * @param data defines a JSON compatible representation of the set
  63542. * @param scene defines the hosting scene
  63543. * @param gpu defines if we want GPU particles or CPU particles
  63544. * @returns a new ParticleSystemSet
  63545. */
  63546. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63547. }
  63548. }
  63549. declare module BABYLON {
  63550. /**
  63551. * This class is made for on one-liner static method to help creating particle system set.
  63552. */
  63553. export class ParticleHelper {
  63554. /**
  63555. * Gets or sets base Assets URL
  63556. */
  63557. static BaseAssetsUrl: string;
  63558. /** Define the Url to load snippets */
  63559. static SnippetUrl: string;
  63560. /**
  63561. * Create a default particle system that you can tweak
  63562. * @param emitter defines the emitter to use
  63563. * @param capacity defines the system capacity (default is 500 particles)
  63564. * @param scene defines the hosting scene
  63565. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63566. * @returns the new Particle system
  63567. */
  63568. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63569. /**
  63570. * This is the main static method (one-liner) of this helper to create different particle systems
  63571. * @param type This string represents the type to the particle system to create
  63572. * @param scene The scene where the particle system should live
  63573. * @param gpu If the system will use gpu
  63574. * @returns the ParticleSystemSet created
  63575. */
  63576. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63577. /**
  63578. * Static function used to export a particle system to a ParticleSystemSet variable.
  63579. * Please note that the emitter shape is not exported
  63580. * @param systems defines the particle systems to export
  63581. * @returns the created particle system set
  63582. */
  63583. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63584. /**
  63585. * Creates a particle system from a snippet saved in a remote file
  63586. * @param name defines the name of the particle system to create
  63587. * @param url defines the url to load from
  63588. * @param scene defines the hosting scene
  63589. * @param gpu If the system will use gpu
  63590. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63591. * @returns a promise that will resolve to the new particle system
  63592. */
  63593. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63594. /**
  63595. * Creates a particle system from a snippet saved by the particle system editor
  63596. * @param snippetId defines the snippet to load
  63597. * @param scene defines the hosting scene
  63598. * @param gpu If the system will use gpu
  63599. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63600. * @returns a promise that will resolve to the new particle system
  63601. */
  63602. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63603. }
  63604. }
  63605. declare module BABYLON {
  63606. interface Engine {
  63607. /**
  63608. * Create an effect to use with particle systems.
  63609. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63610. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63611. * @param uniformsNames defines a list of attribute names
  63612. * @param samplers defines an array of string used to represent textures
  63613. * @param defines defines the string containing the defines to use to compile the shaders
  63614. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63615. * @param onCompiled defines a function to call when the effect creation is successful
  63616. * @param onError defines a function to call when the effect creation has failed
  63617. * @returns the new Effect
  63618. */
  63619. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63620. }
  63621. interface Mesh {
  63622. /**
  63623. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63624. * @returns an array of IParticleSystem
  63625. */
  63626. getEmittedParticleSystems(): IParticleSystem[];
  63627. /**
  63628. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63629. * @returns an array of IParticleSystem
  63630. */
  63631. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63632. }
  63633. /**
  63634. * @hidden
  63635. */
  63636. export var _IDoNeedToBeInTheBuild: number;
  63637. }
  63638. declare module BABYLON {
  63639. /** Defines the 4 color options */
  63640. export enum PointColor {
  63641. /** color value */
  63642. Color = 2,
  63643. /** uv value */
  63644. UV = 1,
  63645. /** random value */
  63646. Random = 0,
  63647. /** stated value */
  63648. Stated = 3
  63649. }
  63650. /**
  63651. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63652. * 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.
  63653. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63654. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63655. *
  63656. * Full documentation here : TO BE ENTERED
  63657. */
  63658. export class PointsCloudSystem implements IDisposable {
  63659. /**
  63660. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63661. * Example : var p = SPS.particles[i];
  63662. */
  63663. particles: CloudPoint[];
  63664. /**
  63665. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63666. */
  63667. nbParticles: number;
  63668. /**
  63669. * This a counter for your own usage. It's not set by any SPS functions.
  63670. */
  63671. counter: number;
  63672. /**
  63673. * The PCS name. This name is also given to the underlying mesh.
  63674. */
  63675. name: string;
  63676. /**
  63677. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63678. */
  63679. mesh: Mesh;
  63680. /**
  63681. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63682. * Please read :
  63683. */
  63684. vars: any;
  63685. /**
  63686. * @hidden
  63687. */
  63688. _size: number;
  63689. private _scene;
  63690. private _promises;
  63691. private _positions;
  63692. private _indices;
  63693. private _normals;
  63694. private _colors;
  63695. private _uvs;
  63696. private _indices32;
  63697. private _positions32;
  63698. private _colors32;
  63699. private _uvs32;
  63700. private _updatable;
  63701. private _isVisibilityBoxLocked;
  63702. private _alwaysVisible;
  63703. private _groups;
  63704. private _groupCounter;
  63705. private _computeParticleColor;
  63706. private _computeParticleTexture;
  63707. private _computeParticleRotation;
  63708. private _computeBoundingBox;
  63709. private _isReady;
  63710. /**
  63711. * Creates a PCS (Points Cloud System) object
  63712. * @param name (String) is the PCS name, this will be the underlying mesh name
  63713. * @param pointSize (number) is the size for each point
  63714. * @param scene (Scene) is the scene in which the PCS is added
  63715. * @param options defines the options of the PCS e.g.
  63716. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63717. */
  63718. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63719. updatable?: boolean;
  63720. });
  63721. /**
  63722. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63723. * If no points were added to the PCS, the returned mesh is just a single point.
  63724. * @returns a promise for the created mesh
  63725. */
  63726. buildMeshAsync(): Promise<Mesh>;
  63727. /**
  63728. * @hidden
  63729. */
  63730. private _buildMesh;
  63731. private _addParticle;
  63732. private _randomUnitVector;
  63733. private _getColorIndicesForCoord;
  63734. private _setPointsColorOrUV;
  63735. private _colorFromTexture;
  63736. private _calculateDensity;
  63737. /**
  63738. * Adds points to the PCS in random positions within a unit sphere
  63739. * @param nb (positive integer) the number of particles to be created from this model
  63740. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63741. * @returns the number of groups in the system
  63742. */
  63743. addPoints(nb: number, pointFunction?: any): number;
  63744. /**
  63745. * Adds points to the PCS from the surface of the model shape
  63746. * @param mesh is any Mesh object that will be used as a surface model for the points
  63747. * @param nb (positive integer) the number of particles to be created from this model
  63748. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63749. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63750. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63751. * @returns the number of groups in the system
  63752. */
  63753. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63754. /**
  63755. * Adds points to the PCS inside the model shape
  63756. * @param mesh is any Mesh object that will be used as a surface model for the points
  63757. * @param nb (positive integer) the number of particles to be created from this model
  63758. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63759. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63760. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63761. * @returns the number of groups in the system
  63762. */
  63763. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63764. /**
  63765. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63766. * This method calls `updateParticle()` for each particle of the SPS.
  63767. * For an animated SPS, it is usually called within the render loop.
  63768. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63769. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63770. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63771. * @returns the PCS.
  63772. */
  63773. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63774. /**
  63775. * Disposes the PCS.
  63776. */
  63777. dispose(): void;
  63778. /**
  63779. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63780. * doc :
  63781. * @returns the PCS.
  63782. */
  63783. refreshVisibleSize(): PointsCloudSystem;
  63784. /**
  63785. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63786. * @param size the size (float) of the visibility box
  63787. * note : this doesn't lock the PCS mesh bounding box.
  63788. * doc :
  63789. */
  63790. setVisibilityBox(size: number): void;
  63791. /**
  63792. * Gets whether the PCS is always visible or not
  63793. * doc :
  63794. */
  63795. get isAlwaysVisible(): boolean;
  63796. /**
  63797. * Sets the PCS as always visible or not
  63798. * doc :
  63799. */
  63800. set isAlwaysVisible(val: boolean);
  63801. /**
  63802. * Tells to `setParticles()` to compute the particle rotations or not
  63803. * Default value : false. The PCS is faster when it's set to false
  63804. * Note : particle rotations are only applied to parent particles
  63805. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63806. */
  63807. set computeParticleRotation(val: boolean);
  63808. /**
  63809. * Tells to `setParticles()` to compute the particle colors or not.
  63810. * Default value : true. The PCS is faster when it's set to false.
  63811. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63812. */
  63813. set computeParticleColor(val: boolean);
  63814. set computeParticleTexture(val: boolean);
  63815. /**
  63816. * Gets if `setParticles()` computes the particle colors or not.
  63817. * Default value : false. The PCS is faster when it's set to false.
  63818. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63819. */
  63820. get computeParticleColor(): boolean;
  63821. /**
  63822. * Gets if `setParticles()` computes the particle textures or not.
  63823. * Default value : false. The PCS is faster when it's set to false.
  63824. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63825. */
  63826. get computeParticleTexture(): boolean;
  63827. /**
  63828. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63829. */
  63830. set computeBoundingBox(val: boolean);
  63831. /**
  63832. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63833. */
  63834. get computeBoundingBox(): boolean;
  63835. /**
  63836. * This function does nothing. It may be overwritten to set all the particle first values.
  63837. * The PCS doesn't call this function, you may have to call it by your own.
  63838. * doc :
  63839. */
  63840. initParticles(): void;
  63841. /**
  63842. * This function does nothing. It may be overwritten to recycle a particle
  63843. * The PCS doesn't call this function, you can to call it
  63844. * doc :
  63845. * @param particle The particle to recycle
  63846. * @returns the recycled particle
  63847. */
  63848. recycleParticle(particle: CloudPoint): CloudPoint;
  63849. /**
  63850. * Updates a particle : this function should be overwritten by the user.
  63851. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63852. * doc :
  63853. * @example : just set a particle position or velocity and recycle conditions
  63854. * @param particle The particle to update
  63855. * @returns the updated particle
  63856. */
  63857. updateParticle(particle: CloudPoint): CloudPoint;
  63858. /**
  63859. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63860. * This does nothing and may be overwritten by the user.
  63861. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63862. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63863. * @param update the boolean update value actually passed to setParticles()
  63864. */
  63865. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63866. /**
  63867. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63868. * This will be passed three parameters.
  63869. * This does nothing and may be overwritten by the user.
  63870. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63871. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63872. * @param update the boolean update value actually passed to setParticles()
  63873. */
  63874. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63875. }
  63876. }
  63877. declare module BABYLON {
  63878. /**
  63879. * Represents one particle of a points cloud system.
  63880. */
  63881. export class CloudPoint {
  63882. /**
  63883. * particle global index
  63884. */
  63885. idx: number;
  63886. /**
  63887. * The color of the particle
  63888. */
  63889. color: Nullable<Color4>;
  63890. /**
  63891. * The world space position of the particle.
  63892. */
  63893. position: Vector3;
  63894. /**
  63895. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63896. */
  63897. rotation: Vector3;
  63898. /**
  63899. * The world space rotation quaternion of the particle.
  63900. */
  63901. rotationQuaternion: Nullable<Quaternion>;
  63902. /**
  63903. * The uv of the particle.
  63904. */
  63905. uv: Nullable<Vector2>;
  63906. /**
  63907. * The current speed of the particle.
  63908. */
  63909. velocity: Vector3;
  63910. /**
  63911. * The pivot point in the particle local space.
  63912. */
  63913. pivot: Vector3;
  63914. /**
  63915. * Must the particle be translated from its pivot point in its local space ?
  63916. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63917. * Default : false
  63918. */
  63919. translateFromPivot: boolean;
  63920. /**
  63921. * Index of this particle in the global "positions" array (Internal use)
  63922. * @hidden
  63923. */
  63924. _pos: number;
  63925. /**
  63926. * @hidden Index of this particle in the global "indices" array (Internal use)
  63927. */
  63928. _ind: number;
  63929. /**
  63930. * Group this particle belongs to
  63931. */
  63932. _group: PointsGroup;
  63933. /**
  63934. * Group id of this particle
  63935. */
  63936. groupId: number;
  63937. /**
  63938. * Index of the particle in its group id (Internal use)
  63939. */
  63940. idxInGroup: number;
  63941. /**
  63942. * @hidden Particle BoundingInfo object (Internal use)
  63943. */
  63944. _boundingInfo: BoundingInfo;
  63945. /**
  63946. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63947. */
  63948. _pcs: PointsCloudSystem;
  63949. /**
  63950. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63951. */
  63952. _stillInvisible: boolean;
  63953. /**
  63954. * @hidden Last computed particle rotation matrix
  63955. */
  63956. _rotationMatrix: number[];
  63957. /**
  63958. * Parent particle Id, if any.
  63959. * Default null.
  63960. */
  63961. parentId: Nullable<number>;
  63962. /**
  63963. * @hidden Internal global position in the PCS.
  63964. */
  63965. _globalPosition: Vector3;
  63966. /**
  63967. * Creates a Point Cloud object.
  63968. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63969. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63970. * @param group (PointsGroup) is the group the particle belongs to
  63971. * @param groupId (integer) is the group identifier in the PCS.
  63972. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63973. * @param pcs defines the PCS it is associated to
  63974. */
  63975. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63976. /**
  63977. * get point size
  63978. */
  63979. get size(): Vector3;
  63980. /**
  63981. * Set point size
  63982. */
  63983. set size(scale: Vector3);
  63984. /**
  63985. * Legacy support, changed quaternion to rotationQuaternion
  63986. */
  63987. get quaternion(): Nullable<Quaternion>;
  63988. /**
  63989. * Legacy support, changed quaternion to rotationQuaternion
  63990. */
  63991. set quaternion(q: Nullable<Quaternion>);
  63992. /**
  63993. * Returns a boolean. True if the particle intersects a mesh, else false
  63994. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63995. * @param target is the object (point or mesh) what the intersection is computed against
  63996. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63997. * @returns true if it intersects
  63998. */
  63999. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64000. /**
  64001. * get the rotation matrix of the particle
  64002. * @hidden
  64003. */
  64004. getRotationMatrix(m: Matrix): void;
  64005. }
  64006. /**
  64007. * Represents a group of points in a points cloud system
  64008. * * PCS internal tool, don't use it manually.
  64009. */
  64010. export class PointsGroup {
  64011. /**
  64012. * The group id
  64013. * @hidden
  64014. */
  64015. groupID: number;
  64016. /**
  64017. * image data for group (internal use)
  64018. * @hidden
  64019. */
  64020. _groupImageData: Nullable<ArrayBufferView>;
  64021. /**
  64022. * Image Width (internal use)
  64023. * @hidden
  64024. */
  64025. _groupImgWidth: number;
  64026. /**
  64027. * Image Height (internal use)
  64028. * @hidden
  64029. */
  64030. _groupImgHeight: number;
  64031. /**
  64032. * Custom position function (internal use)
  64033. * @hidden
  64034. */
  64035. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64036. /**
  64037. * density per facet for surface points
  64038. * @hidden
  64039. */
  64040. _groupDensity: number[];
  64041. /**
  64042. * Only when points are colored by texture carries pointer to texture list array
  64043. * @hidden
  64044. */
  64045. _textureNb: number;
  64046. /**
  64047. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64048. * PCS internal tool, don't use it manually.
  64049. * @hidden
  64050. */
  64051. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64052. }
  64053. }
  64054. declare module BABYLON {
  64055. /**
  64056. * Represents a set of particle systems working together to create a specific effect
  64057. */
  64058. export class ParticleSystemDebugger implements IDisposable {
  64059. /**
  64060. * Defines the particle system to debug
  64061. */
  64062. system: IParticleSystem;
  64063. /**
  64064. * Creates a new particle system debugger
  64065. * @param system defines the particle system to debug
  64066. */
  64067. constructor(
  64068. /**
  64069. * Defines the particle system to debug
  64070. */
  64071. system: IParticleSystem);
  64072. /** Clear all the resources */
  64073. dispose(): void;
  64074. }
  64075. }
  64076. declare module BABYLON {
  64077. interface Scene {
  64078. /** @hidden (Backing field) */
  64079. _physicsEngine: Nullable<IPhysicsEngine>;
  64080. /** @hidden */
  64081. _physicsTimeAccumulator: number;
  64082. /**
  64083. * Gets the current physics engine
  64084. * @returns a IPhysicsEngine or null if none attached
  64085. */
  64086. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64087. /**
  64088. * Enables physics to the current scene
  64089. * @param gravity defines the scene's gravity for the physics engine
  64090. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64091. * @return a boolean indicating if the physics engine was initialized
  64092. */
  64093. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64094. /**
  64095. * Disables and disposes the physics engine associated with the scene
  64096. */
  64097. disablePhysicsEngine(): void;
  64098. /**
  64099. * Gets a boolean indicating if there is an active physics engine
  64100. * @returns a boolean indicating if there is an active physics engine
  64101. */
  64102. isPhysicsEnabled(): boolean;
  64103. /**
  64104. * Deletes a physics compound impostor
  64105. * @param compound defines the compound to delete
  64106. */
  64107. deleteCompoundImpostor(compound: any): void;
  64108. /**
  64109. * An event triggered when physic simulation is about to be run
  64110. */
  64111. onBeforePhysicsObservable: Observable<Scene>;
  64112. /**
  64113. * An event triggered when physic simulation has been done
  64114. */
  64115. onAfterPhysicsObservable: Observable<Scene>;
  64116. }
  64117. interface AbstractMesh {
  64118. /** @hidden */
  64119. _physicsImpostor: Nullable<PhysicsImpostor>;
  64120. /**
  64121. * Gets or sets impostor used for physic simulation
  64122. * @see http://doc.babylonjs.com/features/physics_engine
  64123. */
  64124. physicsImpostor: Nullable<PhysicsImpostor>;
  64125. /**
  64126. * Gets the current physics impostor
  64127. * @see http://doc.babylonjs.com/features/physics_engine
  64128. * @returns a physics impostor or null
  64129. */
  64130. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64131. /** Apply a physic impulse to the mesh
  64132. * @param force defines the force to apply
  64133. * @param contactPoint defines where to apply the force
  64134. * @returns the current mesh
  64135. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64136. */
  64137. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64138. /**
  64139. * Creates a physic joint between two meshes
  64140. * @param otherMesh defines the other mesh to use
  64141. * @param pivot1 defines the pivot to use on this mesh
  64142. * @param pivot2 defines the pivot to use on the other mesh
  64143. * @param options defines additional options (can be plugin dependent)
  64144. * @returns the current mesh
  64145. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64146. */
  64147. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64148. /** @hidden */
  64149. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64150. }
  64151. /**
  64152. * Defines the physics engine scene component responsible to manage a physics engine
  64153. */
  64154. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64155. /**
  64156. * The component name helpful to identify the component in the list of scene components.
  64157. */
  64158. readonly name: string;
  64159. /**
  64160. * The scene the component belongs to.
  64161. */
  64162. scene: Scene;
  64163. /**
  64164. * Creates a new instance of the component for the given scene
  64165. * @param scene Defines the scene to register the component in
  64166. */
  64167. constructor(scene: Scene);
  64168. /**
  64169. * Registers the component in a given scene
  64170. */
  64171. register(): void;
  64172. /**
  64173. * Rebuilds the elements related to this component in case of
  64174. * context lost for instance.
  64175. */
  64176. rebuild(): void;
  64177. /**
  64178. * Disposes the component and the associated ressources
  64179. */
  64180. dispose(): void;
  64181. }
  64182. }
  64183. declare module BABYLON {
  64184. /**
  64185. * A helper for physics simulations
  64186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64187. */
  64188. export class PhysicsHelper {
  64189. private _scene;
  64190. private _physicsEngine;
  64191. /**
  64192. * Initializes the Physics helper
  64193. * @param scene Babylon.js scene
  64194. */
  64195. constructor(scene: Scene);
  64196. /**
  64197. * Applies a radial explosion impulse
  64198. * @param origin the origin of the explosion
  64199. * @param radiusOrEventOptions the radius or the options of radial explosion
  64200. * @param strength the explosion strength
  64201. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64202. * @returns A physics radial explosion event, or null
  64203. */
  64204. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64205. /**
  64206. * Applies a radial explosion force
  64207. * @param origin the origin of the explosion
  64208. * @param radiusOrEventOptions the radius or the options of radial explosion
  64209. * @param strength the explosion strength
  64210. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64211. * @returns A physics radial explosion event, or null
  64212. */
  64213. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64214. /**
  64215. * Creates a gravitational field
  64216. * @param origin the origin of the explosion
  64217. * @param radiusOrEventOptions the radius or the options of radial explosion
  64218. * @param strength the explosion strength
  64219. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64220. * @returns A physics gravitational field event, or null
  64221. */
  64222. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64223. /**
  64224. * Creates a physics updraft event
  64225. * @param origin the origin of the updraft
  64226. * @param radiusOrEventOptions the radius or the options of the updraft
  64227. * @param strength the strength of the updraft
  64228. * @param height the height of the updraft
  64229. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64230. * @returns A physics updraft event, or null
  64231. */
  64232. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64233. /**
  64234. * Creates a physics vortex event
  64235. * @param origin the of the vortex
  64236. * @param radiusOrEventOptions the radius or the options of the vortex
  64237. * @param strength the strength of the vortex
  64238. * @param height the height of the vortex
  64239. * @returns a Physics vortex event, or null
  64240. * A physics vortex event or null
  64241. */
  64242. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64243. }
  64244. /**
  64245. * Represents a physics radial explosion event
  64246. */
  64247. class PhysicsRadialExplosionEvent {
  64248. private _scene;
  64249. private _options;
  64250. private _sphere;
  64251. private _dataFetched;
  64252. /**
  64253. * Initializes a radial explosioin event
  64254. * @param _scene BabylonJS scene
  64255. * @param _options The options for the vortex event
  64256. */
  64257. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64258. /**
  64259. * Returns the data related to the radial explosion event (sphere).
  64260. * @returns The radial explosion event data
  64261. */
  64262. getData(): PhysicsRadialExplosionEventData;
  64263. /**
  64264. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64265. * @param impostor A physics imposter
  64266. * @param origin the origin of the explosion
  64267. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64268. */
  64269. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64270. /**
  64271. * Triggers affecterd impostors callbacks
  64272. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64273. */
  64274. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64275. /**
  64276. * Disposes the sphere.
  64277. * @param force Specifies if the sphere should be disposed by force
  64278. */
  64279. dispose(force?: boolean): void;
  64280. /*** Helpers ***/
  64281. private _prepareSphere;
  64282. private _intersectsWithSphere;
  64283. }
  64284. /**
  64285. * Represents a gravitational field event
  64286. */
  64287. class PhysicsGravitationalFieldEvent {
  64288. private _physicsHelper;
  64289. private _scene;
  64290. private _origin;
  64291. private _options;
  64292. private _tickCallback;
  64293. private _sphere;
  64294. private _dataFetched;
  64295. /**
  64296. * Initializes the physics gravitational field event
  64297. * @param _physicsHelper A physics helper
  64298. * @param _scene BabylonJS scene
  64299. * @param _origin The origin position of the gravitational field event
  64300. * @param _options The options for the vortex event
  64301. */
  64302. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64303. /**
  64304. * Returns the data related to the gravitational field event (sphere).
  64305. * @returns A gravitational field event
  64306. */
  64307. getData(): PhysicsGravitationalFieldEventData;
  64308. /**
  64309. * Enables the gravitational field.
  64310. */
  64311. enable(): void;
  64312. /**
  64313. * Disables the gravitational field.
  64314. */
  64315. disable(): void;
  64316. /**
  64317. * Disposes the sphere.
  64318. * @param force The force to dispose from the gravitational field event
  64319. */
  64320. dispose(force?: boolean): void;
  64321. private _tick;
  64322. }
  64323. /**
  64324. * Represents a physics updraft event
  64325. */
  64326. class PhysicsUpdraftEvent {
  64327. private _scene;
  64328. private _origin;
  64329. private _options;
  64330. private _physicsEngine;
  64331. private _originTop;
  64332. private _originDirection;
  64333. private _tickCallback;
  64334. private _cylinder;
  64335. private _cylinderPosition;
  64336. private _dataFetched;
  64337. /**
  64338. * Initializes the physics updraft event
  64339. * @param _scene BabylonJS scene
  64340. * @param _origin The origin position of the updraft
  64341. * @param _options The options for the updraft event
  64342. */
  64343. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64344. /**
  64345. * Returns the data related to the updraft event (cylinder).
  64346. * @returns A physics updraft event
  64347. */
  64348. getData(): PhysicsUpdraftEventData;
  64349. /**
  64350. * Enables the updraft.
  64351. */
  64352. enable(): void;
  64353. /**
  64354. * Disables the updraft.
  64355. */
  64356. disable(): void;
  64357. /**
  64358. * Disposes the cylinder.
  64359. * @param force Specifies if the updraft should be disposed by force
  64360. */
  64361. dispose(force?: boolean): void;
  64362. private getImpostorHitData;
  64363. private _tick;
  64364. /*** Helpers ***/
  64365. private _prepareCylinder;
  64366. private _intersectsWithCylinder;
  64367. }
  64368. /**
  64369. * Represents a physics vortex event
  64370. */
  64371. class PhysicsVortexEvent {
  64372. private _scene;
  64373. private _origin;
  64374. private _options;
  64375. private _physicsEngine;
  64376. private _originTop;
  64377. private _tickCallback;
  64378. private _cylinder;
  64379. private _cylinderPosition;
  64380. private _dataFetched;
  64381. /**
  64382. * Initializes the physics vortex event
  64383. * @param _scene The BabylonJS scene
  64384. * @param _origin The origin position of the vortex
  64385. * @param _options The options for the vortex event
  64386. */
  64387. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64388. /**
  64389. * Returns the data related to the vortex event (cylinder).
  64390. * @returns The physics vortex event data
  64391. */
  64392. getData(): PhysicsVortexEventData;
  64393. /**
  64394. * Enables the vortex.
  64395. */
  64396. enable(): void;
  64397. /**
  64398. * Disables the cortex.
  64399. */
  64400. disable(): void;
  64401. /**
  64402. * Disposes the sphere.
  64403. * @param force
  64404. */
  64405. dispose(force?: boolean): void;
  64406. private getImpostorHitData;
  64407. private _tick;
  64408. /*** Helpers ***/
  64409. private _prepareCylinder;
  64410. private _intersectsWithCylinder;
  64411. }
  64412. /**
  64413. * Options fot the radial explosion event
  64414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64415. */
  64416. export class PhysicsRadialExplosionEventOptions {
  64417. /**
  64418. * The radius of the sphere for the radial explosion.
  64419. */
  64420. radius: number;
  64421. /**
  64422. * The strenth of the explosion.
  64423. */
  64424. strength: number;
  64425. /**
  64426. * The strenght of the force in correspondence to the distance of the affected object
  64427. */
  64428. falloff: PhysicsRadialImpulseFalloff;
  64429. /**
  64430. * Sphere options for the radial explosion.
  64431. */
  64432. sphere: {
  64433. segments: number;
  64434. diameter: number;
  64435. };
  64436. /**
  64437. * Sphere options for the radial explosion.
  64438. */
  64439. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64440. }
  64441. /**
  64442. * Options fot the updraft event
  64443. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64444. */
  64445. export class PhysicsUpdraftEventOptions {
  64446. /**
  64447. * The radius of the cylinder for the vortex
  64448. */
  64449. radius: number;
  64450. /**
  64451. * The strenth of the updraft.
  64452. */
  64453. strength: number;
  64454. /**
  64455. * The height of the cylinder for the updraft.
  64456. */
  64457. height: number;
  64458. /**
  64459. * The mode for the the updraft.
  64460. */
  64461. updraftMode: PhysicsUpdraftMode;
  64462. }
  64463. /**
  64464. * Options fot the vortex event
  64465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64466. */
  64467. export class PhysicsVortexEventOptions {
  64468. /**
  64469. * The radius of the cylinder for the vortex
  64470. */
  64471. radius: number;
  64472. /**
  64473. * The strenth of the vortex.
  64474. */
  64475. strength: number;
  64476. /**
  64477. * The height of the cylinder for the vortex.
  64478. */
  64479. height: number;
  64480. /**
  64481. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64482. */
  64483. centripetalForceThreshold: number;
  64484. /**
  64485. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64486. */
  64487. centripetalForceMultiplier: number;
  64488. /**
  64489. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64490. */
  64491. centrifugalForceMultiplier: number;
  64492. /**
  64493. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64494. */
  64495. updraftForceMultiplier: number;
  64496. }
  64497. /**
  64498. * The strenght of the force in correspondence to the distance of the affected object
  64499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64500. */
  64501. export enum PhysicsRadialImpulseFalloff {
  64502. /** Defines that impulse is constant in strength across it's whole radius */
  64503. Constant = 0,
  64504. /** Defines that impulse gets weaker if it's further from the origin */
  64505. Linear = 1
  64506. }
  64507. /**
  64508. * The strength of the force in correspondence to the distance of the affected object
  64509. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64510. */
  64511. export enum PhysicsUpdraftMode {
  64512. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64513. Center = 0,
  64514. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64515. Perpendicular = 1
  64516. }
  64517. /**
  64518. * Interface for a physics hit data
  64519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64520. */
  64521. export interface PhysicsHitData {
  64522. /**
  64523. * The force applied at the contact point
  64524. */
  64525. force: Vector3;
  64526. /**
  64527. * The contact point
  64528. */
  64529. contactPoint: Vector3;
  64530. /**
  64531. * The distance from the origin to the contact point
  64532. */
  64533. distanceFromOrigin: number;
  64534. }
  64535. /**
  64536. * Interface for radial explosion event data
  64537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64538. */
  64539. export interface PhysicsRadialExplosionEventData {
  64540. /**
  64541. * A sphere used for the radial explosion event
  64542. */
  64543. sphere: Mesh;
  64544. }
  64545. /**
  64546. * Interface for gravitational field event data
  64547. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64548. */
  64549. export interface PhysicsGravitationalFieldEventData {
  64550. /**
  64551. * A sphere mesh used for the gravitational field event
  64552. */
  64553. sphere: Mesh;
  64554. }
  64555. /**
  64556. * Interface for updraft event data
  64557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64558. */
  64559. export interface PhysicsUpdraftEventData {
  64560. /**
  64561. * A cylinder used for the updraft event
  64562. */
  64563. cylinder: Mesh;
  64564. }
  64565. /**
  64566. * Interface for vortex event data
  64567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64568. */
  64569. export interface PhysicsVortexEventData {
  64570. /**
  64571. * A cylinder used for the vortex event
  64572. */
  64573. cylinder: Mesh;
  64574. }
  64575. /**
  64576. * Interface for an affected physics impostor
  64577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64578. */
  64579. export interface PhysicsAffectedImpostorWithData {
  64580. /**
  64581. * The impostor affected by the effect
  64582. */
  64583. impostor: PhysicsImpostor;
  64584. /**
  64585. * The data about the hit/horce from the explosion
  64586. */
  64587. hitData: PhysicsHitData;
  64588. }
  64589. }
  64590. declare module BABYLON {
  64591. /** @hidden */
  64592. export var blackAndWhitePixelShader: {
  64593. name: string;
  64594. shader: string;
  64595. };
  64596. }
  64597. declare module BABYLON {
  64598. /**
  64599. * Post process used to render in black and white
  64600. */
  64601. export class BlackAndWhitePostProcess extends PostProcess {
  64602. /**
  64603. * Linear about to convert he result to black and white (default: 1)
  64604. */
  64605. degree: number;
  64606. /**
  64607. * Creates a black and white post process
  64608. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64609. * @param name The name of the effect.
  64610. * @param options The required width/height ratio to downsize to before computing the render pass.
  64611. * @param camera The camera to apply the render pass to.
  64612. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64613. * @param engine The engine which the post process will be applied. (default: current engine)
  64614. * @param reusable If the post process can be reused on the same frame. (default: false)
  64615. */
  64616. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64617. }
  64618. }
  64619. declare module BABYLON {
  64620. /**
  64621. * This represents a set of one or more post processes in Babylon.
  64622. * A post process can be used to apply a shader to a texture after it is rendered.
  64623. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64624. */
  64625. export class PostProcessRenderEffect {
  64626. private _postProcesses;
  64627. private _getPostProcesses;
  64628. private _singleInstance;
  64629. private _cameras;
  64630. private _indicesForCamera;
  64631. /**
  64632. * Name of the effect
  64633. * @hidden
  64634. */
  64635. _name: string;
  64636. /**
  64637. * Instantiates a post process render effect.
  64638. * A post process can be used to apply a shader to a texture after it is rendered.
  64639. * @param engine The engine the effect is tied to
  64640. * @param name The name of the effect
  64641. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64642. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64643. */
  64644. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64645. /**
  64646. * Checks if all the post processes in the effect are supported.
  64647. */
  64648. get isSupported(): boolean;
  64649. /**
  64650. * Updates the current state of the effect
  64651. * @hidden
  64652. */
  64653. _update(): void;
  64654. /**
  64655. * Attaches the effect on cameras
  64656. * @param cameras The camera to attach to.
  64657. * @hidden
  64658. */
  64659. _attachCameras(cameras: Camera): void;
  64660. /**
  64661. * Attaches the effect on cameras
  64662. * @param cameras The camera to attach to.
  64663. * @hidden
  64664. */
  64665. _attachCameras(cameras: Camera[]): void;
  64666. /**
  64667. * Detaches the effect on cameras
  64668. * @param cameras The camera to detatch from.
  64669. * @hidden
  64670. */
  64671. _detachCameras(cameras: Camera): void;
  64672. /**
  64673. * Detatches the effect on cameras
  64674. * @param cameras The camera to detatch from.
  64675. * @hidden
  64676. */
  64677. _detachCameras(cameras: Camera[]): void;
  64678. /**
  64679. * Enables the effect on given cameras
  64680. * @param cameras The camera to enable.
  64681. * @hidden
  64682. */
  64683. _enable(cameras: Camera): void;
  64684. /**
  64685. * Enables the effect on given cameras
  64686. * @param cameras The camera to enable.
  64687. * @hidden
  64688. */
  64689. _enable(cameras: Nullable<Camera[]>): void;
  64690. /**
  64691. * Disables the effect on the given cameras
  64692. * @param cameras The camera to disable.
  64693. * @hidden
  64694. */
  64695. _disable(cameras: Camera): void;
  64696. /**
  64697. * Disables the effect on the given cameras
  64698. * @param cameras The camera to disable.
  64699. * @hidden
  64700. */
  64701. _disable(cameras: Nullable<Camera[]>): void;
  64702. /**
  64703. * Gets a list of the post processes contained in the effect.
  64704. * @param camera The camera to get the post processes on.
  64705. * @returns The list of the post processes in the effect.
  64706. */
  64707. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64708. }
  64709. }
  64710. declare module BABYLON {
  64711. /** @hidden */
  64712. export var extractHighlightsPixelShader: {
  64713. name: string;
  64714. shader: string;
  64715. };
  64716. }
  64717. declare module BABYLON {
  64718. /**
  64719. * 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.
  64720. */
  64721. export class ExtractHighlightsPostProcess extends PostProcess {
  64722. /**
  64723. * The luminance threshold, pixels below this value will be set to black.
  64724. */
  64725. threshold: number;
  64726. /** @hidden */
  64727. _exposure: number;
  64728. /**
  64729. * Post process which has the input texture to be used when performing highlight extraction
  64730. * @hidden
  64731. */
  64732. _inputPostProcess: Nullable<PostProcess>;
  64733. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64734. }
  64735. }
  64736. declare module BABYLON {
  64737. /** @hidden */
  64738. export var bloomMergePixelShader: {
  64739. name: string;
  64740. shader: string;
  64741. };
  64742. }
  64743. declare module BABYLON {
  64744. /**
  64745. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64746. */
  64747. export class BloomMergePostProcess extends PostProcess {
  64748. /** Weight of the bloom to be added to the original input. */
  64749. weight: number;
  64750. /**
  64751. * Creates a new instance of @see BloomMergePostProcess
  64752. * @param name The name of the effect.
  64753. * @param originalFromInput Post process which's input will be used for the merge.
  64754. * @param blurred Blurred highlights post process which's output will be used.
  64755. * @param weight Weight of the bloom to be added to the original input.
  64756. * @param options The required width/height ratio to downsize to before computing the render pass.
  64757. * @param camera The camera to apply the render pass to.
  64758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64759. * @param engine The engine which the post process will be applied. (default: current engine)
  64760. * @param reusable If the post process can be reused on the same frame. (default: false)
  64761. * @param textureType Type of textures used when performing the post process. (default: 0)
  64762. * @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)
  64763. */
  64764. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64765. /** Weight of the bloom to be added to the original input. */
  64766. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64767. }
  64768. }
  64769. declare module BABYLON {
  64770. /**
  64771. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64772. */
  64773. export class BloomEffect extends PostProcessRenderEffect {
  64774. private bloomScale;
  64775. /**
  64776. * @hidden Internal
  64777. */
  64778. _effects: Array<PostProcess>;
  64779. /**
  64780. * @hidden Internal
  64781. */
  64782. _downscale: ExtractHighlightsPostProcess;
  64783. private _blurX;
  64784. private _blurY;
  64785. private _merge;
  64786. /**
  64787. * The luminance threshold to find bright areas of the image to bloom.
  64788. */
  64789. get threshold(): number;
  64790. set threshold(value: number);
  64791. /**
  64792. * The strength of the bloom.
  64793. */
  64794. get weight(): number;
  64795. set weight(value: number);
  64796. /**
  64797. * Specifies the size of the bloom blur kernel, relative to the final output size
  64798. */
  64799. get kernel(): number;
  64800. set kernel(value: number);
  64801. /**
  64802. * Creates a new instance of @see BloomEffect
  64803. * @param scene The scene the effect belongs to.
  64804. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64805. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64806. * @param bloomWeight The the strength of bloom.
  64807. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64808. * @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)
  64809. */
  64810. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64811. /**
  64812. * Disposes each of the internal effects for a given camera.
  64813. * @param camera The camera to dispose the effect on.
  64814. */
  64815. disposeEffects(camera: Camera): void;
  64816. /**
  64817. * @hidden Internal
  64818. */
  64819. _updateEffects(): void;
  64820. /**
  64821. * Internal
  64822. * @returns if all the contained post processes are ready.
  64823. * @hidden
  64824. */
  64825. _isReady(): boolean;
  64826. }
  64827. }
  64828. declare module BABYLON {
  64829. /** @hidden */
  64830. export var chromaticAberrationPixelShader: {
  64831. name: string;
  64832. shader: string;
  64833. };
  64834. }
  64835. declare module BABYLON {
  64836. /**
  64837. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64838. */
  64839. export class ChromaticAberrationPostProcess extends PostProcess {
  64840. /**
  64841. * The amount of seperation of rgb channels (default: 30)
  64842. */
  64843. aberrationAmount: number;
  64844. /**
  64845. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64846. */
  64847. radialIntensity: number;
  64848. /**
  64849. * 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))
  64850. */
  64851. direction: Vector2;
  64852. /**
  64853. * 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))
  64854. */
  64855. centerPosition: Vector2;
  64856. /**
  64857. * Creates a new instance ChromaticAberrationPostProcess
  64858. * @param name The name of the effect.
  64859. * @param screenWidth The width of the screen to apply the effect on.
  64860. * @param screenHeight The height of the screen to apply the effect on.
  64861. * @param options The required width/height ratio to downsize to before computing the render pass.
  64862. * @param camera The camera to apply the render pass to.
  64863. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64864. * @param engine The engine which the post process will be applied. (default: current engine)
  64865. * @param reusable If the post process can be reused on the same frame. (default: false)
  64866. * @param textureType Type of textures used when performing the post process. (default: 0)
  64867. * @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)
  64868. */
  64869. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64870. }
  64871. }
  64872. declare module BABYLON {
  64873. /** @hidden */
  64874. export var circleOfConfusionPixelShader: {
  64875. name: string;
  64876. shader: string;
  64877. };
  64878. }
  64879. declare module BABYLON {
  64880. /**
  64881. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64882. */
  64883. export class CircleOfConfusionPostProcess extends PostProcess {
  64884. /**
  64885. * 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.
  64886. */
  64887. lensSize: number;
  64888. /**
  64889. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64890. */
  64891. fStop: number;
  64892. /**
  64893. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64894. */
  64895. focusDistance: number;
  64896. /**
  64897. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64898. */
  64899. focalLength: number;
  64900. private _depthTexture;
  64901. /**
  64902. * Creates a new instance CircleOfConfusionPostProcess
  64903. * @param name The name of the effect.
  64904. * @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.
  64905. * @param options The required width/height ratio to downsize to before computing the render pass.
  64906. * @param camera The camera to apply the render pass to.
  64907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64908. * @param engine The engine which the post process will be applied. (default: current engine)
  64909. * @param reusable If the post process can be reused on the same frame. (default: false)
  64910. * @param textureType Type of textures used when performing the post process. (default: 0)
  64911. * @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)
  64912. */
  64913. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64914. /**
  64915. * 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.
  64916. */
  64917. set depthTexture(value: RenderTargetTexture);
  64918. }
  64919. }
  64920. declare module BABYLON {
  64921. /** @hidden */
  64922. export var colorCorrectionPixelShader: {
  64923. name: string;
  64924. shader: string;
  64925. };
  64926. }
  64927. declare module BABYLON {
  64928. /**
  64929. *
  64930. * This post-process allows the modification of rendered colors by using
  64931. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64932. *
  64933. * The object needs to be provided an url to a texture containing the color
  64934. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64935. * Use an image editing software to tweak the LUT to match your needs.
  64936. *
  64937. * For an example of a color LUT, see here:
  64938. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64939. * For explanations on color grading, see here:
  64940. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64941. *
  64942. */
  64943. export class ColorCorrectionPostProcess extends PostProcess {
  64944. private _colorTableTexture;
  64945. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64946. }
  64947. }
  64948. declare module BABYLON {
  64949. /** @hidden */
  64950. export var convolutionPixelShader: {
  64951. name: string;
  64952. shader: string;
  64953. };
  64954. }
  64955. declare module BABYLON {
  64956. /**
  64957. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64958. * input texture to perform effects such as edge detection or sharpening
  64959. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64960. */
  64961. export class ConvolutionPostProcess extends PostProcess {
  64962. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64963. kernel: number[];
  64964. /**
  64965. * Creates a new instance ConvolutionPostProcess
  64966. * @param name The name of the effect.
  64967. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64968. * @param options The required width/height ratio to downsize to before computing the render pass.
  64969. * @param camera The camera to apply the render pass to.
  64970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64971. * @param engine The engine which the post process will be applied. (default: current engine)
  64972. * @param reusable If the post process can be reused on the same frame. (default: false)
  64973. * @param textureType Type of textures used when performing the post process. (default: 0)
  64974. */
  64975. constructor(name: string,
  64976. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64977. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64978. /**
  64979. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64980. */
  64981. static EdgeDetect0Kernel: number[];
  64982. /**
  64983. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64984. */
  64985. static EdgeDetect1Kernel: number[];
  64986. /**
  64987. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64988. */
  64989. static EdgeDetect2Kernel: number[];
  64990. /**
  64991. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64992. */
  64993. static SharpenKernel: number[];
  64994. /**
  64995. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64996. */
  64997. static EmbossKernel: number[];
  64998. /**
  64999. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  65000. */
  65001. static GaussianKernel: number[];
  65002. }
  65003. }
  65004. declare module BABYLON {
  65005. /**
  65006. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65007. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65008. * based on samples that have a large difference in distance than the center pixel.
  65009. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65010. */
  65011. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65012. direction: Vector2;
  65013. /**
  65014. * Creates a new instance CircleOfConfusionPostProcess
  65015. * @param name The name of the effect.
  65016. * @param scene The scene the effect belongs to.
  65017. * @param direction The direction the blur should be applied.
  65018. * @param kernel The size of the kernel used to blur.
  65019. * @param options The required width/height ratio to downsize to before computing the render pass.
  65020. * @param camera The camera to apply the render pass to.
  65021. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65022. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65024. * @param engine The engine which the post process will be applied. (default: current engine)
  65025. * @param reusable If the post process can be reused on the same frame. (default: false)
  65026. * @param textureType Type of textures used when performing the post process. (default: 0)
  65027. * @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)
  65028. */
  65029. 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);
  65030. }
  65031. }
  65032. declare module BABYLON {
  65033. /** @hidden */
  65034. export var depthOfFieldMergePixelShader: {
  65035. name: string;
  65036. shader: string;
  65037. };
  65038. }
  65039. declare module BABYLON {
  65040. /**
  65041. * Options to be set when merging outputs from the default pipeline.
  65042. */
  65043. export class DepthOfFieldMergePostProcessOptions {
  65044. /**
  65045. * The original image to merge on top of
  65046. */
  65047. originalFromInput: PostProcess;
  65048. /**
  65049. * Parameters to perform the merge of the depth of field effect
  65050. */
  65051. depthOfField?: {
  65052. circleOfConfusion: PostProcess;
  65053. blurSteps: Array<PostProcess>;
  65054. };
  65055. /**
  65056. * Parameters to perform the merge of bloom effect
  65057. */
  65058. bloom?: {
  65059. blurred: PostProcess;
  65060. weight: number;
  65061. };
  65062. }
  65063. /**
  65064. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65065. */
  65066. export class DepthOfFieldMergePostProcess extends PostProcess {
  65067. private blurSteps;
  65068. /**
  65069. * Creates a new instance of DepthOfFieldMergePostProcess
  65070. * @param name The name of the effect.
  65071. * @param originalFromInput Post process which's input will be used for the merge.
  65072. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65073. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65074. * @param options The required width/height ratio to downsize to before computing the render pass.
  65075. * @param camera The camera to apply the render pass to.
  65076. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65077. * @param engine The engine which the post process will be applied. (default: current engine)
  65078. * @param reusable If the post process can be reused on the same frame. (default: false)
  65079. * @param textureType Type of textures used when performing the post process. (default: 0)
  65080. * @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)
  65081. */
  65082. 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);
  65083. /**
  65084. * Updates the effect with the current post process compile time values and recompiles the shader.
  65085. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65086. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65087. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65088. * @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
  65089. * @param onCompiled Called when the shader has been compiled.
  65090. * @param onError Called if there is an error when compiling a shader.
  65091. */
  65092. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65093. }
  65094. }
  65095. declare module BABYLON {
  65096. /**
  65097. * Specifies the level of max blur that should be applied when using the depth of field effect
  65098. */
  65099. export enum DepthOfFieldEffectBlurLevel {
  65100. /**
  65101. * Subtle blur
  65102. */
  65103. Low = 0,
  65104. /**
  65105. * Medium blur
  65106. */
  65107. Medium = 1,
  65108. /**
  65109. * Large blur
  65110. */
  65111. High = 2
  65112. }
  65113. /**
  65114. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65115. */
  65116. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65117. private _circleOfConfusion;
  65118. /**
  65119. * @hidden Internal, blurs from high to low
  65120. */
  65121. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65122. private _depthOfFieldBlurY;
  65123. private _dofMerge;
  65124. /**
  65125. * @hidden Internal post processes in depth of field effect
  65126. */
  65127. _effects: Array<PostProcess>;
  65128. /**
  65129. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65130. */
  65131. set focalLength(value: number);
  65132. get focalLength(): number;
  65133. /**
  65134. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65135. */
  65136. set fStop(value: number);
  65137. get fStop(): number;
  65138. /**
  65139. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65140. */
  65141. set focusDistance(value: number);
  65142. get focusDistance(): number;
  65143. /**
  65144. * 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.
  65145. */
  65146. set lensSize(value: number);
  65147. get lensSize(): number;
  65148. /**
  65149. * Creates a new instance DepthOfFieldEffect
  65150. * @param scene The scene the effect belongs to.
  65151. * @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.
  65152. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65153. * @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)
  65154. */
  65155. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65156. /**
  65157. * Get the current class name of the current effet
  65158. * @returns "DepthOfFieldEffect"
  65159. */
  65160. getClassName(): string;
  65161. /**
  65162. * 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.
  65163. */
  65164. set depthTexture(value: RenderTargetTexture);
  65165. /**
  65166. * Disposes each of the internal effects for a given camera.
  65167. * @param camera The camera to dispose the effect on.
  65168. */
  65169. disposeEffects(camera: Camera): void;
  65170. /**
  65171. * @hidden Internal
  65172. */
  65173. _updateEffects(): void;
  65174. /**
  65175. * Internal
  65176. * @returns if all the contained post processes are ready.
  65177. * @hidden
  65178. */
  65179. _isReady(): boolean;
  65180. }
  65181. }
  65182. declare module BABYLON {
  65183. /** @hidden */
  65184. export var displayPassPixelShader: {
  65185. name: string;
  65186. shader: string;
  65187. };
  65188. }
  65189. declare module BABYLON {
  65190. /**
  65191. * DisplayPassPostProcess which produces an output the same as it's input
  65192. */
  65193. export class DisplayPassPostProcess extends PostProcess {
  65194. /**
  65195. * Creates the DisplayPassPostProcess
  65196. * @param name The name of the effect.
  65197. * @param options The required width/height ratio to downsize to before computing the render pass.
  65198. * @param camera The camera to apply the render pass to.
  65199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65200. * @param engine The engine which the post process will be applied. (default: current engine)
  65201. * @param reusable If the post process can be reused on the same frame. (default: false)
  65202. */
  65203. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65204. }
  65205. }
  65206. declare module BABYLON {
  65207. /** @hidden */
  65208. export var filterPixelShader: {
  65209. name: string;
  65210. shader: string;
  65211. };
  65212. }
  65213. declare module BABYLON {
  65214. /**
  65215. * Applies a kernel filter to the image
  65216. */
  65217. export class FilterPostProcess extends PostProcess {
  65218. /** The matrix to be applied to the image */
  65219. kernelMatrix: Matrix;
  65220. /**
  65221. *
  65222. * @param name The name of the effect.
  65223. * @param kernelMatrix The matrix to be applied to the image
  65224. * @param options The required width/height ratio to downsize to before computing the render pass.
  65225. * @param camera The camera to apply the render pass to.
  65226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65227. * @param engine The engine which the post process will be applied. (default: current engine)
  65228. * @param reusable If the post process can be reused on the same frame. (default: false)
  65229. */
  65230. constructor(name: string,
  65231. /** The matrix to be applied to the image */
  65232. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65233. }
  65234. }
  65235. declare module BABYLON {
  65236. /** @hidden */
  65237. export var fxaaPixelShader: {
  65238. name: string;
  65239. shader: string;
  65240. };
  65241. }
  65242. declare module BABYLON {
  65243. /** @hidden */
  65244. export var fxaaVertexShader: {
  65245. name: string;
  65246. shader: string;
  65247. };
  65248. }
  65249. declare module BABYLON {
  65250. /**
  65251. * Fxaa post process
  65252. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65253. */
  65254. export class FxaaPostProcess extends PostProcess {
  65255. /** @hidden */
  65256. texelWidth: number;
  65257. /** @hidden */
  65258. texelHeight: number;
  65259. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65260. private _getDefines;
  65261. }
  65262. }
  65263. declare module BABYLON {
  65264. /** @hidden */
  65265. export var grainPixelShader: {
  65266. name: string;
  65267. shader: string;
  65268. };
  65269. }
  65270. declare module BABYLON {
  65271. /**
  65272. * The GrainPostProcess adds noise to the image at mid luminance levels
  65273. */
  65274. export class GrainPostProcess extends PostProcess {
  65275. /**
  65276. * The intensity of the grain added (default: 30)
  65277. */
  65278. intensity: number;
  65279. /**
  65280. * If the grain should be randomized on every frame
  65281. */
  65282. animated: boolean;
  65283. /**
  65284. * Creates a new instance of @see GrainPostProcess
  65285. * @param name The name of the effect.
  65286. * @param options The required width/height ratio to downsize to before computing the render pass.
  65287. * @param camera The camera to apply the render pass to.
  65288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65289. * @param engine The engine which the post process will be applied. (default: current engine)
  65290. * @param reusable If the post process can be reused on the same frame. (default: false)
  65291. * @param textureType Type of textures used when performing the post process. (default: 0)
  65292. * @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)
  65293. */
  65294. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65295. }
  65296. }
  65297. declare module BABYLON {
  65298. /** @hidden */
  65299. export var highlightsPixelShader: {
  65300. name: string;
  65301. shader: string;
  65302. };
  65303. }
  65304. declare module BABYLON {
  65305. /**
  65306. * Extracts highlights from the image
  65307. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65308. */
  65309. export class HighlightsPostProcess extends PostProcess {
  65310. /**
  65311. * Extracts highlights from the image
  65312. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65313. * @param name The name of the effect.
  65314. * @param options The required width/height ratio to downsize to before computing the render pass.
  65315. * @param camera The camera to apply the render pass to.
  65316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65317. * @param engine The engine which the post process will be applied. (default: current engine)
  65318. * @param reusable If the post process can be reused on the same frame. (default: false)
  65319. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65320. */
  65321. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65322. }
  65323. }
  65324. declare module BABYLON {
  65325. /** @hidden */
  65326. export var mrtFragmentDeclaration: {
  65327. name: string;
  65328. shader: string;
  65329. };
  65330. }
  65331. declare module BABYLON {
  65332. /** @hidden */
  65333. export var geometryPixelShader: {
  65334. name: string;
  65335. shader: string;
  65336. };
  65337. }
  65338. declare module BABYLON {
  65339. /** @hidden */
  65340. export var geometryVertexShader: {
  65341. name: string;
  65342. shader: string;
  65343. };
  65344. }
  65345. declare module BABYLON {
  65346. /** @hidden */
  65347. interface ISavedTransformationMatrix {
  65348. world: Matrix;
  65349. viewProjection: Matrix;
  65350. }
  65351. /**
  65352. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65353. */
  65354. export class GeometryBufferRenderer {
  65355. /**
  65356. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65357. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65358. */
  65359. static readonly POSITION_TEXTURE_TYPE: number;
  65360. /**
  65361. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65362. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65363. */
  65364. static readonly VELOCITY_TEXTURE_TYPE: number;
  65365. /**
  65366. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65367. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65368. */
  65369. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65370. /**
  65371. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65372. * in order to compute objects velocities when enableVelocity is set to "true"
  65373. * @hidden
  65374. */
  65375. _previousTransformationMatrices: {
  65376. [index: number]: ISavedTransformationMatrix;
  65377. };
  65378. /**
  65379. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65380. * in order to compute objects velocities when enableVelocity is set to "true"
  65381. * @hidden
  65382. */
  65383. _previousBonesTransformationMatrices: {
  65384. [index: number]: Float32Array;
  65385. };
  65386. /**
  65387. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65388. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65389. */
  65390. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65391. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65392. renderTransparentMeshes: boolean;
  65393. private _scene;
  65394. private _multiRenderTarget;
  65395. private _ratio;
  65396. private _enablePosition;
  65397. private _enableVelocity;
  65398. private _enableReflectivity;
  65399. private _positionIndex;
  65400. private _velocityIndex;
  65401. private _reflectivityIndex;
  65402. protected _effect: Effect;
  65403. protected _cachedDefines: string;
  65404. /**
  65405. * Set the render list (meshes to be rendered) used in the G buffer.
  65406. */
  65407. set renderList(meshes: Mesh[]);
  65408. /**
  65409. * Gets wether or not G buffer are supported by the running hardware.
  65410. * This requires draw buffer supports
  65411. */
  65412. get isSupported(): boolean;
  65413. /**
  65414. * Returns the index of the given texture type in the G-Buffer textures array
  65415. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65416. * @returns the index of the given texture type in the G-Buffer textures array
  65417. */
  65418. getTextureIndex(textureType: number): number;
  65419. /**
  65420. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65421. */
  65422. get enablePosition(): boolean;
  65423. /**
  65424. * Sets whether or not objects positions are enabled for the G buffer.
  65425. */
  65426. set enablePosition(enable: boolean);
  65427. /**
  65428. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65429. */
  65430. get enableVelocity(): boolean;
  65431. /**
  65432. * Sets wether or not objects velocities are enabled for the G buffer.
  65433. */
  65434. set enableVelocity(enable: boolean);
  65435. /**
  65436. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65437. */
  65438. get enableReflectivity(): boolean;
  65439. /**
  65440. * Sets wether or not objects roughness are enabled for the G buffer.
  65441. */
  65442. set enableReflectivity(enable: boolean);
  65443. /**
  65444. * Gets the scene associated with the buffer.
  65445. */
  65446. get scene(): Scene;
  65447. /**
  65448. * Gets the ratio used by the buffer during its creation.
  65449. * How big is the buffer related to the main canvas.
  65450. */
  65451. get ratio(): number;
  65452. /** @hidden */
  65453. static _SceneComponentInitialization: (scene: Scene) => void;
  65454. /**
  65455. * Creates a new G Buffer for the scene
  65456. * @param scene The scene the buffer belongs to
  65457. * @param ratio How big is the buffer related to the main canvas.
  65458. */
  65459. constructor(scene: Scene, ratio?: number);
  65460. /**
  65461. * Checks wether everything is ready to render a submesh to the G buffer.
  65462. * @param subMesh the submesh to check readiness for
  65463. * @param useInstances is the mesh drawn using instance or not
  65464. * @returns true if ready otherwise false
  65465. */
  65466. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65467. /**
  65468. * Gets the current underlying G Buffer.
  65469. * @returns the buffer
  65470. */
  65471. getGBuffer(): MultiRenderTarget;
  65472. /**
  65473. * Gets the number of samples used to render the buffer (anti aliasing).
  65474. */
  65475. get samples(): number;
  65476. /**
  65477. * Sets the number of samples used to render the buffer (anti aliasing).
  65478. */
  65479. set samples(value: number);
  65480. /**
  65481. * Disposes the renderer and frees up associated resources.
  65482. */
  65483. dispose(): void;
  65484. protected _createRenderTargets(): void;
  65485. private _copyBonesTransformationMatrices;
  65486. }
  65487. }
  65488. declare module BABYLON {
  65489. interface Scene {
  65490. /** @hidden (Backing field) */
  65491. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65492. /**
  65493. * Gets or Sets the current geometry buffer associated to the scene.
  65494. */
  65495. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65496. /**
  65497. * Enables a GeometryBufferRender and associates it with the scene
  65498. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65499. * @returns the GeometryBufferRenderer
  65500. */
  65501. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65502. /**
  65503. * Disables the GeometryBufferRender associated with the scene
  65504. */
  65505. disableGeometryBufferRenderer(): void;
  65506. }
  65507. /**
  65508. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65509. * in several rendering techniques.
  65510. */
  65511. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65512. /**
  65513. * The component name helpful to identify the component in the list of scene components.
  65514. */
  65515. readonly name: string;
  65516. /**
  65517. * The scene the component belongs to.
  65518. */
  65519. scene: Scene;
  65520. /**
  65521. * Creates a new instance of the component for the given scene
  65522. * @param scene Defines the scene to register the component in
  65523. */
  65524. constructor(scene: Scene);
  65525. /**
  65526. * Registers the component in a given scene
  65527. */
  65528. register(): void;
  65529. /**
  65530. * Rebuilds the elements related to this component in case of
  65531. * context lost for instance.
  65532. */
  65533. rebuild(): void;
  65534. /**
  65535. * Disposes the component and the associated ressources
  65536. */
  65537. dispose(): void;
  65538. private _gatherRenderTargets;
  65539. }
  65540. }
  65541. declare module BABYLON {
  65542. /** @hidden */
  65543. export var motionBlurPixelShader: {
  65544. name: string;
  65545. shader: string;
  65546. };
  65547. }
  65548. declare module BABYLON {
  65549. /**
  65550. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65551. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65552. * As an example, all you have to do is to create the post-process:
  65553. * var mb = new BABYLON.MotionBlurPostProcess(
  65554. * 'mb', // The name of the effect.
  65555. * scene, // The scene containing the objects to blur according to their velocity.
  65556. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65557. * camera // The camera to apply the render pass to.
  65558. * );
  65559. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65560. */
  65561. export class MotionBlurPostProcess extends PostProcess {
  65562. /**
  65563. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65564. */
  65565. motionStrength: number;
  65566. /**
  65567. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65568. */
  65569. get motionBlurSamples(): number;
  65570. /**
  65571. * Sets the number of iterations to be used for motion blur quality
  65572. */
  65573. set motionBlurSamples(samples: number);
  65574. private _motionBlurSamples;
  65575. private _geometryBufferRenderer;
  65576. /**
  65577. * Creates a new instance MotionBlurPostProcess
  65578. * @param name The name of the effect.
  65579. * @param scene The scene containing the objects to blur according to their velocity.
  65580. * @param options The required width/height ratio to downsize to before computing the render pass.
  65581. * @param camera The camera to apply the render pass to.
  65582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65583. * @param engine The engine which the post process will be applied. (default: current engine)
  65584. * @param reusable If the post process can be reused on the same frame. (default: false)
  65585. * @param textureType Type of textures used when performing the post process. (default: 0)
  65586. * @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)
  65587. */
  65588. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65589. /**
  65590. * Excludes the given skinned mesh from computing bones velocities.
  65591. * 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.
  65592. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65593. */
  65594. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65595. /**
  65596. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65597. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65598. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65599. */
  65600. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65601. /**
  65602. * Disposes the post process.
  65603. * @param camera The camera to dispose the post process on.
  65604. */
  65605. dispose(camera?: Camera): void;
  65606. }
  65607. }
  65608. declare module BABYLON {
  65609. /** @hidden */
  65610. export var refractionPixelShader: {
  65611. name: string;
  65612. shader: string;
  65613. };
  65614. }
  65615. declare module BABYLON {
  65616. /**
  65617. * Post process which applies a refractin texture
  65618. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65619. */
  65620. export class RefractionPostProcess extends PostProcess {
  65621. /** the base color of the refraction (used to taint the rendering) */
  65622. color: Color3;
  65623. /** simulated refraction depth */
  65624. depth: number;
  65625. /** the coefficient of the base color (0 to remove base color tainting) */
  65626. colorLevel: number;
  65627. private _refTexture;
  65628. private _ownRefractionTexture;
  65629. /**
  65630. * Gets or sets the refraction texture
  65631. * Please note that you are responsible for disposing the texture if you set it manually
  65632. */
  65633. get refractionTexture(): Texture;
  65634. set refractionTexture(value: Texture);
  65635. /**
  65636. * Initializes the RefractionPostProcess
  65637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65638. * @param name The name of the effect.
  65639. * @param refractionTextureUrl Url of the refraction texture to use
  65640. * @param color the base color of the refraction (used to taint the rendering)
  65641. * @param depth simulated refraction depth
  65642. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65643. * @param camera The camera to apply the render pass to.
  65644. * @param options The required width/height ratio to downsize to before computing the render pass.
  65645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65646. * @param engine The engine which the post process will be applied. (default: current engine)
  65647. * @param reusable If the post process can be reused on the same frame. (default: false)
  65648. */
  65649. constructor(name: string, refractionTextureUrl: string,
  65650. /** the base color of the refraction (used to taint the rendering) */
  65651. color: Color3,
  65652. /** simulated refraction depth */
  65653. depth: number,
  65654. /** the coefficient of the base color (0 to remove base color tainting) */
  65655. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65656. /**
  65657. * Disposes of the post process
  65658. * @param camera Camera to dispose post process on
  65659. */
  65660. dispose(camera: Camera): void;
  65661. }
  65662. }
  65663. declare module BABYLON {
  65664. /** @hidden */
  65665. export var sharpenPixelShader: {
  65666. name: string;
  65667. shader: string;
  65668. };
  65669. }
  65670. declare module BABYLON {
  65671. /**
  65672. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65673. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65674. */
  65675. export class SharpenPostProcess extends PostProcess {
  65676. /**
  65677. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65678. */
  65679. colorAmount: number;
  65680. /**
  65681. * How much sharpness should be applied (default: 0.3)
  65682. */
  65683. edgeAmount: number;
  65684. /**
  65685. * Creates a new instance ConvolutionPostProcess
  65686. * @param name The name of the effect.
  65687. * @param options The required width/height ratio to downsize to before computing the render pass.
  65688. * @param camera The camera to apply the render pass to.
  65689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65690. * @param engine The engine which the post process will be applied. (default: current engine)
  65691. * @param reusable If the post process can be reused on the same frame. (default: false)
  65692. * @param textureType Type of textures used when performing the post process. (default: 0)
  65693. * @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)
  65694. */
  65695. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65696. }
  65697. }
  65698. declare module BABYLON {
  65699. /**
  65700. * PostProcessRenderPipeline
  65701. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65702. */
  65703. export class PostProcessRenderPipeline {
  65704. private engine;
  65705. private _renderEffects;
  65706. private _renderEffectsForIsolatedPass;
  65707. /**
  65708. * List of inspectable custom properties (used by the Inspector)
  65709. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65710. */
  65711. inspectableCustomProperties: IInspectable[];
  65712. /**
  65713. * @hidden
  65714. */
  65715. protected _cameras: Camera[];
  65716. /** @hidden */
  65717. _name: string;
  65718. /**
  65719. * Gets pipeline name
  65720. */
  65721. get name(): string;
  65722. /** Gets the list of attached cameras */
  65723. get cameras(): Camera[];
  65724. /**
  65725. * Initializes a PostProcessRenderPipeline
  65726. * @param engine engine to add the pipeline to
  65727. * @param name name of the pipeline
  65728. */
  65729. constructor(engine: Engine, name: string);
  65730. /**
  65731. * Gets the class name
  65732. * @returns "PostProcessRenderPipeline"
  65733. */
  65734. getClassName(): string;
  65735. /**
  65736. * If all the render effects in the pipeline are supported
  65737. */
  65738. get isSupported(): boolean;
  65739. /**
  65740. * Adds an effect to the pipeline
  65741. * @param renderEffect the effect to add
  65742. */
  65743. addEffect(renderEffect: PostProcessRenderEffect): void;
  65744. /** @hidden */
  65745. _rebuild(): void;
  65746. /** @hidden */
  65747. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65748. /** @hidden */
  65749. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65750. /** @hidden */
  65751. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65752. /** @hidden */
  65753. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65754. /** @hidden */
  65755. _attachCameras(cameras: Camera, unique: boolean): void;
  65756. /** @hidden */
  65757. _attachCameras(cameras: Camera[], unique: boolean): void;
  65758. /** @hidden */
  65759. _detachCameras(cameras: Camera): void;
  65760. /** @hidden */
  65761. _detachCameras(cameras: Nullable<Camera[]>): void;
  65762. /** @hidden */
  65763. _update(): void;
  65764. /** @hidden */
  65765. _reset(): void;
  65766. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65767. /**
  65768. * Disposes of the pipeline
  65769. */
  65770. dispose(): void;
  65771. }
  65772. }
  65773. declare module BABYLON {
  65774. /**
  65775. * PostProcessRenderPipelineManager class
  65776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65777. */
  65778. export class PostProcessRenderPipelineManager {
  65779. private _renderPipelines;
  65780. /**
  65781. * Initializes a PostProcessRenderPipelineManager
  65782. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65783. */
  65784. constructor();
  65785. /**
  65786. * Gets the list of supported render pipelines
  65787. */
  65788. get supportedPipelines(): PostProcessRenderPipeline[];
  65789. /**
  65790. * Adds a pipeline to the manager
  65791. * @param renderPipeline The pipeline to add
  65792. */
  65793. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65794. /**
  65795. * Attaches a camera to the pipeline
  65796. * @param renderPipelineName The name of the pipeline to attach to
  65797. * @param cameras the camera to attach
  65798. * @param unique if the camera can be attached multiple times to the pipeline
  65799. */
  65800. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65801. /**
  65802. * Detaches a camera from the pipeline
  65803. * @param renderPipelineName The name of the pipeline to detach from
  65804. * @param cameras the camera to detach
  65805. */
  65806. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65807. /**
  65808. * Enables an effect by name on a pipeline
  65809. * @param renderPipelineName the name of the pipeline to enable the effect in
  65810. * @param renderEffectName the name of the effect to enable
  65811. * @param cameras the cameras that the effect should be enabled on
  65812. */
  65813. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65814. /**
  65815. * Disables an effect by name on a pipeline
  65816. * @param renderPipelineName the name of the pipeline to disable the effect in
  65817. * @param renderEffectName the name of the effect to disable
  65818. * @param cameras the cameras that the effect should be disabled on
  65819. */
  65820. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65821. /**
  65822. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65823. */
  65824. update(): void;
  65825. /** @hidden */
  65826. _rebuild(): void;
  65827. /**
  65828. * Disposes of the manager and pipelines
  65829. */
  65830. dispose(): void;
  65831. }
  65832. }
  65833. declare module BABYLON {
  65834. interface Scene {
  65835. /** @hidden (Backing field) */
  65836. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65837. /**
  65838. * Gets the postprocess render pipeline manager
  65839. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65840. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65841. */
  65842. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65843. }
  65844. /**
  65845. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65846. */
  65847. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65848. /**
  65849. * The component name helpfull to identify the component in the list of scene components.
  65850. */
  65851. readonly name: string;
  65852. /**
  65853. * The scene the component belongs to.
  65854. */
  65855. scene: Scene;
  65856. /**
  65857. * Creates a new instance of the component for the given scene
  65858. * @param scene Defines the scene to register the component in
  65859. */
  65860. constructor(scene: Scene);
  65861. /**
  65862. * Registers the component in a given scene
  65863. */
  65864. register(): void;
  65865. /**
  65866. * Rebuilds the elements related to this component in case of
  65867. * context lost for instance.
  65868. */
  65869. rebuild(): void;
  65870. /**
  65871. * Disposes the component and the associated ressources
  65872. */
  65873. dispose(): void;
  65874. private _gatherRenderTargets;
  65875. }
  65876. }
  65877. declare module BABYLON {
  65878. /**
  65879. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65880. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65881. */
  65882. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65883. private _scene;
  65884. private _camerasToBeAttached;
  65885. /**
  65886. * ID of the sharpen post process,
  65887. */
  65888. private readonly SharpenPostProcessId;
  65889. /**
  65890. * @ignore
  65891. * ID of the image processing post process;
  65892. */
  65893. readonly ImageProcessingPostProcessId: string;
  65894. /**
  65895. * @ignore
  65896. * ID of the Fast Approximate Anti-Aliasing post process;
  65897. */
  65898. readonly FxaaPostProcessId: string;
  65899. /**
  65900. * ID of the chromatic aberration post process,
  65901. */
  65902. private readonly ChromaticAberrationPostProcessId;
  65903. /**
  65904. * ID of the grain post process
  65905. */
  65906. private readonly GrainPostProcessId;
  65907. /**
  65908. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65909. */
  65910. sharpen: SharpenPostProcess;
  65911. private _sharpenEffect;
  65912. private bloom;
  65913. /**
  65914. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65915. */
  65916. depthOfField: DepthOfFieldEffect;
  65917. /**
  65918. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65919. */
  65920. fxaa: FxaaPostProcess;
  65921. /**
  65922. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65923. */
  65924. imageProcessing: ImageProcessingPostProcess;
  65925. /**
  65926. * Chromatic aberration post process which will shift rgb colors in the image
  65927. */
  65928. chromaticAberration: ChromaticAberrationPostProcess;
  65929. private _chromaticAberrationEffect;
  65930. /**
  65931. * Grain post process which add noise to the image
  65932. */
  65933. grain: GrainPostProcess;
  65934. private _grainEffect;
  65935. /**
  65936. * Glow post process which adds a glow to emissive areas of the image
  65937. */
  65938. private _glowLayer;
  65939. /**
  65940. * Animations which can be used to tweak settings over a period of time
  65941. */
  65942. animations: Animation[];
  65943. private _imageProcessingConfigurationObserver;
  65944. private _sharpenEnabled;
  65945. private _bloomEnabled;
  65946. private _depthOfFieldEnabled;
  65947. private _depthOfFieldBlurLevel;
  65948. private _fxaaEnabled;
  65949. private _imageProcessingEnabled;
  65950. private _defaultPipelineTextureType;
  65951. private _bloomScale;
  65952. private _chromaticAberrationEnabled;
  65953. private _grainEnabled;
  65954. private _buildAllowed;
  65955. /**
  65956. * Gets active scene
  65957. */
  65958. get scene(): Scene;
  65959. /**
  65960. * Enable or disable the sharpen process from the pipeline
  65961. */
  65962. set sharpenEnabled(enabled: boolean);
  65963. get sharpenEnabled(): boolean;
  65964. private _resizeObserver;
  65965. private _hardwareScaleLevel;
  65966. private _bloomKernel;
  65967. /**
  65968. * Specifies the size of the bloom blur kernel, relative to the final output size
  65969. */
  65970. get bloomKernel(): number;
  65971. set bloomKernel(value: number);
  65972. /**
  65973. * Specifies the weight of the bloom in the final rendering
  65974. */
  65975. private _bloomWeight;
  65976. /**
  65977. * Specifies the luma threshold for the area that will be blurred by the bloom
  65978. */
  65979. private _bloomThreshold;
  65980. private _hdr;
  65981. /**
  65982. * The strength of the bloom.
  65983. */
  65984. set bloomWeight(value: number);
  65985. get bloomWeight(): number;
  65986. /**
  65987. * The strength of the bloom.
  65988. */
  65989. set bloomThreshold(value: number);
  65990. get bloomThreshold(): number;
  65991. /**
  65992. * The scale of the bloom, lower value will provide better performance.
  65993. */
  65994. set bloomScale(value: number);
  65995. get bloomScale(): number;
  65996. /**
  65997. * Enable or disable the bloom from the pipeline
  65998. */
  65999. set bloomEnabled(enabled: boolean);
  66000. get bloomEnabled(): boolean;
  66001. private _rebuildBloom;
  66002. /**
  66003. * If the depth of field is enabled.
  66004. */
  66005. get depthOfFieldEnabled(): boolean;
  66006. set depthOfFieldEnabled(enabled: boolean);
  66007. /**
  66008. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66009. */
  66010. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66011. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66012. /**
  66013. * If the anti aliasing is enabled.
  66014. */
  66015. set fxaaEnabled(enabled: boolean);
  66016. get fxaaEnabled(): boolean;
  66017. private _samples;
  66018. /**
  66019. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66020. */
  66021. set samples(sampleCount: number);
  66022. get samples(): number;
  66023. /**
  66024. * If image processing is enabled.
  66025. */
  66026. set imageProcessingEnabled(enabled: boolean);
  66027. get imageProcessingEnabled(): boolean;
  66028. /**
  66029. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66030. */
  66031. set glowLayerEnabled(enabled: boolean);
  66032. get glowLayerEnabled(): boolean;
  66033. /**
  66034. * Gets the glow layer (or null if not defined)
  66035. */
  66036. get glowLayer(): Nullable<GlowLayer>;
  66037. /**
  66038. * Enable or disable the chromaticAberration process from the pipeline
  66039. */
  66040. set chromaticAberrationEnabled(enabled: boolean);
  66041. get chromaticAberrationEnabled(): boolean;
  66042. /**
  66043. * Enable or disable the grain process from the pipeline
  66044. */
  66045. set grainEnabled(enabled: boolean);
  66046. get grainEnabled(): boolean;
  66047. /**
  66048. * @constructor
  66049. * @param name - The rendering pipeline name (default: "")
  66050. * @param hdr - If high dynamic range textures should be used (default: true)
  66051. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66052. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66053. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66054. */
  66055. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66056. /**
  66057. * Get the class name
  66058. * @returns "DefaultRenderingPipeline"
  66059. */
  66060. getClassName(): string;
  66061. /**
  66062. * Force the compilation of the entire pipeline.
  66063. */
  66064. prepare(): void;
  66065. private _hasCleared;
  66066. private _prevPostProcess;
  66067. private _prevPrevPostProcess;
  66068. private _setAutoClearAndTextureSharing;
  66069. private _depthOfFieldSceneObserver;
  66070. private _buildPipeline;
  66071. private _disposePostProcesses;
  66072. /**
  66073. * Adds a camera to the pipeline
  66074. * @param camera the camera to be added
  66075. */
  66076. addCamera(camera: Camera): void;
  66077. /**
  66078. * Removes a camera from the pipeline
  66079. * @param camera the camera to remove
  66080. */
  66081. removeCamera(camera: Camera): void;
  66082. /**
  66083. * Dispose of the pipeline and stop all post processes
  66084. */
  66085. dispose(): void;
  66086. /**
  66087. * Serialize the rendering pipeline (Used when exporting)
  66088. * @returns the serialized object
  66089. */
  66090. serialize(): any;
  66091. /**
  66092. * Parse the serialized pipeline
  66093. * @param source Source pipeline.
  66094. * @param scene The scene to load the pipeline to.
  66095. * @param rootUrl The URL of the serialized pipeline.
  66096. * @returns An instantiated pipeline from the serialized object.
  66097. */
  66098. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66099. }
  66100. }
  66101. declare module BABYLON {
  66102. /** @hidden */
  66103. export var lensHighlightsPixelShader: {
  66104. name: string;
  66105. shader: string;
  66106. };
  66107. }
  66108. declare module BABYLON {
  66109. /** @hidden */
  66110. export var depthOfFieldPixelShader: {
  66111. name: string;
  66112. shader: string;
  66113. };
  66114. }
  66115. declare module BABYLON {
  66116. /**
  66117. * BABYLON.JS Chromatic Aberration GLSL Shader
  66118. * Author: Olivier Guyot
  66119. * Separates very slightly R, G and B colors on the edges of the screen
  66120. * Inspired by Francois Tarlier & Martins Upitis
  66121. */
  66122. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66123. /**
  66124. * @ignore
  66125. * The chromatic aberration PostProcess id in the pipeline
  66126. */
  66127. LensChromaticAberrationEffect: string;
  66128. /**
  66129. * @ignore
  66130. * The highlights enhancing PostProcess id in the pipeline
  66131. */
  66132. HighlightsEnhancingEffect: string;
  66133. /**
  66134. * @ignore
  66135. * The depth-of-field PostProcess id in the pipeline
  66136. */
  66137. LensDepthOfFieldEffect: string;
  66138. private _scene;
  66139. private _depthTexture;
  66140. private _grainTexture;
  66141. private _chromaticAberrationPostProcess;
  66142. private _highlightsPostProcess;
  66143. private _depthOfFieldPostProcess;
  66144. private _edgeBlur;
  66145. private _grainAmount;
  66146. private _chromaticAberration;
  66147. private _distortion;
  66148. private _highlightsGain;
  66149. private _highlightsThreshold;
  66150. private _dofDistance;
  66151. private _dofAperture;
  66152. private _dofDarken;
  66153. private _dofPentagon;
  66154. private _blurNoise;
  66155. /**
  66156. * @constructor
  66157. *
  66158. * Effect parameters are as follow:
  66159. * {
  66160. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66161. * edge_blur: number; // from 0 to x (1 for realism)
  66162. * distortion: number; // from 0 to x (1 for realism)
  66163. * grain_amount: number; // from 0 to 1
  66164. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66165. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66166. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66167. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66168. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66169. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66170. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66171. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66172. * }
  66173. * Note: if an effect parameter is unset, effect is disabled
  66174. *
  66175. * @param name The rendering pipeline name
  66176. * @param parameters - An object containing all parameters (see above)
  66177. * @param scene The scene linked to this pipeline
  66178. * @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)
  66179. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66180. */
  66181. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66182. /**
  66183. * Get the class name
  66184. * @returns "LensRenderingPipeline"
  66185. */
  66186. getClassName(): string;
  66187. /**
  66188. * Gets associated scene
  66189. */
  66190. get scene(): Scene;
  66191. /**
  66192. * Gets or sets the edge blur
  66193. */
  66194. get edgeBlur(): number;
  66195. set edgeBlur(value: number);
  66196. /**
  66197. * Gets or sets the grain amount
  66198. */
  66199. get grainAmount(): number;
  66200. set grainAmount(value: number);
  66201. /**
  66202. * Gets or sets the chromatic aberration amount
  66203. */
  66204. get chromaticAberration(): number;
  66205. set chromaticAberration(value: number);
  66206. /**
  66207. * Gets or sets the depth of field aperture
  66208. */
  66209. get dofAperture(): number;
  66210. set dofAperture(value: number);
  66211. /**
  66212. * Gets or sets the edge distortion
  66213. */
  66214. get edgeDistortion(): number;
  66215. set edgeDistortion(value: number);
  66216. /**
  66217. * Gets or sets the depth of field distortion
  66218. */
  66219. get dofDistortion(): number;
  66220. set dofDistortion(value: number);
  66221. /**
  66222. * Gets or sets the darken out of focus amount
  66223. */
  66224. get darkenOutOfFocus(): number;
  66225. set darkenOutOfFocus(value: number);
  66226. /**
  66227. * Gets or sets a boolean indicating if blur noise is enabled
  66228. */
  66229. get blurNoise(): boolean;
  66230. set blurNoise(value: boolean);
  66231. /**
  66232. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66233. */
  66234. get pentagonBokeh(): boolean;
  66235. set pentagonBokeh(value: boolean);
  66236. /**
  66237. * Gets or sets the highlight grain amount
  66238. */
  66239. get highlightsGain(): number;
  66240. set highlightsGain(value: number);
  66241. /**
  66242. * Gets or sets the highlight threshold
  66243. */
  66244. get highlightsThreshold(): number;
  66245. set highlightsThreshold(value: number);
  66246. /**
  66247. * Sets the amount of blur at the edges
  66248. * @param amount blur amount
  66249. */
  66250. setEdgeBlur(amount: number): void;
  66251. /**
  66252. * Sets edge blur to 0
  66253. */
  66254. disableEdgeBlur(): void;
  66255. /**
  66256. * Sets the amout of grain
  66257. * @param amount Amount of grain
  66258. */
  66259. setGrainAmount(amount: number): void;
  66260. /**
  66261. * Set grain amount to 0
  66262. */
  66263. disableGrain(): void;
  66264. /**
  66265. * Sets the chromatic aberration amount
  66266. * @param amount amount of chromatic aberration
  66267. */
  66268. setChromaticAberration(amount: number): void;
  66269. /**
  66270. * Sets chromatic aberration amount to 0
  66271. */
  66272. disableChromaticAberration(): void;
  66273. /**
  66274. * Sets the EdgeDistortion amount
  66275. * @param amount amount of EdgeDistortion
  66276. */
  66277. setEdgeDistortion(amount: number): void;
  66278. /**
  66279. * Sets edge distortion to 0
  66280. */
  66281. disableEdgeDistortion(): void;
  66282. /**
  66283. * Sets the FocusDistance amount
  66284. * @param amount amount of FocusDistance
  66285. */
  66286. setFocusDistance(amount: number): void;
  66287. /**
  66288. * Disables depth of field
  66289. */
  66290. disableDepthOfField(): void;
  66291. /**
  66292. * Sets the Aperture amount
  66293. * @param amount amount of Aperture
  66294. */
  66295. setAperture(amount: number): void;
  66296. /**
  66297. * Sets the DarkenOutOfFocus amount
  66298. * @param amount amount of DarkenOutOfFocus
  66299. */
  66300. setDarkenOutOfFocus(amount: number): void;
  66301. private _pentagonBokehIsEnabled;
  66302. /**
  66303. * Creates a pentagon bokeh effect
  66304. */
  66305. enablePentagonBokeh(): void;
  66306. /**
  66307. * Disables the pentagon bokeh effect
  66308. */
  66309. disablePentagonBokeh(): void;
  66310. /**
  66311. * Enables noise blur
  66312. */
  66313. enableNoiseBlur(): void;
  66314. /**
  66315. * Disables noise blur
  66316. */
  66317. disableNoiseBlur(): void;
  66318. /**
  66319. * Sets the HighlightsGain amount
  66320. * @param amount amount of HighlightsGain
  66321. */
  66322. setHighlightsGain(amount: number): void;
  66323. /**
  66324. * Sets the HighlightsThreshold amount
  66325. * @param amount amount of HighlightsThreshold
  66326. */
  66327. setHighlightsThreshold(amount: number): void;
  66328. /**
  66329. * Disables highlights
  66330. */
  66331. disableHighlights(): void;
  66332. /**
  66333. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66334. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66335. */
  66336. dispose(disableDepthRender?: boolean): void;
  66337. private _createChromaticAberrationPostProcess;
  66338. private _createHighlightsPostProcess;
  66339. private _createDepthOfFieldPostProcess;
  66340. private _createGrainTexture;
  66341. }
  66342. }
  66343. declare module BABYLON {
  66344. /** @hidden */
  66345. export var ssao2PixelShader: {
  66346. name: string;
  66347. shader: string;
  66348. };
  66349. }
  66350. declare module BABYLON {
  66351. /** @hidden */
  66352. export var ssaoCombinePixelShader: {
  66353. name: string;
  66354. shader: string;
  66355. };
  66356. }
  66357. declare module BABYLON {
  66358. /**
  66359. * Render pipeline to produce ssao effect
  66360. */
  66361. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66362. /**
  66363. * @ignore
  66364. * The PassPostProcess id in the pipeline that contains the original scene color
  66365. */
  66366. SSAOOriginalSceneColorEffect: string;
  66367. /**
  66368. * @ignore
  66369. * The SSAO PostProcess id in the pipeline
  66370. */
  66371. SSAORenderEffect: string;
  66372. /**
  66373. * @ignore
  66374. * The horizontal blur PostProcess id in the pipeline
  66375. */
  66376. SSAOBlurHRenderEffect: string;
  66377. /**
  66378. * @ignore
  66379. * The vertical blur PostProcess id in the pipeline
  66380. */
  66381. SSAOBlurVRenderEffect: string;
  66382. /**
  66383. * @ignore
  66384. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66385. */
  66386. SSAOCombineRenderEffect: string;
  66387. /**
  66388. * The output strength of the SSAO post-process. Default value is 1.0.
  66389. */
  66390. totalStrength: number;
  66391. /**
  66392. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66393. */
  66394. maxZ: number;
  66395. /**
  66396. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66397. */
  66398. minZAspect: number;
  66399. private _samples;
  66400. /**
  66401. * Number of samples used for the SSAO calculations. Default value is 8
  66402. */
  66403. set samples(n: number);
  66404. get samples(): number;
  66405. private _textureSamples;
  66406. /**
  66407. * Number of samples to use for antialiasing
  66408. */
  66409. set textureSamples(n: number);
  66410. get textureSamples(): number;
  66411. /**
  66412. * Ratio object used for SSAO ratio and blur ratio
  66413. */
  66414. private _ratio;
  66415. /**
  66416. * Dynamically generated sphere sampler.
  66417. */
  66418. private _sampleSphere;
  66419. /**
  66420. * Blur filter offsets
  66421. */
  66422. private _samplerOffsets;
  66423. private _expensiveBlur;
  66424. /**
  66425. * If bilateral blur should be used
  66426. */
  66427. set expensiveBlur(b: boolean);
  66428. get expensiveBlur(): boolean;
  66429. /**
  66430. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66431. */
  66432. radius: number;
  66433. /**
  66434. * The base color of the SSAO post-process
  66435. * The final result is "base + ssao" between [0, 1]
  66436. */
  66437. base: number;
  66438. /**
  66439. * Support test.
  66440. */
  66441. static get IsSupported(): boolean;
  66442. private _scene;
  66443. private _depthTexture;
  66444. private _normalTexture;
  66445. private _randomTexture;
  66446. private _originalColorPostProcess;
  66447. private _ssaoPostProcess;
  66448. private _blurHPostProcess;
  66449. private _blurVPostProcess;
  66450. private _ssaoCombinePostProcess;
  66451. /**
  66452. * Gets active scene
  66453. */
  66454. get scene(): Scene;
  66455. /**
  66456. * @constructor
  66457. * @param name The rendering pipeline name
  66458. * @param scene The scene linked to this pipeline
  66459. * @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 }
  66460. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66461. */
  66462. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66463. /**
  66464. * Get the class name
  66465. * @returns "SSAO2RenderingPipeline"
  66466. */
  66467. getClassName(): string;
  66468. /**
  66469. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66470. */
  66471. dispose(disableGeometryBufferRenderer?: boolean): void;
  66472. private _createBlurPostProcess;
  66473. /** @hidden */
  66474. _rebuild(): void;
  66475. private _bits;
  66476. private _radicalInverse_VdC;
  66477. private _hammersley;
  66478. private _hemisphereSample_uniform;
  66479. private _generateHemisphere;
  66480. private _createSSAOPostProcess;
  66481. private _createSSAOCombinePostProcess;
  66482. private _createRandomTexture;
  66483. /**
  66484. * Serialize the rendering pipeline (Used when exporting)
  66485. * @returns the serialized object
  66486. */
  66487. serialize(): any;
  66488. /**
  66489. * Parse the serialized pipeline
  66490. * @param source Source pipeline.
  66491. * @param scene The scene to load the pipeline to.
  66492. * @param rootUrl The URL of the serialized pipeline.
  66493. * @returns An instantiated pipeline from the serialized object.
  66494. */
  66495. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66496. }
  66497. }
  66498. declare module BABYLON {
  66499. /** @hidden */
  66500. export var ssaoPixelShader: {
  66501. name: string;
  66502. shader: string;
  66503. };
  66504. }
  66505. declare module BABYLON {
  66506. /**
  66507. * Render pipeline to produce ssao effect
  66508. */
  66509. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66510. /**
  66511. * @ignore
  66512. * The PassPostProcess id in the pipeline that contains the original scene color
  66513. */
  66514. SSAOOriginalSceneColorEffect: string;
  66515. /**
  66516. * @ignore
  66517. * The SSAO PostProcess id in the pipeline
  66518. */
  66519. SSAORenderEffect: string;
  66520. /**
  66521. * @ignore
  66522. * The horizontal blur PostProcess id in the pipeline
  66523. */
  66524. SSAOBlurHRenderEffect: string;
  66525. /**
  66526. * @ignore
  66527. * The vertical blur PostProcess id in the pipeline
  66528. */
  66529. SSAOBlurVRenderEffect: string;
  66530. /**
  66531. * @ignore
  66532. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66533. */
  66534. SSAOCombineRenderEffect: string;
  66535. /**
  66536. * The output strength of the SSAO post-process. Default value is 1.0.
  66537. */
  66538. totalStrength: number;
  66539. /**
  66540. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66541. */
  66542. radius: number;
  66543. /**
  66544. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66545. * Must not be equal to fallOff and superior to fallOff.
  66546. * Default value is 0.0075
  66547. */
  66548. area: number;
  66549. /**
  66550. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66551. * Must not be equal to area and inferior to area.
  66552. * Default value is 0.000001
  66553. */
  66554. fallOff: number;
  66555. /**
  66556. * The base color of the SSAO post-process
  66557. * The final result is "base + ssao" between [0, 1]
  66558. */
  66559. base: number;
  66560. private _scene;
  66561. private _depthTexture;
  66562. private _randomTexture;
  66563. private _originalColorPostProcess;
  66564. private _ssaoPostProcess;
  66565. private _blurHPostProcess;
  66566. private _blurVPostProcess;
  66567. private _ssaoCombinePostProcess;
  66568. private _firstUpdate;
  66569. /**
  66570. * Gets active scene
  66571. */
  66572. get scene(): Scene;
  66573. /**
  66574. * @constructor
  66575. * @param name - The rendering pipeline name
  66576. * @param scene - The scene linked to this pipeline
  66577. * @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 }
  66578. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66579. */
  66580. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66581. /**
  66582. * Get the class name
  66583. * @returns "SSAORenderingPipeline"
  66584. */
  66585. getClassName(): string;
  66586. /**
  66587. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66588. */
  66589. dispose(disableDepthRender?: boolean): void;
  66590. private _createBlurPostProcess;
  66591. /** @hidden */
  66592. _rebuild(): void;
  66593. private _createSSAOPostProcess;
  66594. private _createSSAOCombinePostProcess;
  66595. private _createRandomTexture;
  66596. }
  66597. }
  66598. declare module BABYLON {
  66599. /** @hidden */
  66600. export var screenSpaceReflectionPixelShader: {
  66601. name: string;
  66602. shader: string;
  66603. };
  66604. }
  66605. declare module BABYLON {
  66606. /**
  66607. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66608. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66609. */
  66610. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66611. /**
  66612. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66613. */
  66614. threshold: number;
  66615. /**
  66616. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66617. */
  66618. strength: number;
  66619. /**
  66620. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66621. */
  66622. reflectionSpecularFalloffExponent: number;
  66623. /**
  66624. * 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]
  66625. */
  66626. step: number;
  66627. /**
  66628. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66629. */
  66630. roughnessFactor: number;
  66631. private _geometryBufferRenderer;
  66632. private _enableSmoothReflections;
  66633. private _reflectionSamples;
  66634. private _smoothSteps;
  66635. /**
  66636. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66637. * @param name The name of the effect.
  66638. * @param scene The scene containing the objects to calculate reflections.
  66639. * @param options The required width/height ratio to downsize to before computing the render pass.
  66640. * @param camera The camera to apply the render pass to.
  66641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66642. * @param engine The engine which the post process will be applied. (default: current engine)
  66643. * @param reusable If the post process can be reused on the same frame. (default: false)
  66644. * @param textureType Type of textures used when performing the post process. (default: 0)
  66645. * @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)
  66646. */
  66647. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66648. /**
  66649. * Gets wether or not smoothing reflections is enabled.
  66650. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66651. */
  66652. get enableSmoothReflections(): boolean;
  66653. /**
  66654. * Sets wether or not smoothing reflections is enabled.
  66655. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66656. */
  66657. set enableSmoothReflections(enabled: boolean);
  66658. /**
  66659. * Gets the number of samples taken while computing reflections. More samples count is high,
  66660. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66661. */
  66662. get reflectionSamples(): number;
  66663. /**
  66664. * Sets the number of samples taken while computing reflections. More samples count is high,
  66665. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66666. */
  66667. set reflectionSamples(samples: number);
  66668. /**
  66669. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66670. * more the post-process will require GPU power and can generate a drop in FPS.
  66671. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66672. */
  66673. get smoothSteps(): number;
  66674. set smoothSteps(steps: number);
  66675. private _updateEffectDefines;
  66676. }
  66677. }
  66678. declare module BABYLON {
  66679. /** @hidden */
  66680. export var standardPixelShader: {
  66681. name: string;
  66682. shader: string;
  66683. };
  66684. }
  66685. declare module BABYLON {
  66686. /**
  66687. * Standard rendering pipeline
  66688. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66689. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66690. */
  66691. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66692. /**
  66693. * Public members
  66694. */
  66695. /**
  66696. * Post-process which contains the original scene color before the pipeline applies all the effects
  66697. */
  66698. originalPostProcess: Nullable<PostProcess>;
  66699. /**
  66700. * Post-process used to down scale an image x4
  66701. */
  66702. downSampleX4PostProcess: Nullable<PostProcess>;
  66703. /**
  66704. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66705. */
  66706. brightPassPostProcess: Nullable<PostProcess>;
  66707. /**
  66708. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66709. */
  66710. blurHPostProcesses: PostProcess[];
  66711. /**
  66712. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66713. */
  66714. blurVPostProcesses: PostProcess[];
  66715. /**
  66716. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66717. */
  66718. textureAdderPostProcess: Nullable<PostProcess>;
  66719. /**
  66720. * Post-process used to create volumetric lighting effect
  66721. */
  66722. volumetricLightPostProcess: Nullable<PostProcess>;
  66723. /**
  66724. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66725. */
  66726. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66727. /**
  66728. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66729. */
  66730. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66731. /**
  66732. * Post-process used to merge the volumetric light effect and the real scene color
  66733. */
  66734. volumetricLightMergePostProces: Nullable<PostProcess>;
  66735. /**
  66736. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66737. */
  66738. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66739. /**
  66740. * Base post-process used to calculate the average luminance of the final image for HDR
  66741. */
  66742. luminancePostProcess: Nullable<PostProcess>;
  66743. /**
  66744. * Post-processes used to create down sample post-processes in order to get
  66745. * the average luminance of the final image for HDR
  66746. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66747. */
  66748. luminanceDownSamplePostProcesses: PostProcess[];
  66749. /**
  66750. * Post-process used to create a HDR effect (light adaptation)
  66751. */
  66752. hdrPostProcess: Nullable<PostProcess>;
  66753. /**
  66754. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66755. */
  66756. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66757. /**
  66758. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66759. */
  66760. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66761. /**
  66762. * Post-process used to merge the final HDR post-process and the real scene color
  66763. */
  66764. hdrFinalPostProcess: Nullable<PostProcess>;
  66765. /**
  66766. * Post-process used to create a lens flare effect
  66767. */
  66768. lensFlarePostProcess: Nullable<PostProcess>;
  66769. /**
  66770. * Post-process that merges the result of the lens flare post-process and the real scene color
  66771. */
  66772. lensFlareComposePostProcess: Nullable<PostProcess>;
  66773. /**
  66774. * Post-process used to create a motion blur effect
  66775. */
  66776. motionBlurPostProcess: Nullable<PostProcess>;
  66777. /**
  66778. * Post-process used to create a depth of field effect
  66779. */
  66780. depthOfFieldPostProcess: Nullable<PostProcess>;
  66781. /**
  66782. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66783. */
  66784. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66785. /**
  66786. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66787. */
  66788. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66789. /**
  66790. * Represents the brightness threshold in order to configure the illuminated surfaces
  66791. */
  66792. brightThreshold: number;
  66793. /**
  66794. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66795. */
  66796. blurWidth: number;
  66797. /**
  66798. * Sets if the blur for highlighted surfaces must be only horizontal
  66799. */
  66800. horizontalBlur: boolean;
  66801. /**
  66802. * Gets the overall exposure used by the pipeline
  66803. */
  66804. get exposure(): number;
  66805. /**
  66806. * Sets the overall exposure used by the pipeline
  66807. */
  66808. set exposure(value: number);
  66809. /**
  66810. * Texture used typically to simulate "dirty" on camera lens
  66811. */
  66812. lensTexture: Nullable<Texture>;
  66813. /**
  66814. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66815. */
  66816. volumetricLightCoefficient: number;
  66817. /**
  66818. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66819. */
  66820. volumetricLightPower: number;
  66821. /**
  66822. * Used the set the blur intensity to smooth the volumetric lights
  66823. */
  66824. volumetricLightBlurScale: number;
  66825. /**
  66826. * Light (spot or directional) used to generate the volumetric lights rays
  66827. * The source light must have a shadow generate so the pipeline can get its
  66828. * depth map
  66829. */
  66830. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66831. /**
  66832. * For eye adaptation, represents the minimum luminance the eye can see
  66833. */
  66834. hdrMinimumLuminance: number;
  66835. /**
  66836. * For eye adaptation, represents the decrease luminance speed
  66837. */
  66838. hdrDecreaseRate: number;
  66839. /**
  66840. * For eye adaptation, represents the increase luminance speed
  66841. */
  66842. hdrIncreaseRate: number;
  66843. /**
  66844. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66845. */
  66846. get hdrAutoExposure(): boolean;
  66847. /**
  66848. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66849. */
  66850. set hdrAutoExposure(value: boolean);
  66851. /**
  66852. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66853. */
  66854. lensColorTexture: Nullable<Texture>;
  66855. /**
  66856. * The overall strengh for the lens flare effect
  66857. */
  66858. lensFlareStrength: number;
  66859. /**
  66860. * Dispersion coefficient for lens flare ghosts
  66861. */
  66862. lensFlareGhostDispersal: number;
  66863. /**
  66864. * Main lens flare halo width
  66865. */
  66866. lensFlareHaloWidth: number;
  66867. /**
  66868. * Based on the lens distortion effect, defines how much the lens flare result
  66869. * is distorted
  66870. */
  66871. lensFlareDistortionStrength: number;
  66872. /**
  66873. * Configures the blur intensity used for for lens flare (halo)
  66874. */
  66875. lensFlareBlurWidth: number;
  66876. /**
  66877. * Lens star texture must be used to simulate rays on the flares and is available
  66878. * in the documentation
  66879. */
  66880. lensStarTexture: Nullable<Texture>;
  66881. /**
  66882. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66883. * flare effect by taking account of the dirt texture
  66884. */
  66885. lensFlareDirtTexture: Nullable<Texture>;
  66886. /**
  66887. * Represents the focal length for the depth of field effect
  66888. */
  66889. depthOfFieldDistance: number;
  66890. /**
  66891. * Represents the blur intensity for the blurred part of the depth of field effect
  66892. */
  66893. depthOfFieldBlurWidth: number;
  66894. /**
  66895. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66896. */
  66897. get motionStrength(): number;
  66898. /**
  66899. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66900. */
  66901. set motionStrength(strength: number);
  66902. /**
  66903. * Gets wether or not the motion blur post-process is object based or screen based.
  66904. */
  66905. get objectBasedMotionBlur(): boolean;
  66906. /**
  66907. * Sets wether or not the motion blur post-process should be object based or screen based
  66908. */
  66909. set objectBasedMotionBlur(value: boolean);
  66910. /**
  66911. * List of animations for the pipeline (IAnimatable implementation)
  66912. */
  66913. animations: Animation[];
  66914. /**
  66915. * Private members
  66916. */
  66917. private _scene;
  66918. private _currentDepthOfFieldSource;
  66919. private _basePostProcess;
  66920. private _fixedExposure;
  66921. private _currentExposure;
  66922. private _hdrAutoExposure;
  66923. private _hdrCurrentLuminance;
  66924. private _motionStrength;
  66925. private _isObjectBasedMotionBlur;
  66926. private _floatTextureType;
  66927. private _camerasToBeAttached;
  66928. private _ratio;
  66929. private _bloomEnabled;
  66930. private _depthOfFieldEnabled;
  66931. private _vlsEnabled;
  66932. private _lensFlareEnabled;
  66933. private _hdrEnabled;
  66934. private _motionBlurEnabled;
  66935. private _fxaaEnabled;
  66936. private _screenSpaceReflectionsEnabled;
  66937. private _motionBlurSamples;
  66938. private _volumetricLightStepsCount;
  66939. private _samples;
  66940. /**
  66941. * @ignore
  66942. * Specifies if the bloom pipeline is enabled
  66943. */
  66944. get BloomEnabled(): boolean;
  66945. set BloomEnabled(enabled: boolean);
  66946. /**
  66947. * @ignore
  66948. * Specifies if the depth of field pipeline is enabed
  66949. */
  66950. get DepthOfFieldEnabled(): boolean;
  66951. set DepthOfFieldEnabled(enabled: boolean);
  66952. /**
  66953. * @ignore
  66954. * Specifies if the lens flare pipeline is enabed
  66955. */
  66956. get LensFlareEnabled(): boolean;
  66957. set LensFlareEnabled(enabled: boolean);
  66958. /**
  66959. * @ignore
  66960. * Specifies if the HDR pipeline is enabled
  66961. */
  66962. get HDREnabled(): boolean;
  66963. set HDREnabled(enabled: boolean);
  66964. /**
  66965. * @ignore
  66966. * Specifies if the volumetric lights scattering effect is enabled
  66967. */
  66968. get VLSEnabled(): boolean;
  66969. set VLSEnabled(enabled: boolean);
  66970. /**
  66971. * @ignore
  66972. * Specifies if the motion blur effect is enabled
  66973. */
  66974. get MotionBlurEnabled(): boolean;
  66975. set MotionBlurEnabled(enabled: boolean);
  66976. /**
  66977. * Specifies if anti-aliasing is enabled
  66978. */
  66979. get fxaaEnabled(): boolean;
  66980. set fxaaEnabled(enabled: boolean);
  66981. /**
  66982. * Specifies if screen space reflections are enabled.
  66983. */
  66984. get screenSpaceReflectionsEnabled(): boolean;
  66985. set screenSpaceReflectionsEnabled(enabled: boolean);
  66986. /**
  66987. * Specifies the number of steps used to calculate the volumetric lights
  66988. * Typically in interval [50, 200]
  66989. */
  66990. get volumetricLightStepsCount(): number;
  66991. set volumetricLightStepsCount(count: number);
  66992. /**
  66993. * Specifies the number of samples used for the motion blur effect
  66994. * Typically in interval [16, 64]
  66995. */
  66996. get motionBlurSamples(): number;
  66997. set motionBlurSamples(samples: number);
  66998. /**
  66999. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67000. */
  67001. get samples(): number;
  67002. set samples(sampleCount: number);
  67003. /**
  67004. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67005. * @constructor
  67006. * @param name The rendering pipeline name
  67007. * @param scene The scene linked to this pipeline
  67008. * @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)
  67009. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67010. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67011. */
  67012. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67013. private _buildPipeline;
  67014. private _createDownSampleX4PostProcess;
  67015. private _createBrightPassPostProcess;
  67016. private _createBlurPostProcesses;
  67017. private _createTextureAdderPostProcess;
  67018. private _createVolumetricLightPostProcess;
  67019. private _createLuminancePostProcesses;
  67020. private _createHdrPostProcess;
  67021. private _createLensFlarePostProcess;
  67022. private _createDepthOfFieldPostProcess;
  67023. private _createMotionBlurPostProcess;
  67024. private _getDepthTexture;
  67025. private _disposePostProcesses;
  67026. /**
  67027. * Dispose of the pipeline and stop all post processes
  67028. */
  67029. dispose(): void;
  67030. /**
  67031. * Serialize the rendering pipeline (Used when exporting)
  67032. * @returns the serialized object
  67033. */
  67034. serialize(): any;
  67035. /**
  67036. * Parse the serialized pipeline
  67037. * @param source Source pipeline.
  67038. * @param scene The scene to load the pipeline to.
  67039. * @param rootUrl The URL of the serialized pipeline.
  67040. * @returns An instantiated pipeline from the serialized object.
  67041. */
  67042. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67043. /**
  67044. * Luminance steps
  67045. */
  67046. static LuminanceSteps: number;
  67047. }
  67048. }
  67049. declare module BABYLON {
  67050. /** @hidden */
  67051. export var tonemapPixelShader: {
  67052. name: string;
  67053. shader: string;
  67054. };
  67055. }
  67056. declare module BABYLON {
  67057. /** Defines operator used for tonemapping */
  67058. export enum TonemappingOperator {
  67059. /** Hable */
  67060. Hable = 0,
  67061. /** Reinhard */
  67062. Reinhard = 1,
  67063. /** HejiDawson */
  67064. HejiDawson = 2,
  67065. /** Photographic */
  67066. Photographic = 3
  67067. }
  67068. /**
  67069. * Defines a post process to apply tone mapping
  67070. */
  67071. export class TonemapPostProcess extends PostProcess {
  67072. private _operator;
  67073. /** Defines the required exposure adjustement */
  67074. exposureAdjustment: number;
  67075. /**
  67076. * Creates a new TonemapPostProcess
  67077. * @param name defines the name of the postprocess
  67078. * @param _operator defines the operator to use
  67079. * @param exposureAdjustment defines the required exposure adjustement
  67080. * @param camera defines the camera to use (can be null)
  67081. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67082. * @param engine defines the hosting engine (can be ignore if camera is set)
  67083. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67084. */
  67085. constructor(name: string, _operator: TonemappingOperator,
  67086. /** Defines the required exposure adjustement */
  67087. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67088. }
  67089. }
  67090. declare module BABYLON {
  67091. /** @hidden */
  67092. export var volumetricLightScatteringPixelShader: {
  67093. name: string;
  67094. shader: string;
  67095. };
  67096. }
  67097. declare module BABYLON {
  67098. /** @hidden */
  67099. export var volumetricLightScatteringPassVertexShader: {
  67100. name: string;
  67101. shader: string;
  67102. };
  67103. }
  67104. declare module BABYLON {
  67105. /** @hidden */
  67106. export var volumetricLightScatteringPassPixelShader: {
  67107. name: string;
  67108. shader: string;
  67109. };
  67110. }
  67111. declare module BABYLON {
  67112. /**
  67113. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67114. */
  67115. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67116. private _volumetricLightScatteringPass;
  67117. private _volumetricLightScatteringRTT;
  67118. private _viewPort;
  67119. private _screenCoordinates;
  67120. private _cachedDefines;
  67121. /**
  67122. * If not undefined, the mesh position is computed from the attached node position
  67123. */
  67124. attachedNode: {
  67125. position: Vector3;
  67126. };
  67127. /**
  67128. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67129. */
  67130. customMeshPosition: Vector3;
  67131. /**
  67132. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67133. */
  67134. useCustomMeshPosition: boolean;
  67135. /**
  67136. * If the post-process should inverse the light scattering direction
  67137. */
  67138. invert: boolean;
  67139. /**
  67140. * The internal mesh used by the post-process
  67141. */
  67142. mesh: Mesh;
  67143. /**
  67144. * @hidden
  67145. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67146. */
  67147. get useDiffuseColor(): boolean;
  67148. set useDiffuseColor(useDiffuseColor: boolean);
  67149. /**
  67150. * Array containing the excluded meshes not rendered in the internal pass
  67151. */
  67152. excludedMeshes: AbstractMesh[];
  67153. /**
  67154. * Controls the overall intensity of the post-process
  67155. */
  67156. exposure: number;
  67157. /**
  67158. * Dissipates each sample's contribution in range [0, 1]
  67159. */
  67160. decay: number;
  67161. /**
  67162. * Controls the overall intensity of each sample
  67163. */
  67164. weight: number;
  67165. /**
  67166. * Controls the density of each sample
  67167. */
  67168. density: number;
  67169. /**
  67170. * @constructor
  67171. * @param name The post-process name
  67172. * @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)
  67173. * @param camera The camera that the post-process will be attached to
  67174. * @param mesh The mesh used to create the light scattering
  67175. * @param samples The post-process quality, default 100
  67176. * @param samplingModeThe post-process filtering mode
  67177. * @param engine The babylon engine
  67178. * @param reusable If the post-process is reusable
  67179. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67180. */
  67181. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67182. /**
  67183. * Returns the string "VolumetricLightScatteringPostProcess"
  67184. * @returns "VolumetricLightScatteringPostProcess"
  67185. */
  67186. getClassName(): string;
  67187. private _isReady;
  67188. /**
  67189. * Sets the new light position for light scattering effect
  67190. * @param position The new custom light position
  67191. */
  67192. setCustomMeshPosition(position: Vector3): void;
  67193. /**
  67194. * Returns the light position for light scattering effect
  67195. * @return Vector3 The custom light position
  67196. */
  67197. getCustomMeshPosition(): Vector3;
  67198. /**
  67199. * Disposes the internal assets and detaches the post-process from the camera
  67200. */
  67201. dispose(camera: Camera): void;
  67202. /**
  67203. * Returns the render target texture used by the post-process
  67204. * @return the render target texture used by the post-process
  67205. */
  67206. getPass(): RenderTargetTexture;
  67207. private _meshExcluded;
  67208. private _createPass;
  67209. private _updateMeshScreenCoordinates;
  67210. /**
  67211. * Creates a default mesh for the Volumeric Light Scattering post-process
  67212. * @param name The mesh name
  67213. * @param scene The scene where to create the mesh
  67214. * @return the default mesh
  67215. */
  67216. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67217. }
  67218. }
  67219. declare module BABYLON {
  67220. interface Scene {
  67221. /** @hidden (Backing field) */
  67222. _boundingBoxRenderer: BoundingBoxRenderer;
  67223. /** @hidden (Backing field) */
  67224. _forceShowBoundingBoxes: boolean;
  67225. /**
  67226. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67227. */
  67228. forceShowBoundingBoxes: boolean;
  67229. /**
  67230. * Gets the bounding box renderer associated with the scene
  67231. * @returns a BoundingBoxRenderer
  67232. */
  67233. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67234. }
  67235. interface AbstractMesh {
  67236. /** @hidden (Backing field) */
  67237. _showBoundingBox: boolean;
  67238. /**
  67239. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67240. */
  67241. showBoundingBox: boolean;
  67242. }
  67243. /**
  67244. * Component responsible of rendering the bounding box of the meshes in a scene.
  67245. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67246. */
  67247. export class BoundingBoxRenderer implements ISceneComponent {
  67248. /**
  67249. * The component name helpfull to identify the component in the list of scene components.
  67250. */
  67251. readonly name: string;
  67252. /**
  67253. * The scene the component belongs to.
  67254. */
  67255. scene: Scene;
  67256. /**
  67257. * Color of the bounding box lines placed in front of an object
  67258. */
  67259. frontColor: Color3;
  67260. /**
  67261. * Color of the bounding box lines placed behind an object
  67262. */
  67263. backColor: Color3;
  67264. /**
  67265. * Defines if the renderer should show the back lines or not
  67266. */
  67267. showBackLines: boolean;
  67268. /**
  67269. * @hidden
  67270. */
  67271. renderList: SmartArray<BoundingBox>;
  67272. private _colorShader;
  67273. private _vertexBuffers;
  67274. private _indexBuffer;
  67275. private _fillIndexBuffer;
  67276. private _fillIndexData;
  67277. /**
  67278. * Instantiates a new bounding box renderer in a scene.
  67279. * @param scene the scene the renderer renders in
  67280. */
  67281. constructor(scene: Scene);
  67282. /**
  67283. * Registers the component in a given scene
  67284. */
  67285. register(): void;
  67286. private _evaluateSubMesh;
  67287. private _activeMesh;
  67288. private _prepareRessources;
  67289. private _createIndexBuffer;
  67290. /**
  67291. * Rebuilds the elements related to this component in case of
  67292. * context lost for instance.
  67293. */
  67294. rebuild(): void;
  67295. /**
  67296. * @hidden
  67297. */
  67298. reset(): void;
  67299. /**
  67300. * Render the bounding boxes of a specific rendering group
  67301. * @param renderingGroupId defines the rendering group to render
  67302. */
  67303. render(renderingGroupId: number): void;
  67304. /**
  67305. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67306. * @param mesh Define the mesh to render the occlusion bounding box for
  67307. */
  67308. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67309. /**
  67310. * Dispose and release the resources attached to this renderer.
  67311. */
  67312. dispose(): void;
  67313. }
  67314. }
  67315. declare module BABYLON {
  67316. interface Scene {
  67317. /** @hidden (Backing field) */
  67318. _depthRenderer: {
  67319. [id: string]: DepthRenderer;
  67320. };
  67321. /**
  67322. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67323. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67324. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67325. * @returns the created depth renderer
  67326. */
  67327. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67328. /**
  67329. * Disables a depth renderer for a given camera
  67330. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67331. */
  67332. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67333. }
  67334. /**
  67335. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67336. * in several rendering techniques.
  67337. */
  67338. export class DepthRendererSceneComponent implements ISceneComponent {
  67339. /**
  67340. * The component name helpfull to identify the component in the list of scene components.
  67341. */
  67342. readonly name: string;
  67343. /**
  67344. * The scene the component belongs to.
  67345. */
  67346. scene: Scene;
  67347. /**
  67348. * Creates a new instance of the component for the given scene
  67349. * @param scene Defines the scene to register the component in
  67350. */
  67351. constructor(scene: Scene);
  67352. /**
  67353. * Registers the component in a given scene
  67354. */
  67355. register(): void;
  67356. /**
  67357. * Rebuilds the elements related to this component in case of
  67358. * context lost for instance.
  67359. */
  67360. rebuild(): void;
  67361. /**
  67362. * Disposes the component and the associated ressources
  67363. */
  67364. dispose(): void;
  67365. private _gatherRenderTargets;
  67366. private _gatherActiveCameraRenderTargets;
  67367. }
  67368. }
  67369. declare module BABYLON {
  67370. /** @hidden */
  67371. export var outlinePixelShader: {
  67372. name: string;
  67373. shader: string;
  67374. };
  67375. }
  67376. declare module BABYLON {
  67377. /** @hidden */
  67378. export var outlineVertexShader: {
  67379. name: string;
  67380. shader: string;
  67381. };
  67382. }
  67383. declare module BABYLON {
  67384. interface Scene {
  67385. /** @hidden */
  67386. _outlineRenderer: OutlineRenderer;
  67387. /**
  67388. * Gets the outline renderer associated with the scene
  67389. * @returns a OutlineRenderer
  67390. */
  67391. getOutlineRenderer(): OutlineRenderer;
  67392. }
  67393. interface AbstractMesh {
  67394. /** @hidden (Backing field) */
  67395. _renderOutline: boolean;
  67396. /**
  67397. * Gets or sets a boolean indicating if the outline must be rendered as well
  67398. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67399. */
  67400. renderOutline: boolean;
  67401. /** @hidden (Backing field) */
  67402. _renderOverlay: boolean;
  67403. /**
  67404. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67405. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67406. */
  67407. renderOverlay: boolean;
  67408. }
  67409. /**
  67410. * This class is responsible to draw bothe outline/overlay of meshes.
  67411. * It should not be used directly but through the available method on mesh.
  67412. */
  67413. export class OutlineRenderer implements ISceneComponent {
  67414. /**
  67415. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67416. */
  67417. private static _StencilReference;
  67418. /**
  67419. * The name of the component. Each component must have a unique name.
  67420. */
  67421. name: string;
  67422. /**
  67423. * The scene the component belongs to.
  67424. */
  67425. scene: Scene;
  67426. /**
  67427. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67428. */
  67429. zOffset: number;
  67430. private _engine;
  67431. private _effect;
  67432. private _cachedDefines;
  67433. private _savedDepthWrite;
  67434. /**
  67435. * Instantiates a new outline renderer. (There could be only one per scene).
  67436. * @param scene Defines the scene it belongs to
  67437. */
  67438. constructor(scene: Scene);
  67439. /**
  67440. * Register the component to one instance of a scene.
  67441. */
  67442. register(): void;
  67443. /**
  67444. * Rebuilds the elements related to this component in case of
  67445. * context lost for instance.
  67446. */
  67447. rebuild(): void;
  67448. /**
  67449. * Disposes the component and the associated ressources.
  67450. */
  67451. dispose(): void;
  67452. /**
  67453. * Renders the outline in the canvas.
  67454. * @param subMesh Defines the sumesh to render
  67455. * @param batch Defines the batch of meshes in case of instances
  67456. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67457. */
  67458. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67459. /**
  67460. * Returns whether or not the outline renderer is ready for a given submesh.
  67461. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67462. * @param subMesh Defines the submesh to check readyness for
  67463. * @param useInstances Defines wheter wee are trying to render instances or not
  67464. * @returns true if ready otherwise false
  67465. */
  67466. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67467. private _beforeRenderingMesh;
  67468. private _afterRenderingMesh;
  67469. }
  67470. }
  67471. declare module BABYLON {
  67472. /**
  67473. * Defines the basic options interface of a Sprite Frame Source Size.
  67474. */
  67475. export interface ISpriteJSONSpriteSourceSize {
  67476. /**
  67477. * number of the original width of the Frame
  67478. */
  67479. w: number;
  67480. /**
  67481. * number of the original height of the Frame
  67482. */
  67483. h: number;
  67484. }
  67485. /**
  67486. * Defines the basic options interface of a Sprite Frame Data.
  67487. */
  67488. export interface ISpriteJSONSpriteFrameData {
  67489. /**
  67490. * number of the x offset of the Frame
  67491. */
  67492. x: number;
  67493. /**
  67494. * number of the y offset of the Frame
  67495. */
  67496. y: number;
  67497. /**
  67498. * number of the width of the Frame
  67499. */
  67500. w: number;
  67501. /**
  67502. * number of the height of the Frame
  67503. */
  67504. h: number;
  67505. }
  67506. /**
  67507. * Defines the basic options interface of a JSON Sprite.
  67508. */
  67509. export interface ISpriteJSONSprite {
  67510. /**
  67511. * string name of the Frame
  67512. */
  67513. filename: string;
  67514. /**
  67515. * ISpriteJSONSpriteFrame basic object of the frame data
  67516. */
  67517. frame: ISpriteJSONSpriteFrameData;
  67518. /**
  67519. * boolean to flag is the frame was rotated.
  67520. */
  67521. rotated: boolean;
  67522. /**
  67523. * boolean to flag is the frame was trimmed.
  67524. */
  67525. trimmed: boolean;
  67526. /**
  67527. * ISpriteJSONSpriteFrame basic object of the source data
  67528. */
  67529. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67530. /**
  67531. * ISpriteJSONSpriteFrame basic object of the source data
  67532. */
  67533. sourceSize: ISpriteJSONSpriteSourceSize;
  67534. }
  67535. /**
  67536. * Defines the basic options interface of a JSON atlas.
  67537. */
  67538. export interface ISpriteJSONAtlas {
  67539. /**
  67540. * Array of objects that contain the frame data.
  67541. */
  67542. frames: Array<ISpriteJSONSprite>;
  67543. /**
  67544. * object basic object containing the sprite meta data.
  67545. */
  67546. meta?: object;
  67547. }
  67548. }
  67549. declare module BABYLON {
  67550. /** @hidden */
  67551. export var spriteMapPixelShader: {
  67552. name: string;
  67553. shader: string;
  67554. };
  67555. }
  67556. declare module BABYLON {
  67557. /** @hidden */
  67558. export var spriteMapVertexShader: {
  67559. name: string;
  67560. shader: string;
  67561. };
  67562. }
  67563. declare module BABYLON {
  67564. /**
  67565. * Defines the basic options interface of a SpriteMap
  67566. */
  67567. export interface ISpriteMapOptions {
  67568. /**
  67569. * Vector2 of the number of cells in the grid.
  67570. */
  67571. stageSize?: Vector2;
  67572. /**
  67573. * Vector2 of the size of the output plane in World Units.
  67574. */
  67575. outputSize?: Vector2;
  67576. /**
  67577. * Vector3 of the position of the output plane in World Units.
  67578. */
  67579. outputPosition?: Vector3;
  67580. /**
  67581. * Vector3 of the rotation of the output plane.
  67582. */
  67583. outputRotation?: Vector3;
  67584. /**
  67585. * number of layers that the system will reserve in resources.
  67586. */
  67587. layerCount?: number;
  67588. /**
  67589. * number of max animation frames a single cell will reserve in resources.
  67590. */
  67591. maxAnimationFrames?: number;
  67592. /**
  67593. * number cell index of the base tile when the system compiles.
  67594. */
  67595. baseTile?: number;
  67596. /**
  67597. * boolean flip the sprite after its been repositioned by the framing data.
  67598. */
  67599. flipU?: boolean;
  67600. /**
  67601. * Vector3 scalar of the global RGB values of the SpriteMap.
  67602. */
  67603. colorMultiply?: Vector3;
  67604. }
  67605. /**
  67606. * Defines the IDisposable interface in order to be cleanable from resources.
  67607. */
  67608. export interface ISpriteMap extends IDisposable {
  67609. /**
  67610. * String name of the SpriteMap.
  67611. */
  67612. name: string;
  67613. /**
  67614. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67615. */
  67616. atlasJSON: ISpriteJSONAtlas;
  67617. /**
  67618. * Texture of the SpriteMap.
  67619. */
  67620. spriteSheet: Texture;
  67621. /**
  67622. * The parameters to initialize the SpriteMap with.
  67623. */
  67624. options: ISpriteMapOptions;
  67625. }
  67626. /**
  67627. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67628. */
  67629. export class SpriteMap implements ISpriteMap {
  67630. /** The Name of the spriteMap */
  67631. name: string;
  67632. /** The JSON file with the frame and meta data */
  67633. atlasJSON: ISpriteJSONAtlas;
  67634. /** The systems Sprite Sheet Texture */
  67635. spriteSheet: Texture;
  67636. /** Arguments passed with the Constructor */
  67637. options: ISpriteMapOptions;
  67638. /** Public Sprite Storage array, parsed from atlasJSON */
  67639. sprites: Array<ISpriteJSONSprite>;
  67640. /** Returns the Number of Sprites in the System */
  67641. get spriteCount(): number;
  67642. /** Returns the Position of Output Plane*/
  67643. get position(): Vector3;
  67644. /** Returns the Position of Output Plane*/
  67645. set position(v: Vector3);
  67646. /** Returns the Rotation of Output Plane*/
  67647. get rotation(): Vector3;
  67648. /** Returns the Rotation of Output Plane*/
  67649. set rotation(v: Vector3);
  67650. /** Sets the AnimationMap*/
  67651. get animationMap(): RawTexture;
  67652. /** Sets the AnimationMap*/
  67653. set animationMap(v: RawTexture);
  67654. /** Scene that the SpriteMap was created in */
  67655. private _scene;
  67656. /** Texture Buffer of Float32 that holds tile frame data*/
  67657. private _frameMap;
  67658. /** Texture Buffers of Float32 that holds tileMap data*/
  67659. private _tileMaps;
  67660. /** Texture Buffer of Float32 that holds Animation Data*/
  67661. private _animationMap;
  67662. /** Custom ShaderMaterial Central to the System*/
  67663. private _material;
  67664. /** Custom ShaderMaterial Central to the System*/
  67665. private _output;
  67666. /** Systems Time Ticker*/
  67667. private _time;
  67668. /**
  67669. * Creates a new SpriteMap
  67670. * @param name defines the SpriteMaps Name
  67671. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67672. * @param spriteSheet is the Texture that the Sprites are on.
  67673. * @param options a basic deployment configuration
  67674. * @param scene The Scene that the map is deployed on
  67675. */
  67676. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67677. /**
  67678. * Returns tileID location
  67679. * @returns Vector2 the cell position ID
  67680. */
  67681. getTileID(): Vector2;
  67682. /**
  67683. * Gets the UV location of the mouse over the SpriteMap.
  67684. * @returns Vector2 the UV position of the mouse interaction
  67685. */
  67686. getMousePosition(): Vector2;
  67687. /**
  67688. * Creates the "frame" texture Buffer
  67689. * -------------------------------------
  67690. * Structure of frames
  67691. * "filename": "Falling-Water-2.png",
  67692. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67693. * "rotated": true,
  67694. * "trimmed": true,
  67695. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67696. * "sourceSize": {"w":32,"h":32}
  67697. * @returns RawTexture of the frameMap
  67698. */
  67699. private _createFrameBuffer;
  67700. /**
  67701. * Creates the tileMap texture Buffer
  67702. * @param buffer normally and array of numbers, or a false to generate from scratch
  67703. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67704. * @returns RawTexture of the tileMap
  67705. */
  67706. private _createTileBuffer;
  67707. /**
  67708. * Modifies the data of the tileMaps
  67709. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67710. * @param pos is the iVector2 Coordinates of the Tile
  67711. * @param tile The SpriteIndex of the new Tile
  67712. */
  67713. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67714. /**
  67715. * Creates the animationMap texture Buffer
  67716. * @param buffer normally and array of numbers, or a false to generate from scratch
  67717. * @returns RawTexture of the animationMap
  67718. */
  67719. private _createTileAnimationBuffer;
  67720. /**
  67721. * Modifies the data of the animationMap
  67722. * @param cellID is the Index of the Sprite
  67723. * @param _frame is the target Animation frame
  67724. * @param toCell is the Target Index of the next frame of the animation
  67725. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67726. * @param speed is a global scalar of the time variable on the map.
  67727. */
  67728. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67729. /**
  67730. * Exports the .tilemaps file
  67731. */
  67732. saveTileMaps(): void;
  67733. /**
  67734. * Imports the .tilemaps file
  67735. * @param url of the .tilemaps file
  67736. */
  67737. loadTileMaps(url: string): void;
  67738. /**
  67739. * Release associated resources
  67740. */
  67741. dispose(): void;
  67742. }
  67743. }
  67744. declare module BABYLON {
  67745. /**
  67746. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67747. * @see http://doc.babylonjs.com/babylon101/sprites
  67748. */
  67749. export class SpritePackedManager extends SpriteManager {
  67750. /** defines the packed manager's name */
  67751. name: string;
  67752. /**
  67753. * Creates a new sprite manager from a packed sprite sheet
  67754. * @param name defines the manager's name
  67755. * @param imgUrl defines the sprite sheet url
  67756. * @param capacity defines the maximum allowed number of sprites
  67757. * @param scene defines the hosting scene
  67758. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67759. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67760. * @param samplingMode defines the smapling mode to use with spritesheet
  67761. * @param fromPacked set to true; do not alter
  67762. */
  67763. constructor(
  67764. /** defines the packed manager's name */
  67765. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67766. }
  67767. }
  67768. declare module BABYLON {
  67769. /**
  67770. * Defines the list of states available for a task inside a AssetsManager
  67771. */
  67772. export enum AssetTaskState {
  67773. /**
  67774. * Initialization
  67775. */
  67776. INIT = 0,
  67777. /**
  67778. * Running
  67779. */
  67780. RUNNING = 1,
  67781. /**
  67782. * Done
  67783. */
  67784. DONE = 2,
  67785. /**
  67786. * Error
  67787. */
  67788. ERROR = 3
  67789. }
  67790. /**
  67791. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67792. */
  67793. export abstract class AbstractAssetTask {
  67794. /**
  67795. * Task name
  67796. */ name: string;
  67797. /**
  67798. * Callback called when the task is successful
  67799. */
  67800. onSuccess: (task: any) => void;
  67801. /**
  67802. * Callback called when the task is not successful
  67803. */
  67804. onError: (task: any, message?: string, exception?: any) => void;
  67805. /**
  67806. * Creates a new AssetsManager
  67807. * @param name defines the name of the task
  67808. */
  67809. constructor(
  67810. /**
  67811. * Task name
  67812. */ name: string);
  67813. private _isCompleted;
  67814. private _taskState;
  67815. private _errorObject;
  67816. /**
  67817. * Get if the task is completed
  67818. */
  67819. get isCompleted(): boolean;
  67820. /**
  67821. * Gets the current state of the task
  67822. */
  67823. get taskState(): AssetTaskState;
  67824. /**
  67825. * Gets the current error object (if task is in error)
  67826. */
  67827. get errorObject(): {
  67828. message?: string;
  67829. exception?: any;
  67830. };
  67831. /**
  67832. * Internal only
  67833. * @hidden
  67834. */
  67835. _setErrorObject(message?: string, exception?: any): void;
  67836. /**
  67837. * Execute the current task
  67838. * @param scene defines the scene where you want your assets to be loaded
  67839. * @param onSuccess is a callback called when the task is successfully executed
  67840. * @param onError is a callback called if an error occurs
  67841. */
  67842. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67843. /**
  67844. * Execute the current task
  67845. * @param scene defines the scene where you want your assets to be loaded
  67846. * @param onSuccess is a callback called when the task is successfully executed
  67847. * @param onError is a callback called if an error occurs
  67848. */
  67849. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67850. /**
  67851. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67852. * This can be used with failed tasks that have the reason for failure fixed.
  67853. */
  67854. reset(): void;
  67855. private onErrorCallback;
  67856. private onDoneCallback;
  67857. }
  67858. /**
  67859. * Define the interface used by progress events raised during assets loading
  67860. */
  67861. export interface IAssetsProgressEvent {
  67862. /**
  67863. * Defines the number of remaining tasks to process
  67864. */
  67865. remainingCount: number;
  67866. /**
  67867. * Defines the total number of tasks
  67868. */
  67869. totalCount: number;
  67870. /**
  67871. * Defines the task that was just processed
  67872. */
  67873. task: AbstractAssetTask;
  67874. }
  67875. /**
  67876. * Class used to share progress information about assets loading
  67877. */
  67878. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67879. /**
  67880. * Defines the number of remaining tasks to process
  67881. */
  67882. remainingCount: number;
  67883. /**
  67884. * Defines the total number of tasks
  67885. */
  67886. totalCount: number;
  67887. /**
  67888. * Defines the task that was just processed
  67889. */
  67890. task: AbstractAssetTask;
  67891. /**
  67892. * Creates a AssetsProgressEvent
  67893. * @param remainingCount defines the number of remaining tasks to process
  67894. * @param totalCount defines the total number of tasks
  67895. * @param task defines the task that was just processed
  67896. */
  67897. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67898. }
  67899. /**
  67900. * Define a task used by AssetsManager to load meshes
  67901. */
  67902. export class MeshAssetTask extends AbstractAssetTask {
  67903. /**
  67904. * Defines the name of the task
  67905. */
  67906. name: string;
  67907. /**
  67908. * Defines the list of mesh's names you want to load
  67909. */
  67910. meshesNames: any;
  67911. /**
  67912. * Defines the root url to use as a base to load your meshes and associated resources
  67913. */
  67914. rootUrl: string;
  67915. /**
  67916. * Defines the filename of the scene to load from
  67917. */
  67918. sceneFilename: string;
  67919. /**
  67920. * Gets the list of loaded meshes
  67921. */
  67922. loadedMeshes: Array<AbstractMesh>;
  67923. /**
  67924. * Gets the list of loaded particle systems
  67925. */
  67926. loadedParticleSystems: Array<IParticleSystem>;
  67927. /**
  67928. * Gets the list of loaded skeletons
  67929. */
  67930. loadedSkeletons: Array<Skeleton>;
  67931. /**
  67932. * Gets the list of loaded animation groups
  67933. */
  67934. loadedAnimationGroups: Array<AnimationGroup>;
  67935. /**
  67936. * Callback called when the task is successful
  67937. */
  67938. onSuccess: (task: MeshAssetTask) => void;
  67939. /**
  67940. * Callback called when the task is successful
  67941. */
  67942. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67943. /**
  67944. * Creates a new MeshAssetTask
  67945. * @param name defines the name of the task
  67946. * @param meshesNames defines the list of mesh's names you want to load
  67947. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67948. * @param sceneFilename defines the filename of the scene to load from
  67949. */
  67950. constructor(
  67951. /**
  67952. * Defines the name of the task
  67953. */
  67954. name: string,
  67955. /**
  67956. * Defines the list of mesh's names you want to load
  67957. */
  67958. meshesNames: any,
  67959. /**
  67960. * Defines the root url to use as a base to load your meshes and associated resources
  67961. */
  67962. rootUrl: string,
  67963. /**
  67964. * Defines the filename of the scene to load from
  67965. */
  67966. sceneFilename: string);
  67967. /**
  67968. * Execute the current task
  67969. * @param scene defines the scene where you want your assets to be loaded
  67970. * @param onSuccess is a callback called when the task is successfully executed
  67971. * @param onError is a callback called if an error occurs
  67972. */
  67973. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67974. }
  67975. /**
  67976. * Define a task used by AssetsManager to load text content
  67977. */
  67978. export class TextFileAssetTask extends AbstractAssetTask {
  67979. /**
  67980. * Defines the name of the task
  67981. */
  67982. name: string;
  67983. /**
  67984. * Defines the location of the file to load
  67985. */
  67986. url: string;
  67987. /**
  67988. * Gets the loaded text string
  67989. */
  67990. text: string;
  67991. /**
  67992. * Callback called when the task is successful
  67993. */
  67994. onSuccess: (task: TextFileAssetTask) => void;
  67995. /**
  67996. * Callback called when the task is successful
  67997. */
  67998. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67999. /**
  68000. * Creates a new TextFileAssetTask object
  68001. * @param name defines the name of the task
  68002. * @param url defines the location of the file to load
  68003. */
  68004. constructor(
  68005. /**
  68006. * Defines the name of the task
  68007. */
  68008. name: string,
  68009. /**
  68010. * Defines the location of the file to load
  68011. */
  68012. url: string);
  68013. /**
  68014. * Execute the current task
  68015. * @param scene defines the scene where you want your assets to be loaded
  68016. * @param onSuccess is a callback called when the task is successfully executed
  68017. * @param onError is a callback called if an error occurs
  68018. */
  68019. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68020. }
  68021. /**
  68022. * Define a task used by AssetsManager to load binary data
  68023. */
  68024. export class BinaryFileAssetTask extends AbstractAssetTask {
  68025. /**
  68026. * Defines the name of the task
  68027. */
  68028. name: string;
  68029. /**
  68030. * Defines the location of the file to load
  68031. */
  68032. url: string;
  68033. /**
  68034. * Gets the lodaded data (as an array buffer)
  68035. */
  68036. data: ArrayBuffer;
  68037. /**
  68038. * Callback called when the task is successful
  68039. */
  68040. onSuccess: (task: BinaryFileAssetTask) => void;
  68041. /**
  68042. * Callback called when the task is successful
  68043. */
  68044. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68045. /**
  68046. * Creates a new BinaryFileAssetTask object
  68047. * @param name defines the name of the new task
  68048. * @param url defines the location of the file to load
  68049. */
  68050. constructor(
  68051. /**
  68052. * Defines the name of the task
  68053. */
  68054. name: string,
  68055. /**
  68056. * Defines the location of the file to load
  68057. */
  68058. url: string);
  68059. /**
  68060. * Execute the current task
  68061. * @param scene defines the scene where you want your assets to be loaded
  68062. * @param onSuccess is a callback called when the task is successfully executed
  68063. * @param onError is a callback called if an error occurs
  68064. */
  68065. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68066. }
  68067. /**
  68068. * Define a task used by AssetsManager to load images
  68069. */
  68070. export class ImageAssetTask extends AbstractAssetTask {
  68071. /**
  68072. * Defines the name of the task
  68073. */
  68074. name: string;
  68075. /**
  68076. * Defines the location of the image to load
  68077. */
  68078. url: string;
  68079. /**
  68080. * Gets the loaded images
  68081. */
  68082. image: HTMLImageElement;
  68083. /**
  68084. * Callback called when the task is successful
  68085. */
  68086. onSuccess: (task: ImageAssetTask) => void;
  68087. /**
  68088. * Callback called when the task is successful
  68089. */
  68090. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68091. /**
  68092. * Creates a new ImageAssetTask
  68093. * @param name defines the name of the task
  68094. * @param url defines the location of the image to load
  68095. */
  68096. constructor(
  68097. /**
  68098. * Defines the name of the task
  68099. */
  68100. name: string,
  68101. /**
  68102. * Defines the location of the image to load
  68103. */
  68104. url: string);
  68105. /**
  68106. * Execute the current task
  68107. * @param scene defines the scene where you want your assets to be loaded
  68108. * @param onSuccess is a callback called when the task is successfully executed
  68109. * @param onError is a callback called if an error occurs
  68110. */
  68111. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68112. }
  68113. /**
  68114. * Defines the interface used by texture loading tasks
  68115. */
  68116. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68117. /**
  68118. * Gets the loaded texture
  68119. */
  68120. texture: TEX;
  68121. }
  68122. /**
  68123. * Define a task used by AssetsManager to load 2D textures
  68124. */
  68125. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68126. /**
  68127. * Defines the name of the task
  68128. */
  68129. name: string;
  68130. /**
  68131. * Defines the location of the file to load
  68132. */
  68133. url: string;
  68134. /**
  68135. * Defines if mipmap should not be generated (default is false)
  68136. */
  68137. noMipmap?: boolean | undefined;
  68138. /**
  68139. * Defines if texture must be inverted on Y axis (default is true)
  68140. */
  68141. invertY: boolean;
  68142. /**
  68143. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68144. */
  68145. samplingMode: number;
  68146. /**
  68147. * Gets the loaded texture
  68148. */
  68149. texture: Texture;
  68150. /**
  68151. * Callback called when the task is successful
  68152. */
  68153. onSuccess: (task: TextureAssetTask) => void;
  68154. /**
  68155. * Callback called when the task is successful
  68156. */
  68157. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68158. /**
  68159. * Creates a new TextureAssetTask object
  68160. * @param name defines the name of the task
  68161. * @param url defines the location of the file to load
  68162. * @param noMipmap defines if mipmap should not be generated (default is false)
  68163. * @param invertY defines if texture must be inverted on Y axis (default is true)
  68164. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68165. */
  68166. constructor(
  68167. /**
  68168. * Defines the name of the task
  68169. */
  68170. name: string,
  68171. /**
  68172. * Defines the location of the file to load
  68173. */
  68174. url: string,
  68175. /**
  68176. * Defines if mipmap should not be generated (default is false)
  68177. */
  68178. noMipmap?: boolean | undefined,
  68179. /**
  68180. * Defines if texture must be inverted on Y axis (default is true)
  68181. */
  68182. invertY?: boolean,
  68183. /**
  68184. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68185. */
  68186. samplingMode?: number);
  68187. /**
  68188. * Execute the current task
  68189. * @param scene defines the scene where you want your assets to be loaded
  68190. * @param onSuccess is a callback called when the task is successfully executed
  68191. * @param onError is a callback called if an error occurs
  68192. */
  68193. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68194. }
  68195. /**
  68196. * Define a task used by AssetsManager to load cube textures
  68197. */
  68198. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68199. /**
  68200. * Defines the name of the task
  68201. */
  68202. name: string;
  68203. /**
  68204. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68205. */
  68206. url: string;
  68207. /**
  68208. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68209. */
  68210. extensions?: string[] | undefined;
  68211. /**
  68212. * Defines if mipmaps should not be generated (default is false)
  68213. */
  68214. noMipmap?: boolean | undefined;
  68215. /**
  68216. * Defines the explicit list of files (undefined by default)
  68217. */
  68218. files?: string[] | undefined;
  68219. /**
  68220. * Gets the loaded texture
  68221. */
  68222. texture: CubeTexture;
  68223. /**
  68224. * Callback called when the task is successful
  68225. */
  68226. onSuccess: (task: CubeTextureAssetTask) => void;
  68227. /**
  68228. * Callback called when the task is successful
  68229. */
  68230. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68231. /**
  68232. * Creates a new CubeTextureAssetTask
  68233. * @param name defines the name of the task
  68234. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68235. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68236. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68237. * @param files defines the explicit list of files (undefined by default)
  68238. */
  68239. constructor(
  68240. /**
  68241. * Defines the name of the task
  68242. */
  68243. name: string,
  68244. /**
  68245. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68246. */
  68247. url: string,
  68248. /**
  68249. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68250. */
  68251. extensions?: string[] | undefined,
  68252. /**
  68253. * Defines if mipmaps should not be generated (default is false)
  68254. */
  68255. noMipmap?: boolean | undefined,
  68256. /**
  68257. * Defines the explicit list of files (undefined by default)
  68258. */
  68259. files?: string[] | undefined);
  68260. /**
  68261. * Execute the current task
  68262. * @param scene defines the scene where you want your assets to be loaded
  68263. * @param onSuccess is a callback called when the task is successfully executed
  68264. * @param onError is a callback called if an error occurs
  68265. */
  68266. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68267. }
  68268. /**
  68269. * Define a task used by AssetsManager to load HDR cube textures
  68270. */
  68271. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68272. /**
  68273. * Defines the name of the task
  68274. */
  68275. name: string;
  68276. /**
  68277. * Defines the location of the file to load
  68278. */
  68279. url: string;
  68280. /**
  68281. * Defines the desired size (the more it increases the longer the generation will be)
  68282. */
  68283. size: number;
  68284. /**
  68285. * Defines if mipmaps should not be generated (default is false)
  68286. */
  68287. noMipmap: boolean;
  68288. /**
  68289. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68290. */
  68291. generateHarmonics: boolean;
  68292. /**
  68293. * 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)
  68294. */
  68295. gammaSpace: boolean;
  68296. /**
  68297. * Internal Use Only
  68298. */
  68299. reserved: boolean;
  68300. /**
  68301. * Gets the loaded texture
  68302. */
  68303. texture: HDRCubeTexture;
  68304. /**
  68305. * Callback called when the task is successful
  68306. */
  68307. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68308. /**
  68309. * Callback called when the task is successful
  68310. */
  68311. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68312. /**
  68313. * Creates a new HDRCubeTextureAssetTask object
  68314. * @param name defines the name of the task
  68315. * @param url defines the location of the file to load
  68316. * @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.
  68317. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68318. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68319. * @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)
  68320. * @param reserved Internal use only
  68321. */
  68322. constructor(
  68323. /**
  68324. * Defines the name of the task
  68325. */
  68326. name: string,
  68327. /**
  68328. * Defines the location of the file to load
  68329. */
  68330. url: string,
  68331. /**
  68332. * Defines the desired size (the more it increases the longer the generation will be)
  68333. */
  68334. size: number,
  68335. /**
  68336. * Defines if mipmaps should not be generated (default is false)
  68337. */
  68338. noMipmap?: boolean,
  68339. /**
  68340. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68341. */
  68342. generateHarmonics?: boolean,
  68343. /**
  68344. * 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)
  68345. */
  68346. gammaSpace?: boolean,
  68347. /**
  68348. * Internal Use Only
  68349. */
  68350. reserved?: boolean);
  68351. /**
  68352. * Execute the current task
  68353. * @param scene defines the scene where you want your assets to be loaded
  68354. * @param onSuccess is a callback called when the task is successfully executed
  68355. * @param onError is a callback called if an error occurs
  68356. */
  68357. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68358. }
  68359. /**
  68360. * Define a task used by AssetsManager to load Equirectangular cube textures
  68361. */
  68362. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68363. /**
  68364. * Defines the name of the task
  68365. */
  68366. name: string;
  68367. /**
  68368. * Defines the location of the file to load
  68369. */
  68370. url: string;
  68371. /**
  68372. * Defines the desired size (the more it increases the longer the generation will be)
  68373. */
  68374. size: number;
  68375. /**
  68376. * Defines if mipmaps should not be generated (default is false)
  68377. */
  68378. noMipmap: boolean;
  68379. /**
  68380. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68381. * but the standard material would require them in Gamma space) (default is true)
  68382. */
  68383. gammaSpace: boolean;
  68384. /**
  68385. * Gets the loaded texture
  68386. */
  68387. texture: EquiRectangularCubeTexture;
  68388. /**
  68389. * Callback called when the task is successful
  68390. */
  68391. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68392. /**
  68393. * Callback called when the task is successful
  68394. */
  68395. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68396. /**
  68397. * Creates a new EquiRectangularCubeTextureAssetTask object
  68398. * @param name defines the name of the task
  68399. * @param url defines the location of the file to load
  68400. * @param size defines the desired size (the more it increases the longer the generation will be)
  68401. * If the size is omitted this implies you are using a preprocessed cubemap.
  68402. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68403. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68404. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68405. * (default is true)
  68406. */
  68407. constructor(
  68408. /**
  68409. * Defines the name of the task
  68410. */
  68411. name: string,
  68412. /**
  68413. * Defines the location of the file to load
  68414. */
  68415. url: string,
  68416. /**
  68417. * Defines the desired size (the more it increases the longer the generation will be)
  68418. */
  68419. size: number,
  68420. /**
  68421. * Defines if mipmaps should not be generated (default is false)
  68422. */
  68423. noMipmap?: boolean,
  68424. /**
  68425. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68426. * but the standard material would require them in Gamma space) (default is true)
  68427. */
  68428. gammaSpace?: boolean);
  68429. /**
  68430. * Execute the current task
  68431. * @param scene defines the scene where you want your assets to be loaded
  68432. * @param onSuccess is a callback called when the task is successfully executed
  68433. * @param onError is a callback called if an error occurs
  68434. */
  68435. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68436. }
  68437. /**
  68438. * This class can be used to easily import assets into a scene
  68439. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68440. */
  68441. export class AssetsManager {
  68442. private _scene;
  68443. private _isLoading;
  68444. protected _tasks: AbstractAssetTask[];
  68445. protected _waitingTasksCount: number;
  68446. protected _totalTasksCount: number;
  68447. /**
  68448. * Callback called when all tasks are processed
  68449. */
  68450. onFinish: (tasks: AbstractAssetTask[]) => void;
  68451. /**
  68452. * Callback called when a task is successful
  68453. */
  68454. onTaskSuccess: (task: AbstractAssetTask) => void;
  68455. /**
  68456. * Callback called when a task had an error
  68457. */
  68458. onTaskError: (task: AbstractAssetTask) => void;
  68459. /**
  68460. * Callback called when a task is done (whatever the result is)
  68461. */
  68462. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68463. /**
  68464. * Observable called when all tasks are processed
  68465. */
  68466. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68467. /**
  68468. * Observable called when a task had an error
  68469. */
  68470. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68471. /**
  68472. * Observable called when all tasks were executed
  68473. */
  68474. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68475. /**
  68476. * Observable called when a task is done (whatever the result is)
  68477. */
  68478. onProgressObservable: Observable<IAssetsProgressEvent>;
  68479. /**
  68480. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68481. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68482. */
  68483. useDefaultLoadingScreen: boolean;
  68484. /**
  68485. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68486. * when all assets have been downloaded.
  68487. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68488. */
  68489. autoHideLoadingUI: boolean;
  68490. /**
  68491. * Creates a new AssetsManager
  68492. * @param scene defines the scene to work on
  68493. */
  68494. constructor(scene: Scene);
  68495. /**
  68496. * Add a MeshAssetTask to the list of active tasks
  68497. * @param taskName defines the name of the new task
  68498. * @param meshesNames defines the name of meshes to load
  68499. * @param rootUrl defines the root url to use to locate files
  68500. * @param sceneFilename defines the filename of the scene file
  68501. * @returns a new MeshAssetTask object
  68502. */
  68503. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68504. /**
  68505. * Add a TextFileAssetTask to the list of active tasks
  68506. * @param taskName defines the name of the new task
  68507. * @param url defines the url of the file to load
  68508. * @returns a new TextFileAssetTask object
  68509. */
  68510. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68511. /**
  68512. * Add a BinaryFileAssetTask to the list of active tasks
  68513. * @param taskName defines the name of the new task
  68514. * @param url defines the url of the file to load
  68515. * @returns a new BinaryFileAssetTask object
  68516. */
  68517. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68518. /**
  68519. * Add a ImageAssetTask to the list of active tasks
  68520. * @param taskName defines the name of the new task
  68521. * @param url defines the url of the file to load
  68522. * @returns a new ImageAssetTask object
  68523. */
  68524. addImageTask(taskName: string, url: string): ImageAssetTask;
  68525. /**
  68526. * Add a TextureAssetTask to the list of active tasks
  68527. * @param taskName defines the name of the new task
  68528. * @param url defines the url of the file to load
  68529. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68530. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68531. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68532. * @returns a new TextureAssetTask object
  68533. */
  68534. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68535. /**
  68536. * Add a CubeTextureAssetTask to the list of active tasks
  68537. * @param taskName defines the name of the new task
  68538. * @param url defines the url of the file to load
  68539. * @param extensions defines the extension to use to load the cube map (can be null)
  68540. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68541. * @param files defines the list of files to load (can be null)
  68542. * @returns a new CubeTextureAssetTask object
  68543. */
  68544. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68545. /**
  68546. *
  68547. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68548. * @param taskName defines the name of the new task
  68549. * @param url defines the url of the file to load
  68550. * @param size defines the size you want for the cubemap (can be null)
  68551. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68552. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68553. * @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)
  68554. * @param reserved Internal use only
  68555. * @returns a new HDRCubeTextureAssetTask object
  68556. */
  68557. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68558. /**
  68559. *
  68560. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68561. * @param taskName defines the name of the new task
  68562. * @param url defines the url of the file to load
  68563. * @param size defines the size you want for the cubemap (can be null)
  68564. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68565. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68566. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68567. * @returns a new EquiRectangularCubeTextureAssetTask object
  68568. */
  68569. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68570. /**
  68571. * Remove a task from the assets manager.
  68572. * @param task the task to remove
  68573. */
  68574. removeTask(task: AbstractAssetTask): void;
  68575. private _decreaseWaitingTasksCount;
  68576. private _runTask;
  68577. /**
  68578. * Reset the AssetsManager and remove all tasks
  68579. * @return the current instance of the AssetsManager
  68580. */
  68581. reset(): AssetsManager;
  68582. /**
  68583. * Start the loading process
  68584. * @return the current instance of the AssetsManager
  68585. */
  68586. load(): AssetsManager;
  68587. /**
  68588. * Start the loading process as an async operation
  68589. * @return a promise returning the list of failed tasks
  68590. */
  68591. loadAsync(): Promise<void>;
  68592. }
  68593. }
  68594. declare module BABYLON {
  68595. /**
  68596. * Wrapper class for promise with external resolve and reject.
  68597. */
  68598. export class Deferred<T> {
  68599. /**
  68600. * The promise associated with this deferred object.
  68601. */
  68602. readonly promise: Promise<T>;
  68603. private _resolve;
  68604. private _reject;
  68605. /**
  68606. * The resolve method of the promise associated with this deferred object.
  68607. */
  68608. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68609. /**
  68610. * The reject method of the promise associated with this deferred object.
  68611. */
  68612. get reject(): (reason?: any) => void;
  68613. /**
  68614. * Constructor for this deferred object.
  68615. */
  68616. constructor();
  68617. }
  68618. }
  68619. declare module BABYLON {
  68620. /**
  68621. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68622. */
  68623. export class MeshExploder {
  68624. private _centerMesh;
  68625. private _meshes;
  68626. private _meshesOrigins;
  68627. private _toCenterVectors;
  68628. private _scaledDirection;
  68629. private _newPosition;
  68630. private _centerPosition;
  68631. /**
  68632. * Explodes meshes from a center mesh.
  68633. * @param meshes The meshes to explode.
  68634. * @param centerMesh The mesh to be center of explosion.
  68635. */
  68636. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68637. private _setCenterMesh;
  68638. /**
  68639. * Get class name
  68640. * @returns "MeshExploder"
  68641. */
  68642. getClassName(): string;
  68643. /**
  68644. * "Exploded meshes"
  68645. * @returns Array of meshes with the centerMesh at index 0.
  68646. */
  68647. getMeshes(): Array<Mesh>;
  68648. /**
  68649. * Explodes meshes giving a specific direction
  68650. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68651. */
  68652. explode(direction?: number): void;
  68653. }
  68654. }
  68655. declare module BABYLON {
  68656. /**
  68657. * Class used to help managing file picking and drag'n'drop
  68658. */
  68659. export class FilesInput {
  68660. /**
  68661. * List of files ready to be loaded
  68662. */
  68663. static get FilesToLoad(): {
  68664. [key: string]: File;
  68665. };
  68666. /**
  68667. * Callback called when a file is processed
  68668. */
  68669. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68670. private _engine;
  68671. private _currentScene;
  68672. private _sceneLoadedCallback;
  68673. private _progressCallback;
  68674. private _additionalRenderLoopLogicCallback;
  68675. private _textureLoadingCallback;
  68676. private _startingProcessingFilesCallback;
  68677. private _onReloadCallback;
  68678. private _errorCallback;
  68679. private _elementToMonitor;
  68680. private _sceneFileToLoad;
  68681. private _filesToLoad;
  68682. /**
  68683. * Creates a new FilesInput
  68684. * @param engine defines the rendering engine
  68685. * @param scene defines the hosting scene
  68686. * @param sceneLoadedCallback callback called when scene is loaded
  68687. * @param progressCallback callback called to track progress
  68688. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68689. * @param textureLoadingCallback callback called when a texture is loading
  68690. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68691. * @param onReloadCallback callback called when a reload is requested
  68692. * @param errorCallback callback call if an error occurs
  68693. */
  68694. 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);
  68695. private _dragEnterHandler;
  68696. private _dragOverHandler;
  68697. private _dropHandler;
  68698. /**
  68699. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68700. * @param elementToMonitor defines the DOM element to track
  68701. */
  68702. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68703. /**
  68704. * Release all associated resources
  68705. */
  68706. dispose(): void;
  68707. private renderFunction;
  68708. private drag;
  68709. private drop;
  68710. private _traverseFolder;
  68711. private _processFiles;
  68712. /**
  68713. * Load files from a drop event
  68714. * @param event defines the drop event to use as source
  68715. */
  68716. loadFiles(event: any): void;
  68717. private _processReload;
  68718. /**
  68719. * Reload the current scene from the loaded files
  68720. */
  68721. reload(): void;
  68722. }
  68723. }
  68724. declare module BABYLON {
  68725. /**
  68726. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68727. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68728. */
  68729. export class SceneOptimization {
  68730. /**
  68731. * Defines the priority of this optimization (0 by default which means first in the list)
  68732. */
  68733. priority: number;
  68734. /**
  68735. * Gets a string describing the action executed by the current optimization
  68736. * @returns description string
  68737. */
  68738. getDescription(): string;
  68739. /**
  68740. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68741. * @param scene defines the current scene where to apply this optimization
  68742. * @param optimizer defines the current optimizer
  68743. * @returns true if everything that can be done was applied
  68744. */
  68745. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68746. /**
  68747. * Creates the SceneOptimization object
  68748. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68749. * @param desc defines the description associated with the optimization
  68750. */
  68751. constructor(
  68752. /**
  68753. * Defines the priority of this optimization (0 by default which means first in the list)
  68754. */
  68755. priority?: number);
  68756. }
  68757. /**
  68758. * Defines an optimization used to reduce the size of render target textures
  68759. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68760. */
  68761. export class TextureOptimization extends SceneOptimization {
  68762. /**
  68763. * Defines the priority of this optimization (0 by default which means first in the list)
  68764. */
  68765. priority: number;
  68766. /**
  68767. * 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
  68768. */
  68769. maximumSize: number;
  68770. /**
  68771. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68772. */
  68773. step: number;
  68774. /**
  68775. * Gets a string describing the action executed by the current optimization
  68776. * @returns description string
  68777. */
  68778. getDescription(): string;
  68779. /**
  68780. * Creates the TextureOptimization object
  68781. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68782. * @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
  68783. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68784. */
  68785. constructor(
  68786. /**
  68787. * Defines the priority of this optimization (0 by default which means first in the list)
  68788. */
  68789. priority?: number,
  68790. /**
  68791. * 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
  68792. */
  68793. maximumSize?: number,
  68794. /**
  68795. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68796. */
  68797. step?: number);
  68798. /**
  68799. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68800. * @param scene defines the current scene where to apply this optimization
  68801. * @param optimizer defines the current optimizer
  68802. * @returns true if everything that can be done was applied
  68803. */
  68804. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68805. }
  68806. /**
  68807. * Defines an optimization used to increase or decrease the rendering resolution
  68808. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68809. */
  68810. export class HardwareScalingOptimization extends SceneOptimization {
  68811. /**
  68812. * Defines the priority of this optimization (0 by default which means first in the list)
  68813. */
  68814. priority: number;
  68815. /**
  68816. * Defines the maximum scale to use (2 by default)
  68817. */
  68818. maximumScale: number;
  68819. /**
  68820. * Defines the step to use between two passes (0.5 by default)
  68821. */
  68822. step: number;
  68823. private _currentScale;
  68824. private _directionOffset;
  68825. /**
  68826. * Gets a string describing the action executed by the current optimization
  68827. * @return description string
  68828. */
  68829. getDescription(): string;
  68830. /**
  68831. * Creates the HardwareScalingOptimization object
  68832. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68833. * @param maximumScale defines the maximum scale to use (2 by default)
  68834. * @param step defines the step to use between two passes (0.5 by default)
  68835. */
  68836. constructor(
  68837. /**
  68838. * Defines the priority of this optimization (0 by default which means first in the list)
  68839. */
  68840. priority?: number,
  68841. /**
  68842. * Defines the maximum scale to use (2 by default)
  68843. */
  68844. maximumScale?: number,
  68845. /**
  68846. * Defines the step to use between two passes (0.5 by default)
  68847. */
  68848. step?: number);
  68849. /**
  68850. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68851. * @param scene defines the current scene where to apply this optimization
  68852. * @param optimizer defines the current optimizer
  68853. * @returns true if everything that can be done was applied
  68854. */
  68855. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68856. }
  68857. /**
  68858. * Defines an optimization used to remove shadows
  68859. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68860. */
  68861. export class ShadowsOptimization extends SceneOptimization {
  68862. /**
  68863. * Gets a string describing the action executed by the current optimization
  68864. * @return description string
  68865. */
  68866. getDescription(): string;
  68867. /**
  68868. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68869. * @param scene defines the current scene where to apply this optimization
  68870. * @param optimizer defines the current optimizer
  68871. * @returns true if everything that can be done was applied
  68872. */
  68873. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68874. }
  68875. /**
  68876. * Defines an optimization used to turn post-processes off
  68877. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68878. */
  68879. export class PostProcessesOptimization extends SceneOptimization {
  68880. /**
  68881. * Gets a string describing the action executed by the current optimization
  68882. * @return description string
  68883. */
  68884. getDescription(): string;
  68885. /**
  68886. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68887. * @param scene defines the current scene where to apply this optimization
  68888. * @param optimizer defines the current optimizer
  68889. * @returns true if everything that can be done was applied
  68890. */
  68891. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68892. }
  68893. /**
  68894. * Defines an optimization used to turn lens flares off
  68895. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68896. */
  68897. export class LensFlaresOptimization extends SceneOptimization {
  68898. /**
  68899. * Gets a string describing the action executed by the current optimization
  68900. * @return description string
  68901. */
  68902. getDescription(): string;
  68903. /**
  68904. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68905. * @param scene defines the current scene where to apply this optimization
  68906. * @param optimizer defines the current optimizer
  68907. * @returns true if everything that can be done was applied
  68908. */
  68909. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68910. }
  68911. /**
  68912. * Defines an optimization based on user defined callback.
  68913. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68914. */
  68915. export class CustomOptimization extends SceneOptimization {
  68916. /**
  68917. * Callback called to apply the custom optimization.
  68918. */
  68919. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68920. /**
  68921. * Callback called to get custom description
  68922. */
  68923. onGetDescription: () => string;
  68924. /**
  68925. * Gets a string describing the action executed by the current optimization
  68926. * @returns description string
  68927. */
  68928. getDescription(): string;
  68929. /**
  68930. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68931. * @param scene defines the current scene where to apply this optimization
  68932. * @param optimizer defines the current optimizer
  68933. * @returns true if everything that can be done was applied
  68934. */
  68935. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68936. }
  68937. /**
  68938. * Defines an optimization used to turn particles off
  68939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68940. */
  68941. export class ParticlesOptimization extends SceneOptimization {
  68942. /**
  68943. * Gets a string describing the action executed by the current optimization
  68944. * @return description string
  68945. */
  68946. getDescription(): string;
  68947. /**
  68948. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68949. * @param scene defines the current scene where to apply this optimization
  68950. * @param optimizer defines the current optimizer
  68951. * @returns true if everything that can be done was applied
  68952. */
  68953. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68954. }
  68955. /**
  68956. * Defines an optimization used to turn render targets off
  68957. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68958. */
  68959. export class RenderTargetsOptimization extends SceneOptimization {
  68960. /**
  68961. * Gets a string describing the action executed by the current optimization
  68962. * @return description string
  68963. */
  68964. getDescription(): string;
  68965. /**
  68966. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68967. * @param scene defines the current scene where to apply this optimization
  68968. * @param optimizer defines the current optimizer
  68969. * @returns true if everything that can be done was applied
  68970. */
  68971. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68972. }
  68973. /**
  68974. * Defines an optimization used to merge meshes with compatible materials
  68975. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68976. */
  68977. export class MergeMeshesOptimization extends SceneOptimization {
  68978. private static _UpdateSelectionTree;
  68979. /**
  68980. * Gets or sets a boolean which defines if optimization octree has to be updated
  68981. */
  68982. static get UpdateSelectionTree(): boolean;
  68983. /**
  68984. * Gets or sets a boolean which defines if optimization octree has to be updated
  68985. */
  68986. static set UpdateSelectionTree(value: boolean);
  68987. /**
  68988. * Gets a string describing the action executed by the current optimization
  68989. * @return description string
  68990. */
  68991. getDescription(): string;
  68992. private _canBeMerged;
  68993. /**
  68994. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68995. * @param scene defines the current scene where to apply this optimization
  68996. * @param optimizer defines the current optimizer
  68997. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68998. * @returns true if everything that can be done was applied
  68999. */
  69000. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69001. }
  69002. /**
  69003. * Defines a list of options used by SceneOptimizer
  69004. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69005. */
  69006. export class SceneOptimizerOptions {
  69007. /**
  69008. * Defines the target frame rate to reach (60 by default)
  69009. */
  69010. targetFrameRate: number;
  69011. /**
  69012. * Defines the interval between two checkes (2000ms by default)
  69013. */
  69014. trackerDuration: number;
  69015. /**
  69016. * Gets the list of optimizations to apply
  69017. */
  69018. optimizations: SceneOptimization[];
  69019. /**
  69020. * Creates a new list of options used by SceneOptimizer
  69021. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69022. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69023. */
  69024. constructor(
  69025. /**
  69026. * Defines the target frame rate to reach (60 by default)
  69027. */
  69028. targetFrameRate?: number,
  69029. /**
  69030. * Defines the interval between two checkes (2000ms by default)
  69031. */
  69032. trackerDuration?: number);
  69033. /**
  69034. * Add a new optimization
  69035. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69036. * @returns the current SceneOptimizerOptions
  69037. */
  69038. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69039. /**
  69040. * Add a new custom optimization
  69041. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69042. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69043. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69044. * @returns the current SceneOptimizerOptions
  69045. */
  69046. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69047. /**
  69048. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69049. * @param targetFrameRate defines the target frame rate (60 by default)
  69050. * @returns a SceneOptimizerOptions object
  69051. */
  69052. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69053. /**
  69054. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69055. * @param targetFrameRate defines the target frame rate (60 by default)
  69056. * @returns a SceneOptimizerOptions object
  69057. */
  69058. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69059. /**
  69060. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69061. * @param targetFrameRate defines the target frame rate (60 by default)
  69062. * @returns a SceneOptimizerOptions object
  69063. */
  69064. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69065. }
  69066. /**
  69067. * Class used to run optimizations in order to reach a target frame rate
  69068. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69069. */
  69070. export class SceneOptimizer implements IDisposable {
  69071. private _isRunning;
  69072. private _options;
  69073. private _scene;
  69074. private _currentPriorityLevel;
  69075. private _targetFrameRate;
  69076. private _trackerDuration;
  69077. private _currentFrameRate;
  69078. private _sceneDisposeObserver;
  69079. private _improvementMode;
  69080. /**
  69081. * Defines an observable called when the optimizer reaches the target frame rate
  69082. */
  69083. onSuccessObservable: Observable<SceneOptimizer>;
  69084. /**
  69085. * Defines an observable called when the optimizer enables an optimization
  69086. */
  69087. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69088. /**
  69089. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69090. */
  69091. onFailureObservable: Observable<SceneOptimizer>;
  69092. /**
  69093. * Gets a boolean indicating if the optimizer is in improvement mode
  69094. */
  69095. get isInImprovementMode(): boolean;
  69096. /**
  69097. * Gets the current priority level (0 at start)
  69098. */
  69099. get currentPriorityLevel(): number;
  69100. /**
  69101. * Gets the current frame rate checked by the SceneOptimizer
  69102. */
  69103. get currentFrameRate(): number;
  69104. /**
  69105. * Gets or sets the current target frame rate (60 by default)
  69106. */
  69107. get targetFrameRate(): number;
  69108. /**
  69109. * Gets or sets the current target frame rate (60 by default)
  69110. */
  69111. set targetFrameRate(value: number);
  69112. /**
  69113. * Gets or sets the current interval between two checks (every 2000ms by default)
  69114. */
  69115. get trackerDuration(): number;
  69116. /**
  69117. * Gets or sets the current interval between two checks (every 2000ms by default)
  69118. */
  69119. set trackerDuration(value: number);
  69120. /**
  69121. * Gets the list of active optimizations
  69122. */
  69123. get optimizations(): SceneOptimization[];
  69124. /**
  69125. * Creates a new SceneOptimizer
  69126. * @param scene defines the scene to work on
  69127. * @param options defines the options to use with the SceneOptimizer
  69128. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69129. * @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)
  69130. */
  69131. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69132. /**
  69133. * Stops the current optimizer
  69134. */
  69135. stop(): void;
  69136. /**
  69137. * Reset the optimizer to initial step (current priority level = 0)
  69138. */
  69139. reset(): void;
  69140. /**
  69141. * Start the optimizer. By default it will try to reach a specific framerate
  69142. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69143. */
  69144. start(): void;
  69145. private _checkCurrentState;
  69146. /**
  69147. * Release all resources
  69148. */
  69149. dispose(): void;
  69150. /**
  69151. * Helper function to create a SceneOptimizer with one single line of code
  69152. * @param scene defines the scene to work on
  69153. * @param options defines the options to use with the SceneOptimizer
  69154. * @param onSuccess defines a callback to call on success
  69155. * @param onFailure defines a callback to call on failure
  69156. * @returns the new SceneOptimizer object
  69157. */
  69158. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69159. }
  69160. }
  69161. declare module BABYLON {
  69162. /**
  69163. * Class used to serialize a scene into a string
  69164. */
  69165. export class SceneSerializer {
  69166. /**
  69167. * Clear cache used by a previous serialization
  69168. */
  69169. static ClearCache(): void;
  69170. /**
  69171. * Serialize a scene into a JSON compatible object
  69172. * @param scene defines the scene to serialize
  69173. * @returns a JSON compatible object
  69174. */
  69175. static Serialize(scene: Scene): any;
  69176. /**
  69177. * Serialize a mesh into a JSON compatible object
  69178. * @param toSerialize defines the mesh to serialize
  69179. * @param withParents defines if parents must be serialized as well
  69180. * @param withChildren defines if children must be serialized as well
  69181. * @returns a JSON compatible object
  69182. */
  69183. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69184. }
  69185. }
  69186. declare module BABYLON {
  69187. /**
  69188. * Class used to host texture specific utilities
  69189. */
  69190. export class TextureTools {
  69191. /**
  69192. * Uses the GPU to create a copy texture rescaled at a given size
  69193. * @param texture Texture to copy from
  69194. * @param width defines the desired width
  69195. * @param height defines the desired height
  69196. * @param useBilinearMode defines if bilinear mode has to be used
  69197. * @return the generated texture
  69198. */
  69199. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69200. }
  69201. }
  69202. declare module BABYLON {
  69203. /**
  69204. * This represents the different options available for the video capture.
  69205. */
  69206. export interface VideoRecorderOptions {
  69207. /** Defines the mime type of the video. */
  69208. mimeType: string;
  69209. /** Defines the FPS the video should be recorded at. */
  69210. fps: number;
  69211. /** Defines the chunk size for the recording data. */
  69212. recordChunckSize: number;
  69213. /** The audio tracks to attach to the recording. */
  69214. audioTracks?: MediaStreamTrack[];
  69215. }
  69216. /**
  69217. * This can help with recording videos from BabylonJS.
  69218. * This is based on the available WebRTC functionalities of the browser.
  69219. *
  69220. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69221. */
  69222. export class VideoRecorder {
  69223. private static readonly _defaultOptions;
  69224. /**
  69225. * Returns whether or not the VideoRecorder is available in your browser.
  69226. * @param engine Defines the Babylon Engine.
  69227. * @returns true if supported otherwise false.
  69228. */
  69229. static IsSupported(engine: Engine): boolean;
  69230. private readonly _options;
  69231. private _canvas;
  69232. private _mediaRecorder;
  69233. private _recordedChunks;
  69234. private _fileName;
  69235. private _resolve;
  69236. private _reject;
  69237. /**
  69238. * True when a recording is already in progress.
  69239. */
  69240. get isRecording(): boolean;
  69241. /**
  69242. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69243. * @param engine Defines the BabylonJS Engine you wish to record.
  69244. * @param options Defines options that can be used to customize the capture.
  69245. */
  69246. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69247. /**
  69248. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69249. */
  69250. stopRecording(): void;
  69251. /**
  69252. * Starts recording the canvas for a max duration specified in parameters.
  69253. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69254. * If null no automatic download will start and you can rely on the promise to get the data back.
  69255. * @param maxDuration Defines the maximum recording time in seconds.
  69256. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69257. * @return A promise callback at the end of the recording with the video data in Blob.
  69258. */
  69259. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69260. /**
  69261. * Releases internal resources used during the recording.
  69262. */
  69263. dispose(): void;
  69264. private _handleDataAvailable;
  69265. private _handleError;
  69266. private _handleStop;
  69267. }
  69268. }
  69269. declare module BABYLON {
  69270. /**
  69271. * Class containing a set of static utilities functions for screenshots
  69272. */
  69273. export class ScreenshotTools {
  69274. /**
  69275. * Captures a screenshot of the current rendering
  69276. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69277. * @param engine defines the rendering engine
  69278. * @param camera defines the source camera
  69279. * @param size This parameter can be set to a single number or to an object with the
  69280. * following (optional) properties: precision, width, height. If a single number is passed,
  69281. * it will be used for both width and height. If an object is passed, the screenshot size
  69282. * will be derived from the parameters. The precision property is a multiplier allowing
  69283. * rendering at a higher or lower resolution
  69284. * @param successCallback defines the callback receives a single parameter which contains the
  69285. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69286. * src parameter of an <img> to display it
  69287. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69288. * Check your browser for supported MIME types
  69289. */
  69290. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69291. /**
  69292. * Captures a screenshot of the current rendering
  69293. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69294. * @param engine defines the rendering engine
  69295. * @param camera defines the source camera
  69296. * @param size This parameter can be set to a single number or to an object with the
  69297. * following (optional) properties: precision, width, height. If a single number is passed,
  69298. * it will be used for both width and height. If an object is passed, the screenshot size
  69299. * will be derived from the parameters. The precision property is a multiplier allowing
  69300. * rendering at a higher or lower resolution
  69301. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69302. * Check your browser for supported MIME types
  69303. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69304. * to the src parameter of an <img> to display it
  69305. */
  69306. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69307. /**
  69308. * Generates an image screenshot from the specified camera.
  69309. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69310. * @param engine The engine to use for rendering
  69311. * @param camera The camera to use for rendering
  69312. * @param size This parameter can be set to a single number or to an object with the
  69313. * following (optional) properties: precision, width, height. If a single number is passed,
  69314. * it will be used for both width and height. If an object is passed, the screenshot size
  69315. * will be derived from the parameters. The precision property is a multiplier allowing
  69316. * rendering at a higher or lower resolution
  69317. * @param successCallback The callback receives a single parameter which contains the
  69318. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69319. * src parameter of an <img> to display it
  69320. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69321. * Check your browser for supported MIME types
  69322. * @param samples Texture samples (default: 1)
  69323. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69324. * @param fileName A name for for the downloaded file.
  69325. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69326. */
  69327. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69328. /**
  69329. * Generates an image screenshot from the specified camera.
  69330. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69331. * @param engine The engine to use for rendering
  69332. * @param camera The camera to use for rendering
  69333. * @param size This parameter can be set to a single number or to an object with the
  69334. * following (optional) properties: precision, width, height. If a single number is passed,
  69335. * it will be used for both width and height. If an object is passed, the screenshot size
  69336. * will be derived from the parameters. The precision property is a multiplier allowing
  69337. * rendering at a higher or lower resolution
  69338. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69339. * Check your browser for supported MIME types
  69340. * @param samples Texture samples (default: 1)
  69341. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69342. * @param fileName A name for for the downloaded file.
  69343. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69344. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69345. * to the src parameter of an <img> to display it
  69346. */
  69347. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69348. /**
  69349. * Gets height and width for screenshot size
  69350. * @private
  69351. */
  69352. private static _getScreenshotSize;
  69353. }
  69354. }
  69355. declare module BABYLON {
  69356. /**
  69357. * Interface for a data buffer
  69358. */
  69359. export interface IDataBuffer {
  69360. /**
  69361. * Reads bytes from the data buffer.
  69362. * @param byteOffset The byte offset to read
  69363. * @param byteLength The byte length to read
  69364. * @returns A promise that resolves when the bytes are read
  69365. */
  69366. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69367. /**
  69368. * The byte length of the buffer.
  69369. */
  69370. readonly byteLength: number;
  69371. }
  69372. /**
  69373. * Utility class for reading from a data buffer
  69374. */
  69375. export class DataReader {
  69376. /**
  69377. * The data buffer associated with this data reader.
  69378. */
  69379. readonly buffer: IDataBuffer;
  69380. /**
  69381. * The current byte offset from the beginning of the data buffer.
  69382. */
  69383. byteOffset: number;
  69384. private _dataView;
  69385. private _dataByteOffset;
  69386. /**
  69387. * Constructor
  69388. * @param buffer The buffer to read
  69389. */
  69390. constructor(buffer: IDataBuffer);
  69391. /**
  69392. * Loads the given byte length.
  69393. * @param byteLength The byte length to load
  69394. * @returns A promise that resolves when the load is complete
  69395. */
  69396. loadAsync(byteLength: number): Promise<void>;
  69397. /**
  69398. * Read a unsigned 32-bit integer from the currently loaded data range.
  69399. * @returns The 32-bit integer read
  69400. */
  69401. readUint32(): number;
  69402. /**
  69403. * Read a byte array from the currently loaded data range.
  69404. * @param byteLength The byte length to read
  69405. * @returns The byte array read
  69406. */
  69407. readUint8Array(byteLength: number): Uint8Array;
  69408. /**
  69409. * Read a string from the currently loaded data range.
  69410. * @param byteLength The byte length to read
  69411. * @returns The string read
  69412. */
  69413. readString(byteLength: number): string;
  69414. /**
  69415. * Skips the given byte length the currently loaded data range.
  69416. * @param byteLength The byte length to skip
  69417. */
  69418. skipBytes(byteLength: number): void;
  69419. }
  69420. }
  69421. declare module BABYLON {
  69422. /**
  69423. * Class for storing data to local storage if available or in-memory storage otherwise
  69424. */
  69425. export class DataStorage {
  69426. private static _Storage;
  69427. private static _GetStorage;
  69428. /**
  69429. * Reads a string from the data storage
  69430. * @param key The key to read
  69431. * @param defaultValue The value if the key doesn't exist
  69432. * @returns The string value
  69433. */
  69434. static ReadString(key: string, defaultValue: string): string;
  69435. /**
  69436. * Writes a string to the data storage
  69437. * @param key The key to write
  69438. * @param value The value to write
  69439. */
  69440. static WriteString(key: string, value: string): void;
  69441. /**
  69442. * Reads a boolean from the data storage
  69443. * @param key The key to read
  69444. * @param defaultValue The value if the key doesn't exist
  69445. * @returns The boolean value
  69446. */
  69447. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69448. /**
  69449. * Writes a boolean to the data storage
  69450. * @param key The key to write
  69451. * @param value The value to write
  69452. */
  69453. static WriteBoolean(key: string, value: boolean): void;
  69454. /**
  69455. * Reads a number from the data storage
  69456. * @param key The key to read
  69457. * @param defaultValue The value if the key doesn't exist
  69458. * @returns The number value
  69459. */
  69460. static ReadNumber(key: string, defaultValue: number): number;
  69461. /**
  69462. * Writes a number to the data storage
  69463. * @param key The key to write
  69464. * @param value The value to write
  69465. */
  69466. static WriteNumber(key: string, value: number): void;
  69467. }
  69468. }
  69469. declare module BABYLON {
  69470. /**
  69471. * Options used for hit testing
  69472. */
  69473. export interface IWebXRLegacyHitTestOptions {
  69474. /**
  69475. * Only test when user interacted with the scene. Default - hit test every frame
  69476. */
  69477. testOnPointerDownOnly?: boolean;
  69478. /**
  69479. * The node to use to transform the local results to world coordinates
  69480. */
  69481. worldParentNode?: TransformNode;
  69482. }
  69483. /**
  69484. * Interface defining the babylon result of raycasting/hit-test
  69485. */
  69486. export interface IWebXRLegacyHitResult {
  69487. /**
  69488. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69489. */
  69490. transformationMatrix: Matrix;
  69491. /**
  69492. * The native hit test result
  69493. */
  69494. xrHitResult: XRHitResult | XRHitTestResult;
  69495. }
  69496. /**
  69497. * The currently-working hit-test module.
  69498. * Hit test (or Ray-casting) is used to interact with the real world.
  69499. * For further information read here - https://github.com/immersive-web/hit-test
  69500. */
  69501. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69502. /**
  69503. * options to use when constructing this feature
  69504. */
  69505. readonly options: IWebXRLegacyHitTestOptions;
  69506. private _direction;
  69507. private _mat;
  69508. private _onSelectEnabled;
  69509. private _origin;
  69510. /**
  69511. * The module's name
  69512. */
  69513. static readonly Name: string;
  69514. /**
  69515. * The (Babylon) version of this module.
  69516. * This is an integer representing the implementation version.
  69517. * This number does not correspond to the WebXR specs version
  69518. */
  69519. static readonly Version: number;
  69520. /**
  69521. * Populated with the last native XR Hit Results
  69522. */
  69523. lastNativeXRHitResults: XRHitResult[];
  69524. /**
  69525. * Triggered when new babylon (transformed) hit test results are available
  69526. */
  69527. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69528. /**
  69529. * Creates a new instance of the (legacy version) hit test feature
  69530. * @param _xrSessionManager an instance of WebXRSessionManager
  69531. * @param options options to use when constructing this feature
  69532. */
  69533. constructor(_xrSessionManager: WebXRSessionManager,
  69534. /**
  69535. * options to use when constructing this feature
  69536. */
  69537. options?: IWebXRLegacyHitTestOptions);
  69538. /**
  69539. * execute a hit test with an XR Ray
  69540. *
  69541. * @param xrSession a native xrSession that will execute this hit test
  69542. * @param xrRay the ray (position and direction) to use for ray-casting
  69543. * @param referenceSpace native XR reference space to use for the hit-test
  69544. * @param filter filter function that will filter the results
  69545. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69546. */
  69547. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69548. /**
  69549. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69550. * @param event the (select) event to use to select with
  69551. * @param referenceSpace the reference space to use for this hit test
  69552. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69553. */
  69554. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69555. /**
  69556. * attach this feature
  69557. * Will usually be called by the features manager
  69558. *
  69559. * @returns true if successful.
  69560. */
  69561. attach(): boolean;
  69562. /**
  69563. * detach this feature.
  69564. * Will usually be called by the features manager
  69565. *
  69566. * @returns true if successful.
  69567. */
  69568. detach(): boolean;
  69569. /**
  69570. * Dispose this feature and all of the resources attached
  69571. */
  69572. dispose(): void;
  69573. protected _onXRFrame(frame: XRFrame): void;
  69574. private _onHitTestResults;
  69575. private _onSelect;
  69576. }
  69577. }
  69578. declare module BABYLON {
  69579. /**
  69580. * Options used in the plane detector module
  69581. */
  69582. export interface IWebXRPlaneDetectorOptions {
  69583. /**
  69584. * The node to use to transform the local results to world coordinates
  69585. */
  69586. worldParentNode?: TransformNode;
  69587. }
  69588. /**
  69589. * A babylon interface for a WebXR plane.
  69590. * A Plane is actually a polygon, built from N points in space
  69591. *
  69592. * Supported in chrome 79, not supported in canary 81 ATM
  69593. */
  69594. export interface IWebXRPlane {
  69595. /**
  69596. * a babylon-assigned ID for this polygon
  69597. */
  69598. id: number;
  69599. /**
  69600. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69601. */
  69602. polygonDefinition: Array<Vector3>;
  69603. /**
  69604. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69605. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69606. */
  69607. transformationMatrix: Matrix;
  69608. /**
  69609. * the native xr-plane object
  69610. */
  69611. xrPlane: XRPlane;
  69612. }
  69613. /**
  69614. * The plane detector is used to detect planes in the real world when in AR
  69615. * For more information see https://github.com/immersive-web/real-world-geometry/
  69616. */
  69617. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69618. private _options;
  69619. private _detectedPlanes;
  69620. private _enabled;
  69621. private _lastFrameDetected;
  69622. /**
  69623. * The module's name
  69624. */
  69625. static readonly Name: string;
  69626. /**
  69627. * The (Babylon) version of this module.
  69628. * This is an integer representing the implementation version.
  69629. * This number does not correspond to the WebXR specs version
  69630. */
  69631. static readonly Version: number;
  69632. /**
  69633. * Observers registered here will be executed when a new plane was added to the session
  69634. */
  69635. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69636. /**
  69637. * Observers registered here will be executed when a plane is no longer detected in the session
  69638. */
  69639. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69640. /**
  69641. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69642. * This can execute N times every frame
  69643. */
  69644. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69645. /**
  69646. * construct a new Plane Detector
  69647. * @param _xrSessionManager an instance of xr Session manager
  69648. * @param _options configuration to use when constructing this feature
  69649. */
  69650. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69651. /**
  69652. * Dispose this feature and all of the resources attached
  69653. */
  69654. dispose(): void;
  69655. protected _onXRFrame(frame: XRFrame): void;
  69656. private _init;
  69657. private _updatePlaneWithXRPlane;
  69658. /**
  69659. * avoiding using Array.find for global support.
  69660. * @param xrPlane the plane to find in the array
  69661. */
  69662. private findIndexInPlaneArray;
  69663. }
  69664. }
  69665. declare module BABYLON {
  69666. /**
  69667. * Configuration options of the anchor system
  69668. */
  69669. export interface IWebXRAnchorSystemOptions {
  69670. /**
  69671. * Should a new anchor be added every time a select event is triggered
  69672. */
  69673. addAnchorOnSelect?: boolean;
  69674. /**
  69675. * should the anchor system use plane detection.
  69676. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69677. */
  69678. usePlaneDetection?: boolean;
  69679. /**
  69680. * a node that will be used to convert local to world coordinates
  69681. */
  69682. worldParentNode?: TransformNode;
  69683. }
  69684. /**
  69685. * A babylon container for an XR Anchor
  69686. */
  69687. export interface IWebXRAnchor {
  69688. /**
  69689. * A babylon-assigned ID for this anchor
  69690. */
  69691. id: number;
  69692. /**
  69693. * Transformation matrix to apply to an object attached to this anchor
  69694. */
  69695. transformationMatrix: Matrix;
  69696. /**
  69697. * The native anchor object
  69698. */
  69699. xrAnchor: XRAnchor;
  69700. }
  69701. /**
  69702. * An implementation of the anchor system of WebXR.
  69703. * Note that the current documented implementation is not available in any browser. Future implementations
  69704. * will use the frame to create an anchor and not the session or a detected plane
  69705. * For further information see https://github.com/immersive-web/anchors/
  69706. */
  69707. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69708. private _options;
  69709. private _enabled;
  69710. private _hitTestModule;
  69711. private _lastFrameDetected;
  69712. private _onSelect;
  69713. private _planeDetector;
  69714. private _trackedAnchors;
  69715. /**
  69716. * The module's name
  69717. */
  69718. static readonly Name: string;
  69719. /**
  69720. * The (Babylon) version of this module.
  69721. * This is an integer representing the implementation version.
  69722. * This number does not correspond to the WebXR specs version
  69723. */
  69724. static readonly Version: number;
  69725. /**
  69726. * Observers registered here will be executed when a new anchor was added to the session
  69727. */
  69728. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69729. /**
  69730. * Observers registered here will be executed when an anchor was removed from the session
  69731. */
  69732. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69733. /**
  69734. * Observers registered here will be executed when an existing anchor updates
  69735. * This can execute N times every frame
  69736. */
  69737. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69738. /**
  69739. * constructs a new anchor system
  69740. * @param _xrSessionManager an instance of WebXRSessionManager
  69741. * @param _options configuration object for this feature
  69742. */
  69743. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69744. /**
  69745. * Add anchor at a specific XR point.
  69746. *
  69747. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69748. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69749. * @returns a promise the fulfills when the anchor was created
  69750. */
  69751. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69752. /**
  69753. * attach this feature
  69754. * Will usually be called by the features manager
  69755. *
  69756. * @returns true if successful.
  69757. */
  69758. attach(): boolean;
  69759. /**
  69760. * detach this feature.
  69761. * Will usually be called by the features manager
  69762. *
  69763. * @returns true if successful.
  69764. */
  69765. detach(): boolean;
  69766. /**
  69767. * Dispose this feature and all of the resources attached
  69768. */
  69769. dispose(): void;
  69770. /**
  69771. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69772. * @param hitTestModule the hit-test module to use.
  69773. */
  69774. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69775. /**
  69776. * set the plane detector to use in order to create anchors from frames
  69777. * @param planeDetector the plane-detector module to use
  69778. * @param enable enable plane-anchors. default is true
  69779. */
  69780. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69781. protected _onXRFrame(frame: XRFrame): void;
  69782. /**
  69783. * avoiding using Array.find for global support.
  69784. * @param xrAnchor the plane to find in the array
  69785. */
  69786. private _findIndexInAnchorArray;
  69787. private _updateAnchorWithXRFrame;
  69788. }
  69789. }
  69790. declare module BABYLON {
  69791. /**
  69792. * Options interface for the background remover plugin
  69793. */
  69794. export interface IWebXRBackgroundRemoverOptions {
  69795. /**
  69796. * Further background meshes to disable when entering AR
  69797. */
  69798. backgroundMeshes?: AbstractMesh[];
  69799. /**
  69800. * flags to configure the removal of the environment helper.
  69801. * If not set, the entire background will be removed. If set, flags should be set as well.
  69802. */
  69803. environmentHelperRemovalFlags?: {
  69804. /**
  69805. * Should the skybox be removed (default false)
  69806. */
  69807. skyBox?: boolean;
  69808. /**
  69809. * Should the ground be removed (default false)
  69810. */
  69811. ground?: boolean;
  69812. };
  69813. /**
  69814. * don't disable the environment helper
  69815. */
  69816. ignoreEnvironmentHelper?: boolean;
  69817. }
  69818. /**
  69819. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69820. */
  69821. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69822. /**
  69823. * read-only options to be used in this module
  69824. */
  69825. readonly options: IWebXRBackgroundRemoverOptions;
  69826. /**
  69827. * The module's name
  69828. */
  69829. static readonly Name: string;
  69830. /**
  69831. * The (Babylon) version of this module.
  69832. * This is an integer representing the implementation version.
  69833. * This number does not correspond to the WebXR specs version
  69834. */
  69835. static readonly Version: number;
  69836. /**
  69837. * registered observers will be triggered when the background state changes
  69838. */
  69839. onBackgroundStateChangedObservable: Observable<boolean>;
  69840. /**
  69841. * constructs a new background remover module
  69842. * @param _xrSessionManager the session manager for this module
  69843. * @param options read-only options to be used in this module
  69844. */
  69845. constructor(_xrSessionManager: WebXRSessionManager,
  69846. /**
  69847. * read-only options to be used in this module
  69848. */
  69849. options?: IWebXRBackgroundRemoverOptions);
  69850. /**
  69851. * attach this feature
  69852. * Will usually be called by the features manager
  69853. *
  69854. * @returns true if successful.
  69855. */
  69856. attach(): boolean;
  69857. /**
  69858. * detach this feature.
  69859. * Will usually be called by the features manager
  69860. *
  69861. * @returns true if successful.
  69862. */
  69863. detach(): boolean;
  69864. /**
  69865. * Dispose this feature and all of the resources attached
  69866. */
  69867. dispose(): void;
  69868. protected _onXRFrame(_xrFrame: XRFrame): void;
  69869. private _setBackgroundState;
  69870. }
  69871. }
  69872. declare module BABYLON {
  69873. /**
  69874. * Options for the controller physics feature
  69875. */
  69876. export class IWebXRControllerPhysicsOptions {
  69877. /**
  69878. * Should the headset get its own impostor
  69879. */
  69880. enableHeadsetImpostor?: boolean;
  69881. /**
  69882. * Optional parameters for the headset impostor
  69883. */
  69884. headsetImpostorParams?: {
  69885. /**
  69886. * The type of impostor to create. Default is sphere
  69887. */
  69888. impostorType: number;
  69889. /**
  69890. * the size of the impostor. Defaults to 10cm
  69891. */
  69892. impostorSize?: number | {
  69893. width: number;
  69894. height: number;
  69895. depth: number;
  69896. };
  69897. /**
  69898. * Friction definitions
  69899. */
  69900. friction?: number;
  69901. /**
  69902. * Restitution
  69903. */
  69904. restitution?: number;
  69905. };
  69906. /**
  69907. * The physics properties of the future impostors
  69908. */
  69909. physicsProperties?: {
  69910. /**
  69911. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69912. * Note that this requires a physics engine that supports mesh impostors!
  69913. */
  69914. useControllerMesh?: boolean;
  69915. /**
  69916. * The type of impostor to create. Default is sphere
  69917. */
  69918. impostorType?: number;
  69919. /**
  69920. * the size of the impostor. Defaults to 10cm
  69921. */
  69922. impostorSize?: number | {
  69923. width: number;
  69924. height: number;
  69925. depth: number;
  69926. };
  69927. /**
  69928. * Friction definitions
  69929. */
  69930. friction?: number;
  69931. /**
  69932. * Restitution
  69933. */
  69934. restitution?: number;
  69935. };
  69936. /**
  69937. * the xr input to use with this pointer selection
  69938. */
  69939. xrInput: WebXRInput;
  69940. }
  69941. /**
  69942. * Add physics impostor to your webxr controllers,
  69943. * including naive calculation of their linear and angular velocity
  69944. */
  69945. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69946. private readonly _options;
  69947. private _attachController;
  69948. private _controllers;
  69949. private _debugMode;
  69950. private _delta;
  69951. private _headsetImpostor?;
  69952. private _headsetMesh?;
  69953. private _lastTimestamp;
  69954. private _tmpQuaternion;
  69955. private _tmpVector;
  69956. /**
  69957. * The module's name
  69958. */
  69959. static readonly Name: string;
  69960. /**
  69961. * The (Babylon) version of this module.
  69962. * This is an integer representing the implementation version.
  69963. * This number does not correspond to the webxr specs version
  69964. */
  69965. static readonly Version: number;
  69966. /**
  69967. * Construct a new Controller Physics Feature
  69968. * @param _xrSessionManager the corresponding xr session manager
  69969. * @param _options options to create this feature with
  69970. */
  69971. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69972. /**
  69973. * @hidden
  69974. * enable debugging - will show console outputs and the impostor mesh
  69975. */
  69976. _enablePhysicsDebug(): void;
  69977. /**
  69978. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69979. * @param xrController the controller to add
  69980. */
  69981. addController(xrController: WebXRInputSource): void;
  69982. /**
  69983. * attach this feature
  69984. * Will usually be called by the features manager
  69985. *
  69986. * @returns true if successful.
  69987. */
  69988. attach(): boolean;
  69989. /**
  69990. * detach this feature.
  69991. * Will usually be called by the features manager
  69992. *
  69993. * @returns true if successful.
  69994. */
  69995. detach(): boolean;
  69996. /**
  69997. * Get the headset impostor, if enabled
  69998. * @returns the impostor
  69999. */
  70000. getHeadsetImpostor(): PhysicsImpostor | undefined;
  70001. /**
  70002. * Get the physics impostor of a specific controller.
  70003. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  70004. * @param controller the controller or the controller id of which to get the impostor
  70005. * @returns the impostor or null
  70006. */
  70007. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  70008. /**
  70009. * Update the physics properties provided in the constructor
  70010. * @param newProperties the new properties object
  70011. */
  70012. setPhysicsProperties(newProperties: {
  70013. impostorType?: number;
  70014. impostorSize?: number | {
  70015. width: number;
  70016. height: number;
  70017. depth: number;
  70018. };
  70019. friction?: number;
  70020. restitution?: number;
  70021. }): void;
  70022. protected _onXRFrame(_xrFrame: any): void;
  70023. private _detachController;
  70024. }
  70025. }
  70026. declare module BABYLON {
  70027. /**
  70028. * Options used for hit testing (version 2)
  70029. */
  70030. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  70031. /**
  70032. * Do not create a permanent hit test. Will usually be used when only
  70033. * transient inputs are needed.
  70034. */
  70035. disablePermanentHitTest?: boolean;
  70036. /**
  70037. * Enable transient (for example touch-based) hit test inspections
  70038. */
  70039. enableTransientHitTest?: boolean;
  70040. /**
  70041. * Offset ray for the permanent hit test
  70042. */
  70043. offsetRay?: Vector3;
  70044. /**
  70045. * Offset ray for the transient hit test
  70046. */
  70047. transientOffsetRay?: Vector3;
  70048. /**
  70049. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  70050. */
  70051. useReferenceSpace?: boolean;
  70052. }
  70053. /**
  70054. * Interface defining the babylon result of hit-test
  70055. */
  70056. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  70057. /**
  70058. * The input source that generated this hit test (if transient)
  70059. */
  70060. inputSource?: XRInputSource;
  70061. /**
  70062. * Is this a transient hit test
  70063. */
  70064. isTransient?: boolean;
  70065. /**
  70066. * Position of the hit test result
  70067. */
  70068. position: Vector3;
  70069. /**
  70070. * Rotation of the hit test result
  70071. */
  70072. rotationQuaternion: Quaternion;
  70073. }
  70074. /**
  70075. * The currently-working hit-test module.
  70076. * Hit test (or Ray-casting) is used to interact with the real world.
  70077. * For further information read here - https://github.com/immersive-web/hit-test
  70078. *
  70079. * Tested on chrome (mobile) 80.
  70080. */
  70081. export class WebXRHitTest extends WebXRAbstractFeature {
  70082. /**
  70083. * options to use when constructing this feature
  70084. */
  70085. readonly options: IWebXRHitTestOptions;
  70086. private _tmpMat;
  70087. private _tmpPos;
  70088. private _tmpQuat;
  70089. private _transientXrHitTestSource;
  70090. private _xrHitTestSource;
  70091. private initHitTestSource;
  70092. /**
  70093. * The module's name
  70094. */
  70095. static readonly Name: string;
  70096. /**
  70097. * The (Babylon) version of this module.
  70098. * This is an integer representing the implementation version.
  70099. * This number does not correspond to the WebXR specs version
  70100. */
  70101. static readonly Version: number;
  70102. /**
  70103. * When set to true, each hit test will have its own position/rotation objects
  70104. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  70105. * the developers will clone them or copy them as they see fit.
  70106. */
  70107. autoCloneTransformation: boolean;
  70108. /**
  70109. * Populated with the last native XR Hit Results
  70110. */
  70111. lastNativeXRHitResults: XRHitResult[];
  70112. /**
  70113. * Triggered when new babylon (transformed) hit test results are available
  70114. */
  70115. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  70116. /**
  70117. * Use this to temporarily pause hit test checks.
  70118. */
  70119. paused: boolean;
  70120. /**
  70121. * Creates a new instance of the hit test feature
  70122. * @param _xrSessionManager an instance of WebXRSessionManager
  70123. * @param options options to use when constructing this feature
  70124. */
  70125. constructor(_xrSessionManager: WebXRSessionManager,
  70126. /**
  70127. * options to use when constructing this feature
  70128. */
  70129. options?: IWebXRHitTestOptions);
  70130. /**
  70131. * attach this feature
  70132. * Will usually be called by the features manager
  70133. *
  70134. * @returns true if successful.
  70135. */
  70136. attach(): boolean;
  70137. /**
  70138. * detach this feature.
  70139. * Will usually be called by the features manager
  70140. *
  70141. * @returns true if successful.
  70142. */
  70143. detach(): boolean;
  70144. /**
  70145. * Dispose this feature and all of the resources attached
  70146. */
  70147. dispose(): void;
  70148. protected _onXRFrame(frame: XRFrame): void;
  70149. private _processWebXRHitTestResult;
  70150. }
  70151. }
  70152. declare module BABYLON {
  70153. /**
  70154. * The motion controller class for all microsoft mixed reality controllers
  70155. */
  70156. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  70157. protected readonly _mapping: {
  70158. defaultButton: {
  70159. valueNodeName: string;
  70160. unpressedNodeName: string;
  70161. pressedNodeName: string;
  70162. };
  70163. defaultAxis: {
  70164. valueNodeName: string;
  70165. minNodeName: string;
  70166. maxNodeName: string;
  70167. };
  70168. buttons: {
  70169. "xr-standard-trigger": {
  70170. rootNodeName: string;
  70171. componentProperty: string;
  70172. states: string[];
  70173. };
  70174. "xr-standard-squeeze": {
  70175. rootNodeName: string;
  70176. componentProperty: string;
  70177. states: string[];
  70178. };
  70179. "xr-standard-touchpad": {
  70180. rootNodeName: string;
  70181. labelAnchorNodeName: string;
  70182. touchPointNodeName: string;
  70183. };
  70184. "xr-standard-thumbstick": {
  70185. rootNodeName: string;
  70186. componentProperty: string;
  70187. states: string[];
  70188. };
  70189. };
  70190. axes: {
  70191. "xr-standard-touchpad": {
  70192. "x-axis": {
  70193. rootNodeName: string;
  70194. };
  70195. "y-axis": {
  70196. rootNodeName: string;
  70197. };
  70198. };
  70199. "xr-standard-thumbstick": {
  70200. "x-axis": {
  70201. rootNodeName: string;
  70202. };
  70203. "y-axis": {
  70204. rootNodeName: string;
  70205. };
  70206. };
  70207. };
  70208. };
  70209. /**
  70210. * The base url used to load the left and right controller models
  70211. */
  70212. static MODEL_BASE_URL: string;
  70213. /**
  70214. * The name of the left controller model file
  70215. */
  70216. static MODEL_LEFT_FILENAME: string;
  70217. /**
  70218. * The name of the right controller model file
  70219. */
  70220. static MODEL_RIGHT_FILENAME: string;
  70221. profileId: string;
  70222. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70223. protected _getFilenameAndPath(): {
  70224. filename: string;
  70225. path: string;
  70226. };
  70227. protected _getModelLoadingConstraints(): boolean;
  70228. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70229. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70230. protected _updateModel(): void;
  70231. }
  70232. }
  70233. declare module BABYLON {
  70234. /**
  70235. * The motion controller class for oculus touch (quest, rift).
  70236. * This class supports legacy mapping as well the standard xr mapping
  70237. */
  70238. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70239. private _forceLegacyControllers;
  70240. private _modelRootNode;
  70241. /**
  70242. * The base url used to load the left and right controller models
  70243. */
  70244. static MODEL_BASE_URL: string;
  70245. /**
  70246. * The name of the left controller model file
  70247. */
  70248. static MODEL_LEFT_FILENAME: string;
  70249. /**
  70250. * The name of the right controller model file
  70251. */
  70252. static MODEL_RIGHT_FILENAME: string;
  70253. /**
  70254. * Base Url for the Quest controller model.
  70255. */
  70256. static QUEST_MODEL_BASE_URL: string;
  70257. profileId: string;
  70258. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70259. protected _getFilenameAndPath(): {
  70260. filename: string;
  70261. path: string;
  70262. };
  70263. protected _getModelLoadingConstraints(): boolean;
  70264. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70265. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70266. protected _updateModel(): void;
  70267. /**
  70268. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70269. * between the touch and touch 2.
  70270. */
  70271. private _isQuest;
  70272. }
  70273. }
  70274. declare module BABYLON {
  70275. /**
  70276. * The motion controller class for the standard HTC-Vive controllers
  70277. */
  70278. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70279. private _modelRootNode;
  70280. /**
  70281. * The base url used to load the left and right controller models
  70282. */
  70283. static MODEL_BASE_URL: string;
  70284. /**
  70285. * File name for the controller model.
  70286. */
  70287. static MODEL_FILENAME: string;
  70288. profileId: string;
  70289. /**
  70290. * Create a new Vive motion controller object
  70291. * @param scene the scene to use to create this controller
  70292. * @param gamepadObject the corresponding gamepad object
  70293. * @param handness the handness of the controller
  70294. */
  70295. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70296. protected _getFilenameAndPath(): {
  70297. filename: string;
  70298. path: string;
  70299. };
  70300. protected _getModelLoadingConstraints(): boolean;
  70301. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70302. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70303. protected _updateModel(): void;
  70304. }
  70305. }
  70306. declare module BABYLON {
  70307. /**
  70308. * A cursor which tracks a point on a path
  70309. */
  70310. export class PathCursor {
  70311. private path;
  70312. /**
  70313. * Stores path cursor callbacks for when an onchange event is triggered
  70314. */
  70315. private _onchange;
  70316. /**
  70317. * The value of the path cursor
  70318. */
  70319. value: number;
  70320. /**
  70321. * The animation array of the path cursor
  70322. */
  70323. animations: Animation[];
  70324. /**
  70325. * Initializes the path cursor
  70326. * @param path The path to track
  70327. */
  70328. constructor(path: Path2);
  70329. /**
  70330. * Gets the cursor point on the path
  70331. * @returns A point on the path cursor at the cursor location
  70332. */
  70333. getPoint(): Vector3;
  70334. /**
  70335. * Moves the cursor ahead by the step amount
  70336. * @param step The amount to move the cursor forward
  70337. * @returns This path cursor
  70338. */
  70339. moveAhead(step?: number): PathCursor;
  70340. /**
  70341. * Moves the cursor behind by the step amount
  70342. * @param step The amount to move the cursor back
  70343. * @returns This path cursor
  70344. */
  70345. moveBack(step?: number): PathCursor;
  70346. /**
  70347. * Moves the cursor by the step amount
  70348. * If the step amount is greater than one, an exception is thrown
  70349. * @param step The amount to move the cursor
  70350. * @returns This path cursor
  70351. */
  70352. move(step: number): PathCursor;
  70353. /**
  70354. * Ensures that the value is limited between zero and one
  70355. * @returns This path cursor
  70356. */
  70357. private ensureLimits;
  70358. /**
  70359. * Runs onchange callbacks on change (used by the animation engine)
  70360. * @returns This path cursor
  70361. */
  70362. private raiseOnChange;
  70363. /**
  70364. * Executes a function on change
  70365. * @param f A path cursor onchange callback
  70366. * @returns This path cursor
  70367. */
  70368. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70369. }
  70370. }
  70371. declare module BABYLON {
  70372. /** @hidden */
  70373. export var blurPixelShader: {
  70374. name: string;
  70375. shader: string;
  70376. };
  70377. }
  70378. declare module BABYLON {
  70379. /** @hidden */
  70380. export var pointCloudVertexDeclaration: {
  70381. name: string;
  70382. shader: string;
  70383. };
  70384. }
  70385. // Mixins
  70386. interface Window {
  70387. mozIndexedDB: IDBFactory;
  70388. webkitIndexedDB: IDBFactory;
  70389. msIndexedDB: IDBFactory;
  70390. webkitURL: typeof URL;
  70391. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70392. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70393. WebGLRenderingContext: WebGLRenderingContext;
  70394. MSGesture: MSGesture;
  70395. CANNON: any;
  70396. AudioContext: AudioContext;
  70397. webkitAudioContext: AudioContext;
  70398. PointerEvent: any;
  70399. Math: Math;
  70400. Uint8Array: Uint8ArrayConstructor;
  70401. Float32Array: Float32ArrayConstructor;
  70402. mozURL: typeof URL;
  70403. msURL: typeof URL;
  70404. VRFrameData: any; // WebVR, from specs 1.1
  70405. DracoDecoderModule: any;
  70406. setImmediate(handler: (...args: any[]) => void): number;
  70407. }
  70408. interface HTMLCanvasElement {
  70409. requestPointerLock(): void;
  70410. msRequestPointerLock?(): void;
  70411. mozRequestPointerLock?(): void;
  70412. webkitRequestPointerLock?(): void;
  70413. /** Track wether a record is in progress */
  70414. isRecording: boolean;
  70415. /** Capture Stream method defined by some browsers */
  70416. captureStream(fps?: number): MediaStream;
  70417. }
  70418. interface CanvasRenderingContext2D {
  70419. msImageSmoothingEnabled: boolean;
  70420. }
  70421. interface MouseEvent {
  70422. mozMovementX: number;
  70423. mozMovementY: number;
  70424. webkitMovementX: number;
  70425. webkitMovementY: number;
  70426. msMovementX: number;
  70427. msMovementY: number;
  70428. }
  70429. interface Navigator {
  70430. mozGetVRDevices: (any: any) => any;
  70431. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70432. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70433. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70434. webkitGetGamepads(): Gamepad[];
  70435. msGetGamepads(): Gamepad[];
  70436. webkitGamepads(): Gamepad[];
  70437. }
  70438. interface HTMLVideoElement {
  70439. mozSrcObject: any;
  70440. }
  70441. interface Math {
  70442. fround(x: number): number;
  70443. imul(a: number, b: number): number;
  70444. }
  70445. interface WebGLRenderingContext {
  70446. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70447. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70448. vertexAttribDivisor(index: number, divisor: number): void;
  70449. createVertexArray(): any;
  70450. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70451. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70452. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70453. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70454. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70455. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70456. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70457. // Queries
  70458. createQuery(): WebGLQuery;
  70459. deleteQuery(query: WebGLQuery): void;
  70460. beginQuery(target: number, query: WebGLQuery): void;
  70461. endQuery(target: number): void;
  70462. getQueryParameter(query: WebGLQuery, pname: number): any;
  70463. getQuery(target: number, pname: number): any;
  70464. MAX_SAMPLES: number;
  70465. RGBA8: number;
  70466. READ_FRAMEBUFFER: number;
  70467. DRAW_FRAMEBUFFER: number;
  70468. UNIFORM_BUFFER: number;
  70469. HALF_FLOAT_OES: number;
  70470. RGBA16F: number;
  70471. RGBA32F: number;
  70472. R32F: number;
  70473. RG32F: number;
  70474. RGB32F: number;
  70475. R16F: number;
  70476. RG16F: number;
  70477. RGB16F: number;
  70478. RED: number;
  70479. RG: number;
  70480. R8: number;
  70481. RG8: number;
  70482. UNSIGNED_INT_24_8: number;
  70483. DEPTH24_STENCIL8: number;
  70484. MIN: number;
  70485. MAX: number;
  70486. /* Multiple Render Targets */
  70487. drawBuffers(buffers: number[]): void;
  70488. readBuffer(src: number): void;
  70489. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70490. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70491. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70492. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70493. // Occlusion Query
  70494. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70495. ANY_SAMPLES_PASSED: number;
  70496. QUERY_RESULT_AVAILABLE: number;
  70497. QUERY_RESULT: number;
  70498. }
  70499. interface WebGLProgram {
  70500. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70501. }
  70502. interface EXT_disjoint_timer_query {
  70503. QUERY_COUNTER_BITS_EXT: number;
  70504. TIME_ELAPSED_EXT: number;
  70505. TIMESTAMP_EXT: number;
  70506. GPU_DISJOINT_EXT: number;
  70507. QUERY_RESULT_EXT: number;
  70508. QUERY_RESULT_AVAILABLE_EXT: number;
  70509. queryCounterEXT(query: WebGLQuery, target: number): void;
  70510. createQueryEXT(): WebGLQuery;
  70511. beginQueryEXT(target: number, query: WebGLQuery): void;
  70512. endQueryEXT(target: number): void;
  70513. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70514. deleteQueryEXT(query: WebGLQuery): void;
  70515. }
  70516. interface WebGLUniformLocation {
  70517. _currentState: any;
  70518. }
  70519. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70520. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70521. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70522. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70523. interface WebGLRenderingContext {
  70524. readonly RASTERIZER_DISCARD: number;
  70525. readonly DEPTH_COMPONENT24: number;
  70526. readonly TEXTURE_3D: number;
  70527. readonly TEXTURE_2D_ARRAY: number;
  70528. readonly TEXTURE_COMPARE_FUNC: number;
  70529. readonly TEXTURE_COMPARE_MODE: number;
  70530. readonly COMPARE_REF_TO_TEXTURE: number;
  70531. readonly TEXTURE_WRAP_R: number;
  70532. readonly HALF_FLOAT: number;
  70533. readonly RGB8: number;
  70534. readonly RED_INTEGER: number;
  70535. readonly RG_INTEGER: number;
  70536. readonly RGB_INTEGER: number;
  70537. readonly RGBA_INTEGER: number;
  70538. readonly R8_SNORM: number;
  70539. readonly RG8_SNORM: number;
  70540. readonly RGB8_SNORM: number;
  70541. readonly RGBA8_SNORM: number;
  70542. readonly R8I: number;
  70543. readonly RG8I: number;
  70544. readonly RGB8I: number;
  70545. readonly RGBA8I: number;
  70546. readonly R8UI: number;
  70547. readonly RG8UI: number;
  70548. readonly RGB8UI: number;
  70549. readonly RGBA8UI: number;
  70550. readonly R16I: number;
  70551. readonly RG16I: number;
  70552. readonly RGB16I: number;
  70553. readonly RGBA16I: number;
  70554. readonly R16UI: number;
  70555. readonly RG16UI: number;
  70556. readonly RGB16UI: number;
  70557. readonly RGBA16UI: number;
  70558. readonly R32I: number;
  70559. readonly RG32I: number;
  70560. readonly RGB32I: number;
  70561. readonly RGBA32I: number;
  70562. readonly R32UI: number;
  70563. readonly RG32UI: number;
  70564. readonly RGB32UI: number;
  70565. readonly RGBA32UI: number;
  70566. readonly RGB10_A2UI: number;
  70567. readonly R11F_G11F_B10F: number;
  70568. readonly RGB9_E5: number;
  70569. readonly RGB10_A2: number;
  70570. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70571. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70572. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70573. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70574. readonly DEPTH_COMPONENT32F: number;
  70575. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70576. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70577. 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;
  70578. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70579. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70580. readonly TRANSFORM_FEEDBACK: number;
  70581. readonly INTERLEAVED_ATTRIBS: number;
  70582. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70583. createTransformFeedback(): WebGLTransformFeedback;
  70584. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70585. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70586. beginTransformFeedback(primitiveMode: number): void;
  70587. endTransformFeedback(): void;
  70588. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70589. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70590. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70591. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70592. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70593. }
  70594. interface ImageBitmap {
  70595. readonly width: number;
  70596. readonly height: number;
  70597. close(): void;
  70598. }
  70599. interface WebGLQuery extends WebGLObject {
  70600. }
  70601. declare var WebGLQuery: {
  70602. prototype: WebGLQuery;
  70603. new(): WebGLQuery;
  70604. };
  70605. interface WebGLSampler extends WebGLObject {
  70606. }
  70607. declare var WebGLSampler: {
  70608. prototype: WebGLSampler;
  70609. new(): WebGLSampler;
  70610. };
  70611. interface WebGLSync extends WebGLObject {
  70612. }
  70613. declare var WebGLSync: {
  70614. prototype: WebGLSync;
  70615. new(): WebGLSync;
  70616. };
  70617. interface WebGLTransformFeedback extends WebGLObject {
  70618. }
  70619. declare var WebGLTransformFeedback: {
  70620. prototype: WebGLTransformFeedback;
  70621. new(): WebGLTransformFeedback;
  70622. };
  70623. interface WebGLVertexArrayObject extends WebGLObject {
  70624. }
  70625. declare var WebGLVertexArrayObject: {
  70626. prototype: WebGLVertexArrayObject;
  70627. new(): WebGLVertexArrayObject;
  70628. };
  70629. // Type definitions for WebVR API
  70630. // Project: https://w3c.github.io/webvr/
  70631. // Definitions by: six a <https://github.com/lostfictions>
  70632. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70633. interface VRDisplay extends EventTarget {
  70634. /**
  70635. * Dictionary of capabilities describing the VRDisplay.
  70636. */
  70637. readonly capabilities: VRDisplayCapabilities;
  70638. /**
  70639. * z-depth defining the far plane of the eye view frustum
  70640. * enables mapping of values in the render target depth
  70641. * attachment to scene coordinates. Initially set to 10000.0.
  70642. */
  70643. depthFar: number;
  70644. /**
  70645. * z-depth defining the near plane of the eye view frustum
  70646. * enables mapping of values in the render target depth
  70647. * attachment to scene coordinates. Initially set to 0.01.
  70648. */
  70649. depthNear: number;
  70650. /**
  70651. * An identifier for this distinct VRDisplay. Used as an
  70652. * association point in the Gamepad API.
  70653. */
  70654. readonly displayId: number;
  70655. /**
  70656. * A display name, a user-readable name identifying it.
  70657. */
  70658. readonly displayName: string;
  70659. readonly isConnected: boolean;
  70660. readonly isPresenting: boolean;
  70661. /**
  70662. * If this VRDisplay supports room-scale experiences, the optional
  70663. * stage attribute contains details on the room-scale parameters.
  70664. */
  70665. readonly stageParameters: VRStageParameters | null;
  70666. /**
  70667. * Passing the value returned by `requestAnimationFrame` to
  70668. * `cancelAnimationFrame` will unregister the callback.
  70669. * @param handle Define the hanle of the request to cancel
  70670. */
  70671. cancelAnimationFrame(handle: number): void;
  70672. /**
  70673. * Stops presenting to the VRDisplay.
  70674. * @returns a promise to know when it stopped
  70675. */
  70676. exitPresent(): Promise<void>;
  70677. /**
  70678. * Return the current VREyeParameters for the given eye.
  70679. * @param whichEye Define the eye we want the parameter for
  70680. * @returns the eye parameters
  70681. */
  70682. getEyeParameters(whichEye: string): VREyeParameters;
  70683. /**
  70684. * Populates the passed VRFrameData with the information required to render
  70685. * the current frame.
  70686. * @param frameData Define the data structure to populate
  70687. * @returns true if ok otherwise false
  70688. */
  70689. getFrameData(frameData: VRFrameData): boolean;
  70690. /**
  70691. * Get the layers currently being presented.
  70692. * @returns the list of VR layers
  70693. */
  70694. getLayers(): VRLayer[];
  70695. /**
  70696. * Return a VRPose containing the future predicted pose of the VRDisplay
  70697. * when the current frame will be presented. The value returned will not
  70698. * change until JavaScript has returned control to the browser.
  70699. *
  70700. * The VRPose will contain the position, orientation, velocity,
  70701. * and acceleration of each of these properties.
  70702. * @returns the pose object
  70703. */
  70704. getPose(): VRPose;
  70705. /**
  70706. * Return the current instantaneous pose of the VRDisplay, with no
  70707. * prediction applied.
  70708. * @returns the current instantaneous pose
  70709. */
  70710. getImmediatePose(): VRPose;
  70711. /**
  70712. * The callback passed to `requestAnimationFrame` will be called
  70713. * any time a new frame should be rendered. When the VRDisplay is
  70714. * presenting the callback will be called at the native refresh
  70715. * rate of the HMD. When not presenting this function acts
  70716. * identically to how window.requestAnimationFrame acts. Content should
  70717. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70718. * asynchronously from other displays and at differing refresh rates.
  70719. * @param callback Define the eaction to run next frame
  70720. * @returns the request handle it
  70721. */
  70722. requestAnimationFrame(callback: FrameRequestCallback): number;
  70723. /**
  70724. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70725. * Repeat calls while already presenting will update the VRLayers being displayed.
  70726. * @param layers Define the list of layer to present
  70727. * @returns a promise to know when the request has been fulfilled
  70728. */
  70729. requestPresent(layers: VRLayer[]): Promise<void>;
  70730. /**
  70731. * Reset the pose for this display, treating its current position and
  70732. * orientation as the "origin/zero" values. VRPose.position,
  70733. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70734. * updated when calling resetPose(). This should be called in only
  70735. * sitting-space experiences.
  70736. */
  70737. resetPose(): void;
  70738. /**
  70739. * The VRLayer provided to the VRDisplay will be captured and presented
  70740. * in the HMD. Calling this function has the same effect on the source
  70741. * canvas as any other operation that uses its source image, and canvases
  70742. * created without preserveDrawingBuffer set to true will be cleared.
  70743. * @param pose Define the pose to submit
  70744. */
  70745. submitFrame(pose?: VRPose): void;
  70746. }
  70747. declare var VRDisplay: {
  70748. prototype: VRDisplay;
  70749. new(): VRDisplay;
  70750. };
  70751. interface VRLayer {
  70752. leftBounds?: number[] | Float32Array | null;
  70753. rightBounds?: number[] | Float32Array | null;
  70754. source?: HTMLCanvasElement | null;
  70755. }
  70756. interface VRDisplayCapabilities {
  70757. readonly canPresent: boolean;
  70758. readonly hasExternalDisplay: boolean;
  70759. readonly hasOrientation: boolean;
  70760. readonly hasPosition: boolean;
  70761. readonly maxLayers: number;
  70762. }
  70763. interface VREyeParameters {
  70764. /** @deprecated */
  70765. readonly fieldOfView: VRFieldOfView;
  70766. readonly offset: Float32Array;
  70767. readonly renderHeight: number;
  70768. readonly renderWidth: number;
  70769. }
  70770. interface VRFieldOfView {
  70771. readonly downDegrees: number;
  70772. readonly leftDegrees: number;
  70773. readonly rightDegrees: number;
  70774. readonly upDegrees: number;
  70775. }
  70776. interface VRFrameData {
  70777. readonly leftProjectionMatrix: Float32Array;
  70778. readonly leftViewMatrix: Float32Array;
  70779. readonly pose: VRPose;
  70780. readonly rightProjectionMatrix: Float32Array;
  70781. readonly rightViewMatrix: Float32Array;
  70782. readonly timestamp: number;
  70783. }
  70784. interface VRPose {
  70785. readonly angularAcceleration: Float32Array | null;
  70786. readonly angularVelocity: Float32Array | null;
  70787. readonly linearAcceleration: Float32Array | null;
  70788. readonly linearVelocity: Float32Array | null;
  70789. readonly orientation: Float32Array | null;
  70790. readonly position: Float32Array | null;
  70791. readonly timestamp: number;
  70792. }
  70793. interface VRStageParameters {
  70794. sittingToStandingTransform?: Float32Array;
  70795. sizeX?: number;
  70796. sizeY?: number;
  70797. }
  70798. interface Navigator {
  70799. getVRDisplays(): Promise<VRDisplay[]>;
  70800. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70801. }
  70802. interface Window {
  70803. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70804. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70805. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70806. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70807. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70808. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70809. }
  70810. interface Gamepad {
  70811. readonly displayId: number;
  70812. }
  70813. type XRSessionMode =
  70814. | "inline"
  70815. | "immersive-vr"
  70816. | "immersive-ar";
  70817. type XRReferenceSpaceType =
  70818. | "viewer"
  70819. | "local"
  70820. | "local-floor"
  70821. | "bounded-floor"
  70822. | "unbounded";
  70823. type XREnvironmentBlendMode =
  70824. | "opaque"
  70825. | "additive"
  70826. | "alpha-blend";
  70827. type XRVisibilityState =
  70828. | "visible"
  70829. | "visible-blurred"
  70830. | "hidden";
  70831. type XRHandedness =
  70832. | "none"
  70833. | "left"
  70834. | "right";
  70835. type XRTargetRayMode =
  70836. | "gaze"
  70837. | "tracked-pointer"
  70838. | "screen";
  70839. type XREye =
  70840. | "none"
  70841. | "left"
  70842. | "right";
  70843. interface XRSpace extends EventTarget {
  70844. }
  70845. interface XRRenderState {
  70846. depthNear?: number;
  70847. depthFar?: number;
  70848. inlineVerticalFieldOfView?: number;
  70849. baseLayer?: XRWebGLLayer;
  70850. }
  70851. interface XRInputSource {
  70852. handedness: XRHandedness;
  70853. targetRayMode: XRTargetRayMode;
  70854. targetRaySpace: XRSpace;
  70855. gripSpace: XRSpace | undefined;
  70856. gamepad: Gamepad | undefined;
  70857. profiles: Array<string>;
  70858. }
  70859. interface XRSessionInit {
  70860. optionalFeatures?: XRReferenceSpaceType[];
  70861. requiredFeatures?: XRReferenceSpaceType[];
  70862. }
  70863. interface XRSession extends XRAnchorCreator {
  70864. addEventListener: Function;
  70865. removeEventListener: Function;
  70866. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70867. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70868. requestAnimationFrame: Function;
  70869. end(): Promise<void>;
  70870. renderState: XRRenderState;
  70871. inputSources: Array<XRInputSource>;
  70872. // hit test
  70873. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  70874. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  70875. // legacy AR hit test
  70876. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70877. // legacy plane detection
  70878. updateWorldTrackingState(options: {
  70879. planeDetectionState?: { enabled: boolean; }
  70880. }): void;
  70881. }
  70882. interface XRReferenceSpace extends XRSpace {
  70883. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70884. onreset: any;
  70885. }
  70886. type XRPlaneSet = Set<XRPlane>;
  70887. type XRAnchorSet = Set<XRAnchor>;
  70888. interface XRFrame {
  70889. session: XRSession;
  70890. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70891. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70892. // AR
  70893. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  70894. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  70895. // Anchors
  70896. trackedAnchors?: XRAnchorSet;
  70897. // Planes
  70898. worldInformation: {
  70899. detectedPlanes?: XRPlaneSet;
  70900. };
  70901. }
  70902. interface XRViewerPose extends XRPose {
  70903. views: Array<XRView>;
  70904. }
  70905. interface XRPose {
  70906. transform: XRRigidTransform;
  70907. emulatedPosition: boolean;
  70908. }
  70909. interface XRWebGLLayerOptions {
  70910. antialias?: boolean;
  70911. depth?: boolean;
  70912. stencil?: boolean;
  70913. alpha?: boolean;
  70914. multiview?: boolean;
  70915. framebufferScaleFactor?: number;
  70916. }
  70917. declare var XRWebGLLayer: {
  70918. prototype: XRWebGLLayer;
  70919. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70920. };
  70921. interface XRWebGLLayer {
  70922. framebuffer: WebGLFramebuffer;
  70923. framebufferWidth: number;
  70924. framebufferHeight: number;
  70925. getViewport: Function;
  70926. }
  70927. declare class XRRigidTransform {
  70928. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70929. position: DOMPointReadOnly;
  70930. orientation: DOMPointReadOnly;
  70931. matrix: Float32Array;
  70932. inverse: XRRigidTransform;
  70933. }
  70934. interface XRView {
  70935. eye: XREye;
  70936. projectionMatrix: Float32Array;
  70937. transform: XRRigidTransform;
  70938. }
  70939. interface XRInputSourceChangeEvent {
  70940. session: XRSession;
  70941. removed: Array<XRInputSource>;
  70942. added: Array<XRInputSource>;
  70943. }
  70944. interface XRInputSourceEvent extends Event {
  70945. readonly frame: XRFrame;
  70946. readonly inputSource: XRInputSource;
  70947. }
  70948. // Experimental(er) features
  70949. declare class XRRay {
  70950. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70951. origin: DOMPointReadOnly;
  70952. direction: DOMPointReadOnly;
  70953. matrix: Float32Array;
  70954. }
  70955. declare enum XRHitTestTrackableType {
  70956. "point",
  70957. "plane"
  70958. }
  70959. interface XRHitResult {
  70960. hitMatrix: Float32Array;
  70961. }
  70962. interface XRTransientInputHitTestResult {
  70963. readonly inputSource: XRInputSource;
  70964. readonly results: Array<XRHitTestResult>;
  70965. }
  70966. interface XRHitTestResult {
  70967. getPose(baseSpace: XRSpace): XRPose | undefined;
  70968. }
  70969. interface XRHitTestSource {
  70970. cancel(): void;
  70971. }
  70972. interface XRTransientInputHitTestSource {
  70973. cancel(): void;
  70974. }
  70975. interface XRHitTestOptionsInit {
  70976. space: XRSpace;
  70977. entityTypes?: Array<XRHitTestTrackableType>;
  70978. offsetRay?: XRRay;
  70979. }
  70980. interface XRTransientInputHitTestOptionsInit {
  70981. profile: string;
  70982. entityTypes?: Array<XRHitTestTrackableType>;
  70983. offsetRay?: XRRay;
  70984. }
  70985. interface XRAnchor {
  70986. // remove?
  70987. id?: string;
  70988. anchorSpace: XRSpace;
  70989. lastChangedTime: number;
  70990. detach(): void;
  70991. }
  70992. interface XRPlane extends XRAnchorCreator {
  70993. orientation: "Horizontal" | "Vertical";
  70994. planeSpace: XRSpace;
  70995. polygon: Array<DOMPointReadOnly>;
  70996. lastChangedTime: number;
  70997. }
  70998. interface XRAnchorCreator {
  70999. // AR Anchors
  71000. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  71001. }